fix: only render on changes
This commit is contained in:
+5
-5
@@ -71,7 +71,7 @@ m3_switch :: proc(on: ^bool, id: engine.Id) -> bool {
|
||||
|
||||
d := new(Switch_Draw, context.temp_allocator)
|
||||
d.t = engine.ui_anim_f32(id, on^ ? 1 : 0)
|
||||
engine.ui_box_equip_custom_draw(box, switch_draw, d)
|
||||
engine.ui_box_equip_custom_draw(box, switch_draw, d, transmute(u32)d.t)
|
||||
return clicked
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ m3_checkbox :: proc(checked: ^bool, id: engine.Id) -> bool {
|
||||
|
||||
d := new(Check_Draw, context.temp_allocator)
|
||||
d.t = engine.ui_anim_f32(id, checked^ ? 1 : 0)
|
||||
engine.ui_box_equip_custom_draw(box, checkbox_draw, d)
|
||||
engine.ui_box_equip_custom_draw(box, checkbox_draw, d, transmute(u32)d.t)
|
||||
|
||||
if checked^ {
|
||||
engine.push_parent(box)
|
||||
@@ -182,7 +182,7 @@ m3_radio :: proc(selected: bool, id: engine.Id) -> bool {
|
||||
|
||||
d := new(Radio_Draw, context.temp_allocator)
|
||||
d.t = engine.ui_anim_f32(id, selected ? 1 : 0)
|
||||
engine.ui_box_equip_custom_draw(box, radio_draw, d)
|
||||
engine.ui_box_equip_custom_draw(box, radio_draw, d, transmute(u32)d.t)
|
||||
return engine.ui_clicked(sig)
|
||||
}
|
||||
|
||||
@@ -246,7 +246,7 @@ m3_slider :: proc(value: ^f32, id: engine.Id) -> bool {
|
||||
|
||||
d := new(Slider_Draw, context.temp_allocator)
|
||||
d.t = clamp(value^, 0, 1)
|
||||
engine.ui_box_equip_custom_draw(box, slider_draw, d)
|
||||
engine.ui_box_equip_custom_draw(box, slider_draw, d, transmute(u32)d.t)
|
||||
return changed
|
||||
}
|
||||
|
||||
@@ -283,7 +283,7 @@ m3_progress_linear :: proc(value: f32, id: engine.Id) {
|
||||
|
||||
d := new(Progress_Draw, context.temp_allocator)
|
||||
d.t = value
|
||||
engine.ui_box_equip_custom_draw(box, progress_draw, d)
|
||||
engine.ui_box_equip_custom_draw(box, progress_draw, d, transmute(u32)d.t)
|
||||
}
|
||||
|
||||
m3_lerp_color :: proc(a, b: engine.Color, t: f32) -> engine.Color {
|
||||
|
||||
@@ -37,6 +37,10 @@ real_main :: proc() {
|
||||
|
||||
m3_init_dark()
|
||||
|
||||
// Only draw when something actually changed. Without this the loop renders
|
||||
// flat out forever, which on a phone is straight battery burn.
|
||||
engine.set_render_on_change(true)
|
||||
|
||||
for !engine.should_quit() {
|
||||
engine.frame_start()
|
||||
defer engine.frame_end()
|
||||
@@ -55,6 +59,13 @@ real_main :: proc() {
|
||||
|
||||
if !insets_valid {
|
||||
insets_valid = refresh_insets()
|
||||
if !insets_valid {
|
||||
// The decor view attaches asynchronously and produces no event
|
||||
// when it does. Under render_on_change the loop would park
|
||||
// before the retry ever ran, leaving the app bar with no status
|
||||
// bar padding.
|
||||
engine.request_render()
|
||||
}
|
||||
}
|
||||
|
||||
window_size := engine.get_window_size()
|
||||
|
||||
Reference in New Issue
Block a user