diff --git a/crates/ui-panels/src/docking/config.rs b/crates/ui-panels/src/docking/config.rs index d0d49752e..32a08d55e 100644 --- a/crates/ui-panels/src/docking/config.rs +++ b/crates/ui-panels/src/docking/config.rs @@ -3,7 +3,7 @@ use super::IconicMode; use super::targets::ZoneRule; -use craft_behavior::DockSide; +use craft_behavior::{DockSide, IconId}; /// A set of the sides of the layout's outer edge or of a group. #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] @@ -99,6 +99,8 @@ pub struct DockConfig { /// Every group shows its panel menu button, whose menu holds the dock's own rows when the shown panel has none of /// its own (`DockPanels::panel_rows`). Off: only a group whose shown panel has rows of its own shows the button. pub panel_menu_always: bool, + /// The panel menu button's icon: `more` (the default), or `menu` for the three-line mark. + pub panel_menu_icon: IconId, /// What the icons of a docked column collapsed to icons open: flyouts, or with [`IconicMode::Rail`] the column /// itself, whose icons then stay beside it while it is expanded. Floating windows' icons open flyouts. pub iconic_mode: IconicMode, @@ -124,6 +126,7 @@ impl Default for DockConfig { native_windows: true, group_order_items: false, panel_menu_always: false, + panel_menu_icon: IconId::new("more"), iconic_mode: IconicMode::Flyouts, } } @@ -151,6 +154,13 @@ impl DockConfig { self } + /// The panel menu button's icon ([`panel_menu_icon`](Self::panel_menu_icon)). + #[must_use] + pub fn panel_menu_icon(mut self, icon: IconId) -> Self { + self.panel_menu_icon = icon; + self + } + /// The picture-frame profile on or off. #[must_use] pub fn side_edge_zones(mut self, on: bool) -> Self { diff --git a/crates/ui-panels/src/docking/group.rs b/crates/ui-panels/src/docking/group.rs index f6cf1c585..cc7a1bcb7 100644 --- a/crates/ui-panels/src/docking/group.rs +++ b/crates/ui-panels/src/docking/group.rs @@ -368,6 +368,9 @@ pub struct DockGroup<'a, P: Clone + Hash + Send + Sync + 'static> { /// Whether the panel menu button shows beside the tabs; a context request on a tab opens the menu either way. #[prop] panel_menu_shown: bool, + /// The panel menu button's icon: `more` unless the dock gives another (`DockConfig::panel_menu_icon`). + #[prop] + panel_menu_icon: IconId, /// The state of each panel command for the shown panel, published in the group's scope every pass. #[prop] command_states: Vec<(DockCommands, CommandState)>, @@ -405,6 +408,7 @@ impl<'a, P: Clone + Hash + Send + Sync + PartialEq + Debug + 'static> DockGroup< in_window: false, menu: None, panel_menu_shown: true, + panel_menu_icon: IconId::new("more"), command_states: Vec::new(), extra: None, footer: None, @@ -429,8 +433,8 @@ impl<'a, P: Clone + Hash + Send + Sync + PartialEq + Debug + 'static> DockGroup< } /// The panel menu button's face. - fn menu_face(name: Label) -> IconButton<'static> { - IconButton::new(IconId::new("more")).size(ControlSize::Sm).popup(PopupKind::Menu).label(name) + fn menu_face(&self, name: Label) -> IconButton<'static> { + IconButton::new(self.panel_menu_icon.clone()).size(ControlSize::Sm).popup(PopupKind::Menu).label(name) } /// Starts a drag of the whole group: its drop region shows the group's name. @@ -523,7 +527,7 @@ impl Component for /// tabs meet it. fn paint_over(&mut self, ui: &mut PaintUi<'_>, cx: &Cx<'_, Self>) { if cx.part_if_declared(MENU).is_some() { - ui.face(MENU, Self::menu_face(cx.words::().panel_menu.clone())); + ui.face(MENU, self.menu_face(cx.words::().panel_menu.clone())); } ui.draw().surface(cx.rect, SurfaceKind::Frame, Corners::None); } @@ -588,7 +592,7 @@ impl Container for fn header_parts(&self, cx: &MeasureCx<'_, Self>) -> HeaderParts { let band = grip_width(cx.tokens); let button = if self.shows_menu_button() { - cx.tokens.space.gap.item + cx.face(Self::menu_face(cx.words::().panel_menu.clone())).x + cx.tokens.space.gap.item + cx.face(self.menu_face(cx.words::().panel_menu.clone())).x } else { 0.0 }; diff --git a/crates/ui-patterns/src/patterns/dock/area.rs b/crates/ui-patterns/src/patterns/dock/area.rs index 3d461f036..7eeae1d62 100644 --- a/crates/ui-patterns/src/patterns/dock/area.rs +++ b/crates/ui-patterns/src/patterns/dock/area.rs @@ -1094,6 +1094,7 @@ impl Pass<'_, P> { .movable(scene.permissions(shown).movable) .menu(move || panel_menu_rows(scene, &mut **panels.borrow_mut(), words, shown).0) .panel_menu_shown(*hosted || scene.config.panel_menu_always) + .panel_menu_icon(scene.config.panel_menu_icon.clone()) .command_states(states.clone()); if look.in_window { group = group.in_window(); diff --git a/crates/ui-patterns/src/patterns/dock/area/stories.rs b/crates/ui-patterns/src/patterns/dock/area/stories.rs index 2dd2b3a58..9513ad85a 100644 --- a/crates/ui-patterns/src/patterns/dock/area/stories.rs +++ b/crates/ui-patterns/src/patterns/dock/area/stories.rs @@ -121,8 +121,12 @@ fn workspace(minimized: bool) -> Arc> { static SPECS: LazyLock> = LazyLock::new(|| Tracked::new(DemoSpecs)); fn dock(ui: &mut Ui, data: &mut StoryData, demo: &mut Demo, minimized: bool) -> StoryOutput { + dock_with(ui, data, demo, minimized, DockConfig::default()) +} + +fn dock_with(ui: &mut Ui, data: &mut StoryData, demo: &mut Demo, minimized: bool, config: DockConfig) -> StoryOutput { let (workspace, workspace_at) = data.value_at("workspace", workspace(minimized)); - DockArea::new("Dock", workspace_at.bind(&mut *workspace), &*SPECS, demo, DockConfig::default()).show(ui).into() + DockArea::new("Dock", workspace_at.bind(&mut *workspace), &*SPECS, demo, config).show(ui).into() } #[story(DockArea<'static, usize>, covers = [Default], drive = Drive::Never)] @@ -140,6 +144,14 @@ fn host_rows_above_the_dock_rows_in_a_panel_menu(ui: &mut Ui, data: &mut StoryDa dock(ui, data, &mut Demo { canvas_view: false, host_rows: true }, false) } +/// Every group shows its panel menu button, the three-line mark, whether its shown panel has rows of its own or only +/// the dock's (`DockConfig::panel_menu_always`, `DockConfig::panel_menu_icon`): VectorCraft's dock. +#[story(DockArea<'static, usize>, covers = [Default], drive = Drive::Never)] +fn a_menu_button_on_every_group(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + let config = DockConfig::default().panel_menu_always(true).panel_menu_icon(IconId::new("menu")); + dock_with(ui, data, &mut Demo { canvas_view: false, host_rows: false }, false, config) +} + /// The floating group minimized: its window shows the title row and the tab strip at its width. #[story(DockArea<'static, usize>, covers = [Default], drive = Drive::Never)] fn a_minimized_floating_window(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { diff --git a/docs/ui-docking.md b/docs/ui-docking.md index 2ea72bcf2..081948655 100644 --- a/docs/ui-docking.md +++ b/docs/ui-docking.md @@ -103,6 +103,7 @@ The host handles these `DockEvent`s: | `close_menu_items`, `close_button` | on | Built-in Close items, and the close action on floating windows. | | `tab_close_buttons` | off | Close buttons on tabs (middle click closes too), for tabs that act as documents. | | `panel_menu_always` | off | Every group shows its panel menu button, with the dock's own rows when the shown panel has none. Off: only a panel with rows of its own (`DockPanels::panel_rows`) gets the button. | +| `panel_menu_icon` | `more` | The panel menu button's icon; `menu` gives the three-line mark. | | `native_windows` | on | Floating windows open as OS windows where the window host opens them and reports their positions (not on Wayland) and `PanelSpec::allow_native` allows. | The theme's docking sizes (`DockSizes`) set the drop bands and zones. `DockWords` holds the words.