mirror of
https://github.com/storytold/photocraft.git
synced 2026-11-21 17:37:14 +00:00
commit
c013fa29d4
5 files changed
+68
No files matched your search
@@ -888,6 +888,23 @@ fn pen_dialog(app: &mut PhotocraftApp, command: &str, label: &str, name: &str) {
|
||||
spec_dialog(app, command, label, spec, fields);
|
||||
}
|
||||
|
||||
/// The Pen options bar's Make Selection (Path mode, #5703): the canvas menu's Make Selection…
|
||||
/// dialog for the path being drawn (committed first, as the menu does) or the active path.
|
||||
pub(crate) fn make_selection(app: &mut PhotocraftApp) -> Result<(), String> {
|
||||
let pending = app.ui.pen.as_ref().is_some_and(|p| p.knots.len() >= 2);
|
||||
// Where `pen_commit` puts the path being drawn: a shape layer or the targeted vector mask,
|
||||
// else the Paths panel path it adds to (a selected saved path, or the Work Path), which it
|
||||
// selects so it is the active path.
|
||||
let pending_layer = pending && (app.ui.tool_options.vector_mode == "shape" || crate::vector_ui::targeted_vector_mask(app).is_some());
|
||||
if pending {
|
||||
crate::vector_ui::pen_commit(app, false);
|
||||
}
|
||||
let name = if pending_layer { Some("layer".to_string()) } else { crate::vector_ui::active_path_name(app) }
|
||||
.ok_or_else(|| "No path is available for this action".to_string())?;
|
||||
pen_dialog(app, "path.toSelection", "Make Selection…", &name);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn choose_pen(app: &mut PhotocraftApp, ctx: &Context, menu: &CanvasToolMenu, command: &str) -> Result<(), String> {
|
||||
if command == "select.isolateLayers" {
|
||||
crate::menus::invoke(app, ctx, command, json!({}))?;
|
||||
@@ -1672,6 +1689,42 @@ mod tests {
|
||||
assert!(app.session.active().unwrap().doc.selection.is_some());
|
||||
}
|
||||
|
||||
/// #5703: the Pen options bar's Make Selection (Path mode) opens the same dialog for the path
|
||||
/// being drawn (finished into the Work Path first), and OK selects inside it; with no path at
|
||||
/// all it reports that instead.
|
||||
#[test]
|
||||
fn pen_options_bar_makes_a_selection_from_the_path() {
|
||||
let mut app = app();
|
||||
app.ui.tool = Tool::Pen;
|
||||
assert!(make_selection(&mut app).is_err(), "no path yet");
|
||||
assert!(app.ui.dialogs.is_empty());
|
||||
for (x, y) in [(2.0, 2.0), (20.0, 2.0), (20.0, 20.0)] {
|
||||
crate::vector_ui::pen_down(&mut app, x, y, false);
|
||||
crate::vector_ui::pen_up(&mut app);
|
||||
}
|
||||
make_selection(&mut app).unwrap();
|
||||
let dialog = app.ui.dialogs.last().map(|d| d.id).unwrap();
|
||||
crate::dialogs::confirm(&mut app, dialog).unwrap();
|
||||
let st = app.session.active().unwrap();
|
||||
assert!(st.doc.work_path.is_some() && st.doc.selection.is_some());
|
||||
// The active (Work) path again, with no pen path in progress.
|
||||
app.run("select.deselect", json!({})).unwrap();
|
||||
make_selection(&mut app).unwrap();
|
||||
let dialog = app.ui.dialogs.last().map(|d| d.id).unwrap();
|
||||
crate::dialogs::confirm(&mut app, dialog).unwrap();
|
||||
assert!(app.session.active().unwrap().doc.selection.is_some());
|
||||
// Drawn with a saved path selected, the path is added to that one (#4721): the dialog is
|
||||
// for it, not for a Work Path.
|
||||
app.run("path.rename", json!({"name": "work", "to": "Cutout"})).unwrap();
|
||||
app.ui.selected_path = Some("Cutout".into());
|
||||
for (x, y) in [(4.0, 24.0), (12.0, 24.0), (12.0, 30.0)] {
|
||||
crate::vector_ui::pen_down(&mut app, x, y, false);
|
||||
crate::vector_ui::pen_up(&mut app);
|
||||
}
|
||||
make_selection(&mut app).unwrap();
|
||||
assert_eq!(app.ui.dialogs.last().and_then(|d| d.fields.get("name")), Some(&json!("Cutout")));
|
||||
}
|
||||
|
||||
/// #1056: the Path Selection and Direct Selection tools' right-click opens the path menu for
|
||||
/// the selected path, as the Pen's does, instead of nothing.
|
||||
#[test]
|
||||
|
||||
@@ -3408,6 +3408,7 @@ curves Smooth 매끄럽게
|
||||
# View › Guides › right-click a guide
|
||||
Edit Selected Guides 선택한 안내선 편집
|
||||
Clear Selected Guides 선택한 안내선 지우기
|
||||
Make Selection 선택 영역 만들기
|
||||
Bicubic Automatic 쌍입방 자동
|
||||
Bicubic Smoother 쌍입방 더 부드럽게
|
||||
Bicubic Sharper 쌍입방 더 선명하게
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 3173 and column 53.
|
@@ -2866,6 +2866,7 @@ curves Smooth 平滑
|
||||
# View › Guides › right-click a guide
|
||||
Edit Selected Guides 编辑所选参考线
|
||||
Clear Selected Guides 清除所选参考线
|
||||
Make Selection 建立选区
|
||||
Bicubic Automatic 双三次(自动)
|
||||
Bicubic Smoother 双三次(较平滑)
|
||||
Bicubic Sharper 双三次(较锐利)
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2623 and column 53.
|
@@ -2835,6 +2835,7 @@ curves Smooth 平滑
|
||||
# View › Guides › right-click a guide
|
||||
Edit Selected Guides 編輯所選參考線
|
||||
Clear Selected Guides 清除所選參考線
|
||||
Make Selection 建立選取範圍
|
||||
Bicubic Automatic 雙三次 (自動)
|
||||
Bicubic Smoother 雙三次 (較平滑)
|
||||
Bicubic Sharper 雙三次 (較銳利)
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -1292,6 +1292,18 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui, tool: Tool) -> bo
|
||||
),
|
||||
),
|
||||
}
|
||||
// Path mode: Make Selection from the path being drawn or the active path, as Photoshop's
|
||||
// options bar's "Make: Selection…" does (#5703).
|
||||
if app.ui.tool_options.vector_mode == "path" {
|
||||
crate::widgets::vline(ui, 22.0);
|
||||
let has_path = active_path_name(app).is_some() || app.ui.pen.as_ref().is_some_and(|p| p.knots.len() >= 2);
|
||||
if ui.add_enabled(has_path, egui::Button::new(tl!("Make Selection"))).clicked()
|
||||
&& let Err(e) = crate::canvas_tool_menu::make_selection(app)
|
||||
{
|
||||
app.ui.status = e;
|
||||
app.ui.status_error = true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
let mut mode = "shape".to_string();
|
||||
|
||||
Reference in new issue
Block a user