Skip to content

Commit

Permalink
Fix even more references to "region"
Browse files Browse the repository at this point in the history
  • Loading branch information
DJMcNab committed Nov 21, 2024
1 parent 0fc07ff commit 28beac5
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion masonry/src/widget/prose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl Prose {
/// 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<TextArea<false>> {
pub fn text_area_pod(&self) -> &WidgetPod<TextArea<false>> {
&self.text
}
}
Expand Down
6 changes: 3 additions & 3 deletions masonry/src/widget/text_area.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub struct TextArea<const USER_EDITABLE: bool> {
/// How many clicks have occurred in this click sequence.
click_count: u32,

/// Whether to wrap words in this region.
/// Whether to wrap words in this area.
///
/// Note that if clipping is desired, that should be added by the parent widget.
/// Can be set using [`set_word_wrap`](Self::set_word_wrap).
Expand Down Expand Up @@ -779,11 +779,11 @@ impl<const EDITABLE: bool> Widget for TextArea<EDITABLE> {
let text_width = max_advance.unwrap_or(layout.full_width());
let text_size = Size::new(text_width.into(), layout.height().into());

let region_size = Size {
let area_size = Size {
height: text_size.height + padding_size.height,
width: text_size.width + padding_size.width,
};
bc.constrain(region_size)
bc.constrain(area_size)
}

fn paint(&mut self, ctx: &mut PaintCtx, scene: &mut Scene) {
Expand Down
2 changes: 1 addition & 1 deletion masonry/src/widget/textbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub struct Textbox {
impl Textbox {
/// Create a new `Prose` with the given text.
///
/// To use non-default text properties, use [`from_area_region`](Self::from_text_area) 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_area(TextArea::new_editable(text))
}
Expand Down
14 changes: 7 additions & 7 deletions xilem/src/view/prose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,25 +92,25 @@ impl<State, Action> View<State, Action, ViewCtx> for Prose {
_ctx: &mut ViewCtx,
mut element: Mut<Self::Element>,
) {
let mut region = widget::Prose::text_mut(&mut element);
let mut text_area = widget::Prose::text_mut(&mut element);
if prev.content != self.content {
widget::TextArea::reset_text(&mut region, &self.content);
widget::TextArea::reset_text(&mut text_area, &self.content);
}
if prev.text_brush != self.text_brush {
widget::TextArea::set_brush(&mut region, self.text_brush.clone());
widget::TextArea::set_brush(&mut text_area, self.text_brush.clone());
}
if prev.alignment != self.alignment {
widget::TextArea::set_alignment(&mut region, self.alignment);
widget::TextArea::set_alignment(&mut text_area, self.alignment);
}
if prev.text_size != self.text_size {
widget::TextArea::insert_style(&mut region, StyleProperty::FontSize(self.text_size));
widget::TextArea::insert_style(&mut text_area, StyleProperty::FontSize(self.text_size));
}
if prev.line_break_mode != self.line_break_mode {
widget::TextArea::set_word_wrap(
&mut region,
&mut text_area,
self.line_break_mode == LineBreaking::WordWrap,
);
drop(region);
drop(text_area);
widget::Prose::set_clip(&mut element, line_break_clips(self.line_break_mode));
}
}
Expand Down
10 changes: 5 additions & 5 deletions xilem/src/view/textbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl<State: 'static, Action: 'static> View<State, Action, ViewCtx> for Textbox<S
_ctx: &mut ViewCtx,
mut element: Mut<Self::Element>,
) {
let mut region = widget::Textbox::text_mut(&mut element);
let mut text_area = widget::Textbox::text_mut(&mut element);

// Unlike the other properties, we don't compare to the previous value;
// instead, we compare directly to the element's text. This is to handle
Expand All @@ -94,15 +94,15 @@ impl<State: 'static, Action: 'static> View<State, Action, ViewCtx> for Textbox<S
// without calling `set_text`.

// This is probably not the right behaviour, but determining what is the right behaviour is hard
if self.contents != region.widget.text() {
widget::TextArea::reset_text(&mut region, &self.contents);
if self.contents != text_area.widget.text() {
widget::TextArea::reset_text(&mut text_area, &self.contents);
}

if prev.text_brush != self.text_brush {
widget::TextArea::set_brush(&mut region, self.text_brush.clone());
widget::TextArea::set_brush(&mut text_area, self.text_brush.clone());
}
if prev.alignment != self.alignment {
widget::TextArea::set_alignment(&mut region, self.alignment);
widget::TextArea::set_alignment(&mut text_area, self.alignment);
}
}

Expand Down

0 comments on commit 28beac5

Please sign in to comment.