add option to defer draw updates

this is helpful for composited UIs
This commit is contained in:
bunnie 2025-11-25 19:07:32 +08:00
parent 27e5f0b72f
commit 765a36bd3a

View file

@ -60,6 +60,7 @@ pub struct ScrollableList {
/// for some global shared state to lock the UI for a given model which I haven't
/// figured out how to handle any other way.
pub gfx: Gfx,
autoflush: bool,
}
impl Clone for ScrollableList {
@ -104,9 +105,12 @@ impl ScrollableList {
text_alignment: TextAlignment::Left,
pane: RefCell::new(pane),
gfx,
autoflush: true,
}
}
pub fn set_autoflush(&mut self, autoflush: bool) { self.autoflush = autoflush; }
pub fn get_alignment(&self) -> TextAlignment { self.text_alignment }
pub fn set_alignment<'a>(&'a mut self, alignment: TextAlignment) -> &'a mut Self {
@ -507,7 +511,9 @@ impl ScrollableList {
self.gfx.draw_object_list(ol).unwrap();
}
}
self.gfx.flush().unwrap();
if self.autoflush {
self.gfx.flush().unwrap();
}
}
/// Update the scrollable list state based on a key action. Passes on