Merge pull request #17947 from davidmann4/fix/options-bar-tool-arrow-centred

Options bar: centre Home, the tool icon and its arrow on the bar's line (#17946)
This commit is contained in:
David Mann authored and GitHub committed 2026-11-29 18:26:35 +01:00
commit cf0753ad7b
3 files changed
+40 -12

No files matched your search

+3
View File
@@ -1023,6 +1023,9 @@ mod hidden_layer_tests;
#[cfg(test)]
mod warp_text_dialog_tests;
#[cfg(test)]
mod options_bar_lead_centred_tests;
#[cfg(test)]
mod options_bar_mode_wheel_tests;
@@ -0,0 +1,21 @@
//! #17946: the options bar's lead (Home, the tool icon and its arrow) stands on the bar's line, centred like the
//! tool's options after it, not at the top of the bar.
use egui::Rect;
use egui_kittest::kittest::Queryable;
use crate::options_bar_mode_wheel_tests::{harness, mode_dropdown};
use crate::state::Tool;
#[test]
fn home_and_the_tool_icon_share_the_bars_centre_line() {
let h = harness(Tool::Brush);
let mode = mode_dropdown(&h);
let home = h.get_by_label("Home").rect();
// The toolbar has a Brush Tool button too; the options bar's is the one above the canvas.
let tool = h.query_all_by_label("Brush Tool").map(|n| n.rect()).filter(|r| r.top() < mode.bottom()).collect::<Vec<Rect>>();
let [tool] = tool[..] else { panic!("one Brush Tool icon in the options bar, got {tool:?}") };
for (name, rect) in [("Home", home), ("tool icon", tool)] {
assert!((rect.center().y - mode.center().y).abs() < 0.5, "{name} centre {} vs Mode {}", rect.center().y, mode.center().y);
}
}
+16 -12
View File
@@ -8,9 +8,10 @@ use craft::behavior::{EditEvents, IconId, NumberCodec};
use craft::ui::bars::{Bar, BarHome, BarKind, BarOutput, BarTool};
use craft::ui::buttons::{IconButton, PopupMark, ToggleButton};
use craft::ui::choice::Checkbox;
use craft::ui::contract::{Bind, Entry, MemoProps, MemoView, Outbox, PopupKind, Props as _, Show as _, ShowContainer as _, Trigger};
use craft::ui::contract::{Bind, Entry, Gap, MemoProps, MemoView, Outbox, PopupKind, Props as _, Show as _, ShowContainer as _, Trigger};
use craft::ui::display::Divider;
use craft::ui::form::Field;
use craft::ui::layout_components::Row;
use craft::ui::menu::Menu;
use craft::ui::runtime::env::{Env, Label, UnitKind, WheelScope, with_env};
use craft::ui::text::{NumberField, RangeAlert};
@@ -287,18 +288,21 @@ fn lead(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
}
}
/// The bar lead's view.
/// The bar lead's view. Its members sit in a row of their own: a memoized view's children take no slots on the bar's
/// line, so without the row they would stand at the top of the view, the small arrow above the icon's middle (#17946).
fn lead_view(props: &mut LeadProps<'_>, ui: &mut egui::Ui) {
let home = BarHome::new(tl!("Home").to_owned(), Bind::given(props.home_on)).enabled(props.home_enabled).show(ui);
if home.events.value().is_some() {
props.out.send(LeadEvent::Home);
}
let tool = BarTool::new(icons::tool_icon(props.tool), tl!(props.tool.label()).to_owned()).enabled(!props.warping).show(ui);
// Photoshop: right-click the tool icon for Reset Tool / Reset All Tools.
let rows = [Entry::new(Reset::Tool, tl!("Reset Tool").to_owned()), Entry::new(Reset::All, tl!("Reset All Tools").to_owned())];
if let Some(reset) = Menu::context(tl!("Tool").to_owned(), &tool.response).pick(ui, &rows).picked {
props.out.send(LeadEvent::Reset(reset));
}
let _ = Row::new().gap(Gap::Item).show(ui, |ui, _| {
let home = BarHome::new(tl!("Home").to_owned(), Bind::given(props.home_on)).enabled(props.home_enabled).show(ui);
if home.events.value().is_some() {
props.out.send(LeadEvent::Home);
}
let tool = BarTool::new(icons::tool_icon(props.tool), tl!(props.tool.label()).to_owned()).enabled(!props.warping).show(ui);
// Photoshop: right-click the tool icon for Reset Tool / Reset All Tools.
let rows = [Entry::new(Reset::Tool, tl!("Reset Tool").to_owned()), Entry::new(Reset::All, tl!("Reset All Tools").to_owned())];
if let Some(reset) = Menu::context(tl!("Tool").to_owned(), &tool.response).pick(ui, &rows).picked {
props.out.send(LeadEvent::Reset(reset));
}
});
}
/// The Mode, Opacity and Flow of the stamp tools, Healing and Art History: the tool's own brush's, kept per tool like its