-
Notifications
You must be signed in to change notification settings - Fork 567
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
Associate timers with widget ids #831
Merged
Merged
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
1d099bd
1) More aggressive Timer event traversal.
3f47c3f
1) Comment
1bdc803
Fix clippy warnings.
dd7892e
1) After merging up, Im clearing the map of BaseState. So remove is n…
sjoshid 12cbde9
Merge branch 'master' of https://github.com/xi-editor/druid into Time…
6349aa4
1) Removing window's timer token before adding base state's token to it.
e6b8496
Merge branch 'master' of https://github.com/xi-editor/druid into Time…
sjoshid 3d4870a
Changes as per https://github.com/xi-editor/druid/pull/831#issuecomme…
sjoshid 2e6b493
Changes as per https://github.com/xi-editor/druid/pull/831#issuecomme…
sjoshid 9a91913
Removing unused import.
sjoshid 0b77763
1) Fmt changes
38210fa
1) Code review changes.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,18 +14,19 @@ | |
|
||
//! Management of multiple windows. | ||
|
||
use std::collections::HashMap; | ||
use std::mem; | ||
use std::time::Instant; | ||
|
||
use crate::core::{BaseState, CommandQueue, FocusChange}; | ||
use crate::kurbo::{Insets, Point, Rect, Size}; | ||
use crate::piet::{Piet, RenderContext}; | ||
use crate::shell::{Counter, Cursor, WindowHandle}; | ||
|
||
use crate::core::{BaseState, CommandQueue, FocusChange}; | ||
use crate::win_handler::RUN_COMMANDS_TOKEN; | ||
use crate::{ | ||
BoxConstraints, Command, Data, Env, Event, EventCtx, LayoutCtx, LifeCycle, LifeCycleCtx, | ||
LocalizedString, MenuDesc, PaintCtx, UpdateCtx, Widget, WidgetId, WidgetPod, WindowDesc, | ||
LocalizedString, MenuDesc, PaintCtx, TimerToken, UpdateCtx, Widget, WidgetId, WidgetPod, | ||
WindowDesc, | ||
}; | ||
|
||
/// A unique identifier for a window. | ||
|
@@ -43,6 +44,7 @@ pub struct Window<T> { | |
pub(crate) last_anim: Option<Instant>, | ||
pub(crate) focus: Option<WidgetId>, | ||
pub(crate) handle: WindowHandle, | ||
pub(crate) timers: HashMap<TimerToken, WidgetId>, | ||
// delegate? | ||
} | ||
|
||
|
@@ -58,6 +60,7 @@ impl<T> Window<T> { | |
last_anim: None, | ||
focus: None, | ||
handle, | ||
timers: HashMap::new(), | ||
} | ||
} | ||
} | ||
|
@@ -145,6 +148,7 @@ impl<T: Data> Window<T> { | |
window: &self.handle, | ||
window_id: self.id, | ||
focus_widget: self.focus, | ||
timers: &self.timers, | ||
}; | ||
|
||
self.root.event(&mut ctx, &event, data, env); | ||
|
@@ -169,6 +173,11 @@ impl<T: Data> Window<T> { | |
self.lifecycle(queue, &LifeCycle::RouteWidgetAdded, data, env); | ||
} | ||
|
||
//If at least one widget requested timer, collect those timers from widgets and add to window's timers map. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If at least one widget requested a timer, |
||
if base_state.request_timer { | ||
self.timers.extend(base_state.timers); | ||
} | ||
|
||
is_handled | ||
} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
After widgets are done processing timer events, should we all ask them to remove map entry?
This is not used anywhere in examples.
I think framework needs to remove it rather than forcing widgets to remove it themselves.
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.
After merging up, Im clearing the map of BaseState. So remove is not needed when event is handled.