Unify button label drawing in a shared routine button_label#276
Unify button label drawing in a shared routine button_label#276lhecker merged 3 commits intomicrosoft:mainfrom
button_label#276Conversation
- Adds support for accelerator characters in any button's label - Allow checkboxes, brackets, accelerator chars to be drawn conditionally with ButtonStyle
lhecker
left a comment
There was a problem hiding this comment.
One minor thing, but otherwise this looks absolutely fantastic!
| #[derive(Clone, Copy)] | ||
| pub struct ButtonStyle { | ||
| accelerator: Option<char>, | ||
| checked: Option<bool>, | ||
| bracketed: bool, | ||
| } |
There was a problem hiding this comment.
FYI: In the future we'll likely have to remove this again. The long-term plan is to add an extension API, including a way to expose the UI framework (so that extensions can draw their own UI). No matter what type of extensions we build, it's unlikely that we can just expose a builder pattern as-is.
However, I think those concerns are still in the distant future so not worth freaking out about just yet. But I figured you may find it curious if you want to ever contribute other parts, or if you simply wondered why the current UI framework is so verbose.
There was a problem hiding this comment.
It could be replaced with a basic struct e.g. ButtonStyle { checked: None, accelerator: None, bracketed: true }, which might make it easier to map through an FFI boundary?
Or perhaps buttons end up with their own "NodeContent" enumeration, so you can set attributes over a number of calls and leave the drawing to the render phase.
lhecker
left a comment
There was a problem hiding this comment.
Thank you so much for the PR! I'll try to test it thoroughly over the coming days. 🙂
|
(I didn't leave a final comment, but I wanted to let you know that I found this PR clever and concise. Thanks for working on it!) |
…oft#276) - Adds support for accelerator characters in any button's label - Allow checkboxes, brackets, accelerator chars to be drawn conditionally with ButtonStyle Closes microsoft#48
This PR offers a resolution for #48
Existing accelerator-enabled buttons draw as before:

But other buttons may now visualize their accelerator character:

Behavior for other localisations:
