Skip to content

VectorCraft: An open-source, vector art tool written by scratch in pure Rust

Contextual Task Bar: the Shape Properties popup stays open for its Corner dropdown

dotCooCoof1a6a9ff67f7
diff --git a/crates/ui-egui/src/canvas/task_bar.rs b/crates/ui-egui/src/canvas/task_bar.rs
index cf40955ee..73a633486 100644
--- a/crates/ui-egui/src/canvas/task_bar.rs
+++ b/crates/ui-egui/src/canvas/task_bar.rs
@@ -267,9 +267,10 @@ pub(super) fn task_bar(app: &mut VectorcraftApp, ui: &mut Ui, xf: &Xf) {
if let Some(shape) = &shape
&& let NodeKind::Path { live: Some(live), .. } = &shape.kind
{
- // The shape's properties in a popup that stays open while its fields are edited.
+ // The shape's properties in a popover that stays open while its fields and
+ // its Corner dropdown are used.
let props = widgets::icon_button(ui, "shapes", tl!("Shape Properties"), false, 30.0);
- egui::Popup::menu(&props).close_behavior(egui::PopupCloseBehavior::CloseOnClickOutside).show(|ui| {
+ widgets::popover(&props, props.clicked(), |ui| {
ui.set_min_width(250.0);
crate::panels::transform::live_shape_rows(app, ui, shape, live, "task-bar-shape", true);
});
diff --git a/crates/ui-egui/src/tests/taskbar.rs b/crates/ui-egui/src/tests/taskbar.rs
index 2cc79e6da..7a6bd2616 100644
--- a/crates/ui-egui/src/tests/taskbar.rs
+++ b/crates/ui-egui/src/tests/taskbar.rs
@@ -323,6 +323,27 @@ fn the_shape_properties_popup_edits_the_shape() {
assert_eq!(sides(&app), 6);
}
+/// The popup stays open while a polygon's Corner dropdown is open, so a corner type can be picked
+/// from it.
+#[test]
+fn the_shape_properties_popup_keeps_its_corner_dropdown() {
+ let mut app = app();
+ app.run("tool.select", json!({"tool": "selection"})).unwrap();
+ let polygon = id(app.run("shape.polygon", json!({"cx": 100, "cy": 100, "radius": 40, "sides": 6})).unwrap());
+ select(&mut app, &[polygon]);
+ let (ctx, texts) = click_lock_slot(&mut app);
+ let click = |app: &mut VectorcraftApp, p: Pos2| {
+ let press = |pressed| Event::PointerButton { pos: p, button: PointerButton::Primary, pressed, modifiers: Default::default() };
+ frame(app, &ctx, vec![Event::PointerMoved(p), press(true), press(false)]);
+ frame(app, &ctx, vec![])
+ };
+ let texts = click(&mut app, at(&texts, "Round"));
+ assert!(has(&texts, "Polygon Properties:") && has(&texts, "Chamfer"), "the popup and its dropdown: {texts:?}");
+ click(&mut app, at(&texts, "Chamfer"));
+ let vectorcraft_doc::LiveShape::Polygon { kinds, .. } = live(&app, polygon) else { panic!("not a polygon") };
+ assert!(!kinds.is_empty() && kinds.iter().all(|k| *k == vectorcraft_geom::shapes::CornerKind::Chamfer), "{kinds:?}");
+}
+
/// Every other selection keeps Lock: a plain closed path, a star (a plain path), a path with live
/// corners, a group and several objects. The Direct Selection tool keeps it for a basic shape.
#[test]