mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-26 00:57:26 +00:00
Dock group header: a raw egui layout again; its side-by-side items take none of the header column's flow facts, the tab row takes the rest of the line and a settled header runs no Row
This commit is contained in:
@@ -9,11 +9,10 @@ use super::{PanelDrag, PanelKey, PanelTitle, Titles};
|
||||
use crate::buttons::IconButton;
|
||||
use crate::contract::overlay::Anchor;
|
||||
use crate::contract::{
|
||||
Access, Bind, BindMut, BodyCx, Common, Component, Container, ContainerProps, ContextMenuRequest, Cx, Gap, HeaderEdge, HeaderParts, HeaderRegion,
|
||||
Access, Bind, BindMut, BodyCx, Common, Component, Container, ContainerProps, ContextMenuRequest, Cx, HeaderEdge, HeaderParts, HeaderRegion,
|
||||
ListDrag, MeasureCx, MemoProps, MemoView, Name, Outbox, Outcome, OverlayUi, Overlays as _, PaintUi, PartsCx, Pointer as _, PopupKind, Props as _,
|
||||
Role, ShowCollection as _, ShowContainer as _, Sizing, WordSetCx as _,
|
||||
};
|
||||
use crate::layout_components::Row;
|
||||
use crate::menu::{GroupItem, Menu, PanelMenu, PanelRow};
|
||||
use crate::runtime::commands::{CommandSet as _, CommandState, Commands as _};
|
||||
use crate::runtime::env::Label;
|
||||
@@ -505,27 +504,35 @@ impl<P: Clone + Hash + Send + Sync + PartialEq + Debug + 'static> Container for
|
||||
let started = drop::started(&cx.env);
|
||||
let mut extra = self.extra.take();
|
||||
let env = crate::runtime::env::Env::of(ui);
|
||||
ui.set_min_height(env.tokens.size.panel_header);
|
||||
let rtl = env.direction.is_rtl();
|
||||
let (line, gap) = (env.tokens.size.panel_header, env.tokens.space.gap.item);
|
||||
ui.set_min_height(line);
|
||||
let surface_pressed = cx.surface_pressed();
|
||||
// A raw egui layout: the host's items and the tab row sit side by side, and the header column's flow facts are
|
||||
// not theirs. The tab row takes the rest of the line, so the strip's empty room is its own, and nothing but the
|
||||
// memoized tab row runs in it, so a settled header replays.
|
||||
let layout = if rtl { egui::Layout::right_to_left(egui::Align::Min) } else { egui::Layout::left_to_right(egui::Align::Min) };
|
||||
let mut sent = Vec::new();
|
||||
let mut strip = None;
|
||||
let _ = Row::new().fill_width().gap(Gap::Item).show(ui, |ui, _| {
|
||||
if let Some(hook) = extra.as_mut() {
|
||||
hook.run(ui, cx);
|
||||
}
|
||||
let row = TabRow {
|
||||
anchor: self.anchor.clone(),
|
||||
panels: self.panels.clone(),
|
||||
active: self.active,
|
||||
closable: self.closable,
|
||||
wheel_selects: self.wheel_selects_tabs,
|
||||
dock: self.dock,
|
||||
sent: Outbox::new(&mut sent),
|
||||
};
|
||||
// The env around the tab row holds only values its key follows (the shell, the dock's arrangement, a
|
||||
// floating window's layer), no handle or context rebuilt each pass, so it replays at rest.
|
||||
strip = MemoView::new(("tabs", cx.id), row, tab_row::<P>).show(ui);
|
||||
});
|
||||
let strip = ui
|
||||
.with_layout(layout, |ui| {
|
||||
ui.spacing_mut().item_spacing.x = gap; // design: allow[style-mutation](the header lays its title cells with an egui layout and sets that layout's gap)
|
||||
if let Some(hook) = extra.as_mut() {
|
||||
hook.run(ui, cx);
|
||||
}
|
||||
let row = TabRow {
|
||||
anchor: self.anchor.clone(),
|
||||
panels: self.panels.clone(),
|
||||
active: self.active,
|
||||
closable: self.closable,
|
||||
wheel_selects: self.wheel_selects_tabs,
|
||||
dock: self.dock,
|
||||
sent: Outbox::new(&mut sent),
|
||||
};
|
||||
// The env around the tab row holds only values its key follows (the shell, the dock's arrangement, a
|
||||
// floating window's layer), no handle or context rebuilt each pass, so it replays at rest.
|
||||
MemoView::new(("tabs", cx.id), row, tab_row::<P>).show(ui)
|
||||
})
|
||||
.inner;
|
||||
self.extra = extra;
|
||||
// A press on the group's empty body focuses its panel, as in Photoshop.
|
||||
if surface_pressed && let Some(strip) = strip {
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
config_version = 1
|
||||
|
||||
[[exception]]
|
||||
name = "dock-header-gap"
|
||||
kind = "marker"
|
||||
rule = "style-mutation"
|
||||
path = "crates/ui-panels/src/docking/group.rs"
|
||||
reason = "The header lays its title cells with an egui layout and sets that layout gap."
|
||||
count = 1
|
||||
|
||||
[[exception]]
|
||||
name = "iconic-story-stage"
|
||||
kind = "marker"
|
||||
|
||||
Reference in New Issue
Block a user