Skip to content

Add Xilem view for Divider.#1707

Merged
xStrom merged 3 commits intolinebender:mainfrom
xStrom:divider-view
Apr 2, 2026
Merged

Add Xilem view for Divider.#1707
xStrom merged 3 commits intolinebender:mainfrom
xStrom:divider-view

Conversation

@xStrom
Copy link
Copy Markdown
Member

@xStrom xStrom commented Mar 31, 2026

This PR implements Divider as a Xilem view. That will help get more usage of the widget and thereby exposes more issues. It already exposed that WidgetMut methods for editing an existing Divider were not implemented, so this PR also adds those.

One annoying thing is that the no-content Divider Xilem view still needs a content type that satisfies WidgetView. I went with a default dummy of Spinner because it's a non-generic type. This allows for easy constructors like divider_h(). The fact that the resulting type uses Spinner is quite hidden but keeps ergonomics better. For the full constructor, specifying it manually is still required, e.g. divider::<_, _, Spinner>(Axis::Horizontal, None). Of course any WidgetView compatible type works as a dummy.

I incorporated two examples of using the divider into cargo run --example to_do_mvc.

xilem-divider

@xStrom xStrom added the needs review Needs review before proceeding. label Mar 31, 2026
Copy link
Copy Markdown
Contributor

@waywardmonkeys waywardmonkeys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall seems fine. A couple of minor nits. Good to see the WidgetMut stuff.

}

/// Removes any existing content.
pub fn remove_content(this: &mut WidgetMut<'_, Self>) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is remove_content a better name than clear_content? (Not sure)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do think clear_content is clearer in this context.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other existing widgets use both remove and clear, so we don't really have a clear winner. I changed this one to clear.

//! A to-do-list app, loosely inspired by todomvc.

use masonry::layout::AsUnit;
use masonry::widgets::DashFit;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should go through xilem::masonry below ...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rust Analyzer strikes again!

Copy link
Copy Markdown
Contributor

@PoignardAzur PoignardAzur Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm really tempted to drop everything I'm doing and finally make a PR in RA to fix that.

@xStrom xStrom removed the needs review Needs review before proceeding. label Apr 2, 2026
@xStrom xStrom enabled auto-merge April 2, 2026 13:24
@xStrom xStrom added this pull request to the merge queue Apr 2, 2026
Merged via the queue into linebender:main with commit ceea579 Apr 2, 2026
17 checks passed
@xStrom xStrom deleted the divider-view branch April 2, 2026 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants