-
Notifications
You must be signed in to change notification settings - Fork 135
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.
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
.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
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.
Well like i+=1
is not a meaningful view; it only happens to work here because it has type ()
, which is the empty tuples, and nested tuples are allowed. We shouldn't have assignment expressions inside view writing code
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 don't understand the proposed change to fix it without having to manually track index increments.
The narrow issue of empty tuples could be fixed via {i+=1;title_prose(format!("§ {i} .alignment"))}
which results in a single valid view result
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.
Ah - when I said expressions above, I meant "statements". Sorry for the confusion
I don't get it, but locally on Windows |
9cfcb01
to
5f7f3f6
Compare
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 is still blocked on applying the Rust style guide.
I know that rustfmt breaks with big expressions; that is another reason to suggest breaking it up into multiple expressions (perhaps a component per section)?
button("Δ1/6", |da:&mut AppState|{da.realign("l1i1");}), | ||
button("Δ2/6", |da:&mut AppState|{da.realign("l1i2");}), | ||
button("Δ3/6", |da:&mut AppState|{da.realign("l1i3");}), | ||
button("Δ4/6", |da:&mut AppState|{da.realign("l1i4");}), | ||
button("Δ5/6", |da:&mut AppState|{da.realign("l1i5");}), | ||
button("Δ6/6", |da:&mut AppState|{da.realign("l1i6");}), |
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's not all that clear what these buttons are useful for?
Even so, with having them, I think they could probably also be changed into an enumarted loop over a sub-array of the state.
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.
For playing with various styling in real time. While currently for some styles all the variants are already included, so buttons are of limited use when you want to see e.g. the whole "table" of labels aligned the same way, that's not true for all styles - Cross-alignment doesn't list all the combos. Neither would font families (though those don't have dynamic buttons/pickers at the moment) and colors/sizes
Co-authored-by: Daniel McNab <[email protected]>
310e02a
to
3bb8789
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)