mirror of
https://github.com/danbulant/appit
synced 2026-06-13 19:31:21 +00:00
delay_visible activation + initialized
This commit is contained in:
parent
331bfdd353
commit
68530e7d69
2 changed files with 21 additions and 4 deletions
|
|
@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
- `Window`'s `Clone` implementation no longer requires its generic parameter to
|
||||
implement `Clone`.
|
||||
- `WindowAttributes::active` is now honored when using `delay_visible`.
|
||||
|
||||
### Added
|
||||
|
||||
|
|
@ -34,6 +35,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
current size including decorations.
|
||||
- `App::prevent_shutdown()` returns a guard that prevents the application from
|
||||
closing automatically when the final window is closed.
|
||||
- `WindowBehavior::initialized` is called once when the window has been fully
|
||||
initialized. This happens after the `delay_visible` logic has been executed.
|
||||
|
||||
### Changed
|
||||
|
||||
|
|
|
|||
|
|
@ -231,8 +231,10 @@ where
|
|||
let (sender, receiver) = mpsc::sync_channel(65536);
|
||||
let sender = Arc::new(sender);
|
||||
let app = self.owner.as_application().app();
|
||||
let show_after_init =
|
||||
self.attributes.delay_visible && std::mem::replace(&mut self.attributes.visible, false);
|
||||
let show_after_init = (self.attributes.delay_visible
|
||||
&& std::mem::replace(&mut self.attributes.visible, false))
|
||||
.then_some(self.attributes.active);
|
||||
|
||||
let Some(winit) = self.owner.as_application_mut().open(
|
||||
self.attributes,
|
||||
sender.clone(),
|
||||
|
|
@ -313,7 +315,7 @@ where
|
|||
focused: bool,
|
||||
theme: Theme,
|
||||
modifiers: Modifiers,
|
||||
show_after_init: bool,
|
||||
show_after_init: Option<bool>,
|
||||
}
|
||||
|
||||
impl<AppMessage> RunningWindow<AppMessage>
|
||||
|
|
@ -487,12 +489,17 @@ where
|
|||
// avoid showing a blank window due to our multi-threaded event
|
||||
// handling by not showing the window until the graphics stack has
|
||||
// been initialized.
|
||||
if self.show_after_init {
|
||||
if let Some(activate) = dbg!(self.show_after_init) {
|
||||
self.next_redraw_target = None;
|
||||
behavior.redraw(&mut self);
|
||||
self.window.set_visible(true);
|
||||
if activate {
|
||||
self.window.focus_window();
|
||||
}
|
||||
}
|
||||
|
||||
behavior.initialized(&mut self);
|
||||
|
||||
while !self.close {
|
||||
match self.process_messages_until_redraw(&mut behavior) {
|
||||
Ok(guard) => {
|
||||
|
|
@ -985,6 +992,13 @@ where
|
|||
/// Displays the contents of the window.
|
||||
fn redraw(&mut self, window: &mut RunningWindow<AppMessage>);
|
||||
|
||||
/// Invoked once a window is fully initialized.
|
||||
///
|
||||
/// This is invoked after the window has been presented to the user, if it
|
||||
/// is initially visible.
|
||||
#[allow(unused_variables)]
|
||||
fn initialized(&mut self, window: &mut RunningWindow<AppMessage>) {}
|
||||
|
||||
/// The window has been requested to be closed. This can happen as a result
|
||||
/// of the user clicking the close button.
|
||||
///
|
||||
|
|
|
|||
Loading…
Reference in a new issue