fix Draw (redraw)
This commit is contained in:
@@ -28,7 +28,7 @@ pub trait UiRsc {
|
||||
#[allow(unused_variables)]
|
||||
fn on_remove(&mut self, id: WidgetId) {}
|
||||
#[allow(unused_variables)]
|
||||
fn on_draw(&mut self, active: &ActiveData) {}
|
||||
fn on_draw(&mut self, active: &ActiveData, redrawn: bool) {}
|
||||
#[allow(unused_variables)]
|
||||
fn on_undraw(&mut self, active: &ActiveData) {}
|
||||
|
||||
|
||||
@@ -81,10 +81,12 @@ impl UiRenderState {
|
||||
old_children: Option<Vec<WidgetId>>,
|
||||
rsc: &mut dyn UiRsc,
|
||||
) {
|
||||
let mut redrawn = old_children.is_some();
|
||||
let mut old_children = old_children.unwrap_or_default();
|
||||
if let Some(active) = self.active.get_mut(&id)
|
||||
&& !rsc.widgets().needs_redraw.contains(&id)
|
||||
{
|
||||
redrawn = true;
|
||||
// check to see if we can skip drawing first
|
||||
if active.region == region {
|
||||
return;
|
||||
@@ -149,7 +151,7 @@ impl UiRenderState {
|
||||
}
|
||||
}
|
||||
|
||||
rsc.on_draw(&active);
|
||||
rsc.on_draw(&active, redrawn);
|
||||
self.active.insert(id, active);
|
||||
}
|
||||
|
||||
|
||||
@@ -146,13 +146,15 @@ impl<State> UiRsc for DefaultRsc<State> {
|
||||
&mut self.ui
|
||||
}
|
||||
|
||||
fn on_draw(&mut self, active: &ActiveData) {
|
||||
fn on_draw(&mut self, active: &ActiveData, redrawn: bool) {
|
||||
self.events.draw(active);
|
||||
if !redrawn {
|
||||
self.widget_events.push(WidgetEvent {
|
||||
id: active.id,
|
||||
ty: WidgetEventType::Draw,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
fn on_undraw(&mut self, active: &ActiveData) {
|
||||
self.events.undraw(active);
|
||||
|
||||
Reference in New Issue
Block a user