From 8703a667ba507af030979d869a282527efe732ea Mon Sep 17 00:00:00 2001 From: aiongg Date: Thu, 12 Nov 2026 06:44:58 +0000 Subject: [PATCH] FooterBar: lay panel actions out from the reading end The first action given sits at the end edge, as the old PanelFooter and Photoshop's panel footers place them; a start group keeps its order. Callers give their actions from the end edge: Layers, Channels, Actions, Pages, the styles panel, the preset footer and MediaBin. The filter gallery keeps Move Up and Move Down at the start edge. LinkList's actions read as in the old: the menu at the start edge, Relink at the end edge. --- crates/automation/src/ui/actions/footer.rs | 28 +++++++-------- crates/browse/src/ui/bin/footer.rs | 23 ++++++------ crates/browse/src/ui/bin/mod.rs | 3 +- crates/imaging/src/ui/channels/footer.rs | 16 ++++----- crates/imaging/src/ui/filter_gallery/stack.rs | 9 ++--- crates/layers/src/ui/panel/footer.rs | 26 +++++++------- crates/pages/src/ui/list.rs | 14 +++++--- crates/text/src/ui/style_panel.rs | 8 ++--- crates/ui-panels/src/sections/footer.rs | 35 +++++++++++-------- .../ui-panels/tests/it/sections/footer_row.rs | 21 ++++++----- .../src/patterns/presets/footer.rs | 18 +++++----- 11 files changed, 109 insertions(+), 92 deletions(-) diff --git a/crates/automation/src/ui/actions/footer.rs b/crates/automation/src/ui/actions/footer.rs index f0e66671b..dbcffcd91 100644 --- a/crates/automation/src/ui/actions/footer.rs +++ b/crates/automation/src/ui/actions/footer.rs @@ -11,16 +11,16 @@ use super::body::{Body, delete_event}; use super::panel::{ActionSelection, ActionsEvent, ActionsPanelState}; use crate::actions::ActionList; -// Reading order of the footer's buttons. -const STOP: usize = 0; -const RECORD: usize = 1; -const PLAY: usize = 2; +// The footer's buttons from its end edge. +const BUTTON_MODE: usize = 0; +const DELETE: usize = 1; +const NEW_ACTION: usize = 2; const NEW_SET: usize = 3; -const NEW_ACTION: usize = 4; -const DELETE: usize = 5; -const BUTTON_MODE: usize = 6; +const PLAY: usize = 4; +const RECORD: usize = 5; +const STOP: usize = 6; -/// The footer under the list, in this order, each a Tab stop with its name and tooltip: +/// The footer under the list, in this order from the start edge, each a Tab stop with its name and tooltip: /// /// | Button | Icon | Reports | Enabled | /// |---|---|---|---| @@ -46,15 +46,15 @@ pub(super) fn show_footer(ui: &mut Ui, body: &Body<'_>, state: &mut ActionsPanel record = record.tone(Tone::Bad); } let actions = [ - FooterAction::new(icon("square"), words.stop.clone()).enabled(hosted && !idle), - record, - FooterAction::new(icon("play"), words.play.clone()).enabled(hosted && idle && target.is_some()), - FooterAction::new(icon("new_folder"), words.new_set.clone()).enabled(idle), - FooterAction::new(icon("plus"), words.new_action.clone()).enabled(hosted && idle), + FooterAction::new(icon("toggle_right"), words.button_mode.clone()).enabled(idle).pressed(state.settings.button_mode), FooterAction::new(icon("trash"), words.delete.clone()).enabled(delete.is_some()).takes_drops_disabled(true).accepts_drops( move |drag: &ListDrag| !playing && drag.list == list_id && delete_event(&drag.grabbed, recording.is_some()).is_some(), ), - FooterAction::new(icon("toggle_right"), words.button_mode.clone()).enabled(idle).pressed(state.settings.button_mode), + FooterAction::new(icon("plus"), words.new_action.clone()).enabled(hosted && idle), + FooterAction::new(icon("new_folder"), words.new_set.clone()).enabled(idle), + FooterAction::new(icon("play"), words.play.clone()).enabled(hosted && idle && target.is_some()), + record, + FooterAction::new(icon("square"), words.stop.clone()).enabled(hosted && !idle), ]; let out = FooterBar::actions(actions).show_footer(ui); // The footer runs twice per pass: the sizing pass measures it and must report nothing. diff --git a/crates/browse/src/ui/bin/footer.rs b/crates/browse/src/ui/bin/footer.rs index ace3499db..77f7b4010 100644 --- a/crates/browse/src/ui/bin/footer.rs +++ b/crates/browse/src/ui/bin/footer.rs @@ -13,6 +13,9 @@ use egui::Ui; use super::list::NAME; use super::{BinEvent, BinState, BinView, BinWords}; +/// New Bin's place among the footer's actions: the first, at the end edge. +const NEW_BIN: usize = 0; + /// A pick in the Sort Icons menu. #[derive(Clone, Debug, PartialEq)] enum SortPick { @@ -25,8 +28,8 @@ fn sortable(columns: &[ColumnSpec], words: &BinWords) -> Vec { if columns.is_empty() { vec![ColumnSpec::new(NAME, words.name.clone(), craft_behavior::ColumnWidth::fill(1.0))] } else { columns.to_vec() } } -/// Draws the footer: the view `Segmented` (List, Icon, Freeform), a `ThumbnailSlider`, then the actions: the -/// host's, Sort Icons (Icon and Freeform views) and New Bin. Returns the footer's events. +/// Draws the footer: the view `Segmented` (List, Icon, Freeform), a `ThumbnailSlider`, then the actions, from the end +/// edge: New Bin, the host's, Sort Icons (Icon and Freeform views). Returns the footer's events. pub(super) fn footer( ui: &mut Ui, state: &BinState, @@ -38,13 +41,13 @@ pub(super) fn footer( let mut events = Vec::new(); let mut view = state.settings.view; let mut zoom_value = state.settings.zoom; - let mut all: Vec = actions.to_vec(); + let mut all = vec![FooterAction::new(IconId::new("new_folder"), words.new_bin.clone())]; + all.extend_from_slice(actions); let sort_at = (view != BinView::List).then(|| { all.push(FooterAction::new(IconId::new("more"), words.sort_icons.clone()).popup(PopupKind::Menu)); all.len() - 1 }); - let new_bin = all.len(); - all.push(FooterAction::new(IconId::new("new_folder"), words.new_bin.clone())); + let host = |at: usize| at.checked_sub(NEW_BIN + 1).filter(|action| *action < actions.len()); let modes = [ Entry::new(BinView::List, words.list_view.clone()).icon(IconId::new("list")), @@ -64,14 +67,14 @@ pub(super) fn footer( events.push(BinEvent::Zoom(event)); } if let Some(drop) = &bar.dropped { - if let Some(drag) = drop.payload::>() { - events.push(BinEvent::FooterDrop { action: drop.index, keys: drag.keys.clone() }); + if let (Some(drag), Some(action)) = (drop.payload::>(), host(drop.index)) { + events.push(BinEvent::FooterDrop { action, keys: drag.keys.clone() }); } } else if let Some(at) = bar.picked { - if at == new_bin { + if at == NEW_BIN { events.push(BinEvent::NewBin); - } else if Some(at) != sort_at { - events.push(BinEvent::Footer { action: at }); + } else if let Some(action) = host(at) { + events.push(BinEvent::Footer { action }); } } if let Some(response) = sort_at.and_then(|at| bar.responses.get(at)) { diff --git a/crates/browse/src/ui/bin/mod.rs b/crates/browse/src/ui/bin/mod.rs index 9d1eecdbf..1eed7f74b 100644 --- a/crates/browse/src/ui/bin/mod.rs +++ b/crates/browse/src/ui/bin/mod.rs @@ -520,7 +520,8 @@ where self } - /// The host's footer buttons, after the view buttons and slider. An action that takes drops reports + /// The host's footer buttons, placed from the end edge as `FooterBar::actions` places them, after New Bin: the + /// first given sits next to New Bin. An action that takes drops reports /// `FooterDrop` with the dragged keys when it was built with `accepts_drops::>`. pub fn footer_actions(mut self, actions: impl IntoIterator) -> Self { self.actions = actions.into_iter().collect(); diff --git a/crates/imaging/src/ui/channels/footer.rs b/crates/imaging/src/ui/channels/footer.rs index 5b7df96c3..3685bdbbc 100644 --- a/crates/imaging/src/ui/channels/footer.rs +++ b/crates/imaging/src/ui/channels/footer.rs @@ -44,11 +44,11 @@ pub(super) fn accepts_footer_drop(button: ChannelsFooterButton, kind: ChannelKin } } -// Photoshop's order from the leading end. -const LOAD: usize = 0; -const SAVE: usize = 1; -const NEW: usize = 2; -const DELETE: usize = 3; +// Photoshop's order from the end edge. +const DELETE: usize = 0; +const NEW: usize = 1; +const SAVE: usize = 2; +const LOAD: usize = 3; fn button_at(at: usize) -> Option { match at { @@ -79,13 +79,13 @@ pub(super) fn show_footer( let takes = |button: ChannelsFooterButton| move |drag: &ChannelDrag| drag.list == list && accepts_footer_drop(button, drag.kind); let icon = |name: &'static str| IconSpec::svg(IconId::new(name)); let actions = [ - FooterAction::new(icon("ellipse_dashed"), words.load_selection.clone()).accepts_drops(takes(ChannelsFooterButton::LoadSelection)), - FooterAction::new(icon("rect_dashed"), words.save_selection.clone()), - FooterAction::new(icon("plus"), words.new.clone()).accepts_drops(takes(ChannelsFooterButton::New)), FooterAction::new(icon("trash"), words.delete.clone()) .enabled(delete_enabled) .takes_drops_disabled(true) .accepts_drops(takes(ChannelsFooterButton::Delete)), + FooterAction::new(icon("plus"), words.new.clone()).accepts_drops(takes(ChannelsFooterButton::New)), + FooterAction::new(icon("rect_dashed"), words.save_selection.clone()), + FooterAction::new(icon("ellipse_dashed"), words.load_selection.clone()).accepts_drops(takes(ChannelsFooterButton::LoadSelection)), ]; let out = FooterBar::actions(actions).show_footer(ui); let mut events = Vec::new(); diff --git a/crates/imaging/src/ui/filter_gallery/stack.rs b/crates/imaging/src/ui/filter_gallery/stack.rs index 090e7d1b5..dc9bc9080 100644 --- a/crates/imaging/src/ui/filter_gallery/stack.rs +++ b/crates/imaging/src/ui/filter_gallery/stack.rs @@ -150,18 +150,19 @@ impl<'a> EffectStack<'a> { _ => {} } } + // Move Up and Move Down at the start edge, then Delete and New from the end edge, as PhotoCraft lays them out. let actions = [ FooterAction::new(IconId::new("chevron_up"), words.move_up.clone()).enabled(current + 1 < count), FooterAction::new(IconId::new("chevron_down"), words.move_down.clone()).enabled(current > 0), - FooterAction::new(IconId::new("new_layer"), words.new_layer.clone()), FooterAction::new(IconId::new("trash"), words.delete_layer.clone()).enabled(count > 1), + FooterAction::new(IconId::new("new_layer"), words.new_layer.clone()), ]; - let footer = FooterBar::actions(actions).show_footer(ui); + let footer = FooterBar::actions(actions).at_start(2).show_footer(ui); let pressed = match footer.picked { Some(0) => Some(EffectChange::move_to(current, current + 1)), Some(1) => Some(EffectChange::move_to(current, current.saturating_sub(1))), - Some(2) => Some(EffectChange::Add), - Some(3) => Some(EffectChange::Delete), + Some(2) => Some(EffectChange::Delete), + Some(3) => Some(EffectChange::Add), _ => None, }; if pressed.is_some() { diff --git a/crates/layers/src/ui/panel/footer.rs b/crates/layers/src/ui/panel/footer.rs index 77a48017e..c278edfed 100644 --- a/crates/layers/src/ui/panel/footer.rs +++ b/crates/layers/src/ui/panel/footer.rs @@ -67,14 +67,14 @@ pub enum LayersFooterAction { Style(String), } -// Reading order of the footer's buttons. -const LINK: usize = 0; -const STYLE: usize = 1; -const MASK: usize = 2; +// The footer's buttons from the end edge, as Photoshop's. +const DELETE: usize = 0; +const LAYER: usize = 1; +const GROUP: usize = 2; const ADJUSTMENT: usize = 3; -const GROUP: usize = 4; -const LAYER: usize = 5; -const DELETE: usize = 6; +const MASK: usize = 4; +const STYLE: usize = 5; +const LINK: usize = 6; fn button_at(at: usize) -> Option { match at { @@ -104,16 +104,16 @@ pub(super) fn show_footer(ui: &mut Ui, cx: &PanelContext<'_, T>, w let icon = |name: &'static str| IconSpec::svg(IconId::new(name)); let mask_name = state.mask_label.clone().map_or_else(|| words.add_mask.clone(), craft_ui::runtime::env::Label::from); let actions = [ - FooterAction::new(icon("link"), words.link_layers.clone()).enabled(state.link_enabled), - FooterAction::new(icon("fx"), words.add_style.clone()).popup(PopupKind::Menu), - FooterAction::new(icon("layer_mask"), mask_name).enabled(state.mask_label.is_some()), - FooterAction::new(icon("adjustment_layer"), words.add_adjustment.clone()).popup(PopupKind::Menu), - FooterAction::new(icon("new_folder"), words.new_group.clone()).accepts_drops(takes(LayersFooterButton::NewGroup)), - FooterAction::new(icon("new_layer"), words.new_layer.clone()).accepts_drops(takes(LayersFooterButton::NewLayer)), FooterAction::new(icon("trash"), craft_ui::runtime::env::Label::from(state.delete_label.clone())) .enabled(state.delete_enabled) .takes_drops_disabled(true) .accepts_drops(takes(LayersFooterButton::Delete)), + FooterAction::new(icon("new_layer"), words.new_layer.clone()).accepts_drops(takes(LayersFooterButton::NewLayer)), + FooterAction::new(icon("new_folder"), words.new_group.clone()).accepts_drops(takes(LayersFooterButton::NewGroup)), + FooterAction::new(icon("adjustment_layer"), words.add_adjustment.clone()).popup(PopupKind::Menu), + FooterAction::new(icon("layer_mask"), mask_name).enabled(state.mask_label.is_some()), + FooterAction::new(icon("fx"), words.add_style.clone()).popup(PopupKind::Menu), + FooterAction::new(icon("link"), words.link_layers.clone()).enabled(state.link_enabled), ]; let out = FooterBar::actions(actions).show_footer(ui); diff --git a/crates/pages/src/ui/list.rs b/crates/pages/src/ui/list.rs index 2d455f8d4..56cd5a2ae 100644 --- a/crates/pages/src/ui/list.rs +++ b/crates/pages/src/ui/list.rs @@ -58,6 +58,10 @@ const LOCKED: ColumnKey = ColumnKey::new("locked"); const NAME: ColumnKey = ColumnKey::new("name"); const OPTIONS: TrailingPart = TrailingPart::new(0); +// The footer's actions from the end edge: Delete, Duplicate, New. +const DUPLICATE: usize = 1; +const NEW: usize = 2; + /// One row. #[derive(Clone, Debug, PartialEq, Eq)] #[non_exhaustive] @@ -243,15 +247,15 @@ impl<'a> PageList<'a> { let list = *list_id.borrow(); let ours = move |drag: &ListDrag| Some(drag.list) == list; let actions = [ - FooterAction::new(IconId::new("plus"), words.new_artboard.clone()).accepts_drops(ours), - FooterAction::new(IconId::new("copy"), words.duplicate.clone()).enabled(any_picked), FooterAction::new(IconId::new("trash"), words.delete.clone()).enabled(!deletable.is_empty()).accepts_drops(ours), + FooterAction::new(IconId::new("copy"), words.duplicate.clone()).enabled(any_picked), + FooterAction::new(IconId::new("plus"), words.new_artboard.clone()).accepts_drops(ours), ]; let footer = FooterBar::actions(actions).show_footer(ui); let mut events = events.borrow_mut(); if let Some(drop) = &footer.dropped { let Some(drag) = drop.payload::>() else { return }; - if drop.index == 0 { + if drop.index == NEW { events.push(PageListEvent::New { duplicate: Some(drag.grabbed), options: false }); } else { let dropped = unlocked(&drag.keys); @@ -261,8 +265,8 @@ impl<'a> PageList<'a> { } } else if let Some(picked_action) = footer.picked { events.push(match picked_action { - 0 => PageListEvent::New { duplicate: None, options: footer.mods.alt }, - 1 => PageListEvent::New { duplicate: Some(active), options: false }, + NEW => PageListEvent::New { duplicate: None, options: footer.mods.alt }, + DUPLICATE => PageListEvent::New { duplicate: Some(active), options: false }, _ => PageListEvent::Delete(deletable.clone()), }); } diff --git a/crates/text/src/ui/style_panel.rs b/crates/text/src/ui/style_panel.rs index 8c93a9381..9a5b29a31 100644 --- a/crates/text/src/ui/style_panel.rs +++ b/crates/text/src/ui/style_panel.rs @@ -198,14 +198,14 @@ impl Facts { } } -/// The footer's buttons in reading order. +/// The footer's buttons: the start group from the start edge, the rest from the end edge. const FOOTER: [TextStyleCommand; 6] = [ TextStyleCommand::ClearOverride, TextStyleCommand::Redefine, - TextStyleCommand::Options, - TextStyleCommand::Duplicate, - TextStyleCommand::New, TextStyleCommand::Delete, + TextStyleCommand::New, + TextStyleCommand::Duplicate, + TextStyleCommand::Options, ]; /// How many of the footer's buttons sit at its start edge: Clear Override and Redefine. diff --git a/crates/ui-panels/src/sections/footer.rs b/crates/ui-panels/src/sections/footer.rs index 417b5a0cf..570cc1c2b 100644 --- a/crates/ui-panels/src/sections/footer.rs +++ b/crates/ui-panels/src/sections/footer.rs @@ -564,14 +564,17 @@ impl FooterBar { self } - /// A footer bar of icon actions, in the given order. Show it with `show_footer`. + /// A footer bar of icon actions laid out from the reading end, as Photoshop's panel footers: the first action given + /// sits at the end edge (Delete), the next one before it, and a panel menu given last at the start of the group. + /// Tab visits them in display order; the indexes the output reports are those of the given order. Show it with + /// `show_footer`. pub fn actions(actions: impl IntoIterator) -> Self { FooterBar { content: Content::Actions(actions.into_iter().collect()), actions: true, ..FooterBar::body() } } - /// The first `count` actions sit at the start edge and the rest at the end edge, the room left between the two - /// groups (Clear Override and Redefine before a style panel's other actions). The indexes the output reports stay - /// those of the given order. + /// The first `count` actions sit at the start edge in the given order and the rest from the end edge as + /// [`actions`](FooterBar::actions) places them, the room left between the two groups (Clear Override and Redefine + /// before a style panel's other actions). The indexes the output reports stay those of the given order. #[must_use] pub fn at_start(mut self, count: usize) -> Self { self.start = count; @@ -594,13 +597,14 @@ impl FooterBar { Content::Actions(actions) => { let mut shown = Shown::default(); let start = start.min(actions.len()); + let from_end = || (start..actions.len()).rev(); if start == 0 { - show_actions(ui, actions, 0, &mut shown); + show_actions(ui, actions, from_end(), &mut shown); } else { - let (first, rest) = actions.split_at(start); - Row::new().show(ui, |ui, _| show_actions(ui, first, 0, &mut shown)); - Row::new().show(ui, |ui, _| show_actions(ui, rest, start, &mut shown)); + Row::new().show(ui, |ui, _| show_actions(ui, actions, 0..start, &mut shown)); + Row::new().show(ui, |ui, _| show_actions(ui, actions, from_end(), &mut shown)); } + shown.responses.sort_by_key(|(at, _)| *at); shown } Content::Buttons(buttons) => { @@ -659,16 +663,16 @@ impl FooterBar { picked: inner.picked, dropped: inner.dropped, drop_hint: inner.drop_hint, - responses: inner.responses, + responses: inner.responses.into_iter().map(|(_, response)| response).collect(), mods, } } } -/// Shows `actions`, the first of them at index `from` of the bar's actions, and collects what happened to them. -fn show_actions(ui: &mut Ui, actions: &[FooterAction], from: usize, shown: &mut Shown) { - for (at, action) in actions.iter().enumerate() { - let at = from + at; +/// Shows the bar's `actions` at the indexes `order`, in display order, and collects what happened to them. +fn show_actions(ui: &mut Ui, actions: &[FooterAction], order: impl Iterator, shown: &mut Shown) { + for at in order { + let action = &actions[at]; let response = match &action.drops { Some(drops) => { let slot = drops(ui, action); @@ -685,7 +689,7 @@ fn show_actions(ui: &mut Ui, actions: &[FooterAction], from: usize, shown: &mut if crate::contract::clicked(&response) { shown.picked = Some(at); } - shown.responses.push(response); + shown.responses.push((at, response)); } } @@ -695,7 +699,8 @@ struct Shown { picked: Option, dropped: Option, drop_hint: Option