mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-03 06:31:42 +01:00
Options bar: centre Home, the tool icon and its arrow on the bar's line (#17946)
The lead is a memoized view, and a memoized view's children take no slots on the bar's row line: they stood at the top of the view, Home and the tool icon about 6 px above the options after them and the small arrow higher still. The lead's members now sit in a row of their own, as PaintBar's do. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
932d1e5aef
commit
d296eea8b1
3 files changed
+40
-12
No files matched your search
@@ -1020,6 +1020,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);
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user