use register-widget more, fewer arrow widget repaints
This commit is contained in:
parent
f64bfeb7fd
commit
2a86a2bfde
@ -126,12 +126,11 @@ label.readout {
|
||||
})))
|
||||
|
||||
(fn readout [name text]
|
||||
(let [w
|
||||
(doto (Gtk.Label {:label text : name})
|
||||
(-> (: :get_style_context)
|
||||
(: :add_class :readout)))]
|
||||
(tset state-widgets name w)
|
||||
w))
|
||||
(register-widget
|
||||
name
|
||||
(doto (Gtk.Label {:label text : name})
|
||||
(-> (: :get_style_context)
|
||||
(: :add_class :readout)))))
|
||||
|
||||
(local knot-in-m-s
|
||||
(/ 1852 ; metres in nautical mile
|
||||
@ -157,6 +156,7 @@ label.readout {
|
||||
:speed (widget:set_label
|
||||
(string.format "%.1f km/h" (* app-state.speed 3.6)))
|
||||
:osm (: (widget:get_window) :invalidate_rect nil)
|
||||
:arrow (: (widget:get_window) :invalidate_rect nil)
|
||||
:time (widget:set_label
|
||||
(hhmmss (+ utc-offset app-state.time-of-day)))
|
||||
)))
|
||||
@ -174,25 +174,26 @@ label.readout {
|
||||
(: :add (readout :speed "0"))))
|
||||
|
||||
(fn arrow []
|
||||
(let [height 40
|
||||
w (Gtk.Label {
|
||||
:halign Gtk.Align.CENTER
|
||||
:valign Gtk.Align.CENTER
|
||||
:width height :height height
|
||||
:on_draw
|
||||
(fn [self g]
|
||||
(g:set_source_rgb 0.4 0.0 0.1)
|
||||
(g:translate (// height 2) (// height 2))
|
||||
(g:rotate (/ (* -2 app-state.course math.pi) 360) )
|
||||
(g:translate (// height -2) (// height -2))
|
||||
(g:set_line_width 4)
|
||||
(g:move_to 10 height)
|
||||
(g:line_to (// height 2) 0)
|
||||
(g:line_to (- height 10) height)
|
||||
(g:fill)
|
||||
true)
|
||||
})]
|
||||
w))
|
||||
(let [height 40]
|
||||
(register-widget
|
||||
:arrow
|
||||
(Gtk.Label {
|
||||
:halign Gtk.Align.CENTER
|
||||
:valign Gtk.Align.CENTER
|
||||
:width height :height height
|
||||
:on_draw
|
||||
(fn [self g]
|
||||
(g:set_source_rgb 0.4 0.0 0.1)
|
||||
(g:translate (// height 2) (// height 2))
|
||||
(g:rotate (/ (* -2 app-state.course math.pi) 360) )
|
||||
(g:translate (// height -2) (// height -2))
|
||||
(g:set_line_width 4)
|
||||
(g:move_to 10 height)
|
||||
(g:line_to (// height 2) 0)
|
||||
(g:line_to (- height 10) height)
|
||||
(g:fill)
|
||||
true)
|
||||
}))))
|
||||
|
||||
|
||||
(local socket-path (or (. arg 1) "/var/run/gnss-share.sock"))
|
||||
|
Loading…
Reference in New Issue
Block a user