diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs index e4be7928eb..ca1573dba2 100644 --- a/crates/ui-egui/src/panels.rs +++ b/crates/ui-egui/src/panels.rs @@ -872,520 +872,522 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) { .show(ui, |ui| { ui.style_mut().spacing.scroll = egui::style::ScrollStyle { bar_width: 4.0, ..egui::style::ScrollStyle::floating() }; egui::ScrollArea::horizontal().id_salt("tool-options").auto_shrink([false, false]).show(ui, |ui| { - // Font ink can extend beyond its advance width at fractional positions. - // Include its gutter in the container layout, including right-aligned actions. - egui::Frame::NONE.inner_margin(egui::Margin { right: 2, ..Default::default() }).show(ui, |ui| { - crate::direction::horizontal_centered(ui, |ui| { - if t.pro { - crate::chrome_ui::home_button(app, ui); - widgets::vline(ui, 22.0); - } - let tool_icon = icons::button(ui, icons::tool_icon(app.ui.tool), if t.pro { 26.0 } else { 28.0 }, !t.pro, tl!(app.ui.tool.label())); - // Photoshop: right-click the tool icon for Reset Tool / Reset All Tools (#2825). - let mut reset = None; - tool_icon.context_menu(|ui| { - if ui.button(tl!("Reset Tool")).clicked() { - reset = Some("tool.reset"); - ui.close(); - } - if ui.button(tl!("Reset All Tools")).clicked() { - reset = Some("tool.resetAll"); - ui.close(); - } - }); - if let Some(id) = reset - && let Err(e) = crate::menus::invoke(app, ui.ctx(), id, json!({})) - { - app.ui.status = e; - } - if t.pro { - let (r, _) = ui.allocate_exact_size(vec2(10.0, 20.0), Sense::hover()); - icons::paint(ui, r, "chevron-down", 10.0, t.text_faint); - } - widgets::vline(ui, 22.0); - if app.ui.transform.is_some() { - crate::transform_tool::options_bar(app, ui); - return; - } - if crate::distort_ui::options_bar(app, ui) { - return; - } - let tool = app.ui.tool; - // The options bar shows the active tool's brush: switch it in before drawing the - // chip, so a tool change swaps the brush with it (Photoshop keeps one per tool). - crate::paint_mouse::sync_tool_brush(app); - // Brush edits here go through `tools.setBrush`, one journal entry per gesture (Rule 1). - if (tool.is_brushlike() && !matches!(tool, Tool::Brush | Tool::Pencil | Tool::MixerBrush | Tool::Eraser)) || tool == Tool::QuickSelection { - brush_preset_chip(ui, &app.session.tools.brush, &mut app.ui); - crate::brush_picker::settings_toggle(app, ui); - widgets::vline(ui, 22.0); - } - if tool == Tool::CloneStamp { - let before = app.session.tools.brush.clone(); - let mut brush = before.clone(); - let width = if t.pro { 62.0 } else { 66.0 }; - percent_field(ui, tl!("Opacity"), &mut brush.opacity, 1.0..=100.0, width); - percent_field(ui, tl!("Flow"), &mut brush.flow, 1.0..=100.0, width); - crate::brush_panel::commit_gesture(app, ui.ctx(), &before, &brush); - widgets::vline(ui, 22.0); - } - if crate::eraser_ui::options_bar(app, ui, tool) - || crate::retouch_ui::options_bar(app, ui, tool) - || crate::vector_ui::options_bar(app, ui, tool) - || crate::analysis_ui::options_bar(app, ui, tool) - || crate::slice_ui::options_bar(app, ui, tool) - || crate::frame_tool::options_bar(app, ui, tool) - || crate::artboard_tool::options_bar(app, ui, tool) - { - return; - } - let brush_before = app.session.tools.brush.clone(); - let mut brush = brush_before.clone(); - let b = &mut brush; - match app.ui.tool { - Tool::Brush | Tool::Eraser if t.pro => { - // A Block-mode Eraser has a fixed size, opacity and flow (Photoshop, #2770). - let block = crate::eraser_ui::block_mode(app, app.ui.tool); - ui.add_enabled_ui(!block, |ui| { - brush_preset_chip(ui, b, &mut app.ui); - crate::brush_picker::settings_toggle(app, ui); - }); - widgets::vline(ui, 22.0); - // The Eraser has no blend mode: its Mode is Brush, Pencil or Block (#2662). - if app.ui.tool == Tool::Eraser { - crate::eraser_ui::mode_dropdown(ui, &mut app.ui.tool_options.eraser_mode); - } else { - opt_label(ui, tl!("Mode")); - let held = app.held_erase; - paint_mode_dropdown(ui, "brush-mode", b, &mut app.ui.tool_options.brush_clear, held); - } - ui.add_enabled_ui(!block, |ui| { - percent_field(ui, tl!("Opacity"), &mut b.opacity, 0.0..=100.0, 62.0); - if icons::button(ui, "circle-dot", 24.0, b.pressure_opacity, tl!("Always use pressure for opacity")).clicked() { - b.pressure_opacity = !b.pressure_opacity; - } - }); - // A Pencil- or Block-mode Eraser is always full flow, without build-up (Photoshop). - ui.add_enabled_ui(!block && !crate::eraser_ui::pencil_mode(app, app.ui.tool), |ui| { - percent_field(ui, tl!("Flow"), &mut b.flow, 1.0..=100.0, 62.0); - let airbrush = icons::button(ui, "sparkles", 24.0, b.build_up, tl!("Enable airbrush-style build-up effects")); - if crate::brush_picker::named(airbrush, "Enable airbrush-style build-up effects").clicked() { - b.build_up = !b.build_up; - } - }); - opt_label(ui, tl!("Smoothing")); - smoothing_field(ui, b, 58.0); - smoothing_options(ui, b); - widgets::vline(ui, 22.0); - if icons::button(ui, "circle-dot", 24.0, b.pressure_size, tl!("Always use pressure for size")).clicked() { - b.pressure_size = !b.pressure_size; - } - } - // Pencil: Photoshop's options (no hardness or flow: the pencil is always hard). - Tool::Pencil => { - brush_preset_chip(ui, b, &mut app.ui); - crate::brush_picker::settings_toggle(app, ui); - widgets::vline(ui, 22.0); - if !t.pro { - opt_label(ui, tl!("Size")); - widgets::value_field(ui, &mut b.size, 1.0..=photocraft_engine::paint::MAX_BRUSH_SIZE, "px", 76.0); + // Font ink can extend beyond its advance width at fractional positions. + // Include its gutter in the container layout, including right-aligned actions. + egui::Frame::NONE.inner_margin(egui::Margin { right: 2, ..Default::default() }).show(ui, |ui| { + crate::direction::horizontal_centered(ui, |ui| { + if t.pro { + crate::chrome_ui::home_button(app, ui); widgets::vline(ui, 22.0); } - opt_label(ui, tl!("Mode")); - let held = app.held_erase; - paint_mode_dropdown(ui, "pencil-mode", b, &mut app.ui.tool_options.pencil_clear, held); - percent_field(ui, tl!("Opacity"), &mut b.opacity, 0.0..=100.0, if t.pro { 62.0 } else { 66.0 }); - opt_label(ui, tl!("Smoothing")); - smoothing_field(ui, b, if t.pro { 58.0 } else { 66.0 }); - widgets::vline(ui, 22.0); - widgets::checkbox(ui, &mut app.ui.tool_options.pencil_auto_erase, tl!("Auto Erase")); - } - Tool::Brush | Tool::Eraser => { - brush_preset_chip(ui, b, &mut app.ui); - crate::brush_picker::settings_toggle(app, ui); - widgets::vline(ui, 22.0); - // A Block-mode Eraser has a fixed size, opacity and flow (Photoshop, #2770). - let block = crate::eraser_ui::block_mode(app, app.ui.tool); - ui.add_enabled_ui(!block, |ui| { - opt_label(ui, tl!("Size")); - widgets::value_field(ui, &mut b.size, 1.0..=2500.0, "px", 76.0); + let tool_icon = icons::button(ui, icons::tool_icon(app.ui.tool), if t.pro { 26.0 } else { 28.0 }, !t.pro, tl!(app.ui.tool.label())); + // Photoshop: right-click the tool icon for Reset Tool / Reset All Tools (#2825). + let mut reset = None; + tool_icon.context_menu(|ui| { + if ui.button(tl!("Reset Tool")).clicked() { + reset = Some("tool.reset"); + ui.close(); + } + if ui.button(tl!("Reset All Tools")).clicked() { + reset = Some("tool.resetAll"); + ui.close(); + } }); - widgets::vline(ui, 22.0); - if app.ui.tool == Tool::Eraser { - crate::eraser_ui::mode_dropdown(ui, &mut app.ui.tool_options.eraser_mode); - } - // A Pencil-mode Eraser is always hard and at full flow (Photoshop). - let fixed = block || crate::eraser_ui::pencil_mode(app, app.ui.tool); - ui.add_enabled_ui(!fixed, |ui| percent_field(ui, tl!("Hardness"), &mut b.hardness, 0.0..=100.0, 66.0)); - ui.add_enabled_ui(!block, |ui| percent_field(ui, tl!("Opacity"), &mut b.opacity, 0.0..=100.0, 66.0)); - ui.add_enabled_ui(!fixed, |ui| percent_field(ui, tl!("Flow"), &mut b.flow, 1.0..=100.0, 66.0)); - opt_label(ui, tl!("Smoothing")); - smoothing_field(ui, b, 66.0); - widgets::vline(ui, 22.0); - widgets::toggle(ui, &mut b.pressure_size, tl!("Pressure for Size")); - widgets::toggle(ui, &mut b.pressure_opacity, tl!("Pressure for Opacity")); - } - Tool::MixerBrush => { - brush_preset_chip(ui, b, &mut app.ui); - crate::brush_picker::settings_toggle(app, ui); - widgets::vline(ui, 22.0); - for (label, value) in [ - (tl!("Wet"), &mut b.mixer.wet), - (tl!("Load"), &mut b.mixer.load), - (tl!("Mix"), &mut b.mixer.mix), - (tl!("Flow"), &mut b.mixer.flow), - ] { - percent_field(ui, label, value, 0.0..=100.0, 62.0); - } - widgets::vline(ui, 22.0); - widgets::checkbox(ui, &mut b.mixer.sample_all_layers, tl!("Sample All Layers")); - } - // Every theme gets Photoshop's tool options (#4178): outside the Pro themes the - // Marquee, Lasso, Paint Bucket, Crop, Perspective Crop and Move tools used to - // show a one-line hint instead, so switching theme "removed" their options. - Tool::RectMarquee | Tool::EllipseMarquee | Tool::SingleRowMarquee | Tool::SingleColumnMarquee => { - ui.spacing_mut().item_spacing.x = 2.0; - for (i, (icon, tip)) in [ - ("square", tl!("New selection").to_string()), - ("plus", crate::i18n::fmt(tl!("Add to selection ({key})"), &[("key", &crate::shortcuts::pretty("Shift"))])), - ("minus", crate::i18n::fmt(tl!("Subtract from selection ({key})"), &[("key", &crate::shortcuts::pretty("Alt"))])), - ( - "squares-subtract", - crate::i18n::fmt(tl!("Intersect with selection ({key})"), &[("key", &crate::shortcuts::pretty("Shift+Alt"))]), - ), - ] - .iter() - .enumerate() + if let Some(id) = reset + && let Err(e) = crate::menus::invoke(app, ui.ctx(), id, json!({})) { - if icons::button(ui, icon, 24.0, app.ui.selection_mode == i as u8, tip).clicked() { - app.ui.selection_mode = i as u8; - } + app.ui.status = e; } - ui.spacing_mut().item_spacing.x = 8.0; - widgets::vline(ui, 22.0); - let o = &mut app.ui.tool_options; - opt_label(ui, tl!("Feather")); - widgets::value_field(ui, &mut o.feather, 0.0..=1000.0, "px", 62.0); - // Photoshop greys Anti-alias for the Rectangular Marquee (its edges are always hard). - ui.add_enabled_ui(app.ui.tool == Tool::EllipseMarquee, |ui| widgets::checkbox(ui, &mut o.anti_alias, tl!("Anti-alias"))); - widgets::vline(ui, 22.0); - // A single row or column has no style or size: Photoshop greys them. - let sized = matches!(app.ui.tool, Tool::RectMarquee | Tool::EllipseMarquee); - ui.add_enabled_ui(sized, |ui| opt_label(ui, tl!("Style"))); - let styles = [ - ("normal".to_string(), tl!("Normal")), - ("fixedRatio".to_string(), tl!("Fixed Ratio")), - ("fixedSize".to_string(), tl!("Fixed Size")), - ]; - if ui.add_enabled_ui(sized, |ui| widgets::dropdown(ui, "marquee-style", &mut o.marquee_style, &styles, 96.0)).inner { - (o.marquee_width, o.marquee_height) = if o.marquee_style == "fixedSize" { (64.0, 64.0) } else { (1.0, 1.0) }; + if t.pro { + let (r, _) = ui.allocate_exact_size(vec2(10.0, 20.0), Sense::hover()); + icons::paint(ui, r, "chevron-down", 10.0, t.text_faint); } - let fixed = sized && o.marquee_style != "normal"; - let (unit, range) = if o.marquee_style == "fixedSize" { ("px", 1.0..=300_000.0) } else { ("", 0.001..=999.0) }; - ui.add_enabled_ui(fixed, |ui| { - opt_label(ui, tl!("Width")); - widgets::value_field(ui, &mut o.marquee_width, range.clone(), unit, 62.0); - if icons::button(ui, "arrow-left-right", 22.0, false, tl!("Swaps height and width")).clicked() { - std::mem::swap(&mut o.marquee_width, &mut o.marquee_height); - } - opt_label(ui, tl!("Height")); - widgets::value_field(ui, &mut o.marquee_height, range, unit, 62.0); - }); widgets::vline(ui, 22.0); - if widgets::secondary_button(ui, tl!("Select and Mask…"), 0.0).clicked() { - let _ = crate::menus::invoke(app, ui.ctx(), "select.selectAndMask", json!({})); + if app.ui.transform.is_some() { + crate::transform_tool::options_bar(app, ui); + return; } - } - Tool::Lasso | Tool::PolygonLasso | Tool::MagneticLasso => { - selection_mode_buttons(app, ui); - widgets::vline(ui, 22.0); - opt_label(ui, tl!("Feather")); - widgets::value_field(ui, &mut app.ui.tool_options.feather, 0.0..=1000.0, "px", 62.0); - widgets::checkbox(ui, &mut app.ui.tool_options.anti_alias, tl!("Anti-alias")); - widgets::vline(ui, 22.0); - if app.ui.tool == Tool::MagneticLasso { - let o = &mut app.ui.tool_options; - opt_label(ui, tl!("Width")); - widgets::value_field(ui, &mut o.magnetic_width, 1.0..=256.0, "px", 58.0) - .on_hover_text(tl!("Follows only edges this close to the pointer ([ and ] change it)")); - opt_label(ui, tl!("Contrast")); - widgets::value_field(ui, &mut o.magnetic_contrast, 1.0..=100.0, "%", 58.0) - .on_hover_text(tl!("Higher values follow only edges that contrast sharply with their surroundings")); - opt_label(ui, tl!("Frequency")); - widgets::value_field(ui, &mut o.magnetic_frequency, 0.0..=100.0, "", 50.0) - .on_hover_text(tl!("How often fastening points are placed by themselves")); - if icons::button(ui, "circle-dot", 24.0, o.magnetic_pressure, tl!("Use tablet pressure to change pen width")).clicked() { - o.magnetic_pressure = !o.magnetic_pressure; - } + if crate::distort_ui::options_bar(app, ui) { + return; + } + let tool = app.ui.tool; + // The options bar shows the active tool's brush: switch it in before drawing the + // chip, so a tool change swaps the brush with it (Photoshop keeps one per tool). + crate::paint_mouse::sync_tool_brush(app); + // Brush edits here go through `tools.setBrush`, one journal entry per gesture (Rule 1). + if (tool.is_brushlike() && !matches!(tool, Tool::Brush | Tool::Pencil | Tool::MixerBrush | Tool::Eraser)) + || tool == Tool::QuickSelection + { + brush_preset_chip(ui, &app.session.tools.brush, &mut app.ui); + crate::brush_picker::settings_toggle(app, ui); widgets::vline(ui, 22.0); } - if widgets::secondary_button(ui, tl!("Select and Mask…"), 0.0).clicked() { - let _ = crate::menus::invoke(app, ui.ctx(), "select.selectAndMask", json!({})); + if tool == Tool::CloneStamp { + let before = app.session.tools.brush.clone(); + let mut brush = before.clone(); + let width = if t.pro { 62.0 } else { 66.0 }; + percent_field(ui, tl!("Opacity"), &mut brush.opacity, 1.0..=100.0, width); + percent_field(ui, tl!("Flow"), &mut brush.flow, 1.0..=100.0, width); + crate::brush_panel::commit_gesture(app, ui.ctx(), &before, &brush); + widgets::vline(ui, 22.0); } - if crate::lasso_ui::active(app) || (app.ui.tool == Tool::PolygonLasso && !app.ui.polygon.is_empty()) { - hint( - ui, - &crate::i18n::fmt( - tl!("Click the first point or press {key} to close · Esc cancels"), - &[("key", &crate::shortcuts::pretty("Enter"))], - ), - ); - } else if app.ui.tool == Tool::Lasso { - hint(ui, tl!("Hold Alt while drawing for straight segments")); + if crate::eraser_ui::options_bar(app, ui, tool) + || crate::retouch_ui::options_bar(app, ui, tool) + || crate::vector_ui::options_bar(app, ui, tool) + || crate::analysis_ui::options_bar(app, ui, tool) + || crate::slice_ui::options_bar(app, ui, tool) + || crate::frame_tool::options_bar(app, ui, tool) + || crate::artboard_tool::options_bar(app, ui, tool) + { + return; } - if app.ui.tool == Tool::MagneticLasso && app.ui.magnetic.active() { - hint( - ui, - &crate::i18n::fmt( - tl!("Click the first point or press {key} to close · {del} removes a point · Esc cancels"), - &[("key", &crate::shortcuts::pretty("Enter")), ("del", &crate::shortcuts::pretty("Backspace"))], - ), - ); - } - } - Tool::MagicWand => { - selection_mode_buttons(app, ui); - widgets::vline(ui, 22.0); - opt_label(ui, tl!("Tolerance")); - widgets::value_field(ui, &mut app.ui.tool_options.tolerance, 0.0..=255.0, "", 58.0); - widgets::checkbox(ui, &mut app.ui.tool_options.anti_alias, tl!("Anti-alias")); - widgets::checkbox(ui, &mut app.ui.tool_options.contiguous, tl!("Contiguous")); - widgets::checkbox(ui, &mut app.ui.tool_options.sample_all_layers, tl!("Sample All Layers")); - widgets::vline(ui, 22.0); - if widgets::secondary_button(ui, tl!("Select Subject"), 0.0).clicked() { - let r = app.run("select.subject", json!({})); - crate::retouch_ui::report_smart_result(app, r, tl!("No subject found — try Object Selection or the Lasso")); - } - if widgets::secondary_button(ui, tl!("Select and Mask…"), 0.0).clicked() { - let _ = crate::menus::invoke(app, ui.ctx(), "select.selectAndMask", json!({})); - } - } - Tool::PaintBucket => { - opt_label(ui, tl!("Fill")); - let mut src = u8::from(app.ui.tool_options.bucket_fill_pattern); - if widgets::dropdown(ui, "bucket-src", &mut src, &[(0u8, tl!("Foreground")), (1, tl!("Pattern"))], 100.0) { - app.ui.tool_options.bucket_fill_pattern = src == 1; - } - opt_label(ui, tl!("Opacity")); - widgets::value_field(ui, &mut app.ui.tool_options.fill_opacity, 1.0..=100.0, "%", 62.0); - opt_label(ui, tl!("Tolerance")); - widgets::value_field(ui, &mut app.ui.tool_options.tolerance, 0.0..=255.0, "", 58.0); - widgets::checkbox(ui, &mut app.ui.tool_options.anti_alias, tl!("Anti-alias")); - widgets::checkbox(ui, &mut app.ui.tool_options.contiguous, tl!("Contiguous")); - widgets::checkbox(ui, &mut app.ui.tool_options.sample_all_layers, tl!("All Layers")); - } - Tool::Gradient => { - // Live "Gradient" (a Gradient Fill layer) or "Classic gradient" (pixels). - let mut classic = app.ui.tool_options.gradient_classic; - if widgets::dropdown(ui, "gradient-mode", &mut classic, &[(false, "Gradient"), (true, "Classic gradient")], 118.0) { - app.ui.tool_options.gradient_classic = classic; - } - // Live "Gradient" (a Gradient Fill layer) or "Classic gradient" (pixels): - // both paint with the same engine-owned preset (#1651), and either swatch - // click opens the Gradient Editor window, as in Photoshop. - if crate::gradient_ui::preset_swatch(app, ui) { - app.ui.panels.gradient_editor = true; - } - widgets::vline(ui, 22.0); - ui.spacing_mut().item_spacing.x = 2.0; - let before = app.ui.tool_options.clone(); - for (style, icon, tip) in [ - ("linear", "blend", tl!("Linear Gradient")), - ("radial", "circle", tl!("Radial Gradient")), - ("angle", "rotate-cw", tl!("Angle Gradient")), - ("reflected", "arrow-left-right", tl!("Reflected Gradient")), - ("diamond", "diamond", tl!("Diamond Gradient")), - ] { - if icons::button(ui, icon, 24.0, app.ui.tool_options.gradient_style == style, tip).clicked() { - app.ui.tool_options.gradient_style = style.into(); + let brush_before = app.session.tools.brush.clone(); + let mut brush = brush_before.clone(); + let b = &mut brush; + match app.ui.tool { + Tool::Brush | Tool::Eraser if t.pro => { + // A Block-mode Eraser has a fixed size, opacity and flow (Photoshop, #2770). + let block = crate::eraser_ui::block_mode(app, app.ui.tool); + ui.add_enabled_ui(!block, |ui| { + brush_preset_chip(ui, b, &mut app.ui); + crate::brush_picker::settings_toggle(app, ui); + }); + widgets::vline(ui, 22.0); + // The Eraser has no blend mode: its Mode is Brush, Pencil or Block (#2662). + if app.ui.tool == Tool::Eraser { + crate::eraser_ui::mode_dropdown(ui, &mut app.ui.tool_options.eraser_mode); + } else { + opt_label(ui, tl!("Mode")); + let held = app.held_erase; + paint_mode_dropdown(ui, "brush-mode", b, &mut app.ui.tool_options.brush_clear, held); + } + ui.add_enabled_ui(!block, |ui| { + percent_field(ui, tl!("Opacity"), &mut b.opacity, 0.0..=100.0, 62.0); + if icons::button(ui, "circle-dot", 24.0, b.pressure_opacity, tl!("Always use pressure for opacity")).clicked() { + b.pressure_opacity = !b.pressure_opacity; + } + }); + // A Pencil- or Block-mode Eraser is always full flow, without build-up (Photoshop). + ui.add_enabled_ui(!block && !crate::eraser_ui::pencil_mode(app, app.ui.tool), |ui| { + percent_field(ui, tl!("Flow"), &mut b.flow, 1.0..=100.0, 62.0); + let airbrush = icons::button(ui, "sparkles", 24.0, b.build_up, tl!("Enable airbrush-style build-up effects")); + if crate::brush_picker::named(airbrush, "Enable airbrush-style build-up effects").clicked() { + b.build_up = !b.build_up; + } + }); + opt_label(ui, tl!("Smoothing")); + smoothing_field(ui, b, 58.0); + smoothing_options(ui, b); + widgets::vline(ui, 22.0); + if icons::button(ui, "circle-dot", 24.0, b.pressure_size, tl!("Always use pressure for size")).clicked() { + b.pressure_size = !b.pressure_size; + } } - } - ui.spacing_mut().item_spacing.x = 8.0; - widgets::vline(ui, 22.0); - opt_label(ui, tl!("Mode")); - let opts: Vec<(BlendMode, &str)> = BlendMode::LAYER_MODES.iter().map(|m| (*m, m.label())).collect(); - widgets::dropdown(ui, "gradient-blend-mode", &mut app.ui.tool_options.gradient_blend_mode, &opts, 96.0); - opt_label(ui, tl!("Opacity")); - widgets::value_field(ui, &mut app.ui.tool_options.fill_opacity, 1.0..=100.0, "%", 62.0); - widgets::checkbox(ui, &mut app.ui.tool_options.gradient_reverse, tl!("Reverse")); - widgets::checkbox(ui, &mut app.ui.tool_options.gradient_dither, tl!("Dither")); - // Live mode: the options also change a selected gradient fill layer. - crate::gradient_ui::options_changed(app, &before); - } - Tool::PerspectiveCrop => crate::perspective_crop_ui::options_bar(app, ui), - Tool::Crop => { - let before_ratio = crate::crop_ui::preset_ratio(app); - let doc_size = app.session.active().map_or((0.0, 0.0), |s| (f64::from(s.doc.size.width), f64::from(s.doc.size.height))); - // Ratios, sizes, saved presets, New / Delete Crop Preset… (#2443, #1919). - crate::crop_presets::dropdown(app, ui); - let o = &mut app.ui.tool_options; - if o.crop_ratio == crate::crop_size::WHR { - crate::crop_size::fields(o, ui); - } else { - // Keep partial edits in ToolOptions so the first side survives a frame; - // Original Ratio shows the document's numbers, as Photoshop does. - let (mut rw, mut rh) = crate::crop_size::custom_ratio_fields(o, doc_size); - let cw = widgets::value_field(ui, &mut rw, 0.0..=99_999.0, "", 54.0).changed(); - let swap = icons::button(ui, "arrow-left-right", 22.0, false, tl!("Swaps height and width")).clicked(); - let ch = widgets::value_field(ui, &mut rh, 0.0..=99_999.0, "", 54.0).changed(); - if swap { - std::mem::swap(&mut rw, &mut rh); + // Pencil: Photoshop's options (no hardness or flow: the pencil is always hard). + Tool::Pencil => { + brush_preset_chip(ui, b, &mut app.ui); + crate::brush_picker::settings_toggle(app, ui); + widgets::vline(ui, 22.0); + if !t.pro { + opt_label(ui, tl!("Size")); + widgets::value_field(ui, &mut b.size, 1.0..=photocraft_engine::paint::MAX_BRUSH_SIZE, "px", 76.0); + widgets::vline(ui, 22.0); + } + opt_label(ui, tl!("Mode")); + let held = app.held_erase; + paint_mode_dropdown(ui, "pencil-mode", b, &mut app.ui.tool_options.pencil_clear, held); + percent_field(ui, tl!("Opacity"), &mut b.opacity, 0.0..=100.0, if t.pro { 62.0 } else { 66.0 }); + opt_label(ui, tl!("Smoothing")); + smoothing_field(ui, b, if t.pro { 58.0 } else { 66.0 }); + widgets::vline(ui, 22.0); + widgets::checkbox(ui, &mut app.ui.tool_options.pencil_auto_erase, tl!("Auto Erase")); } - if cw || ch || swap { - crate::crop_size::set_custom_ratio_fields(o, rw, rh); + Tool::Brush | Tool::Eraser => { + brush_preset_chip(ui, b, &mut app.ui); + crate::brush_picker::settings_toggle(app, ui); + widgets::vline(ui, 22.0); + // A Block-mode Eraser has a fixed size, opacity and flow (Photoshop, #2770). + let block = crate::eraser_ui::block_mode(app, app.ui.tool); + ui.add_enabled_ui(!block, |ui| { + opt_label(ui, tl!("Size")); + widgets::value_field(ui, &mut b.size, 1.0..=2500.0, "px", 76.0); + }); + widgets::vline(ui, 22.0); + if app.ui.tool == Tool::Eraser { + crate::eraser_ui::mode_dropdown(ui, &mut app.ui.tool_options.eraser_mode); + } + // A Pencil-mode Eraser is always hard and at full flow (Photoshop). + let fixed = block || crate::eraser_ui::pencil_mode(app, app.ui.tool); + ui.add_enabled_ui(!fixed, |ui| percent_field(ui, tl!("Hardness"), &mut b.hardness, 0.0..=100.0, 66.0)); + ui.add_enabled_ui(!block, |ui| percent_field(ui, tl!("Opacity"), &mut b.opacity, 0.0..=100.0, 66.0)); + ui.add_enabled_ui(!fixed, |ui| percent_field(ui, tl!("Flow"), &mut b.flow, 1.0..=100.0, 66.0)); + opt_label(ui, tl!("Smoothing")); + smoothing_field(ui, b, 66.0); + widgets::vline(ui, 22.0); + widgets::toggle(ui, &mut b.pressure_size, tl!("Pressure for Size")); + widgets::toggle(ui, &mut b.pressure_opacity, tl!("Pressure for Opacity")); } - } - widgets::vline(ui, 22.0); - if widgets::secondary_button(ui, tl!("Clear"), 0.0).clicked() { - if o.crop_ratio == crate::crop_size::WHR { - crate::crop_size::clear(o); - } else { - o.crop_ratio.clear(); + Tool::MixerBrush => { + brush_preset_chip(ui, b, &mut app.ui); + crate::brush_picker::settings_toggle(app, ui); + widgets::vline(ui, 22.0); + for (label, value) in [ + (tl!("Wet"), &mut b.mixer.wet), + (tl!("Load"), &mut b.mixer.load), + (tl!("Mix"), &mut b.mixer.mix), + (tl!("Flow"), &mut b.mixer.flow), + ] { + percent_field(ui, label, value, 0.0..=100.0, 62.0); + } + widgets::vline(ui, 22.0); + widgets::checkbox(ui, &mut b.mixer.sample_all_layers, tl!("Sample All Layers")); } - } - crate::crop_straighten::options_button(&mut app.crop.straighten, ui); - crate::crop_overlay::options_button(o, ui); - let pick_shield_color = crate::crop_shield::options_button(&mut o.crop_shield, ui); - widgets::checkbox(ui, &mut o.crop_delete, tl!("Delete Cropped Pixels")); - if crate::crop_ui::preset_ratio(app) != before_ratio { - crate::crop_ui::apply_ratio(app); - } - if pick_shield_color { - crate::crop_shield::pick_custom_color(app); - } - ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { - if icons::button( - ui, - "check", - 26.0, - false, - &crate::i18n::fmt(tl!("Commit current crop operation ({key})"), &[("key", &crate::shortcuts::pretty("Enter"))]), - ) - .clicked() - { - crate::canvas::commit_crop(app); - } - if icons::button(ui, "ban", 26.0, false, tl!("Cancel current crop operation (Esc)")).clicked() { - crate::crop_ui::cancel(app); - } - }); - } - // Every theme gets the font, style and size controls (#1387), as with Auto-Select (#1275). - Tool::Type | Tool::VerticalType | Tool::HorizontalTypeMask | Tool::VerticalTypeMask => crate::type_tool::options_bar(app, ui), - Tool::Move => { - let o = &mut app.ui.tool_options; - widgets::checkbox(ui, &mut o.move_auto_select, tl!("Auto-Select:")); - widgets::dropdown( - ui, - "move-target", - &mut o.move_target, - &[("layer".to_string(), tl!("Layer")), ("group".to_string(), tl!("Group"))], - 76.0, - ); - widgets::vline(ui, 22.0); - widgets::checkbox(ui, &mut o.move_show_transform, tl!("Show Transform Controls")); - widgets::vline(ui, 22.0); - ui.spacing_mut().item_spacing.x = 0.0; - for (icon, tip, cmd) in [ - ("panels-top-left", tl!("Align left edges"), "layer.align.leftEdges"), - ("app-window", tl!("Align horizontal centers"), "layer.align.horizontalCenters"), - ("panel-right", tl!("Align right edges"), "layer.align.rightEdges"), - ] { - let on = app.session.is_enabled(cmd); - if ui.add_enabled_ui(on, |ui| icons::button(ui, icon, 24.0, false, tip)).inner.clicked() { - let _ = app.run(cmd, json!({})); - } - } - ui.add_space(6.0); - let more = icons::button(ui, "ellipsis", 24.0, false, tl!("Align and distribute")); - egui::Popup::menu(&more).show(|ui| { - ui.set_min_width(200.0); - let mut section = |ui: &mut egui::Ui, title: &str, prefix: &str| { - ui.label(egui::RichText::new(tl!(&title)).small().color(t.text_dim)); - for c in photocraft_engine::command_specs().iter().filter(|c| c.id.starts_with(prefix)) { - if ui.add_enabled(app.session.is_enabled(c.id), egui::Button::new(tl!(c.label))).clicked() { - let _ = app.run(c.id, json!({})); - ui.close(); + // Every theme gets Photoshop's tool options (#4178): outside the Pro themes the + // Marquee, Lasso, Paint Bucket, Crop, Perspective Crop and Move tools used to + // show a one-line hint instead, so switching theme "removed" their options. + Tool::RectMarquee | Tool::EllipseMarquee | Tool::SingleRowMarquee | Tool::SingleColumnMarquee => { + ui.spacing_mut().item_spacing.x = 2.0; + for (i, (icon, tip)) in [ + ("square", tl!("New selection").to_string()), + ("plus", crate::i18n::fmt(tl!("Add to selection ({key})"), &[("key", &crate::shortcuts::pretty("Shift"))])), + ("minus", crate::i18n::fmt(tl!("Subtract from selection ({key})"), &[("key", &crate::shortcuts::pretty("Alt"))])), + ( + "squares-subtract", + crate::i18n::fmt(tl!("Intersect with selection ({key})"), &[("key", &crate::shortcuts::pretty("Shift+Alt"))]), + ), + ] + .iter() + .enumerate() + { + if icons::button(ui, icon, 24.0, app.ui.selection_mode == i as u8, tip).clicked() { + app.ui.selection_mode = i as u8; } } - }; - section(ui, tl!("Align"), "layer.align."); - ui.separator(); - section(ui, tl!("Distribute"), "layer.distribute."); - }); - } - Tool::Eyedropper => crate::eyedropper_ui::options(app, ui), - Tool::Zoom => { - widgets::checkbox(ui, &mut app.ui.tool_options.zoom_scrubby, tl!("Scrubby Zoom")); - hint( - ui, - &crate::i18n::fmt( - tl!("Click to zoom in · {key}-click to zoom out · drag right/left to zoom in/out"), - &[("key", &crate::shortcuts::pretty("Alt"))], - ), - ); - if widgets::secondary_button(ui, tl!("Fit Screen"), 0.0).clicked() - && let Some(i) = app.session.active_index() - { - app.ui.views[i].fit_pending = true; - } - if widgets::secondary_button(ui, "100%", 0.0).clicked() - && let Some(i) = app.session.active_index() - { - app.ui.views[i].zoom = 1.0; - } - } - Tool::RotateView => { - hint(ui, tl!("Drag around the centre to rotate the view · Shift constrains to 15°")); - if let Some(i) = app.session.active_index() { - ui.label(tl!("Angle")); - let mut angle = app.ui.views.get(i).map(|v| v.rotation).unwrap_or(0.0); - if widgets::value_field(ui, &mut angle, -180.0..=180.0, "°", 56.0).changed() - && let Some(v) = app.ui.views.get_mut(i) - { - v.rotation = crate::rotate_view::wrap_deg(angle); + ui.spacing_mut().item_spacing.x = 8.0; + widgets::vline(ui, 22.0); + let o = &mut app.ui.tool_options; + opt_label(ui, tl!("Feather")); + widgets::value_field(ui, &mut o.feather, 0.0..=1000.0, "px", 62.0); + // Photoshop greys Anti-alias for the Rectangular Marquee (its edges are always hard). + ui.add_enabled_ui(app.ui.tool == Tool::EllipseMarquee, |ui| widgets::checkbox(ui, &mut o.anti_alias, tl!("Anti-alias"))); + widgets::vline(ui, 22.0); + // A single row or column has no style or size: Photoshop greys them. + let sized = matches!(app.ui.tool, Tool::RectMarquee | Tool::EllipseMarquee); + ui.add_enabled_ui(sized, |ui| opt_label(ui, tl!("Style"))); + let styles = [ + ("normal".to_string(), tl!("Normal")), + ("fixedRatio".to_string(), tl!("Fixed Ratio")), + ("fixedSize".to_string(), tl!("Fixed Size")), + ]; + if ui.add_enabled_ui(sized, |ui| widgets::dropdown(ui, "marquee-style", &mut o.marquee_style, &styles, 96.0)).inner { + (o.marquee_width, o.marquee_height) = if o.marquee_style == "fixedSize" { (64.0, 64.0) } else { (1.0, 1.0) }; + } + let fixed = sized && o.marquee_style != "normal"; + let (unit, range) = if o.marquee_style == "fixedSize" { ("px", 1.0..=300_000.0) } else { ("", 0.001..=999.0) }; + ui.add_enabled_ui(fixed, |ui| { + opt_label(ui, tl!("Width")); + widgets::value_field(ui, &mut o.marquee_width, range.clone(), unit, 62.0); + if icons::button(ui, "arrow-left-right", 22.0, false, tl!("Swaps height and width")).clicked() { + std::mem::swap(&mut o.marquee_width, &mut o.marquee_height); + } + opt_label(ui, tl!("Height")); + widgets::value_field(ui, &mut o.marquee_height, range, unit, 62.0); + }); + widgets::vline(ui, 22.0); + if widgets::secondary_button(ui, tl!("Select and Mask…"), 0.0).clicked() { + let _ = crate::menus::invoke(app, ui.ctx(), "select.selectAndMask", json!({})); + } } - if widgets::secondary_button(ui, tl!("Reset View"), 0.0).clicked() - && let Some(v) = app.ui.views.get_mut(i) - { - v.rotation = 0.0; + Tool::Lasso | Tool::PolygonLasso | Tool::MagneticLasso => { + selection_mode_buttons(app, ui); + widgets::vline(ui, 22.0); + opt_label(ui, tl!("Feather")); + widgets::value_field(ui, &mut app.ui.tool_options.feather, 0.0..=1000.0, "px", 62.0); + widgets::checkbox(ui, &mut app.ui.tool_options.anti_alias, tl!("Anti-alias")); + widgets::vline(ui, 22.0); + if app.ui.tool == Tool::MagneticLasso { + let o = &mut app.ui.tool_options; + opt_label(ui, tl!("Width")); + widgets::value_field(ui, &mut o.magnetic_width, 1.0..=256.0, "px", 58.0) + .on_hover_text(tl!("Follows only edges this close to the pointer ([ and ] change it)")); + opt_label(ui, tl!("Contrast")); + widgets::value_field(ui, &mut o.magnetic_contrast, 1.0..=100.0, "%", 58.0) + .on_hover_text(tl!("Higher values follow only edges that contrast sharply with their surroundings")); + opt_label(ui, tl!("Frequency")); + widgets::value_field(ui, &mut o.magnetic_frequency, 0.0..=100.0, "", 50.0) + .on_hover_text(tl!("How often fastening points are placed by themselves")); + if icons::button(ui, "circle-dot", 24.0, o.magnetic_pressure, tl!("Use tablet pressure to change pen width")).clicked() { + o.magnetic_pressure = !o.magnetic_pressure; + } + widgets::vline(ui, 22.0); + } + if widgets::secondary_button(ui, tl!("Select and Mask…"), 0.0).clicked() { + let _ = crate::menus::invoke(app, ui.ctx(), "select.selectAndMask", json!({})); + } + if crate::lasso_ui::active(app) || (app.ui.tool == Tool::PolygonLasso && !app.ui.polygon.is_empty()) { + hint( + ui, + &crate::i18n::fmt( + tl!("Click the first point or press {key} to close · Esc cancels"), + &[("key", &crate::shortcuts::pretty("Enter"))], + ), + ); + } else if app.ui.tool == Tool::Lasso { + hint(ui, tl!("Hold Alt while drawing for straight segments")); + } + if app.ui.tool == Tool::MagneticLasso && app.ui.magnetic.active() { + hint( + ui, + &crate::i18n::fmt( + tl!("Click the first point or press {key} to close · {del} removes a point · Esc cancels"), + &[("key", &crate::shortcuts::pretty("Enter")), ("del", &crate::shortcuts::pretty("Backspace"))], + ), + ); + } } + Tool::MagicWand => { + selection_mode_buttons(app, ui); + widgets::vline(ui, 22.0); + opt_label(ui, tl!("Tolerance")); + widgets::value_field(ui, &mut app.ui.tool_options.tolerance, 0.0..=255.0, "", 58.0); + widgets::checkbox(ui, &mut app.ui.tool_options.anti_alias, tl!("Anti-alias")); + widgets::checkbox(ui, &mut app.ui.tool_options.contiguous, tl!("Contiguous")); + widgets::checkbox(ui, &mut app.ui.tool_options.sample_all_layers, tl!("Sample All Layers")); + widgets::vline(ui, 22.0); + if widgets::secondary_button(ui, tl!("Select Subject"), 0.0).clicked() { + let r = app.run("select.subject", json!({})); + crate::retouch_ui::report_smart_result(app, r, tl!("No subject found — try Object Selection or the Lasso")); + } + if widgets::secondary_button(ui, tl!("Select and Mask…"), 0.0).clicked() { + let _ = crate::menus::invoke(app, ui.ctx(), "select.selectAndMask", json!({})); + } + } + Tool::PaintBucket => { + opt_label(ui, tl!("Fill")); + let mut src = u8::from(app.ui.tool_options.bucket_fill_pattern); + if widgets::dropdown(ui, "bucket-src", &mut src, &[(0u8, tl!("Foreground")), (1, tl!("Pattern"))], 100.0) { + app.ui.tool_options.bucket_fill_pattern = src == 1; + } + opt_label(ui, tl!("Opacity")); + widgets::value_field(ui, &mut app.ui.tool_options.fill_opacity, 1.0..=100.0, "%", 62.0); + opt_label(ui, tl!("Tolerance")); + widgets::value_field(ui, &mut app.ui.tool_options.tolerance, 0.0..=255.0, "", 58.0); + widgets::checkbox(ui, &mut app.ui.tool_options.anti_alias, tl!("Anti-alias")); + widgets::checkbox(ui, &mut app.ui.tool_options.contiguous, tl!("Contiguous")); + widgets::checkbox(ui, &mut app.ui.tool_options.sample_all_layers, tl!("All Layers")); + } + Tool::Gradient => { + // Live "Gradient" (a Gradient Fill layer) or "Classic gradient" (pixels). + let mut classic = app.ui.tool_options.gradient_classic; + if widgets::dropdown(ui, "gradient-mode", &mut classic, &[(false, "Gradient"), (true, "Classic gradient")], 118.0) { + app.ui.tool_options.gradient_classic = classic; + } + // Live "Gradient" (a Gradient Fill layer) or "Classic gradient" (pixels): + // both paint with the same engine-owned preset (#1651), and either swatch + // click opens the Gradient Editor window, as in Photoshop. + if crate::gradient_ui::preset_swatch(app, ui) { + app.ui.panels.gradient_editor = true; + } + widgets::vline(ui, 22.0); + ui.spacing_mut().item_spacing.x = 2.0; + let before = app.ui.tool_options.clone(); + for (style, icon, tip) in [ + ("linear", "blend", tl!("Linear Gradient")), + ("radial", "circle", tl!("Radial Gradient")), + ("angle", "rotate-cw", tl!("Angle Gradient")), + ("reflected", "arrow-left-right", tl!("Reflected Gradient")), + ("diamond", "diamond", tl!("Diamond Gradient")), + ] { + if icons::button(ui, icon, 24.0, app.ui.tool_options.gradient_style == style, tip).clicked() { + app.ui.tool_options.gradient_style = style.into(); + } + } + ui.spacing_mut().item_spacing.x = 8.0; + widgets::vline(ui, 22.0); + opt_label(ui, tl!("Mode")); + let opts: Vec<(BlendMode, &str)> = BlendMode::LAYER_MODES.iter().map(|m| (*m, m.label())).collect(); + widgets::dropdown(ui, "gradient-blend-mode", &mut app.ui.tool_options.gradient_blend_mode, &opts, 96.0); + opt_label(ui, tl!("Opacity")); + widgets::value_field(ui, &mut app.ui.tool_options.fill_opacity, 1.0..=100.0, "%", 62.0); + widgets::checkbox(ui, &mut app.ui.tool_options.gradient_reverse, tl!("Reverse")); + widgets::checkbox(ui, &mut app.ui.tool_options.gradient_dither, tl!("Dither")); + // Live mode: the options also change a selected gradient fill layer. + crate::gradient_ui::options_changed(app, &before); + } + Tool::PerspectiveCrop => crate::perspective_crop_ui::options_bar(app, ui), + Tool::Crop => { + let before_ratio = crate::crop_ui::preset_ratio(app); + let doc_size = app.session.active().map_or((0.0, 0.0), |s| (f64::from(s.doc.size.width), f64::from(s.doc.size.height))); + // Ratios, sizes, saved presets, New / Delete Crop Preset… (#2443, #1919). + crate::crop_presets::dropdown(app, ui); + let o = &mut app.ui.tool_options; + if o.crop_ratio == crate::crop_size::WHR { + crate::crop_size::fields(o, ui); + } else { + // Keep partial edits in ToolOptions so the first side survives a frame; + // Original Ratio shows the document's numbers, as Photoshop does. + let (mut rw, mut rh) = crate::crop_size::custom_ratio_fields(o, doc_size); + let cw = widgets::value_field(ui, &mut rw, 0.0..=99_999.0, "", 54.0).changed(); + let swap = icons::button(ui, "arrow-left-right", 22.0, false, tl!("Swaps height and width")).clicked(); + let ch = widgets::value_field(ui, &mut rh, 0.0..=99_999.0, "", 54.0).changed(); + if swap { + std::mem::swap(&mut rw, &mut rh); + } + if cw || ch || swap { + crate::crop_size::set_custom_ratio_fields(o, rw, rh); + } + } + widgets::vline(ui, 22.0); + if widgets::secondary_button(ui, tl!("Clear"), 0.0).clicked() { + if o.crop_ratio == crate::crop_size::WHR { + crate::crop_size::clear(o); + } else { + o.crop_ratio.clear(); + } + } + crate::crop_straighten::options_button(&mut app.crop.straighten, ui); + crate::crop_overlay::options_button(o, ui); + let pick_shield_color = crate::crop_shield::options_button(&mut o.crop_shield, ui); + widgets::checkbox(ui, &mut o.crop_delete, tl!("Delete Cropped Pixels")); + if crate::crop_ui::preset_ratio(app) != before_ratio { + crate::crop_ui::apply_ratio(app); + } + if pick_shield_color { + crate::crop_shield::pick_custom_color(app); + } + ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { + if icons::button( + ui, + "check", + 26.0, + false, + &crate::i18n::fmt(tl!("Commit current crop operation ({key})"), &[("key", &crate::shortcuts::pretty("Enter"))]), + ) + .clicked() + { + crate::canvas::commit_crop(app); + } + if icons::button(ui, "ban", 26.0, false, tl!("Cancel current crop operation (Esc)")).clicked() { + crate::crop_ui::cancel(app); + } + }); + } + // Every theme gets the font, style and size controls (#1387), as with Auto-Select (#1275). + Tool::Type | Tool::VerticalType | Tool::HorizontalTypeMask | Tool::VerticalTypeMask => crate::type_tool::options_bar(app, ui), + Tool::Move => { + let o = &mut app.ui.tool_options; + widgets::checkbox(ui, &mut o.move_auto_select, tl!("Auto-Select:")); + widgets::dropdown( + ui, + "move-target", + &mut o.move_target, + &[("layer".to_string(), tl!("Layer")), ("group".to_string(), tl!("Group"))], + 76.0, + ); + widgets::vline(ui, 22.0); + widgets::checkbox(ui, &mut o.move_show_transform, tl!("Show Transform Controls")); + widgets::vline(ui, 22.0); + ui.spacing_mut().item_spacing.x = 0.0; + for (icon, tip, cmd) in [ + ("panels-top-left", tl!("Align left edges"), "layer.align.leftEdges"), + ("app-window", tl!("Align horizontal centers"), "layer.align.horizontalCenters"), + ("panel-right", tl!("Align right edges"), "layer.align.rightEdges"), + ] { + let on = app.session.is_enabled(cmd); + if ui.add_enabled_ui(on, |ui| icons::button(ui, icon, 24.0, false, tip)).inner.clicked() { + let _ = app.run(cmd, json!({})); + } + } + ui.add_space(6.0); + let more = icons::button(ui, "ellipsis", 24.0, false, tl!("Align and distribute")); + egui::Popup::menu(&more).show(|ui| { + ui.set_min_width(200.0); + let mut section = |ui: &mut egui::Ui, title: &str, prefix: &str| { + ui.label(egui::RichText::new(tl!(&title)).small().color(t.text_dim)); + for c in photocraft_engine::command_specs().iter().filter(|c| c.id.starts_with(prefix)) { + if ui.add_enabled(app.session.is_enabled(c.id), egui::Button::new(tl!(c.label))).clicked() { + let _ = app.run(c.id, json!({})); + ui.close(); + } + } + }; + section(ui, tl!("Align"), "layer.align."); + ui.separator(); + section(ui, tl!("Distribute"), "layer.distribute."); + }); + } + Tool::Eyedropper => crate::eyedropper_ui::options(app, ui), + Tool::Zoom => { + widgets::checkbox(ui, &mut app.ui.tool_options.zoom_scrubby, tl!("Scrubby Zoom")); + hint( + ui, + &crate::i18n::fmt( + tl!("Click to zoom in · {key}-click to zoom out · drag right/left to zoom in/out"), + &[("key", &crate::shortcuts::pretty("Alt"))], + ), + ); + if widgets::secondary_button(ui, tl!("Fit Screen"), 0.0).clicked() + && let Some(i) = app.session.active_index() + { + app.ui.views[i].fit_pending = true; + } + if widgets::secondary_button(ui, "100%", 0.0).clicked() + && let Some(i) = app.session.active_index() + { + app.ui.views[i].zoom = 1.0; + } + } + Tool::RotateView => { + hint(ui, tl!("Drag around the centre to rotate the view · Shift constrains to 15°")); + if let Some(i) = app.session.active_index() { + ui.label(tl!("Angle")); + let mut angle = app.ui.views.get(i).map(|v| v.rotation).unwrap_or(0.0); + if widgets::value_field(ui, &mut angle, -180.0..=180.0, "°", 56.0).changed() + && let Some(v) = app.ui.views.get_mut(i) + { + v.rotation = crate::rotate_view::wrap_deg(angle); + } + if widgets::secondary_button(ui, tl!("Reset View"), 0.0).clicked() + && let Some(v) = app.ui.views.get_mut(i) + { + v.rotation = 0.0; + } + } + } + Tool::Hand => { + hint(ui, tl!("Drag to pan · hold Space with any tool")); + if widgets::secondary_button(ui, "100%", 0.0).clicked() + && let Some(i) = app.session.active_index() + { + app.ui.views[i].zoom = 1.0; + app.ui.views[i].fit_pending = false; + app.ui.views[i].fill_pending = false; + } + if widgets::secondary_button(ui, tl!("Fit Screen"), 0.0).clicked() + && let Some(i) = app.session.active_index() + { + app.ui.views[i].fit_pending = true; + app.ui.views[i].fill_pending = false; + } + if widgets::secondary_button(ui, tl!("Fill Screen"), 0.0).clicked() + && let Some(i) = app.session.active_index() + { + app.ui.views[i].fill_pending = true; + app.ui.views[i].fit_pending = false; + } + } + // Retouching and smart-selection tools draw their bar in `retouch_ui::options_bar`. + _ => {} } - } - Tool::Hand => { - hint(ui, tl!("Drag to pan · hold Space with any tool")); - if widgets::secondary_button(ui, "100%", 0.0).clicked() - && let Some(i) = app.session.active_index() - { - app.ui.views[i].zoom = 1.0; - app.ui.views[i].fit_pending = false; - app.ui.views[i].fill_pending = false; + // Painting symmetry is independent of visual theme. Keep the options-bar + // action available for Brush, Pencil and Eraser in every palette (#2659). + if matches!(tool, Tool::Brush | Tool::Pencil | Tool::Eraser) { + crate::symmetry_ui::menu(app, ui); } - if widgets::secondary_button(ui, tl!("Fit Screen"), 0.0).clicked() - && let Some(i) = app.session.active_index() - { - app.ui.views[i].fit_pending = true; - app.ui.views[i].fill_pending = false; - } - if widgets::secondary_button(ui, tl!("Fill Screen"), 0.0).clicked() - && let Some(i) = app.session.active_index() - { - app.ui.views[i].fill_pending = true; - app.ui.views[i].fit_pending = false; - } - } - // Retouching and smart-selection tools draw their bar in `retouch_ui::options_bar`. - _ => {} - } - // Painting symmetry is independent of visual theme. Keep the options-bar - // action available for Brush, Pencil and Eraser in every palette (#2659). - if matches!(tool, Tool::Brush | Tool::Pencil | Tool::Eraser) { - crate::symmetry_ui::menu(app, ui); - } - crate::brush_panel::commit_gesture(app, ui.ctx(), &brush_before, &brush); - }); - reveal_focused_control(ui); - }); + crate::brush_panel::commit_gesture(app, ui.ctx(), &brush_before, &brush); + }); + reveal_focused_control(ui); + }); }); }); }