-
Notifications
You must be signed in to change notification settings - Fork 128
Add a "gallery"-type example for Xilem's Label View #864
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
d46449f
to
fe0b012
Compare
My initial feedback here is that Label is that we shouldn't be encouraging developers to reach for I also want to check (as a self-calibration exercise only), was this code LLM assisted? |
That makes sense to me. I think there's something in the naming of label which needs to change, probably. I would agree that we should probably have a paragraph at the start of this, explaining why Label exists and how to use it (which should be copied into Label's docs). That does look pretty cool. Is that saying that the confirm action happens if you press enter or alt-k? I'm not sure about the flex issue. I know that our layout story is still... in flux at the moment. I don't know when I'll find time to review this.
No, I've not tried it myself. I'd hope that they don't, to be honest, because we're still at a stage of refining our APIs. The formatting definitely needs to be changed to follow the Rust style guide. The reason that this isn't happening is the eternally vexing rustfmt issue, rust-lang/rustfmt#3863. We have a few workarounds in the past, e.g. linebender/vello#499 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be nice to get something like this in. It's great to see an exploration of the full range of options here.
This is still blocked on the formatting. I think the 2024 style edition might have resolved this not being formatted, but I've not checked it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that xilem
and view
in this title really carry their weight
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That follows from the desire to differentiate Xilem's Label View from Masonry Label Widget
What title would you like?
fn lc(text: impl Into<ArcStr>) -> Label { | ||
//colored label | ||
label(text).brush(LABEL_COLOR) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name lc
here is actually really interesting.
The "tailwind" style of micro components, requires that you name the components. Which has
Because lc
is to me clearly not a good name, but I don't know what a good name for this would be; the component is so minimal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the minimal name here is so that all the props fit in a single screen width, which with the waste of 4 spaces per indent level and 3 indents in some cases is a challenge
So the only important part in
lc("4/4 alignment Justified" ).alignment(TextAlignment::Justified ).grid_pos(0,3),
is alignment/grid info, so whether it's l
or lc
doesn't really matter, but it fits in 100 chars
|
||
portal( | ||
flex(( | ||
(txt_prose("Xilem view::Label formats vGit@25-02 #25b12ad (in a ↕-scrollable area)").text_size(18.0), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does vGit@25-02 #25b12ad
add? I can parse out that it's that the example was developed in February 2025 based on 25b12ad, but I'm not sure why it's here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the framework can change a lot and docs can lag, this references how old/relevant the examples are without having to search for the source cargo file. Idealy this would just be xilem version, but it's not released frequently enough to use as a reference
// doesn't seem to be different now vs unconstrained | ||
// (lc(" •flex in a 200×70 box to show impact of constraints ").alignment(TextAlignment::Start), | ||
// sized_box( | ||
// flex(( | ||
// lc("1/4 alignment Start" ).alignment(TextAlignment::Start ), | ||
// lc("2/4 alignment Middle" ).alignment(TextAlignment::Middle ), | ||
// lc("3/4 alignment End" ).alignment(TextAlignment::End ), | ||
// lc("4/4 alignment Justified" ).alignment(TextAlignment::Justified ), | ||
// )) | ||
// ).width(200f64).height(70f64).padding(Padding::from(0.)) | ||
// .background(css::LIGHT_GRAY) // .border(css::RED,0.).rounded(RoundedRectRadii::from_single_radius(0.)) | ||
// ,), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will need to be resolved before we can merge; it's not clear what it's doing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
repurposed this into a comparison of how labels spread within a flex vs grid
.brush(l_c) //impl Into<peniko:Brush> brush sets text color, but gradients and images are also supported Solid(color::AlphaColor<Srgb>) Gradient(Gradient) Image(Image), | ||
.line_break_mode(LineBreaking::Overflow) //WordWrap Clip Overflow | ||
, | ||
title_prose(format!("§{i} .alignment")),{i+=1;}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should break this out into multiple expressions, if we're incrementing the counter inside the expression.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't understand this, meanwhile just changed the order so that unused_assignments
allowance isn't needed anymore
.brush(l_c) //impl Into<peniko:Brush> brush sets text color, but gradients and images are also supported Solid(color::AlphaColor<Srgb>) Gradient(Gradient) Image(Image), | ||
.line_break_mode(LineBreaking::Overflow) //WordWrap Clip Overflow | ||
, | ||
title_prose(format!("§{i} .alignment")),{i+=1;}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice use of the section symbol! It's a nice little showcase that we just find the fonts for stuff like that correctly (even though it is a fairly easy case)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does ↕-scrollable area
work for you (in the title)? Or ≝ default signifier in 4 options: ≝Start Middle End Justified
? I see squares there
I don't get it, but locally on Windows |
Co-authored-by: Daniel McNab <[email protected]>
9cfcb01
to
5f7f3f6
Compare
There are existing issues re. the general state of docs with Xilem
#392
#851
so this PR is a suggestion on covering one area I missed when reading the docs: being able to have
So this is an example of a simple gallery-type app that covers Xilem's Label View (but not Masonry Label Widget) where you can simply vertically scroll to see all the available options and even some notes on interaction issues: e.g., the fact that a label with a Start alignment starts in the middle because its parent vertical flex has a Center alignment by default for its horizontal axis. Now, you could find this explanation deep down in Masonry tests, but that would require a lot of digging around (and Masonry screenshots wouldn't show it).
After identifying an issue this example also shows a suggested fix by using
.flex
, though if I do the override, I lose the portal's vertical scrolling, which might be a 🐞bug or just a missing understanding on my part of how these portal/flex/.flex elements interact, in which case it would be nice to change to a better example and to have a shorter alignment section that didn't have to note these issues.Now, there are a few missing pieces, but think this might be still be a good initial fix:
As far as I understand mostly blocked by missing functionality support in the framework:
But also just not yet implemented:
(these are also added in the Todos comment section in the example itself)