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