From 3da412f36b33e7fadf0b421b550cc7006db9006d Mon Sep 17 00:00:00 2001 From: aiongg Date: Thu, 12 Nov 2026 13:06:11 +0000 Subject: [PATCH] Toolbar separators between tool groups AnnotationToolbar puts a vertical divider before each group button, as a Bar separates its groups. GraphEditor's bottom bar draws a divider rule in each gap between two button groups, inset from the bar's edges. --- crates/review/src/ui/annotate/toolbar.rs | 10 ++++++---- crates/timeline/src/ui/graph.rs | 14 ++++++++++++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/crates/review/src/ui/annotate/toolbar.rs b/crates/review/src/ui/annotate/toolbar.rs index ce9229060..8699deb5a 100644 --- a/crates/review/src/ui/annotate/toolbar.rs +++ b/crates/review/src/ui/annotate/toolbar.rs @@ -4,6 +4,7 @@ use craft_behavior::Mixed; use craft_ui::bars::{Bar, BarKind}; use craft_ui::choice::{RadioGroup, Swatch}; use craft_ui::contract::{Bind, BodyCx, NoValue, Outcome, Props as _, Remember as _, Show as _, ShowContainer as _}; +use craft_ui::display::Divider; use craft_ui::layout_components::Row; use craft_ui::popover::Popover; use craft_ui::rails::{FlyoutButton, LastUsed, RailTool, SlotId, ToolSlot, remembered, shown_tool}; @@ -44,10 +45,10 @@ impl Outcome for AnnotationToolbarOutput { #[derive(Clone, Copy, Debug, Default)] struct PaletteOpen(bool); -/// Acrobat's quick bar: Select, then the three groups (Comment, Highlight, Draw), each a button showing its -/// last-used tool with a flyout of the group's tools, then the colour well and the line width of the tool's new -/// annotations ([`AnnotateTool::color`], [`AnnotateTool::width`]); both are disabled for tools that draw nothing -/// (Select, Eraser) and the width for markups. The colour well opens a palette popover. +/// Acrobat's quick bar: Select, then the three groups (Comment, Highlight, Draw), a rule before each, each a button +/// showing its last-used tool with a flyout of the group's tools, then the colour well and the line width of the +/// tool's new annotations ([`AnnotateTool::color`], [`AnnotateTool::width`]); both are disabled for tools that draw +/// nothing (Select, Eraser) and the width for markups. The colour well opens a palette popover. #[derive(craft_ui::contract::Pattern)] pub struct AnnotationToolbar<'a> { tool: &'a mut AnnotateTool, @@ -83,6 +84,7 @@ impl<'a> AnnotationToolbar<'a> { annotate.tool = tool; } for (slot, group) in slots.iter().zip(AnnotationGroup::ALL) { + Divider::vertical().show(ui); let tools: Vec<&RailTool> = slot.tools.iter().collect(); let shown = shown_tool(¤t, slot.id, &tools, &last, |_| true).map_or(current, |tool| tool.id); let out = FlyoutButton::new(&slot.tools, &shown) diff --git a/crates/timeline/src/ui/graph.rs b/crates/timeline/src/ui/graph.rs index 0697aba8d..2d347a34c 100644 --- a/crates/timeline/src/ui/graph.rs +++ b/crates/timeline/src/ui/graph.rs @@ -263,7 +263,7 @@ enum Button { } impl Button { - /// The buttons in reading order; a wider gap separates neighbours of different groups. + /// The buttons in reading order; a wider gap with a rule in it separates neighbours of different groups. const ALL: [Button; 14] = [ Button::Value, Button::Speed, @@ -537,6 +537,12 @@ impl<'a> GraphEditor<'a> { cells } + /// Where a rule separates two groups of the shown buttons `cells`: the middle of the gap between them. A group + /// past the bar's end leaves no rule after the last shown button. + fn bar_rules(cells: &[(usize, Button, Rect)]) -> Vec { + cells.windows(2).filter(|pair| pair[0].1.group() != pair[1].1.group()).map(|pair| (pair[0].2.right() + pair[1].2.left()) / 2.0).collect() + } + /// The keys: a click picks, a drag moves the selected keys. fn press_keys(&mut self, cx: &mut Cx<'_, Self>, axis: &TimeAxis, frame: &Frame, left: f32, shown_range: (f64, f64)) { let keys: Vec<(usize, KeyframeId)> = self.keys_in_order().map(|(n, key)| (n, key.id)).collect(); @@ -999,8 +1005,12 @@ impl Component for GraphEditor<'_> { // The bottom bar, over whatever the curves drew past the plot. draw.fill(&PaintShape::Rect(bar, CornerRadius::ZERO), style.bar_fill); draw.rule(RuleKind::Divider, bar.left_top(), bar.right_top()); + let cells = Self::bar_cells(bar, style); + for x in Self::bar_rules(&cells) { + draw.rule(RuleKind::Divider, Pos2::new(x, bar.top() + style.gap), Pos2::new(x, bar.bottom() - style.gap)); + } let words = cx.words::(); - for (at, button, _) in Self::bar_cells(bar, style) { + for (at, button, _) in cells { let icon = IconSpec::svg(IconId::new(button.icon())); let name = Label::from(button.name(&words).to_owned()); match button.on(&range) {