Skip to content

Commit

Permalink
xilem: Condition from ViewMarker rebuild for Button was removed, beca…
Browse files Browse the repository at this point in the history
…use 'this check is not needed - the rebuild internally will re-do the same work'
  • Loading branch information
Artyom Sinyugin committed Dec 19, 2024
1 parent 9866682 commit c897cb6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
18 changes: 8 additions & 10 deletions xilem/src/view/button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ where
fn build(&self, ctx: &mut ViewCtx) -> (Self::Element, Self::ViewState) {
ctx.with_leaf_action_widget(|ctx| {
ctx.new_pod(widget::Button::from_label(
// TODO: Use `Label::build` here - currently impossible because `Pod` uses `WidgetPod` internally
widget::Label::new(self.label.label.clone())
.with_brush(self.label.text_brush.clone())
.with_alignment(self.label.alignment)
Expand All @@ -70,16 +71,13 @@ where
ctx: &mut ViewCtx,
mut element: Mut<Self::Element>,
) {
if prev.label != self.label {
let child = widget::Button::label_mut(&mut element);
<Label as View<State, Action, ViewCtx>>::rebuild(
&self.label,
&prev.label,
state,
ctx,
child,
);
}
<Label as View<State, Action, ViewCtx>>::rebuild(
&self.label,
&prev.label,
state,
ctx,
widget::Button::label_mut(&mut element),
);
}

fn teardown(&self, _: &mut Self::ViewState, ctx: &mut ViewCtx, element: Mut<Self::Element>) {
Expand Down
4 changes: 1 addition & 3 deletions xilem/src/view/label.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ pub fn label(label: impl Into<ArcStr>) -> Label {
}

#[must_use = "View values do nothing unless provided to Xilem."]
#[derive(PartialEq)]
pub struct Label {
// Public for button and variable_label as a semi-interim state.
pub(in crate::view) label: ArcStr,

// Public for variable_label as a semi-interims state.
pub(in crate::view) text_brush: Brush,
pub(in crate::view) alignment: TextAlignment,
pub(in crate::view) text_size: f32,
Expand Down

0 comments on commit c897cb6

Please sign in to comment.