From d25177f3207740b307ea967c6be2e5d0a63208aa Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 17 Nov 2026 18:10:29 +0000 Subject: [PATCH 1/3] Native trial: the test OS clamps a window's size to its limits, as real ones do --- crates/ui-patterns/tests/it/docking/native.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/crates/ui-patterns/tests/it/docking/native.rs b/crates/ui-patterns/tests/it/docking/native.rs index 9d97a05ed5..df74007eda 100644 --- a/crates/ui-patterns/tests/it/docking/native.rs +++ b/crates/ui-patterns/tests/it/docking/native.rs @@ -523,8 +523,21 @@ fn a_native_palette_collapsed_moved_and_expanded_comes_back_at_its_size() { let follow = |dock: &mut NativeDock, at: &mut Rect, frames: usize| { let mut sent = Vec::new(); for _ in 0..frames { + // The OS clamps a size to the maximum in force when it takes the command: the one the previous frames + // left, then each limit command of this frame in order. + let mut max = dock.builder.as_ref().and_then(|builder| builder.max_inner_size); let commands = dock.frame(vec![]).1; - *at = placed_by(&commands, *at); + for command in &commands { + match command { + ViewportCommand::MaxInnerSize(limit) => max = Some(*limit), + ViewportCommand::InnerSize(size) => { + let size = max.map_or(*size, |max| size.min(max)); + *at = Rect::from_min_size(at.min, size); + } + ViewportCommand::OuterPosition(to) => *at = Rect::from_min_size(*to, at.size()), + _ => {} + } + } dock.windows.child_info(info(true, *at)); sent.extend(commands); } @@ -552,6 +565,7 @@ fn a_native_palette_collapsed_moved_and_expanded_comes_back_at_its_size() { let sent = follow(&mut dock, &mut at, 3); assert!(sent.contains(&ViewportCommand::InnerSize(expanded)), "the window takes its expanded size back: {:?}", placing(&sent)); assert_eq!(at.min, dropped.min, "it opens from the strip's place, against the start edge"); + assert_eq!(at.size(), expanded, "the OS window grows although the strip's limits capped it when the size was sent"); let max = dock.builder.as_ref().and_then(|builder| builder.max_inner_size); assert!(max.is_none_or(|max| max.x >= expanded.x && max.y >= expanded.y), "the OS lets it take that size: max {max:?}"); } From ed277c7a81526ba0470a1bc70dafd30ba010bf8b Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 17 Nov 2026 18:04:19 +0000 Subject: [PATCH 2/3] Trial: a click on the double arrow of a collapsed native palette at 125 % expands it --- crates/ui-patterns/tests/it/docking/native.rs | 41 ++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/crates/ui-patterns/tests/it/docking/native.rs b/crates/ui-patterns/tests/it/docking/native.rs index df74007eda..b9c780d98d 100644 --- a/crates/ui-patterns/tests/it/docking/native.rs +++ b/crates/ui-patterns/tests/it/docking/native.rs @@ -570,6 +570,40 @@ fn a_native_palette_collapsed_moved_and_expanded_comes_back_at_its_size() { assert!(max.is_none_or(|max| max.x >= expanded.x && max.y >= expanded.y), "the OS lets it take that size: max {max:?}"); } +/// On a display at 125 % (Windows), a click on the double arrow of a native palette collapsed to icons expands its +/// column, and the OS window takes its expanded size. +#[trial] +fn a_click_on_the_double_arrow_of_a_collapsed_native_palette_expands_it() { + const SCALE: f32 = 1.25; + let mut dock = NativeDock::on(Os::Windows, Arc::new(FakeSystem::new())); + dock.windows.root_info(scaled(true, MAIN_AT, SCALE)); + let mut at = FLOAT_AT; + // The OS follows the window commands of each frame, and the window reports where it is. + let frame = |dock: &mut NativeDock, at: &mut Rect, events: Vec| { + let (actions, commands) = dock.frame(events); + *at = placed_by(&commands, *at); + dock.windows.child_info(scaled(true, *at, SCALE)); + actions + }; + frame(&mut dock, &mut at, vec![]); + dock.workspace.apply(Action::set_iconic(1, true), false, |_| Permissions::ALL).expect("the column collapses"); + for _ in 0..3 { + frame(&mut dock, &mut at, vec![]); + } + assert!(dock.workspace.layout.floating[0].column.iconic, "the column is collapsed"); + assert!(at.width() < FLOAT_AT.width(), "the OS window shows the strip: {at:?}"); + + // The double arrow is the title row's square at the end the strip keeps to: a point just inside its outer corner. + let end = at.max.x >= FLOAT_AT.max.x - 1.0 && at.min.x > FLOAT_AT.min.x + 1.0; + let arrow = Pos2::new(if end { at.width() - 4.0 } else { 4.0 }, 4.0); + let mut actions = Vec::new(); + for events in [vec![moved(arrow)], vec![press(arrow)], vec![release(arrow)], vec![], vec![]] { + actions.extend(frame(&mut dock, &mut at, events)); + } + assert!(!dock.workspace.layout.floating[0].column.iconic, "the click expands the column: {actions:?}"); + assert_eq!(at.size(), FLOAT_AT.size(), "the OS window takes its expanded size"); +} + /// Palettes no smaller than `PALETTE_LEAST`. struct Least; @@ -711,11 +745,16 @@ fn float() -> Floating { } fn info(focused: bool, rect: Rect) -> ViewportInfo { + scaled(focused, rect, 1.0) +} + +/// The facts of a window at `rect` on a display of `pixels_per_point`. +fn scaled(focused: bool, rect: Rect, pixels_per_point: f32) -> ViewportInfo { ViewportInfo { focused: Some(focused), inner_rect: Some(rect), outer_rect: Some(rect), - native_pixels_per_point: Some(1.0), + native_pixels_per_point: Some(pixels_per_point), ..ViewportInfo::default() } } From 0238e191e3f83bfe5374abe0438b5048113035f5 Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 17 Nov 2026 18:07:20 +0000 Subject: [PATCH 3/3] Native dock windows: the mount carries that the app moves the window (Overlay::moved_by_app), so its first pass knows it before the Windows hit test is routed --- .../ui-contract/src/contract/body/window.rs | 4 +- crates/ui-contract/src/contract/mount.rs | 1 + .../ui-contract/src/contract/overlay/props.rs | 12 ++++++ crates/ui-contract/src/runtime/windows.rs | 17 ++++---- .../ui-contract/src/runtime/windows/native.rs | 11 +---- .../src/runtime/windows/viewport.rs | 3 ++ crates/ui-contract/src/testing/windows.rs | 5 ++- crates/ui-panels/src/docking/floating.rs | 7 ++-- crates/ui-panels/src/docking/native.rs | 8 ---- crates/ui-patterns/tests/it/docking/native.rs | 40 +++++++++++++++++++ docs/contract-api.md | 8 ++-- docs/ui-docking.md | 2 +- 12 files changed, 80 insertions(+), 38 deletions(-) diff --git a/crates/ui-contract/src/contract/body/window.rs b/crates/ui-contract/src/contract/body/window.rs index ffe88ce169..0ee15ed8a4 100644 --- a/crates/ui-contract/src/contract/body/window.rs +++ b/crates/ui-contract/src/contract/body/window.rs @@ -110,7 +110,7 @@ impl WindowMode { } } -/// A move of a viewport mount's OS window that the app runs ([`windows::keeps_app_drag`]), from its Begin to its Commit +/// A move of a viewport mount's OS window that the app runs (`Overlay::moved_by_app`), from its Begin to its Commit /// or Cancel. Rects are the window's outer rect in desktop points. #[derive(Clone, Copy, PartialEq)] struct WindowMove { @@ -562,7 +562,7 @@ impl BodyHooks<'_> { self.mode.sizing = Some(sizing); } - /// The move of an OS window whose app runs it ([`windows::keeps_app_drag`]): a drag of the move band keeps the + /// The move of an OS window whose app runs it (`Overlay::moved_by_app`): a drag of the move band keeps the /// pressed point under the pointer, and each step is reported through `placement_changed` as a layer's move is, /// from Begin to Commit or Cancel. Where the platform tracks the OS's moves ([`Caps::OS_MOVES_TRACKED`]) the OS /// moves the window, from the press: `StartMove` hands it the press event, which a later pass no longer has. The diff --git a/crates/ui-contract/src/contract/mount.rs b/crates/ui-contract/src/contract/mount.rs index fe80781be0..eb8b2635cf 100644 --- a/crates/ui-contract/src/contract/mount.rs +++ b/crates/ui-contract/src/contract/mount.rs @@ -373,6 +373,7 @@ impl Host for ViewportHost { // The full-window overlay has no grips (it covers the window), but its OS window is one the user sizes. A // window its caller sizes takes no resize from the OS: the app runs its grips. resizable: full_window || (self.overlay.resize.edges != ResizeEdges::NONE && !self.overlay.resize.by_caller), + moved_by_app: self.overlay.moved_by_app, }; let dismissed = &mut self.dismissed; windows::show_viewport(&ctx, &open, |ui| { diff --git a/crates/ui-contract/src/contract/overlay/props.rs b/crates/ui-contract/src/contract/overlay/props.rs index 5f1f188424..378413f737 100644 --- a/crates/ui-contract/src/contract/overlay/props.rs +++ b/crates/ui-contract/src/contract/overlay/props.rs @@ -137,6 +137,11 @@ pub struct Overlay { /// Whether the layer's move band moves the OS window the layer is shown in, in place of the layer: the chrome a /// modal puts over the part of a title bar it covers. The layer stays where it is placed. pub moves_window: bool, + /// Whether the app moves the OS window a viewport mount shows in from the move band, never the operating system's + /// move loop: a press on the band reaches the container, which reports each step of the move (a dock window's + /// title row, whose move docks the window). The window is opened knowing it, so its hit test never hands the band + /// to the system. A layer is always moved by the app. + pub moved_by_app: bool, /// Set only by [`Overlay::full_window`]. full_window: bool, } @@ -174,6 +179,7 @@ impl Overlay { opacity: 1.0, body_scroll: true, moves_window: false, + moved_by_app: false, full_window: false, } } @@ -433,6 +439,12 @@ impl Overlay { self } + /// The app moves the OS window from the move band ([`Overlay::moved_by_app`]). + pub fn moved_by_app(mut self) -> Overlay { + self.moved_by_app = true; + self + } + /// Sets the focus scope. pub fn focus(mut self, focus: FocusPolicy) -> Overlay { self.focus = focus; diff --git a/crates/ui-contract/src/runtime/windows.rs b/crates/ui-contract/src/runtime/windows.rs index 9a1d907447..9de47ae824 100644 --- a/crates/ui-contract/src/runtime/windows.rs +++ b/crates/ui-contract/src/runtime/windows.rs @@ -35,8 +35,6 @@ pub(crate) use hit::{hit_sink_installed, note_exclusive}; use hit::{publish_regions, replay_caption_events}; pub use host::{KeyEquivalent, WindowFacts, WindowHost}; pub(crate) use host::{clear_source_pointer, note_moved_pointer, note_source_pointer}; -#[doc(hidden)] -pub use native::keeps_app_drag; #[cfg(windows)] #[doc(hidden)] pub use native::route_root; @@ -132,8 +130,9 @@ pub(crate) struct Record { /// The opacity the window was last set to; 1 is opaque. opacity: Option, /// The app runs the window's move from its move band (a dock window's title row, whose move docks the window), so a - /// press on the band must reach it and the operating system's move loop is not started from the hit test. - app_drag: bool, + /// press on the band must reach it and the operating system's move loop is not started from the hit test. Set from + /// the mount's `ViewportOpen::moved_by_app` before each of the window's passes, its first included. + moved_by_app: bool, /// While the app moves the window: the desktop pointer, at the pressed point of the window where the move last put /// it. The window's reported place lags the move. moved_pointer: Option, @@ -179,9 +178,9 @@ pub(crate) fn take_sent(ctx: &Context) -> Vec<(ViewportId, WindowAction)> { shared(ctx, |shared| std::mem::take(&mut shared.sent)) } -/// Whether the app runs the move of `viewport`'s window ([`keeps_app_drag`]). +/// Whether the app runs the move of `viewport`'s window (`Overlay::moved_by_app`). pub(crate) fn app_moves(ctx: &Context, viewport: ViewportId) -> bool { - PerViewport::::with(ctx, viewport, |record| record.app_drag) + PerViewport::::with(ctx, viewport, |record| record.moved_by_app) } /// Called by `install`: keeps the shell, the app id, the OS services and the placement store. @@ -411,8 +410,8 @@ pub fn logic(ctx: &Context) { /// AppKit's flag is set, after the window's UI has run. A window is told apart by its viewport: the key window is the one /// whose viewport has focus, so an unfocused viewport is left as it is. AppKit is only called when the flag changes. /// Only a macOS window with a full-size content view has a flag to set; elsewhere this does nothing. A window whose -/// move the app runs ([`keeps_app_drag`]) keeps AppKit's own flag: AppKit moves it for the move's hand-off and resizes -/// it from its edges only while it is movable. +/// move the app runs (`Overlay::moved_by_app`) keeps AppKit's own flag: AppKit moves it for the move's hand-off and +/// resizes it from its edges only while it is movable. fn sync_movable(ctx: &Context) { if !viewports::current(ctx).focus_reported { return; @@ -420,7 +419,7 @@ fn sync_movable(ctx: &Context) { let movable = viewports::movable(ctx); let viewport = pass::current_viewport(ctx); PerViewport::::with(ctx, viewport, |record| { - if !record.app_drag && record.movable_applied != Some(movable) { + if !record.moved_by_app && record.movable_applied != Some(movable) { craft_window::mac::set_movable(movable, &mut record.movable_applied); } }); diff --git a/crates/ui-contract/src/runtime/windows/native.rs b/crates/ui-contract/src/runtime/windows/native.rs index 6fa828cfbc..965dd9f886 100644 --- a/crates/ui-contract/src/runtime/windows/native.rs +++ b/crates/ui-contract/src/runtime/windows/native.rs @@ -196,20 +196,11 @@ fn native_of(ctx: &Context, viewport: ViewportId) -> Option { found } -/// Records that the app runs the move of `viewport`'s window from its move band, as the floating dock group does to -/// dock its window, on every platform: the band's press starts the window's move gesture (Begin, Update, Commit or -/// Cancel through `placement_changed`, as a layer's move reports), not the OS's move, and the Windows hit test leaves -/// the band to the app. Runs in each pass of the component. -#[doc(hidden)] -pub fn keeps_app_drag(ctx: &Context, viewport: ViewportId) { - PerViewport::::with(ctx, viewport, |record| record.app_drag = true); -} - /// Routes the Windows hit test of `viewport`'s window to its hit sink, once, when the OS window exists and the app /// draws its frame. A platform without the routing leaves the sink uninstalled, so the app moves and resizes the /// window itself. pub(super) fn route_hit_test(ctx: &Context, viewport: ViewportId) { - if hit_sink_installed(ctx, viewport) || PerViewport::::with(ctx, viewport, |record| record.app_drag) { + if hit_sink_installed(ctx, viewport) || PerViewport::::with(ctx, viewport, |record| record.moved_by_app) { return; } let Some(native) = native_of(ctx, viewport) else { return }; diff --git a/crates/ui-contract/src/runtime/windows/viewport.rs b/crates/ui-contract/src/runtime/windows/viewport.rs index 62cc36634e..71302239c0 100644 --- a/crates/ui-contract/src/runtime/windows/viewport.rs +++ b/crates/ui-contract/src/runtime/windows/viewport.rs @@ -31,6 +31,8 @@ pub(crate) struct ViewportOpen<'a> { pub position: Option, /// Whether the user can resize the window, from the container's overlay. pub resizable: bool, + /// Whether the app moves the window from its move band, from the container's overlay (`Overlay::moved_by_app`). + pub moved_by_app: bool, } /// Opens the OS viewport of a mount and runs `body` once for each pass it gets: with the saved placement, the OS @@ -62,6 +64,7 @@ pub(crate) fn show_viewport(ctx: &Context, open: &ViewportOpen<'_>, mut body: im record.chrome = Some(chrome); record.captions = captions.clone(); record.resizable = Some(open.resizable); + record.moved_by_app = open.moved_by_app; record.awaiting_first_paint |= spec.shown_after_first_paint && record.facts.is_none(); if record.title.as_deref() != Some(open.title) { record.title = Some(open.title.to_owned()); diff --git a/crates/ui-contract/src/testing/windows.rs b/crates/ui-contract/src/testing/windows.rs index 82fa515be0..785d500317 100644 --- a/crates/ui-contract/src/testing/windows.rs +++ b/crates/ui-contract/src/testing/windows.rs @@ -24,8 +24,9 @@ pub fn applied_actions(ctx: &egui::Context) -> Vec<(egui::ViewportId, crate::run crate::runtime::windows::take_sent(ctx) } -/// Whether the window of `viewport` has a component that runs its own drag from the window's move band. -pub fn keeps_app_drag(ctx: &egui::Context, viewport: egui::ViewportId) -> bool { +/// Whether the app runs the move of `viewport`'s window from its move band (`Overlay::moved_by_app`), as the window +/// host knows it in the running pass. +pub fn moved_by_app(ctx: &egui::Context, viewport: egui::ViewportId) -> bool { crate::runtime::windows::app_moves(ctx, viewport) } diff --git a/crates/ui-panels/src/docking/floating.rs b/crates/ui-panels/src/docking/floating.rs index 7bbd47ba43..8e8d95d08d 100644 --- a/crates/ui-panels/src/docking/floating.rs +++ b/crates/ui-panels/src/docking/floating.rs @@ -364,6 +364,10 @@ impl<'a> FloatingGroup<'a> { if let Some(bounds) = self.bounds { overlay = overlay.bounds(bounds); } + // A dock window's move by its title row docks it, so the app runs that move in an OS window too. + if self.start_drag.is_some() { + overlay = overlay.moved_by_app(); + } match &self.native { Some(spec) => Mount::viewport_with(overlay, spec.clone()), None => Mount::Layer(overlay), @@ -433,9 +437,6 @@ impl Component for FloatingGroup<'_> { } fn finish(mut self, mut cx: Cx<'_, Self>) -> FloatingGroupOutput { - if self.start_drag.is_some() { - native::keeps_app_drag(&cx.core.ctx, cx.core.id); - } if self.moving && let Some(start) = self.start_drag.take() { diff --git a/crates/ui-panels/src/docking/native.rs b/crates/ui-panels/src/docking/native.rs index 002147e601..6bb096ac10 100644 --- a/crates/ui-panels/src/docking/native.rs +++ b/crates/ui-panels/src/docking/native.rs @@ -145,11 +145,3 @@ pub(crate) fn fade(ctx: &Context, output: &FloatingGroupOutput) { let highlighted = drag::moves(ctx, viewport) && drag::mark(ctx).is_some(); host.act(viewport, WindowAction::SetOpacity(if highlighted { craft_theme::Opacity::MOVING } else { 1.0 })); } - -/// Tells the window host that the native window of the group `id` is dragged by its title row from the app (the group -/// docks its window), so the Windows hit test leaves that row to the app. -pub(crate) fn keeps_app_drag(ctx: &Context, id: egui::Id) { - if let Some(viewport) = WindowHost::of(ctx).viewport_of(id) { - crate::runtime::windows::keeps_app_drag(ctx, viewport); - } -} diff --git a/crates/ui-patterns/tests/it/docking/native.rs b/crates/ui-patterns/tests/it/docking/native.rs index b9c780d98d..3e2c2f49a5 100644 --- a/crates/ui-patterns/tests/it/docking/native.rs +++ b/crates/ui-patterns/tests/it/docking/native.rs @@ -39,6 +39,46 @@ impl DockPanels for Palettes { fn body(&mut self, _: &u32, _: &mut Ui, _: &mut BodyCx<'_>) {} } +/// Palette panels whose body records, in each pass of its window, whether the window host knows the app moves that +/// window. +struct MoveProbe(Vec); + +impl DockPanels for MoveProbe { + fn spec(&self, _: &u32) -> PanelSpec { + PanelSpec::new(PALETTE_TITLE) + } + + fn permissions(&self, _: &u32) -> Permissions { + Permissions::ALL + } + + fn body(&mut self, _: &u32, ui: &mut Ui, _: &mut BodyCx<'_>) { + let ctx = ui.ctx(); + self.0.push(craft_ui::testing::windows::moved_by_app(ctx, ctx.viewport_id())); + } +} + +/// A dock window's OS window is opened as one the app moves: its first pass knows it before the pass ends, where the +/// Windows hit test is routed, so the system never takes the title row's band for its own move loop. +#[trial] +fn a_native_dock_window_is_moved_by_the_app_from_its_first_pass() { + let windows = Windows::new(); + windows.root_info(info(true, ROOT_AT)); + windows.child_info(info(true, PALETTE_AT)); + let mut window = float(); + let mut saved = Placement::new(PALETTE_AT.size().into(), 1.0); + saved.position_px = Some([PALETTE_AT.min.x as i32, PALETTE_AT.min.y as i32]); + window.native = Some(saved); + let mut workspace = Workspace::new(Layout::new(None, vec![window])); + let mut probe = MoveProbe(Vec::new()); + windows.frame(vec![], vec![], |ui| { + let config = DockConfig::default().native_windows(true); + let _ = DockArea::new("Native dock", Bind::bound(&mut workspace), &mut probe, config).show(ui); + }); + assert!(!probe.0.is_empty(), "the window's first frame runs the panel's body"); + assert!(probe.0.iter().all(|known| *known), "every pass of the window knows the app moves it: {:?}", probe.0); +} + /// The dock records a move the OS made to its native window, and nothing while the OS reports what the model holds. #[trial] fn the_dock_records_where_the_os_put_its_native_window() { diff --git a/docs/contract-api.md b/docs/contract-api.md index 08caf938b9..5dab0dbaa2 100644 --- a/docs/contract-api.md +++ b/docs/contract-api.md @@ -2171,7 +2171,7 @@ The component traits, context types, `PaintUi`, `Looks`, the pipeline and its st - `fn unshown(response: Response) -> Option where Self: Sized,`. The output of a layer-like container that shows nothing this pass (closed, past its exit fade): `response` is - `fn value_text(&self) -> Option<&str>`. The shown value as the component words it to assistive technology; `None` for a component that gives none. - `fn story_facts(&self) -> crate::testing::StoryOutput`. The facts a story reports about this output: its id, click, edit kinds, collection kinds and visible range. -- `craft_ui::contract::Overlay`: `pub struct Overlay { pub place: Place, pub fit: OverlayFit, pub min_width: MinWidth, pub movable: bool, pub resize: Resize, pub rank: Rank, pub keys: OwnerClass, pub focus: FocusPolicy, pub dismiss: Dismiss, pub motion: MotionSpec, pub opener: Option, pub popup: PopupKind, pub size: Option, pub size_limits: SizeLimits, pub placed: Option, pub placed_at: Option, pub bounds: Option, pub opacity: f32, pub body_scroll: bool, pub moves_window: bool }`. Data describing an egui layer. Presets fill focus and dismissal; builders change single fields. +- `craft_ui::contract::Overlay`: `pub struct Overlay { pub place: Place, pub fit: OverlayFit, pub min_width: MinWidth, pub movable: bool, pub resize: Resize, pub rank: Rank, pub keys: OwnerClass, pub focus: FocusPolicy, pub dismiss: Dismiss, pub motion: MotionSpec, pub opener: Option, pub popup: PopupKind, pub size: Option, pub size_limits: SizeLimits, pub placed: Option, pub placed_at: Option, pub bounds: Option, pub opacity: f32, pub body_scroll: bool, pub moves_window: bool, pub moved_by_app: bool }`. Data describing an egui layer. Presets fill focus and dismissal; builders change single fields. - `pub fn popover() -> Overlay`. A popover: a popup anchored below, from its content, at least as wide as its anchor and capped by the window, - `pub fn dropdown() -> Overlay`. A dropdown list: from its content, at least as wide as its anchor and capped, focus stays on the anchor. It - `pub fn menu() -> Overlay`. A menu: a popup the arrow keys move through. A press outside closes it and goes no further. @@ -2198,6 +2198,7 @@ The component traits, context types, `PaintUi`, `Looks`, the pipeline and its st - `pub fn min_width(mut self, min_width: MinWidth) -> Overlay`. Sets the narrowest width. - `pub fn movable(mut self, on: bool) -> Overlay`. Sets whether the user may move it. - `pub fn moves_window(mut self, on: bool) -> Overlay`. Sets whether the move band moves the OS window the layer is shown in, in place of the layer. + - `pub fn moved_by_app(mut self) -> Overlay`. The app moves the OS window from the move band ([`Overlay::moved_by_app`]). - `pub fn focus(mut self, focus: FocusPolicy) -> Overlay`. Sets the focus scope. - `pub fn dismiss(mut self, dismiss: Dismiss) -> Overlay`. Sets the dismissal rules. - `pub fn motion(mut self, motion: MotionSpec) -> Overlay`. Sets the open and close motion. @@ -2446,7 +2447,7 @@ Chapter 15: the `Overlay` data, its presets, popup handles, `OverlayUi` and the - `craft_ui::contract::overlay::OpenFilter`: re-export of `craft_ui::runtime::overlay::OpenFilter`. - `craft_ui::contract::overlay::Opener`: `pub struct Opener { pub id: Id, pub rect: Rect, pub layer: areas::Layer, pub trigger: Trigger, pub enabled: bool, pub anchor: Option, pub others: Vec }`. A component that opens a free-standing popup, and how. A layer with several openers keeps the first as its - `craft_ui::contract::overlay::Outside`: `pub enum Outside { Close, Keep, Absorb }`. What a press outside the layer and its anchor does. -- `craft_ui::contract::overlay::Overlay`: `pub struct Overlay { pub place: Place, pub fit: OverlayFit, pub min_width: MinWidth, pub movable: bool, pub resize: Resize, pub rank: Rank, pub keys: OwnerClass, pub focus: FocusPolicy, pub dismiss: Dismiss, pub motion: MotionSpec, pub opener: Option, pub popup: PopupKind, pub size: Option, pub size_limits: SizeLimits, pub placed: Option, pub placed_at: Option, pub bounds: Option, pub opacity: f32, pub body_scroll: bool, pub moves_window: bool }`. Data describing an egui layer. Presets fill focus and dismissal; builders change single fields. +- `craft_ui::contract::overlay::Overlay`: `pub struct Overlay { pub place: Place, pub fit: OverlayFit, pub min_width: MinWidth, pub movable: bool, pub resize: Resize, pub rank: Rank, pub keys: OwnerClass, pub focus: FocusPolicy, pub dismiss: Dismiss, pub motion: MotionSpec, pub opener: Option, pub popup: PopupKind, pub size: Option, pub size_limits: SizeLimits, pub placed: Option, pub placed_at: Option, pub bounds: Option, pub opacity: f32, pub body_scroll: bool, pub moves_window: bool, pub moved_by_app: bool }`. Data describing an egui layer. Presets fill focus and dismissal; builders change single fields. - `pub fn popover() -> Overlay`. A popover: a popup anchored below, from its content, at least as wide as its anchor and capped by the window, - `pub fn dropdown() -> Overlay`. A dropdown list: from its content, at least as wide as its anchor and capped, focus stays on the anchor. It - `pub fn menu() -> Overlay`. A menu: a popup the arrow keys move through. A press outside closes it and goes no further. @@ -2473,6 +2474,7 @@ Chapter 15: the `Overlay` data, its presets, popup handles, `OverlayUi` and the - `pub fn min_width(mut self, min_width: MinWidth) -> Overlay`. Sets the narrowest width. - `pub fn movable(mut self, on: bool) -> Overlay`. Sets whether the user may move it. - `pub fn moves_window(mut self, on: bool) -> Overlay`. Sets whether the move band moves the OS window the layer is shown in, in place of the layer. + - `pub fn moved_by_app(mut self) -> Overlay`. The app moves the OS window from the move band ([`Overlay::moved_by_app`]). - `pub fn focus(mut self, focus: FocusPolicy) -> Overlay`. Sets the focus scope. - `pub fn dismiss(mut self, dismiss: Dismiss) -> Overlay`. Sets the dismissal rules. - `pub fn motion(mut self, motion: MotionSpec) -> Overlay`. Sets the open and close motion. @@ -4552,7 +4554,7 @@ The window host's fixtures: install inputs that open no OS windows, and the scri - `craft_ui::testing::windows::applied_actions`: `pub fn applied_actions(ctx: &egui::Context) -> Vec<(egui::ViewportId, crate::runtime::windows::WindowAction)>`. The window actions the platform applies out of reach of egui's commands (`SetOpacity`) since the last call. - `craft_ui::testing::windows::begin_window_drag`: `pub fn begin_window_drag(ctx: &egui::Context, source: egui::Id)`. Starts the drag of the window container `source` (what the title row of a dock window does), with the pointer - `craft_ui::testing::windows::install_spec`: `pub fn install_spec() -> InstallSpec`. An install spec for the running build's shell and a system with no OS services. -- `craft_ui::testing::windows::keeps_app_drag`: `pub fn keeps_app_drag(ctx: &egui::Context, viewport: egui::ViewportId) -> bool`. Whether the window of `viewport` has a component that runs its own drag from the window's move band. +- `craft_ui::testing::windows::moved_by_app`: `pub fn moved_by_app(ctx: &egui::Context, viewport: egui::ViewportId) -> bool`. Whether the app runs the move of `viewport`'s window from its move band (`Overlay::moved_by_app`), as the window host knows it in the running pass. - `craft_ui::testing::windows::show_drop_mark`: `pub fn show_drop_mark(ctx: &egui::Context, over: Option)`. Shows (or removes) the mark of a drop target in another window over the running drag. - `craft_ui::testing::windows::FakeSystem`: re-export of `craft_window::system::FakeSystem` (outside these crates). - `craft_ui::testing::windows::FullOutput`: re-export of `craft_ui::runtime::egui::fixture::FullOutput` (defined outside these crates). diff --git a/docs/ui-docking.md b/docs/ui-docking.md index 96ce8d2641..ae80164075 100644 --- a/docs/ui-docking.md +++ b/docs/ui-docking.md @@ -122,7 +122,7 @@ The theme's docking sizes (`DockSizes`) set the drop bands and zones. `DockWords ## Floating and native windows -A floating window is a `Floating` in the layout: its one `column`, its `rect` in logical points in the app's viewport, and `native` and `monitor` while it is an OS window. `FloatingGroup` shows it, with the column inside drawn as a dock column is (`ColumnBar::Window`): the window's title row is the column's bar, whose double arrow, like a double click on the row, collapses the column to icons. A collapsed window shows its icons against the edge of the float area it keeps to, under a title row of the band and the double arrow alone (a context request on the band opens the window's menu), and keeps its expanded size for when it expands. With `DockConfig::native_windows` (on by default), every floating window opens in its own OS window (`docking::native`) where the window host opens OS windows and reports where they are (`WindowHost::positions_reported`; not on Wayland); a window never shown native yet opens over its place in the main window. Elsewhere, and for a panel with `allow_native` off, the window stays inside the main window. The OS close of a native window is its Close action: the window closes when every panel in it may close. Dragging a native window by its title row moves the whole window and docks it where it is released over a group of the main window, as a floating window inside the main window does: the window host runs that move (`runtime::windows::keeps_app_drag`). On macOS the row's press hands the move to the OS, the app follows the system pointer and button (`Caps::OS_MOVES_TRACKED`), and a press that ends within the click distance is a click, which docks nothing; elsewhere the app moves the window, and Escape puts it back. The app sends an OS window its place only when the app changes it (an undo, a reloaded layout); the OS's own moves and resizes are recorded and never sent back. `window_kind` says whether an OS window is a document or a tool window. A tool window's title row is its only title bar, whatever frame the main window has (`craft_window::policy::tool_frame`). +A floating window is a `Floating` in the layout: its one `column`, its `rect` in logical points in the app's viewport, and `native` and `monitor` while it is an OS window. `FloatingGroup` shows it, with the column inside drawn as a dock column is (`ColumnBar::Window`): the window's title row is the column's bar, whose double arrow, like a double click on the row, collapses the column to icons. A collapsed window shows its icons against the edge of the float area it keeps to, under a title row of the band and the double arrow alone (a context request on the band opens the window's menu), and keeps its expanded size for when it expands. With `DockConfig::native_windows` (on by default), every floating window opens in its own OS window (`docking::native`) where the window host opens OS windows and reports where they are (`WindowHost::positions_reported`; not on Wayland); a window never shown native yet opens over its place in the main window. Elsewhere, and for a panel with `allow_native` off, the window stays inside the main window. The OS close of a native window is its Close action: the window closes when every panel in it may close. Dragging a native window by its title row moves the whole window and docks it where it is released over a group of the main window, as a floating window inside the main window does: the app runs that move (`Overlay::moved_by_app`, which the group's mount carries, so the window is opened knowing it). On macOS the row's press hands the move to the OS, the app follows the system pointer and button (`Caps::OS_MOVES_TRACKED`), and a press that ends within the click distance is a click, which docks nothing; elsewhere the app moves the window, and Escape puts it back. The app sends an OS window its place only when the app changes it (an undo, a reloaded layout); the OS's own moves and resizes are recorded and never sent back. `window_kind` says whether an OS window is a document or a tool window. A tool window's title row is its only title bar, whatever frame the main window has (`craft_window::policy::tool_frame`). A panel or group floated out of the dock (a drag, the Float command, a tab torn out of the window) opens at the width it had docked and at the height its group measures at in a floating window's room (`Proposal::Size`), at most `size.float.height`: content that fills its body opens at that height, other content at its own. A column opens at its docked size, at most that height. The area measures once, where the float starts: for a drag in the pass it starts, which adds the size to the drag's payload (`runtime::drag::amend`). A panel's own `PanelSpec` float size wins, and a window that already floats keeps its size.