Make alignment a widget property
This commit is contained in:
1 parent
8220a78d4a
commit
d3b0ebf90c
21 files changed
+823
-300
No files matched your search
+11
-16
@@ -11,14 +11,13 @@ fn plant(h: &mut Harness) -> Vec<WidgetId> {
|
||||
let plain = wtext("Wrapping").size(16).wrap(false).add(&mut h.rsc);
|
||||
let wrapped = wtext("Wrapping shapes").size(16).wrap(true).add(&mut h.rsc);
|
||||
let sized = wrapped.width(76).add(&mut h.rsc);
|
||||
let aligned = Aligned {
|
||||
inner: sized.add_strong(&mut h.rsc),
|
||||
align: Align {
|
||||
x: Some(AxisAlign::Pos),
|
||||
y: Some(AxisAlign::Pos),
|
||||
},
|
||||
}
|
||||
.add(&mut h.rsc);
|
||||
let aligned = sized;
|
||||
h.rsc
|
||||
.widgets_mut()
|
||||
.set_alignment(sized, Axis::X, AxisAlign::POS);
|
||||
h.rsc
|
||||
.widgets_mut()
|
||||
.set_alignment(sized, Axis::Y, AxisAlign::POS);
|
||||
let stack = Stack {
|
||||
children: vec![plain.add_strong(&mut h.rsc), aligned.add_strong(&mut h.rsc)],
|
||||
size: StackSize::Child(0),
|
||||
@@ -94,14 +93,10 @@ fn what_box_the_text_is_drawn_in() {
|
||||
fn plant_fixed(h: &mut Harness) -> Vec<WidgetId> {
|
||||
let words = "Wrapping shapes one source into as many lines as the box leaves";
|
||||
let text = wtext(words).size(16).wrap(true).add(&mut h.rsc);
|
||||
let aligned = Aligned {
|
||||
inner: text.add_strong(&mut h.rsc),
|
||||
align: Align {
|
||||
x: Some(AxisAlign::Neg),
|
||||
y: None,
|
||||
},
|
||||
}
|
||||
.add(&mut h.rsc);
|
||||
let aligned = text;
|
||||
h.rsc
|
||||
.widgets_mut()
|
||||
.set_alignment(text, Axis::X, AxisAlign::NEG);
|
||||
let inner = (aligned,).span(Dir::RIGHT).add(&mut h.rsc);
|
||||
let sized = inner.sized((189, 176)).add(&mut h.rsc);
|
||||
let filler = rect(Color::RED).add(&mut h.rsc);
|
||||
|
||||
Reference in new issue
Block a user