From 9fbe6ab909372862236e98374fae362027601ced Mon Sep 17 00:00:00 2001 From: Daniel McNab <36049421+DJMcNab@users.noreply.github.com> Date: Thu, 21 Nov 2024 10:42:25 +0000 Subject: [PATCH] Fixup last renames from text region --- masonry/examples/grid_masonry.rs | 2 +- masonry/examples/to_do_list.rs | 4 ++-- masonry/src/widget/prose.rs | 14 +++++++------- masonry/src/widget/textbox.rs | 16 ++++++++-------- xilem/src/view/prose.rs | 4 ++-- xilem/src/view/textbox.rs | 6 +++--- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/masonry/examples/grid_masonry.rs b/masonry/examples/grid_masonry.rs index 1b3f4425b..e8fe50c9e 100644 --- a/masonry/examples/grid_masonry.rs +++ b/masonry/examples/grid_masonry.rs @@ -43,7 +43,7 @@ fn grid_button(params: GridParams) -> Button { } fn main() { - let label = SizedBox::new(Prose::from_text_region( + let label = SizedBox::new(Prose::from_text_area( TextArea::new_immutable("Change spacing by right and left clicking on the buttons") .with_style(StyleProperty::FontSize(14.0)) .with_alignment(Alignment::Middle), diff --git a/masonry/examples/to_do_list.rs b/masonry/examples/to_do_list.rs index b8761a523..58fca2c91 100644 --- a/masonry/examples/to_do_list.rs +++ b/masonry/examples/to_do_list.rs @@ -32,8 +32,8 @@ impl AppDriver for Driver { let mut first_row = first_row.downcast::(); let mut textbox = Flex::child_mut(&mut first_row, 0).unwrap(); let mut textbox = textbox.downcast::(); - let mut text_region = Textbox::text_mut(&mut textbox); - TextArea::reset_text(&mut text_region, ""); + let mut text_area = Textbox::text_mut(&mut textbox); + TextArea::reset_text(&mut text_area, ""); } Action::TextChanged(new_text) => { self.next_task = new_text.clone(); diff --git a/masonry/src/widget/prose.rs b/masonry/src/widget/prose.rs index 464a903d3..909f6d3d7 100644 --- a/masonry/src/widget/prose.rs +++ b/masonry/src/widget/prose.rs @@ -45,13 +45,13 @@ pub struct Prose { impl Prose { /// Create a new `Prose` with the given text. /// - /// To use non-default text properties, use [`from_text_region`](Self::from_text_region) instead. + /// To use non-default text properties, use [`from_text_area`](Self::from_text_area) instead. pub fn new(text: &str) -> Self { - Self::from_text_region(TextArea::new_immutable(text)) + Self::from_text_area(TextArea::new_immutable(text)) } /// Create a new `Prose` from a styled text area. - pub fn from_text_region(text: TextArea) -> Self { + pub fn from_text_area(text: TextArea) -> Self { let text = text.with_padding_if_default(PROSE_PADDING); Self { text: WidgetPod::new(text), @@ -62,7 +62,7 @@ impl Prose { /// Create a new `Prose` from a styled text area in a [`WidgetPod`]. /// /// Note that the default padding used for prose will not be applied. - pub fn from_text_region_pod(text: WidgetPod>) -> Self { + pub fn from_text_area_pod(text: WidgetPod>) -> Self { Self { text, clip: false } } @@ -77,8 +77,8 @@ impl Prose { self } - /// Read the underlying text region. Useful for getting its ID. - // This is a bit of a hack, to work around `from_text_region_pod` not being + /// Read the underlying text area. Useful for getting its ID. + // This is a bit of a hack, to work around `from_text_area_pod` not being // able to set padding. pub fn region_pod(&self) -> &WidgetPod> { &self.text @@ -171,7 +171,7 @@ mod tests { fn prose_alignment_flex() { fn base_prose(alignment: Alignment) -> Prose { // Trailing whitespace is displayed when laying out prose. - Prose::from_text_region( + Prose::from_text_area( TextArea::new_immutable("Hello ") .with_style(StyleProperty::FontSize(10.0)) .with_alignment(alignment) diff --git a/masonry/src/widget/textbox.rs b/masonry/src/widget/textbox.rs index fdeb7c465..eade8d2e2 100644 --- a/masonry/src/widget/textbox.rs +++ b/masonry/src/widget/textbox.rs @@ -33,7 +33,7 @@ const TEXTBOX_MARGIN: Padding = Padding::horizontal(2.0); /// /// This widget itself does not emit any actions. /// However, the child widget will do so, as it is user editable. -/// The ID of the child can be accessed using [`region_pod`](Self::region_pod). +/// The ID of the child can be accessed using [`area_pod`](Self::area_pod). /// /// At runtime, most properties of the text will be set using [`text_mut`](Self::text_mut). /// This is because `Textbox` largely serves as a wrapper around a [`TextArea`]. @@ -47,13 +47,13 @@ pub struct Textbox { impl Textbox { /// Create a new `Prose` with the given text. /// - /// To use non-default text properties, use [`from_text_region`](Self::from_text_region) instead. + /// To use non-default text properties, use [`from_area_region`](Self::from_text_area) instead. pub fn new(text: &str) -> Self { - Self::from_text_region(TextArea::new_editable(text)) + Self::from_text_area(TextArea::new_editable(text)) } /// Create a new `Prose` from a styled text area. - pub fn from_text_region(text: TextArea) -> Self { + pub fn from_text_area(text: TextArea) -> Self { let text = text.with_padding_if_default(TEXTBOX_PADDING); Self { text: WidgetPod::new(text), @@ -64,7 +64,7 @@ impl Textbox { /// Create a new `Prose` from a styled text area in a [`WidgetPod`]. /// /// Note that the default padding used for prose will not apply. - pub fn from_text_region_pod(text: WidgetPod>) -> Self { + pub fn from_text_area_pod(text: WidgetPod>) -> Self { Self { text, clip: false } } @@ -79,10 +79,10 @@ impl Textbox { self } - /// Read the underlying text region. + /// Read the underlying text area. /// /// Useful for getting its ID, as most actions from the textbox will be sent by the child. - pub fn region_pod(&self) -> &WidgetPod> { + pub fn area_pod(&self) -> &WidgetPod> { &self.text } } @@ -191,7 +191,7 @@ mod tests { fn prose_alignment_flex() { fn base_prose(alignment: Alignment) -> Prose { // Trailing whitespace is displayed when laying out prose. - Prose::from_text_region( + Prose::from_text_area( TextArea::new_immutable("Hello ") .with_style(StyleProperty::FontSize(10.0)) .with_alignment(alignment) diff --git a/xilem/src/view/prose.rs b/xilem/src/view/prose.rs index e7d047a24..f8c75d646 100644 --- a/xilem/src/view/prose.rs +++ b/xilem/src/view/prose.rs @@ -73,13 +73,13 @@ impl View for Prose { type ViewState = (); fn build(&self, ctx: &mut ViewCtx) -> (Self::Element, Self::ViewState) { - let text_region = widget::TextArea::new_immutable(&self.content) + let text_area = widget::TextArea::new_immutable(&self.content) .with_brush(self.text_brush.clone()) .with_alignment(self.alignment) .with_style(StyleProperty::FontSize(self.text_size)) .with_word_wrap(self.line_break_mode == LineBreaking::WordWrap); let widget_pod = ctx.new_pod( - widget::Prose::from_text_region(text_region) + widget::Prose::from_text_area(text_area) .with_clip(line_break_clips(self.line_break_mode)), ); (widget_pod, ()) diff --git a/xilem/src/view/textbox.rs b/xilem/src/view/textbox.rs index 6ab7b954a..e256d3f7e 100644 --- a/xilem/src/view/textbox.rs +++ b/xilem/src/view/textbox.rs @@ -66,13 +66,13 @@ impl View for Textbox (Self::Element, Self::ViewState) { // TODO: Maybe we want a shared TextArea View? - let text_region = widget::TextArea::new_editable(&self.contents) + let text_area = widget::TextArea::new_editable(&self.contents) .with_brush(self.text_brush.clone()) .with_alignment(self.alignment); - let textbox = widget::Textbox::from_text_region(text_region); + let textbox = widget::Textbox::from_text_area(text_area); // Ensure that the actions from the *inner* TextArea get routed correctly. - let id = textbox.region_pod().id(); + let id = textbox.area_pod().id(); ctx.record_action(id); let widget_pod = ctx.new_pod(textbox); (widget_pod, ())