diff --git a/examples/pane_layout/pane_layout.rs b/examples/pane_layout/pane_layout.rs index e40c9b6..c5fd795 100644 --- a/examples/pane_layout/pane_layout.rs +++ b/examples/pane_layout/pane_layout.rs @@ -26,7 +26,7 @@ impl ObjectImpl for PaneLayout { fn construct(&mut self) { self.parent_construct(); - self.set_orientation(Orientation::Vertical); + self.set_orientation(Orientation::Horizontal); self.set_hexpand(true); self.set_vexpand(true); diff --git a/macros/src/extend_container.rs b/macros/src/extend_container.rs index 419e6a6..e9f70f3 100644 --- a/macros/src/extend_container.rs +++ b/macros/src/extend_container.rs @@ -497,6 +497,11 @@ pub(crate) fn expand( } } + impl #impl_generics InnerRunAfter for #name #ty_generics #where_clause { + #[inline] + fn inner_run_after(&mut self) {} + } + impl #impl_generics #name #ty_generics #where_clause { #async_method_clause } diff --git a/macros/src/extend_popup.rs b/macros/src/extend_popup.rs index f461e98..b166f96 100644 --- a/macros/src/extend_popup.rs +++ b/macros/src/extend_popup.rs @@ -223,6 +223,11 @@ pub(crate) fn expand( } } + impl #impl_generics InnerRunAfter for #name #ty_generics #where_clause { + #[inline] + fn inner_run_after(&mut self) {} + } + impl #impl_generics #name #ty_generics #where_clause { #async_method_clause } diff --git a/macros/src/extend_shared_widget.rs b/macros/src/extend_shared_widget.rs index 535477e..5e68ff6 100644 --- a/macros/src/extend_shared_widget.rs +++ b/macros/src/extend_shared_widget.rs @@ -159,6 +159,13 @@ pub(crate) fn expand( } } + impl #impl_generics InnerRunAfter for #name #ty_generics #where_clause { + #[inline] + fn inner_run_after(&mut self) { + self.shared_widget.run_after(); + } + } + impl #impl_generics #name #ty_generics #where_clause { #async_method_clause } diff --git a/macros/src/extend_widget.rs b/macros/src/extend_widget.rs index 604fcfc..4ed7a3f 100644 --- a/macros/src/extend_widget.rs +++ b/macros/src/extend_widget.rs @@ -241,6 +241,11 @@ pub(crate) fn expand_with_general_attr( } } + impl #impl_generics InnerRunAfter for #name #ty_generics #where_clause { + #[inline] + fn inner_run_after(&mut self) {} + } + impl #impl_generics #name #ty_generics #where_clause { #async_method_clause } diff --git a/tmui/src/application_window.rs b/tmui/src/application_window.rs index 9223f7c..9b28cf3 100644 --- a/tmui/src/application_window.rs +++ b/tmui/src/application_window.rs @@ -162,6 +162,7 @@ impl WidgetImpl for ApplicationWindow { } for widget in self.run_afters.iter_mut() { let widget = nonnull_mut!(widget); + widget.inner_run_after(); widget.run_after(); #[cfg(verbose_logging)] log::info!("[run_after] `{}` executed run after.", widget.name()); @@ -385,12 +386,19 @@ impl ApplicationWindow { } // Layout changes should be based on its parent widget. - if let Some(parent) = widget.get_raw_parent_mut() { + while let Some(parent) = widget.get_raw_parent_mut() { let parent = unsafe { parent.as_mut().unwrap() }; if !parent.initialized() { return; } + widget = parent; + + if (widget.fixed_width() || widget.hexpand()) + && (widget.fixed_height() || widget.vexpand()) + { + break; + } } Self::layout_of(self.id()).layout_change(widget, false); @@ -688,6 +696,10 @@ impl ApplicationWindow { #[inline] pub(crate) fn when_size_change(&mut self, size: Size) { + if size == Size::default() { + return; + } + emit!(self, size_changed(size)); Self::layout_of(self.id()).set_window_size(size); self.window_layout_change(); diff --git a/tmui/src/prelude.rs b/tmui/src/prelude.rs index 6570c35..099f043 100644 --- a/tmui/src/prelude.rs +++ b/tmui/src/prelude.rs @@ -73,7 +73,7 @@ pub use crate::widget::{ WinWidget, }, ChildOp, ChildRegionAcquire, EventBubble, InnerCustomizeEventProcess, InnerEventProcess, - IsolatedVisibility, PointEffective, ReflectInnerCustomizeEventProcess, + InnerRunAfter, IsolatedVisibility, PointEffective, ReflectInnerCustomizeEventProcess, ReflectIsolatedVisibility, ReflectIterExecutor, ReflectWidgetImpl, Transparency, Widget, WidgetAcquire, WidgetGenericExt, WidgetHnd, WidgetImpl, WidgetPropsAcquire, WidgetSignals, WindowAcquire, diff --git a/tmui/src/runtime/windows_process.rs b/tmui/src/runtime/windows_process.rs index 1e36411..5eff1ec 100644 --- a/tmui/src/runtime/windows_process.rs +++ b/tmui/src/runtime/windows_process.rs @@ -229,7 +229,6 @@ impl<'a, T: 'static + Copy + Send + Sync, M: 'static + Copy + Send + Sync> match event { // Window redraw event. WindowEvent::RedrawRequested => { - debug!("Window redraw requested"); let _track = Tracker::start("physical_window_redraw"); #[cfg(macos_platform)] self.windows @@ -805,7 +804,7 @@ impl<'a, T: 'static + Copy + Send + Sync, M: 'static + Copy + Send + Sync> window.slave.read().signal(); } - pub fn send_resize_event(&mut self, window_id: WindowId, size: PhysicalSize) { + pub fn send_resize_event(&mut self, window_id: WindowId, mut size: PhysicalSize) { let window = self .windows .get(&window_id.into()) @@ -817,6 +816,8 @@ impl<'a, T: 'static + Copy + Send + Sync, M: 'static + Copy + Send + Sync> } else if window.winit_window().is_minimized().unwrap_or_default() { self.window_extremed.insert(wrapped_window_id, true); window.send_input(Message::Event(Box::new(WindowMinimized::new()))); + size.width = 0; + size.height = 0; } else { let is_extremed = self .window_extremed diff --git a/tmui/src/shared_widget.rs b/tmui/src/shared_widget.rs index 46db4c1..9e40f25 100644 --- a/tmui/src/shared_widget.rs +++ b/tmui/src/shared_widget.rs @@ -4,13 +4,14 @@ use tlib::{connect, skia_safe::ImageInfo}; use crate::{ application, backend::create_image_info, + opti::tracker::Tracker, platform::PlatformType, prelude::*, tlib::{ object::{ObjectImpl, ObjectSubclass}, run_after, }, - widget::WidgetImpl, opti::tracker::Tracker, + widget::WidgetImpl, }; lazy_static! { diff --git a/tmui/src/widget/mod.rs b/tmui/src/widget/mod.rs index b61e912..80c427e 100644 --- a/tmui/src/widget/mod.rs +++ b/tmui/src/widget/mod.rs @@ -577,7 +577,7 @@ impl ElementImpl for return; } else if !self.first_rendered() || self.render_styles() { let _track = Tracker::start(format!("single_render_{}_styles", self.name())); - let mut background = if self.first_rendered() && !self.is_animation_progressing() { + let mut background = if !self.is_animation_progressing() { self.opaque_background() } else { self.background() @@ -1296,6 +1296,7 @@ pub trait WidgetImpl: + ObjectImpl + SuperType + Layout + + InnerRunAfter + InnerEventProcess + PointEffective + ChildRegionAcquire @@ -1711,6 +1712,14 @@ pub trait IsolatedVisibility: WidgetImpl { fn shadow_rect_mut(&mut self) -> &mut FRect; } +////////////////////////////////////// InnerRunAfter ////////////////////////////////////// +pub trait InnerRunAfter { + fn inner_run_after(&mut self); +} +impl InnerRunAfter for Widget { + fn inner_run_after(&mut self) {} +} + /// `MouseEnter`/`MouseLeave`: /// - `MouseEnter` fires when the mouse pointer enters the bounds of an element, /// and does not bubble up from child elements. It is triggered less frequently,