mirror of
https://github.com/storytold/photocraft.git
synced 2026-11-18 16:04:57 +00:00
Pen menu: name the transform row after what it acts on
The Pen's canvas menu now reads Free Transform (greyed) when the document has no path, Free Transform Points while a path is being drawn, and Free Transform Path on a finished path, as in the reference application. A path that exists but isn't active keeps Free Transform Path, as do the Path Selection and Direct Selection menus. ui.inspect lists the same label.
This commit is contained in:
1 parent
609e2aa727
commit
01a2a3455b
2 files changed
+27
-3
No files matched your search
@@ -506,6 +506,25 @@ pub const PEN_MENU: &[Row] = &[
|
||||
Some(("Disable Symmetry Path", "paint.symmetryDisable")),
|
||||
];
|
||||
|
||||
/// The label a row shows, untranslated. The Pen's transform row names what it acts on, as in
|
||||
/// Photoshop (#12913): the points of the path being drawn, or nothing when the document has no
|
||||
/// path at all. A path that exists but isn't active, and the Path Selection and Direct Selection
|
||||
/// menus, keep the table's label.
|
||||
pub(crate) fn row_label(app: &PhotocraftApp, menu: &CanvasToolMenu, label: &'static str, command: &str) -> &'static str {
|
||||
if command != "path.transform" || menu.tool != Tool::Pen {
|
||||
return label;
|
||||
}
|
||||
if app.ui.pen.as_ref().is_some_and(|p| p.knots.len() >= 2) {
|
||||
return "Free Transform Points";
|
||||
}
|
||||
let any_path = app.session.active().is_some_and(|st| {
|
||||
st.doc.work_path.is_some()
|
||||
|| !st.doc.paths.is_empty()
|
||||
|| st.doc.walk().iter().any(|(_, _, l)| l.vector_mask.is_some() || matches!(l.content, LayerContent::Shape(_)))
|
||||
});
|
||||
if any_path { label } else { "Free Transform" }
|
||||
}
|
||||
|
||||
/// The Color Sampler menu's Delete row: removes the sampler the menu opened on.
|
||||
pub const SAMPLER_DELETE: &str = "view.colorSamplers.delete";
|
||||
|
||||
@@ -1376,7 +1395,12 @@ pub fn show(app: &mut PhotocraftApp, ctx: &Context) {
|
||||
ui.separator();
|
||||
continue;
|
||||
};
|
||||
let item = egui::Button::selectable(mode_checked(app, &menu, command), tl!(label)).min_size(egui::vec2(200.0, 20.0));
|
||||
let text = match row_label(app, &menu, label, command) {
|
||||
// Spelled out so `cargo xtask i18n-coverage` lists the new label.
|
||||
"Free Transform Points" => tl!("Free Transform Points"),
|
||||
key => tl!(key),
|
||||
};
|
||||
let item = egui::Button::selectable(mode_checked(app, &menu, command), text).min_size(egui::vec2(200.0, 20.0));
|
||||
if ui.add_enabled(entry_enabled(app, &menu, command), item).clicked() {
|
||||
selected = Some((*command).to_string());
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ use super::*;
|
||||
/// The open canvas context menu's rows for `ui.state`: the spelling suggestions first (type edit
|
||||
/// menu over a misspelled word), then the menu's own rows.
|
||||
fn context_entries(app: &PhotocraftApp, menu: &crate::canvas_tool_menu::CanvasToolMenu) -> Vec<Value> {
|
||||
use crate::canvas_tool_menu::{crop_rows, entry_enabled, rows, spelling_rows};
|
||||
use crate::canvas_tool_menu::{crop_rows, entry_enabled, row_label, rows, spelling_rows};
|
||||
let spelling = spelling_rows(menu);
|
||||
let mut entries: Vec<Value> = spelling.iter().map(|(label, id)| json!({"label": label, "id": id, "enabled": entry_enabled(app, menu, id)})).collect();
|
||||
if !spelling.is_empty() {
|
||||
@@ -14,7 +14,7 @@ fn context_entries(app: &PhotocraftApp, menu: &crate::canvas_tool_menu::CanvasTo
|
||||
None => json!({"separator": true}),
|
||||
}));
|
||||
entries.extend(rows(menu).iter().map(|row| match row {
|
||||
Some((label, id)) => json!({"label": label, "id": id, "enabled": entry_enabled(app, menu, id)}),
|
||||
Some((label, id)) => json!({"label": row_label(app, menu, label, id), "id": id, "enabled": entry_enabled(app, menu, id)}),
|
||||
None => json!({"separator": true}),
|
||||
}));
|
||||
entries
|
||||
|
||||
Reference in new issue
Block a user