Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/pane_layout/pane_layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
5 changes: 5 additions & 0 deletions macros/src/extend_container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
5 changes: 5 additions & 0 deletions macros/src/extend_popup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
7 changes: 7 additions & 0 deletions macros/src/extend_shared_widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
5 changes: 5 additions & 0 deletions macros/src/extend_widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
14 changes: 13 additions & 1 deletion tmui/src/application_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion tmui/src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions tmui/src/runtime/windows_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<u32>) {
pub fn send_resize_event(&mut self, window_id: WindowId, mut size: PhysicalSize<u32>) {
let window = self
.windows
.get(&window_id.into())
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion tmui/src/shared_widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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! {
Expand Down
11 changes: 10 additions & 1 deletion tmui/src/widget/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ impl<T: WidgetImpl + WidgetExt + WidgetInnerExt + ShadowRender> 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()
Expand Down Expand Up @@ -1296,6 +1296,7 @@ pub trait WidgetImpl:
+ ObjectImpl
+ SuperType
+ Layout
+ InnerRunAfter
+ InnerEventProcess
+ PointEffective
+ ChildRegionAcquire
Expand Down Expand Up @@ -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,
Expand Down