fix: only render on changes

This commit is contained in:
2026-09-04 16:07:32 +02:00
parent 0419237433
commit 3cdbf90de1
2 changed files with 16 additions and 5 deletions
+5 -5
View File
@@ -71,7 +71,7 @@ m3_switch :: proc(on: ^bool, id: engine.Id) -> bool {
d := new(Switch_Draw, context.temp_allocator) d := new(Switch_Draw, context.temp_allocator)
d.t = engine.ui_anim_f32(id, on^ ? 1 : 0) 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 return clicked
} }
@@ -126,7 +126,7 @@ m3_checkbox :: proc(checked: ^bool, id: engine.Id) -> bool {
d := new(Check_Draw, context.temp_allocator) d := new(Check_Draw, context.temp_allocator)
d.t = engine.ui_anim_f32(id, checked^ ? 1 : 0) 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^ { if checked^ {
engine.push_parent(box) 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 := new(Radio_Draw, context.temp_allocator)
d.t = engine.ui_anim_f32(id, selected ? 1 : 0) 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) 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 := new(Slider_Draw, context.temp_allocator)
d.t = clamp(value^, 0, 1) 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 return changed
} }
@@ -283,7 +283,7 @@ m3_progress_linear :: proc(value: f32, id: engine.Id) {
d := new(Progress_Draw, context.temp_allocator) d := new(Progress_Draw, context.temp_allocator)
d.t = value 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 { m3_lerp_color :: proc(a, b: engine.Color, t: f32) -> engine.Color {
+11
View File
@@ -37,6 +37,10 @@ real_main :: proc() {
m3_init_dark() 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() { for !engine.should_quit() {
engine.frame_start() engine.frame_start()
defer engine.frame_end() defer engine.frame_end()
@@ -55,6 +59,13 @@ real_main :: proc() {
if !insets_valid { if !insets_valid {
insets_valid = refresh_insets() 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() window_size := engine.get_window_size()