convenience methods for span
This commit is contained in:
@@ -64,7 +64,7 @@ impl DefaultAppState for Client {
|
||||
let child = image(include_bytes!("assets/sungals.png"))
|
||||
.center()
|
||||
.add_strong(ctx);
|
||||
span_add(ctx).children.push(child);
|
||||
span_add(ctx).push(child);
|
||||
})
|
||||
.sized((150, 150))
|
||||
.align(Align::BOT_RIGHT);
|
||||
@@ -72,7 +72,7 @@ impl DefaultAppState for Client {
|
||||
let del_button = rect(Color::RED)
|
||||
.radius(30)
|
||||
.on(CursorSense::click(), move |ctx| {
|
||||
span_add(ctx).children.pop();
|
||||
span_add(ctx).pop();
|
||||
})
|
||||
.sized((150, 150))
|
||||
.align(Align::BOT_LEFT);
|
||||
@@ -121,7 +121,7 @@ impl DefaultAppState for Client {
|
||||
let msg_box = text
|
||||
.background(rect(Color::WHITE.darker(0.5)))
|
||||
.add_strong(ctx);
|
||||
texts(ctx).children.push(msg_box);
|
||||
texts(ctx).push(msg_box);
|
||||
})
|
||||
.add(&mut rsc);
|
||||
let text_edit_scroll = (
|
||||
|
||||
@@ -62,6 +62,14 @@ impl Span {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn push(&mut self, w: WidgetHandle) {
|
||||
self.children.push(w);
|
||||
}
|
||||
|
||||
pub fn pop(&mut self) -> Option<WidgetHandle> {
|
||||
self.children.pop()
|
||||
}
|
||||
|
||||
fn len_sum(&mut self, ctx: &mut SizeCtx) -> Len {
|
||||
let gap = self.gap * self.children.len().saturating_sub(1) as f32;
|
||||
self.children.iter().fold(Len::abs(gap), |mut s, id| {
|
||||
|
||||
Reference in New Issue
Block a user