-
Notifications
You must be signed in to change notification settings - Fork 0
Use environment system to wire up a radio_group context with radio_buttons #1
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: radio_button
Are you sure you want to change the base?
Use environment system to wire up a radio_group context with radio_buttons #1
Conversation
|
Cool! This will be useful for a drop down widget in the future too. |
|
An alternative way would be to use I think either way is good for me, the advantage of using |
I didn't quite understand the |
|
Also, off-topic: I was thinking these days to use the environment stuff to broadcast "live" system settings, like color scheme or standard keyboard shortcuts. |
On another thought, I don't think it's really (easily) possible, we need to get the value of the
What I meant is that the But then again, it's not really easily possible, as we need to give the current Filter value to the |
|
I see. I tried with |
This is a very dirty draft/idea that takes into account ideas of #xilem > Simplify checkbox?
and the idea proposed in linebender#1428
So don't look too close into the code yet, I'll clean this up, when this is a viable direction.
I'll try to explain how this works on a higher level, to hopefully save you some time skimming/reading the preliminary code:
This is logically similar as
ProvidesandWithContext, i.e. theradio_group"provides" a function pointer (mostly to avoid all the issues with genericFntraits as this type needs to be known in different places of the view tree) to access a value, andradio_buttonaccesses this function pointer to get the current value and potentially modify it when aRadioButtonToggledevent occured.Checkout the updated
to_do_mvcexample to get an idea how this looks in practice.There were some hacks necessary (e.g. in xilem/src/driver.rs) which might need some discussion.
Worth of discussion is also whether we want to use a function pointer, I might overlooked something, but the main "drawback" compared to e.g.
Fnwould be non-capturing, which I think is acceptable (as I don't think it's too clean anyway to capture values here).Another point would be whether we want to directly provide this functionality in masonry, I've decided against this for now, as I think it would be more complicated, and might not even be something that we want there (too opinionated abstraction at this level?)
(Ignore most of the changes in
xilem_corethese were mostly shortcuts, to be able to copy/paste a lot of code without modifying too much, just to get a quick idea, though it hints, that we might want to provide some abstractions for this, as there's quite a bit of code-duplication between the mentioned core views)CC @DJMcNab