mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-28 01:11:23 +01:00
Docking: drop DockConfig::menu_button, which next's panel_menu_always covers
next gained DockConfig::panel_menu_always (with its trial a_dock_that_shows_the_panel_menu_always_gives_every_group_the_button), the same choice this branch added as menu_button. The duplicate option, its GroupMenuButton type, its trial and its docs row go; the dock reads only panel_menu_always.
This commit is contained in:
1 parent
a0f3e6bef7
commit
5b155ab03f
5 files changed
+5
-59
No files matched your search
@@ -115,20 +115,6 @@ pub struct DockConfig {
|
||||
/// 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,
|
||||
/// Which groups show the panel menu button at the end of their tab strip.
|
||||
pub menu_button: GroupMenuButton,
|
||||
}
|
||||
|
||||
/// Which groups show the panel menu button at the end of their tab strip ([`DockConfig::menu_button`]).
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
|
||||
#[non_exhaustive]
|
||||
pub enum GroupMenuButton {
|
||||
/// Only a group whose shown panel has host rows (`DockPanels::panel_rows`) shows the button; the dock's rows open
|
||||
/// from a context request on a tab.
|
||||
#[default]
|
||||
HostRows,
|
||||
/// Every group shows the button, listing the dock's rows when the host has none for its panel.
|
||||
EveryGroup,
|
||||
}
|
||||
|
||||
impl Default for DockConfig {
|
||||
@@ -155,7 +141,6 @@ impl Default for DockConfig {
|
||||
panel_menu_always: false,
|
||||
panel_menu_icon: IconId::new("more"),
|
||||
iconic_mode: IconicMode::Flyouts,
|
||||
menu_button: GroupMenuButton::HostRows,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -168,13 +153,6 @@ impl DockConfig {
|
||||
self
|
||||
}
|
||||
|
||||
/// Which groups show the panel menu button.
|
||||
#[must_use]
|
||||
pub fn menu_button(mut self, shown: GroupMenuButton) -> Self {
|
||||
self.menu_button = shown;
|
||||
self
|
||||
}
|
||||
|
||||
/// The Minimize and Move Group Up and Down items of docked groups' menus on or off.
|
||||
#[must_use]
|
||||
pub fn group_order_items(mut self, on: bool) -> Self {
|
||||
|
||||
@@ -30,7 +30,7 @@ mod commands;
|
||||
pub mod cross_window;
|
||||
pub mod native;
|
||||
|
||||
pub use config::{DockConfig, DockSides, GroupMenuButton};
|
||||
pub use config::{DockConfig, DockSides};
|
||||
#[doc(hidden)]
|
||||
pub use drop::{Arrangement, end_replaced_drags};
|
||||
pub use drop::{DockDrag, DockDropTarget, DockDropped, DragUnit, float_drop, resolve_drop, start_group_drag, start_icon_drag};
|
||||
|
||||
@@ -15,8 +15,8 @@ use crate::docking::{Arrangement, close_requests, cross_window, end_replaced_dra
|
||||
use crate::docking::{
|
||||
ColumnArrow, ColumnBar, DockColumn, DockCommands, DockConfig, DockDropTarget, DockDropped, DockEvent, DockGroup, DockPanels, DockRoot, DockScene,
|
||||
DockSizes, DockSpot, DockTargets, DockTo, DockWords, DragUnit, FloatSpace, FloatingGroup, FlyoutResize, GroupAt, GroupDrag, GroupGrip,
|
||||
GroupMenuButton, HidePanels, IconicColumn, IconicMode, IconicSizes, PanelDrag, PanelKey, PanelSpec, PanelSpecs, PanelTitle, Placing, SpecSource,
|
||||
SplitArea, Titles, WindowColumn, actions, dock_states, fit_widths, frame, move_actions,
|
||||
HidePanels, IconicColumn, IconicMode, IconicSizes, PanelDrag, PanelKey, PanelSpec, PanelSpecs, PanelTitle, Placing, SpecSource, SplitArea,
|
||||
Titles, WindowColumn, actions, dock_states, fit_widths, frame, move_actions,
|
||||
};
|
||||
use crate::layout_components::Stack;
|
||||
use crate::menu::{GroupItem, MenuWords, PanelMenu, PanelRow};
|
||||
@@ -1102,7 +1102,7 @@ impl<P: Clone + Eq + Hash + Debug + Send + Sync + 'static> Pass<'_, P> {
|
||||
.zones(scene.config.zone_rule())
|
||||
.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 || scene.config.menu_button == GroupMenuButton::EveryGroup)
|
||||
.panel_menu_shown(*hosted || scene.config.panel_menu_always)
|
||||
.panel_menu_icon(scene.config.panel_menu_icon.clone())
|
||||
.tab_look(scene.config.tab_look)
|
||||
.command_states(states.clone());
|
||||
|
||||
@@ -5,7 +5,7 @@ use craft_behavior::Axis;
|
||||
use craft_behavior::PartKey;
|
||||
use craft_behavior::dock::{Action, Column, DockEdge, Group, Layout, Node, SplitSize, Workspace};
|
||||
use craft_ui::contract::{Bind, BodyCx, PlainData, Role, ShowContainer as _, Tracked};
|
||||
use craft_ui::docking::{DockConfig, DockPanels, GroupMenuButton, PanelSpec, PanelSpecs, WindowMenuRows};
|
||||
use craft_ui::docking::{DockConfig, DockPanels, PanelSpec, PanelSpecs, WindowMenuRows};
|
||||
use craft_ui::menu::{Menu, PanelRow};
|
||||
use craft_ui::patterns::dock::DockArea;
|
||||
use craft_ui::testing::{Fixture, Target, trial};
|
||||
@@ -179,34 +179,3 @@ fn a_window_floated_after_an_undo_takes_a_new_id() {
|
||||
assert_eq!(ids.len(), 1, "Float made a window again");
|
||||
assert_ne!(ids, undone, "the window after the undo does not take the undone window's id");
|
||||
}
|
||||
|
||||
/// With `GroupMenuButton::EveryGroup`, a group whose panel has no host rows still shows the panel menu button, and its
|
||||
/// menu lists the dock's rows; with the default `GroupMenuButton::HostRows` the group shows none.
|
||||
#[trial]
|
||||
fn the_menu_button_config_shows_the_panel_menu_without_host_rows() {
|
||||
assert_eq!(DockConfig::default().menu_button, GroupMenuButton::HostRows, "by default only groups with host rows show the button");
|
||||
for button in [GroupMenuButton::HostRows, GroupMenuButton::EveryGroup] {
|
||||
let root = Node::split(Axis::X, SplitSize::Ratio(0.5), Node::tabs(vec![0, 1], 0), Node::tabs(vec![2], 0));
|
||||
let workspace = Rc::new(RefCell::new(Arc::new(Workspace::new(Layout::new(Some(root), Vec::new())))));
|
||||
let (held, specs) = (Rc::clone(&workspace), Tracked::new(Specs));
|
||||
let mut fixture = Fixture::new(move |ui| {
|
||||
let mut shown = held.borrow().clone();
|
||||
DockArea::new("Dock", Bind::bound(&mut shown), &specs, &mut Bare, DockConfig::default().menu_button(button)).show(ui);
|
||||
*held.borrow_mut() = shown;
|
||||
});
|
||||
fixture.room(Vec2::new(1200.0, 600.0)).settle();
|
||||
let buttons: Vec<_> =
|
||||
fixture.by_role(Role::BUTTON).into_iter().filter(|button| fixture.tree().name_of(button.node) == Some("Panel Menu")).collect();
|
||||
if button == GroupMenuButton::HostRows {
|
||||
assert!(buttons.is_empty(), "without host rows and with only host-row groups showing it, no group shows the button");
|
||||
continue;
|
||||
}
|
||||
assert_eq!(buttons.len(), 2, "each group shows its panel menu button");
|
||||
fixture.click(&buttons[1]).idle(2);
|
||||
let float = fixture.by_label("Float").expect("the menu lists the dock's Float row");
|
||||
fixture.click(&float).idle(2);
|
||||
let shown = workspace.borrow();
|
||||
let floated: Vec<usize> = shown.layout().floating.iter().flat_map(|window| window.panels().copied().collect::<Vec<_>>()).collect();
|
||||
assert_eq!(floated, vec![2], "the dock's row runs for the group whose button opened the menu");
|
||||
}
|
||||
}
|
||||
@@ -104,7 +104,6 @@ The host handles these `DockEvent`s:
|
||||
| `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. |
|
||||
| `menu_button` | `GroupMenuButton::HostRows` | Which groups show the panel menu button: only those whose shown panel has host rows (`DockPanels::panel_rows`), or with `EveryGroup` every group, its menu listing the dock's rows when the host has none. |
|
||||
| `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.
|
||||
|
||||
Reference in new issue
Block a user