unleash the sizes
This commit is contained in:
@@ -70,7 +70,7 @@ impl<const LEN: usize, Wa: WidgetArrLike<LEN, Tag>, Tag> StackBuilder<LEN, Wa, T
|
||||
}
|
||||
}
|
||||
|
||||
pub fn stack_size(mut self, size: StackSize) -> Self {
|
||||
pub fn size(mut self, size: StackSize) -> Self {
|
||||
self.size = size;
|
||||
self
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ pub struct Text {
|
||||
}
|
||||
|
||||
impl Text {
|
||||
pub fn font_size(mut self, size: impl UiNum) -> Self {
|
||||
pub fn size(mut self, size: impl UiNum) -> Self {
|
||||
self.attrs.font_size = size.to_f32();
|
||||
self.attrs.line_height = self.attrs.font_size * 1.1;
|
||||
self
|
||||
@@ -97,7 +97,7 @@ pub struct TextBuilder {
|
||||
}
|
||||
|
||||
impl TextBuilder {
|
||||
pub fn font_size(mut self, size: impl UiNum) -> Self {
|
||||
pub fn size(mut self, size: impl UiNum) -> Self {
|
||||
self.attrs.font_size = size.to_f32();
|
||||
self.attrs.line_height = self.attrs.font_size * 1.1;
|
||||
self
|
||||
|
||||
@@ -92,7 +92,7 @@ pub struct TextEditBuilder {
|
||||
}
|
||||
|
||||
impl TextEditBuilder {
|
||||
pub fn font_size(mut self, size: impl UiNum) -> Self {
|
||||
pub fn size(mut self, size: impl UiNum) -> Self {
|
||||
self.attrs.font_size = size.to_f32();
|
||||
self.attrs.line_height = self.attrs.font_size * 1.1;
|
||||
self
|
||||
|
||||
@@ -6,7 +6,7 @@ pub trait CoreWidget<W, Tag> {
|
||||
fn align(self, align: Align) -> impl WidgetFn<Aligned>;
|
||||
fn center(self) -> impl WidgetFn<Aligned>;
|
||||
fn label(self, label: impl Into<String>) -> impl WidgetIdFn<W>;
|
||||
fn size(self, size: impl Into<Vec2>) -> impl WidgetFn<Sized>;
|
||||
fn sized(self, size: impl Into<Vec2>) -> impl WidgetFn<Sized>;
|
||||
}
|
||||
|
||||
impl<W: WidgetLike<Tag>, Tag> CoreWidget<W::Widget, Tag> for W {
|
||||
@@ -36,7 +36,7 @@ impl<W: WidgetLike<Tag>, Tag> CoreWidget<W::Widget, Tag> for W {
|
||||
}
|
||||
}
|
||||
|
||||
fn size(self, size: impl Into<Vec2>) -> impl WidgetFn<Sized> {
|
||||
fn sized(self, size: impl Into<Vec2>) -> impl WidgetFn<Sized> {
|
||||
move |ui| Sized {
|
||||
inner: self.add(ui).any(),
|
||||
size: size.into(),
|
||||
|
||||
@@ -40,7 +40,7 @@ impl Client {
|
||||
let pad_test = (
|
||||
rrect.color(Color::BLUE),
|
||||
(
|
||||
rrect.color(Color::RED).size(100).center(),
|
||||
rrect.color(Color::RED).sized(100).center(),
|
||||
(
|
||||
rrect.color(Color::ORANGE),
|
||||
rrect.color(Color::LIME).pad(10.0),
|
||||
@@ -86,7 +86,7 @@ impl Client {
|
||||
.any();
|
||||
ctx.ui[span_add].children.push((child, sized()));
|
||||
})
|
||||
.size(150)
|
||||
.sized(150)
|
||||
.align(Align::BotRight);
|
||||
|
||||
let del_button = rect(Color::RED)
|
||||
@@ -94,7 +94,7 @@ impl Client {
|
||||
.on(Sense::click(), move |ctx: &mut Client, _| {
|
||||
ctx.ui[span_add].children.pop();
|
||||
})
|
||||
.size(150)
|
||||
.sized(150)
|
||||
.align(Align::BotLeft);
|
||||
|
||||
let span_add_test = (span_add, add_button, del_button)
|
||||
@@ -103,7 +103,7 @@ impl Client {
|
||||
|
||||
let main = pad_test.pad(10).add_static(&mut ui);
|
||||
|
||||
let btext = |content| text(content).font_size(30);
|
||||
let btext = |content| text(content).size(30);
|
||||
|
||||
let text_test = (
|
||||
btext("this is a").align(Align::Left),
|
||||
@@ -115,13 +115,13 @@ impl Client {
|
||||
btext("'").family(Family::Monospace).align(Align::Top),
|
||||
btext("'").family(Family::Monospace),
|
||||
btext(":gamer mode").family(Family::Monospace),
|
||||
rect(Color::CYAN).size(10).center(),
|
||||
rect(Color::RED).size(100).center(),
|
||||
rect(Color::PURPLE).size(50).align(Align::Top),
|
||||
rect(Color::CYAN).sized(10).center(),
|
||||
rect(Color::RED).sized(100).center(),
|
||||
rect(Color::PURPLE).sized(50).align(Align::Top),
|
||||
)
|
||||
.span(Dir::RIGHT, sized())
|
||||
.center(),
|
||||
text("pretty cool right?").font_size(50),
|
||||
text("pretty cool right?").size(50),
|
||||
)
|
||||
.span(Dir::DOWN, sized())
|
||||
.add_static(&mut ui);
|
||||
@@ -129,23 +129,23 @@ impl Client {
|
||||
let texts = Span::empty(Dir::DOWN).add_static(&mut ui);
|
||||
let add_text = text_edit("add")
|
||||
.text_align(Align::Left)
|
||||
.font_size(30)
|
||||
.size(30)
|
||||
.id_on(Sense::click(), |id, client: &mut Client, ctx| {
|
||||
client.ui.text(id).select(ctx.cursor, ctx.size);
|
||||
client.focus = Some(id.clone());
|
||||
})
|
||||
.id_on(Submit, move |id, client: &mut Client, _| {
|
||||
let content = client.ui.text(id).take();
|
||||
let text = text_edit(content)
|
||||
.font_size(30)
|
||||
.text_align(Align::Left)
|
||||
.id_on(Sense::click(), |id, client: &mut Client, ctx| {
|
||||
let text = text_edit(content).size(30).text_align(Align::Left).id_on(
|
||||
Sense::click(),
|
||||
|id, client: &mut Client, ctx| {
|
||||
client.ui.text(id).select(ctx.cursor, ctx.size);
|
||||
client.focus = Some(id.clone());
|
||||
});
|
||||
},
|
||||
);
|
||||
let msg_box = (rect(Color::WHITE.darker(0.5)), text)
|
||||
.stack()
|
||||
.stack_size(StackSize::Child(1))
|
||||
.size(StackSize::Child(1))
|
||||
.add(&mut client.ui);
|
||||
client.ui[texts].children.push((msg_box.any(), sized()));
|
||||
})
|
||||
@@ -160,13 +160,13 @@ impl Client {
|
||||
.on(Sense::click(), move |client: &mut Client, _| {
|
||||
client.run_event(&add_text, Submit, ());
|
||||
})
|
||||
.size(40),
|
||||
.sized(40),
|
||||
)
|
||||
.span(Dir::RIGHT, [ratio(1), sized()])
|
||||
.pad(10),
|
||||
)
|
||||
.stack()
|
||||
.stack_size(StackSize::Child(1))
|
||||
.size(StackSize::Child(1))
|
||||
.offset_layer(1)
|
||||
.align(Align::Bot),
|
||||
)
|
||||
@@ -185,7 +185,7 @@ impl Client {
|
||||
.edit_on(Sense::HoverEnd, move |r, _| {
|
||||
r.color = color;
|
||||
});
|
||||
(rect, text(label).font_size(30)).stack()
|
||||
(rect, text(label).size(30)).stack()
|
||||
};
|
||||
|
||||
let tabs = (
|
||||
|
||||
Reference in New Issue
Block a user