biscuit/pkgs/maps/main.fnl

72 lines
1.7 KiB
Plaintext
Raw Permalink Normal View History

2024-07-22 21:25:25 +00:00
; (local { : view } (require :fennel))
(local {
: Gtk
: OsmGpsMap
: Gdk
}
(require :lgi))
(local CSS "
label.readout {
font: 48px \"Noto Sans\";
margin: 10px;
padding: 5px;
background-color: rgba(0, 0, 0, 0.2);
}
")
(fn styles []
(let [style_provider (Gtk.CssProvider)]
(Gtk.StyleContext.add_provider_for_screen
(Gdk.Screen.get_default)
style_provider
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
)
(style_provider:load_from_data CSS)))
(local window (Gtk.Window {
:title "Map"
:name "toplevel"
:default_width 720
:default_height 800
:on_destroy Gtk.main_quit
}))
(fn osm-widget []
(doto (OsmGpsMap.Map {})
(tset :map-source OsmGpsMap.MapSource_t.OPENSTREETMAP)
(: :set_center_and_zoom 52.595 -0.1 14)
(: :layer_add (OsmGpsMap.MapOsd {
:show_copyright true
; :show_coordinates true
:show_scale true
}))
))
(fn readout [text]
(doto (Gtk.Label {:label text})
(-> (: :get_style_context) (: :add_class :readout))))
(fn readouts []
(doto (Gtk.Box
{
:orientation Gtk.Orientation.VERTICAL
:halign Gtk.Align.END
})
(-> (: :get_style_context) (: :add_class :readouts))
(: :add (readout "21:05:00"))
(: :add (readout "00:00"))
(: :add (readout "25 km/h"))))
(window:add
(doto (Gtk.Overlay {})
(: :add (osm-widget))
(: :add_overlay (readouts))
))
(window:show_all)
(styles)
(Gtk:main)