Conversation
7cf7b60 to
66db763
Compare
701d4e8 to
f1d1650
Compare
luleyleo
left a comment
There was a problem hiding this comment.
This sure cleans up quite a bit 👍 It would deserve a Maintenance changelog entry as well but as those purely internal only changes, there is no need for it.
Also I got a few more comments.
druid/src/core.rs
Outdated
| } | ||
|
|
||
| /// Static state that is shared between most contexts. | ||
| pub(crate) struct RootState<'a> { |
There was a problem hiding this comment.
How about calling this ContextState akin to WidgetState? Because RootState really could mean anything.
druid/src/contexts.rs
Outdated
| } | ||
| } | ||
|
|
||
| impl<'a> RootState<'a> { |
There was a problem hiding this comment.
It's a bit odd to have the impl in a different file than the struct itself. Maybe put both into contexts.rs?
There was a problem hiding this comment.
this is fair, I think the impl really should be here so maybe I'll move RootState/ContextState back here as well.
druid/src/contexts.rs
Outdated
| pub struct LayoutCtx<'a, 'b: 'a, 'c> { | ||
| pub(crate) root_state: &'a mut RootState<'c>, |
There was a problem hiding this comment.
This might be a bit annoying to change but it would be nice if all 'bs refer to the RootStates lifetime.
There was a problem hiding this comment.
yea that would be nice but doesn't work unfortunately. :(
There was a problem hiding this comment.
How so? The only 'issue' I see is PainCtx as it does not have RootState 🤔
There was a problem hiding this comment.
oh sorry I thought you meant that we reuse 'b here for both inner lifetimes.
druid/src/contexts.rs
Outdated
| } | ||
|
|
||
| impl<'a, 'b> LayoutCtx<'a, 'b> { | ||
| impl<'a, 'b, 'c> LayoutCtx<'a, 'b, 'c> { |
There was a problem hiding this comment.
Might be useful for the macro introduced by #972 :
This 'b and RootStates 'a are the only required lifetimes in this file (for two functions only), all others could be elided using '_.
There was a problem hiding this comment.
interesting, I'll play around with that.
There was a problem hiding this comment.
cool, I was able to simplify the lifetimes quite a bit, i'd forgotten they'd relaxed that rule :)
There was a problem hiding this comment.
I also still keep adding them and then only realize afterwards that it was completely unnecessary 😅
66db763 to
ddeeca5
Compare
f1d1650 to
6713aa7
Compare
ddeeca5 to
5d1aa86
Compare
I think it makes sense for show_context_menu to only be available in EventCtx, but for the window menu I can imagine needing it in lifecycle and update (and I need it in update in runebender)
6713aa7 to
74fa6a9
Compare
|
/bloat |
🗜 Bloat check ⚖️Comparing 74fa6a9 against e024f60
|
74fa6a9 to
8fc5863
Compare
druid/src/core.rs
Outdated
| child_state: &mut WidgetState, | ||
| window_id: WindowId, | ||
| window: &WindowHandle, | ||
| root_state: &mut ContextState, |
CHANGELOG.md
Outdated
| - `im::Vector` support for the `List` widget. ([#940] by [@xStrom]) | ||
| - `LifeCycle::Size` event to inform widgets that their size changed. ([#953] by [@xStrom]) | ||
| - `Button::dynamic` constructor. ([#963] by [@totsteps]) | ||
| - Add `set_menu` method to `UpdateCtx` and `LifeCycleCtx` ([#970] by [@cmyr]) |
There was a problem hiding this comment.
Given how all the other items under the Added section are written, probably better to remove the word Add from the start here.
luleyleo
left a comment
There was a problem hiding this comment.
Looks good!
Gotta be pedantic about that changelog entry tho 🙈
CHANGELOG.md
Outdated
| - `im::Vector` support for the `List` widget. ([#940] by [@xStrom]) | ||
| - `LifeCycle::Size` event to inform widgets that their size changed. ([#953] by [@xStrom]) | ||
| - `Button::dynamic` constructor. ([#963] by [@totsteps]) | ||
| - Add `set_menu` method to `UpdateCtx` and `LifeCycleCtx` ([#970] by [@cmyr]) |
There was a problem hiding this comment.
Let's keep the style consistent.
| - Add `set_menu` method to `UpdateCtx` and `LifeCycleCtx` ([#970] by [@cmyr]) | |
| - `UpdateCtx::set_menu` and `LifeCycleCtx::set_menu` ([#970] by [@cmyr]) |
This adds a new type, RootState that holds onto all of the app/window-scoped state that is shared between all non-paint contexts. Simplify context lifetimes fixup
8fc5863 to
ce8a1b2
Compare
This is two related commits:
set_menumethod to the lifecycle and update contextsThis is based on #969, which should go in first.