diff --git a/crates/behavior/src/dock/workspaces.rs b/crates/behavior/src/dock/workspaces.rs
index 915dacc93..04535bb53 100644
--- a/crates/behavior/src/dock/workspaces.rs
+++ b/crates/behavior/src/dock/workspaces.rs
@@ -288,13 +288,7 @@ impl
From> for WorkspaceSet {
if let Some(layout) = saved {
workspace.layout = layout;
}
- NamedWorkspace {
- id: named.id,
- name: named.name,
- layout: workspace,
- chrome: named.chrome,
- keeps: named.keeps,
- }
+ NamedWorkspace { id: named.id, name: named.name, layout: workspace, chrome: named.chrome, keeps: named.keeps }
})
.collect();
let mut edited = BTreeMap::new();
diff --git a/crates/behavior/tests/dock_apply.rs b/crates/behavior/tests/dock_apply.rs
index 38f59cb30..4dc1b25a7 100644
--- a/crates/behavior/tests/dock_apply.rs
+++ b/crates/behavior/tests/dock_apply.rs
@@ -126,7 +126,8 @@ fn a_workspace_set_with_a_floating_group_round_trips_through_json() {
fn a_workspace_with_a_bottom_pane_opens_and_closes_it_on_switch() {
const TIMELINE: u32 = 9;
let photography = Workspace::new(Layout::new(Some(tabs(&[1, 2], 0)), Vec::new()));
- let motion = Workspace::new(Layout::new(Some(Node::split(Axis::Y, SplitSize::FixedSecond(200.0), tabs(&[1, 2], 0), tabs(&[TIMELINE], 0))), Vec::new()));
+ let motion =
+ Workspace::new(Layout::new(Some(Node::split(Axis::Y, SplitSize::FixedSecond(200.0), tabs(&[1, 2], 0), tabs(&[TIMELINE], 0))), Vec::new()));
let mut set = WorkspaceSet::new(vec![
NamedWorkspace::new("photography", "Photography", photography.clone()),
NamedWorkspace::new("motion", "Motion", motion),
diff --git a/crates/ui-panels/src/docking/dock_column/sizing.rs b/crates/ui-panels/src/docking/dock_column/sizing.rs
index bb9ef90e4..4d431cd19 100644
--- a/crates/ui-panels/src/docking/dock_column/sizing.rs
+++ b/crates/ui-panels/src/docking/dock_column/sizing.rs
@@ -24,7 +24,8 @@ pub fn fit_widths(columns: &[(f32, Option)], room: f32) -> Vec {
if total <= room {
return columns.iter().map(|(width, _)| *width).collect();
}
- let bounded: Vec<(f32, (f32, f32))> = columns.iter().map(|&(width, floor)| (width, (floor.map_or(width, |floor| floor.min(width)), width))).collect();
+ let bounded: Vec<(f32, (f32, f32))> =
+ columns.iter().map(|&(width, floor)| (width, (floor.map_or(width, |floor| floor.min(width)), width))).collect();
scale_widths(&bounded, room)
}
diff --git a/crates/ui-panels/src/docking/mod.rs b/crates/ui-panels/src/docking/mod.rs
index 60a799545..27e38b30a 100644
--- a/crates/ui-panels/src/docking/mod.rs
+++ b/crates/ui-panels/src/docking/mod.rs
@@ -53,7 +53,9 @@ mod dock_column;
mod flyout;
mod iconic;
-pub use dock_column::{DockColumn, DockColumnOutput, DockColumnStyle, GroupSize, GroupView, fit_widths, group_heights, scale_widths, stacked, width_bounds};
+pub use dock_column::{
+ DockColumn, DockColumnOutput, DockColumnStyle, GroupSize, GroupView, fit_widths, group_heights, scale_widths, stacked, width_bounds,
+};
pub use flyout::{Flyout, GroupAt};
pub use iconic::{IconicColumn, IconicColumnOutput, IconicColumnStyle, IconicSizes};
pub use window_menu::{WindowMenuRows, WindowMenuRowsOutput};
diff --git a/crates/ui-panels/src/docking/targets.rs b/crates/ui-panels/src/docking/targets.rs
index a78b366a3..2efd62f8b 100644
--- a/crates/ui-panels/src/docking/targets.rs
+++ b/crates/ui-panels/src/docking/targets.rs
@@ -126,7 +126,13 @@ impl DockSizes {
/// [`Action::ResizeIconic`] for an iconic one, which keeps its expanded width. Apply them together
/// ([`Workspace::apply_all`](craft_behavior::dock::Workspace::apply_all)). Empty when the side has no dock or the
/// columns already add up to the width; a column without panels keeps its width.
- pub fn resize_side(&self, layout: &Layout, side: DockEdge, spec: &dyn Fn(&P) -> PanelSpec, total: f32) -> Vec> {
+ pub fn resize_side(
+ &self,
+ layout: &Layout,
+ side: DockEdge,
+ spec: &dyn Fn(&P) -> PanelSpec,
+ total: f32,
+ ) -> Vec> {
let columns = match layout.dock_path(side).and_then(|path| node_at(layout.root.as_ref()?, &path)) {
Some(Node::Dock { columns, .. }) => columns,
_ => return Vec::new(),
diff --git a/crates/ui-patterns/src/patterns/dock/workspace_dialogs.rs b/crates/ui-patterns/src/patterns/dock/workspace_dialogs.rs
index af6dfb235..968116554 100644
--- a/crates/ui-patterns/src/patterns/dock/workspace_dialogs.rs
+++ b/crates/ui-patterns/src/patterns/dock/workspace_dialogs.rs
@@ -8,11 +8,12 @@ use super::words::WorkspaceDialogWords;
use crate::choice::Checkbox;
use crate::contract::{Bind, Entry, NoValue, Outcome, Props as _, Show as _, ShowContainer as _};
use crate::display::{Shade, Text};
-use crate::form::{Field, FieldGroup, Help};
+use crate::form::{Field, Help};
use crate::patterns::form_dialogs::FormDialog;
use crate::pickers::Select;
use crate::runtime::env::{Env, Label};
use crate::runtime::overlay::CloseReason;
+use crate::sections::GroupBox;
use crate::style::TypeRole;
use crate::text::TextField;
use craft_behavior::dock::{WorkspaceError, WorkspaceKeeps, WorkspaceSet};
@@ -102,7 +103,7 @@ impl<'a, P: Clone + Eq + Hash> NewWorkspaceDialog<'a, P> {
});
if offered != WorkspaceKeeps::NONE {
let keeps = &mut value.keeps;
- FieldGroup::new(words.capture.clone()).show(ui, |ui, _| {
+ GroupBox::new(words.capture.clone(), None).show(ui, |ui, _| {
Text::new(words.capture_note.clone()).role(TypeRole::Caption).shade(Shade::Muted).show(ui);
let boxes = [
(offered.shortcuts, &words.shortcuts, &mut keeps.shortcuts),
diff --git a/crates/ui-patterns/tests/it/docking/columns.rs b/crates/ui-patterns/tests/it/docking/columns.rs
index fcba0b520..de27bdb15 100644
--- a/crates/ui-patterns/tests/it/docking/columns.rs
+++ b/crates/ui-patterns/tests/it/docking/columns.rs
@@ -36,7 +36,8 @@ fn default_heights_give_way_to_the_group_that_fills_before_it_gets_less() {
fn end_dock_layout() -> Layout {
let mut iconic = Column::new(vec![Group::new(vec![4], 0)]).with_width(300.0);
iconic.iconic = true;
- let columns = vec![Column::new(vec![Group::new(vec![2], 0)]).with_width(250.0), Column::new(vec![Group::new(vec![3], 0)]).with_width(250.0), iconic];
+ let columns =
+ vec![Column::new(vec![Group::new(vec![2], 0)]).with_width(250.0), Column::new(vec![Group::new(vec![3], 0)]).with_width(250.0), iconic];
Layout::new(Some(Node::split(Axis::X, SplitSize::Ratio(0.7), Node::tabs(vec![1], 0), Node::dock(DockEdge::End, columns))), Vec::new())
}
@@ -63,10 +64,12 @@ fn a_dock_sides_total_width_scales_its_columns_within_their_bounds() {
let spec: &dyn Fn(&u32) -> PanelSpec = &spec;
let mut live = Workspace::new(end_dock_layout());
let widths = |live: &Workspace| end_columns(&live.layout).iter().map(|column| sizes.width(column, spec)).collect::>();
- let within = |live: &Workspace| end_columns(&live.layout).iter().zip(widths(live)).all(|(column, width)| {
- let (lo, hi) = sizes.shown_bounds(column, spec);
- (lo - 0.01..=hi + 0.01).contains(&width)
- });
+ let within = |live: &Workspace| {
+ end_columns(&live.layout).iter().zip(widths(live)).all(|(column, width)| {
+ let (lo, hi) = sizes.shown_bounds(column, spec);
+ (lo - 0.01..=hi + 0.01).contains(&width)
+ })
+ };
let start = widths(&live);
for total in [sum(&start) + 120.0, sum(&start) - 60.0] {
diff --git a/docs/contract-api.md b/docs/contract-api.md
index 2940eb370..5f750bfe8 100644
--- a/docs/contract-api.md
+++ b/docs/contract-api.md
@@ -529,8 +529,8 @@ The dock model: the tree of splits over panel frames, the side of a group a drop
- `pub fn new(anchor: Option, placement: DockPlacement
) -> Self`. A location relative to `anchor` by `placement`, with no recorded sizes or siblings.
- `craft_behavior::dock::MAX_DEPTH`: `pub const MAX_DEPTH: usize`. Limits are checked before cloning or recursively modifying an application layout.
- `craft_behavior::dock::MAX_PANELS`: `pub const MAX_PANELS: usize`. Most panels a layout may hold. Larger layouts fail with [`DockError::LimitExceeded`](super::DockError::LimitExceeded).
-- `craft_behavior::dock::NamedWorkspace`: `pub struct NamedWorkspace
{ pub id: String, pub name: String, pub layout: Workspace
, pub chrome: WorkspaceChrome, pub keeps_shortcuts: bool, pub keeps_menus: bool }`. One named workspace.
- - `pub fn new(id: impl Into, name: impl Into, layout: Workspace) -> Self`. A workspace named `name` with the stable id `id`, showing every bar and keeping no shortcuts or menus.
+- `craft_behavior::dock::NamedWorkspace`: `pub struct NamedWorkspace
{ pub id: String, pub name: String, pub layout: Workspace
, pub chrome: WorkspaceChrome, pub keeps: WorkspaceKeeps }`. One named workspace.
+ - `pub fn new(id: impl Into, name: impl Into, layout: Workspace) -> Self`. A workspace named `name` with the stable id `id`, showing every bar and capturing nothing beside the layout.
- `craft_behavior::dock::Node`: `pub enum Node
{ Split { axis: Axis, size: SplitSize, first: Box>, second: Box> }, Tabs { panels: Vec, active: usize }, Stack { entries: Vec> }, Dock { side: DockEdge, columns: Vec> } }`. A node of a layout tree.
- `pub fn tabs(panels: Vec, active: usize) -> Self`. A group of tabs with tab `active` selected.
- `pub fn split(axis: Axis, size: SplitSize, first: Node
, second: Node
) -> Self`. Two children along `axis`, sharing the room by `size`.
@@ -566,13 +566,18 @@ The dock model: the tree of splits over panel frames, the side of a group a drop
- `pub fn apply_all(&mut self, actions: impl IntoIterator- >, locked: bool, permissions: impl Fn(&P) -> Permissions,) -> Result, DockError>`. Apply every action in order, or none, as [`Self::apply`] does. Returns the panels the
- `craft_behavior::dock::WorkspaceChrome`: `pub struct WorkspaceChrome { pub menu_bar: bool, pub tool_rail: bool, pub options_bar: bool, pub status_bar: bool }`. Chrome a workspace remembers beside the dock layout: which bars show. The default shows every bar.
- `craft_behavior::dock::WorkspaceError`: `pub enum WorkspaceError { UnknownId, NameTaken, EmptyName, CurrentCannotBeDeleted }`. Why a [`WorkspaceSet`] edit was refused.
+- `craft_behavior::dock::WorkspaceKeeps`: `pub struct WorkspaceKeeps { pub shortcuts: bool, pub menus: bool, pub toolbar: bool }`. What a saved workspace captures beside the panel layout (the Capture boxes of New Workspace). The application
+ - `pub const NONE: WorkspaceKeeps`. Captures nothing beside the layout.
+ - `pub const ALL: WorkspaceKeeps`. Captures shortcuts, menus and toolbar.
+ - `pub const fn new(shortcuts: bool, menus: bool, toolbar: bool) -> Self`. The keeps with shortcuts, menus and toolbar as given.
- `craft_behavior::dock::WorkspaceSet`: `pub struct WorkspaceSet
{ pub builtin: Vec>, pub saved: Vec>, pub current: String, pub locked: bool, pub edited: BTreeMap> }`. The app's workspaces: built-ins first, saved ones after, one current. It is a settings
- `pub fn new(builtin: Vec>) -> Self`. A set of `builtin` workspaces with the first one current.
- `pub fn current(&self) -> Option<&NamedWorkspace>`. The current workspace, or `None` when `current` names none.
- `pub fn find(&self, id: &str) -> Option<&NamedWorkspace
>`. The workspace with this id.
- `pub fn layout(&self) -> Option<&Workspace
>`. The layout the current workspace shows: what it was left with, else its stored one.
- `pub fn select(&mut self, id: &str, live: &mut Workspace
) -> Result<(), WorkspaceError>`. Switch to `id` and replace `live` with the layout it shows; the current workspace's live
- - `pub fn save(&mut self, name: &str, live: Workspace
, chrome: WorkspaceChrome) -> Result`. Save `live` under `name` and make it current; a name a built-in has is refused. A saved
+ - `pub fn check_name<'n>(&self, name: &'n str) -> Result<(&'n str, Option<&str>), WorkspaceError>`. Whether `name` can be saved: the trimmed name, and the id of the saved workspace it would replace (any case),
+ - `pub fn save(&mut self, name: &str, live: Workspace, chrome: WorkspaceChrome, keeps: WorkspaceKeeps) -> Result`. Save `live` under `name`, capturing `keeps`, and make it current; [`check_name`](Self::check_name) refuses
- `pub fn delete(&mut self, id: &str) -> Result<(), WorkspaceError>`. Delete a saved workspace; the current one can't be deleted (Photoshop greys it).
- `pub fn reset(&mut self, live: &mut Workspace) -> Result<(), WorkspaceError>`. Reset the current workspace: drop what it was left with and replace `live` with its stored
- `craft_behavior::dock::ZoneSize`: `pub enum ZoneSize { Depth(f32), Fraction }`. How deep the side zones of a body are.