Option<Id>.duplicate
This commit is contained in:
@@ -6,7 +6,7 @@ use crate::{
|
|||||||
UiVec2, Vec2, WidgetId, Widgets,
|
UiVec2, Vec2, WidgetId, Widgets,
|
||||||
},
|
},
|
||||||
render::{Primitive, PrimitiveHandle, Primitives},
|
render::{Primitive, PrimitiveHandle, Primitives},
|
||||||
util::{HashMap, HashSet, Id},
|
util::{HashMap, HashSet, Id, IdUtil},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct Painter<'a, 'c> {
|
pub struct Painter<'a, 'c> {
|
||||||
@@ -77,12 +77,16 @@ impl<'a> PainterCtx<'a> {
|
|||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
let parent = active.parent();
|
|
||||||
drop(active.textures);
|
drop(active.textures);
|
||||||
self.textures.free();
|
self.textures.free();
|
||||||
|
|
||||||
self.primitives.set_pos(active.span.start);
|
self.primitives.set_pos(active.span.start);
|
||||||
self.draw_inner(id, active.region, parent, Some(active.children));
|
self.draw_inner(
|
||||||
|
id,
|
||||||
|
active.region,
|
||||||
|
active.parent.duplicate(),
|
||||||
|
Some(active.children),
|
||||||
|
);
|
||||||
self.active.widgets.get_mut(id).unwrap().resize = active.resize;
|
self.active.widgets.get_mut(id).unwrap().resize = active.resize;
|
||||||
|
|
||||||
let delta = self.primitives.apply(active.span.clone());
|
let delta = self.primitives.apply(active.span.clone());
|
||||||
@@ -204,7 +208,7 @@ impl<'a> PainterCtx<'a> {
|
|||||||
let instance = self.active.widgets.get_mut(&parent).unwrap();
|
let instance = self.active.widgets.get_mut(&parent).unwrap();
|
||||||
let end = &mut instance.span.end;
|
let end = &mut instance.span.end;
|
||||||
*end = end.strict_add_signed(delta);
|
*end = end.strict_add_signed(delta);
|
||||||
let parent_parent = instance.parent();
|
let parent_parent = instance.parent.duplicate();
|
||||||
for child in instance
|
for child in instance
|
||||||
.children
|
.children
|
||||||
.iter()
|
.iter()
|
||||||
@@ -346,9 +350,3 @@ impl SizeCtx<'_> {
|
|||||||
self.text.draw(buffer, attrs, self.textures)
|
self.text.draw(buffer, attrs, self.textures)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WidgetInstance {
|
|
||||||
pub fn parent(&self) -> Option<Id> {
|
|
||||||
self.parent.as_ref().map(|p| p.duplicate())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user