From 5f2dffc1893436ba5635b18328fc62e741a965ff Mon Sep 17 00:00:00 2001 From: shadow cat Date: Thu, 25 Sep 2025 21:30:26 -0400 Subject: [PATCH] unleash the sizes --- src/core/stack.rs | 2 +- src/core/text.rs | 4 ++-- src/core/text_edit.rs | 2 +- src/core/trait_fns.rs | 4 ++-- src/testing/mod.rs | 36 ++++++++++++++++++------------------ 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/core/stack.rs b/src/core/stack.rs index 6656590..5d6e766 100644 --- a/src/core/stack.rs +++ b/src/core/stack.rs @@ -70,7 +70,7 @@ impl, Tag> StackBuilder Self { + pub fn size(mut self, size: StackSize) -> Self { self.size = size; self } diff --git a/src/core/text.rs b/src/core/text.rs index da0e684..bbe46e0 100644 --- a/src/core/text.rs +++ b/src/core/text.rs @@ -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 diff --git a/src/core/text_edit.rs b/src/core/text_edit.rs index 8e06e44..cdf596f 100644 --- a/src/core/text_edit.rs +++ b/src/core/text_edit.rs @@ -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 diff --git a/src/core/trait_fns.rs b/src/core/trait_fns.rs index cb26707..505a21c 100644 --- a/src/core/trait_fns.rs +++ b/src/core/trait_fns.rs @@ -6,7 +6,7 @@ pub trait CoreWidget { fn align(self, align: Align) -> impl WidgetFn; fn center(self) -> impl WidgetFn; fn label(self, label: impl Into) -> impl WidgetIdFn; - fn size(self, size: impl Into) -> impl WidgetFn; + fn sized(self, size: impl Into) -> impl WidgetFn; } impl, Tag> CoreWidget for W { @@ -36,7 +36,7 @@ impl, Tag> CoreWidget for W { } } - fn size(self, size: impl Into) -> impl WidgetFn { + fn sized(self, size: impl Into) -> impl WidgetFn { move |ui| Sized { inner: self.add(ui).any(), size: size.into(), diff --git a/src/testing/mod.rs b/src/testing/mod.rs index e1a61f7..f5a8e23 100644 --- a/src/testing/mod.rs +++ b/src/testing/mod.rs @@ -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 = (