Brushes panel: address review comments on deletion confirmation, selection, and assertions

This commit is contained in:
ruchirguitar committed 2026-11-19 15:56:50 +05:30
1 parent 45afa9761a
commit e0b3f6ac5b
3 files changed
+25 -17

No files matched your search

+9 -14
View File
@@ -331,9 +331,7 @@ fn item_context_menu(app: &mut VectorcraftApp, ui: &mut Ui, name: &str) {
ui.close();
}
if menu_item(ui, tl!("Delete Brushes"), can_delete, false) {
if let Err(e) = app.run("brush.delete", json!({ "names": targets })) {
app.status(e);
}
delete(app, &targets, true);
ui.close();
}
} else {
@@ -351,9 +349,7 @@ fn item_context_menu(app: &mut VectorcraftApp, ui: &mut Ui, name: &str) {
ui.close();
}
if menu_item(ui, tl!("Delete Brush"), can_delete, false) {
if let Err(e) = app.run("brush.delete", json!({ "name": name })) {
app.status(e);
}
delete(app, &[name.to_string()], true);
ui.close();
}
}
@@ -429,15 +425,14 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
// options; a right-click selects if unselected and displays its item context menu.
let mut pick = |resp: egui::Response, name: &String| {
if resp.secondary_clicked() {
let is_in_multi = multi.as_ref().is_some_and(|m| m.len() > 1 && m.iter().any(|b| b == name));
let is_current = sel_brush.as_deref() == Some(name) || (sel_brush.is_none() && current.as_deref() == Some(name));
if !is_in_multi && !is_current {
let is_selected = match &multi {
Some(m) if m.len() > 1 => m.iter().any(|b| b == name),
_ => sel_brush.as_deref() == Some(name) || (sel_brush.is_none() && current.as_deref() == Some(name)),
};
if !is_selected {
set_pstate(&resp.ctx, "br-anchor", name.clone());
let has_sel = app.session.active().is_some_and(|d| !d.selection.is_empty());
if has_sel {
app.run("brush.apply", json!({ "name": name })).ok();
} else {
app.run("brush.setCurrent", json!({ "name": name })).ok();
if let Err(e) = app.run("brush.setCurrent", json!({ "name": name })) {
app.status(e);
}
let now = brushes(app).1;
let key = click_key(app, now.as_deref());
+15 -3
View File
@@ -900,6 +900,7 @@ fn right_click_context_menu_in_brushes_panel() {
let mut app = VectorcraftApp::new(Session::new(), Default::default());
app.run("file.new", json!({"width": 400, "height": 300})).unwrap();
app.run("shape.rectangle", json!({"x": 10, "y": 10, "width": 50, "height": 40})).unwrap();
let mut h = egui_kittest::Harness::builder().with_size(vec2(260.0, 500.0)).with_accessibility_check(false).build_ui_state(
|ui, app: &mut VectorcraftApp| {
@@ -924,8 +925,9 @@ fn right_click_context_menu_in_brushes_panel() {
// Right-click unselected "Charcoal"
right_click(&mut h, "Charcoal");
// Right-clicking selects Charcoal
// Right-clicking selects Charcoal in panel without applying it to the selected artwork
assert_eq!(brushes(h.state_mut()).1.as_deref(), Some("Charcoal"));
assert_ne!(selected_brush(h.state()).as_deref(), Some("Charcoal"), "right-click must not apply brush to artwork");
// Context menu displays Brush Options…, Duplicate Brush, Delete Brush
let opt = h.get_by_label(" Brush Options…");
@@ -988,10 +990,20 @@ fn right_click_context_menu_in_brushes_panel() {
h.run_steps(2);
let all_names = names(h.state_mut());
assert!(all_names.contains(&"Charcoal copy 2".to_string()) || all_names.contains(&"Charcoal copy".to_string()));
assert!(all_names.contains(&"Charcoal copy 2".to_string()));
assert!(all_names.contains(&"Tapered Stroke copy".to_string()));
// 6. Delete Brush is disabled when it is the last brush in the library
// 6. Delete a brush in use by artwork prompts with the brushDelete confirmation dialog
h.state_mut().run("brush.apply", json!({ "name": "Tapered Stroke" })).unwrap();
assert_eq!(selected_brush(h.state()).as_deref(), Some("Tapered Stroke"));
right_click(&mut h, "Tapered Stroke");
h.get_by_label(" Delete Brush").click();
h.run_steps(2);
assert_eq!(h.state().ui.dialog.as_ref().map(|d| d.kind.as_str()), Some(crate::dialogs::brush_delete::KIND));
crate::dialogs::cancel(h.state_mut());
assert!(names(h.state_mut()).contains(&"Tapered Stroke".to_string()));
// 7. Delete Brush is disabled when it is the last brush in the library
let current_brushes = names(h.state_mut());
let to_delete: Vec<String> = current_brushes.into_iter().filter(|n| n != "Charcoal").collect();
h.state_mut().run("brush.delete", json!({ "names": to_delete })).unwrap();
+1
View File
@@ -73,6 +73,7 @@ Artboard Options forwards the active Artboard tool's Scale Artwork with Artboard
| Date | Change | Summary |
|---|---|---|
| 2026-11-19 | minor | G12: Brushes panel item right-click context menu offering Brush Options…, Duplicate Brush, and Delete Brush (disabled if the last remaining brush); right-clicking an unselected brush selects it first, and right-clicking within a multi-selection preserves it offering Duplicate Brushes / Delete Brushes; headless tests in `crates/ui-egui/src/panels/brushes/tests.rs`; scores and estimates unchanged. |
| 2026-11-19 | minor | PDF import (#8549 follow-up): type filled and stroked after a page of type filled only came in as a filled object and a stroked one: since #8549 lines filled only are kept for a stroke pass too, and the glyphs of the lines finished past the 64 kept were remembered until the next stroke, so `2 Tr (Title) Tj` after more than 64 lines of type filled only took its first stroke for the start of a stroke pass over them, always once more than 4,096 glyphs had been finished so. Those glyphs are now forgotten when anything else is drawn (a path, an image, a Type 3 glyph's art, a change of blend mode or soft mask: nothing is drawn between an operator's fill pass and its stroke pass), and past the first 4,096 glyphs none are remembered instead of every stroke matching. A `TJ` over more lines than are kept still comes in as a filled object and a stroked one for each part, also when it ends where it began, and when a glyph kept as an outline comes before that (the line it starts keeps the glyphs of the lines finished). Remaining: with nothing drawn between them, type filled and stroked at exactly the place, font, size and text of a glyph filled only on a line finished so still comes in as a filled object and a stroked one, as the device can't tell its stroke pass from the start of one over that glyph. Tests: `type_filled_and_stroked_after_a_dense_page_of_filled_type_is_filled_and_stroked`, `type_filled_and_stroked_over_a_finished_glyph_after_a_path_is_filled_and_stroked`, `an_outline_glyph_in_a_tj_over_more_lines_than_are_kept_leaves_fill_and_stroke_apart`; scores and estimates unchanged. |
| 2026-11-18 | minor | Layers: a layer whose art was all added to the selection from its target circle shows as targeted, as an object does (#8646). Scores and estimates unchanged. |
| 2026-11-18 | minor | G11: SVG export writes physical unit suffixes on the root <svg width="..." height="..."> for documents with physical units (mm, cm, in, pc), preventing drawings from scaling to 75% in external tools and preserving units across round-trips (#864; general unit preference on restart remains open under #864). Tests: export_physical_units_writes_unit_suffixes (crates/svg/tests/it/import_units.rs) and svg_round_trip_preserves_document_units (crates/engine/src/cmd/fileio/tests_svg.rs). G11 estimate 8–15 → 6–13 h. |