mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-28 09:21:55 +01:00
Merge pull request #9737 from dotCooCoo/fix/freehand-tip-preserve-other-component
Preserve the untouched Freehand tip component
This commit is contained in:
2 files changed
+53
-1
No files matched your search
@@ -168,8 +168,10 @@ fn tip_row(ui: &mut Ui, fields: &mut DialogFields, least: f64) -> Response {
|
||||
let _ = TipEllipse::new(tl!("Tip"), Bind::bound(&mut tip)).least_roundness(least).show(ui);
|
||||
dabs(ui, tip);
|
||||
});
|
||||
if tip != start {
|
||||
if tip.degrees != start.degrees {
|
||||
fields.set("angle", FieldValue::Number(tip.degrees.round()));
|
||||
}
|
||||
if tip.roundness != start.roundness {
|
||||
fields.set("roundness", FieldValue::Number((tip.roundness * 100.0).round()));
|
||||
}
|
||||
shown.output
|
||||
|
||||
@@ -8,6 +8,56 @@ fn app() -> VectorcraftApp {
|
||||
app
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn changing_one_tip_component_preserves_the_other_fractional_tool_setting() {
|
||||
use crate::tests::panel_harness::Panel;
|
||||
use egui::{Key, Modifiers};
|
||||
|
||||
for tool in ["eraser", "blobBrush"] {
|
||||
for component in ["none", "angle", "roundness"] {
|
||||
for save in [false, true] {
|
||||
let mut app = app();
|
||||
app.run("tool.setOption", json!({"tool": tool, "values": {"angle": 17.25, "roundness": 25.5}})).unwrap();
|
||||
let original = app.session.tool_options_of(tool);
|
||||
assert_eq!(original["angle"], 17.25);
|
||||
assert_eq!(original["roundness"], 25.5);
|
||||
let document = app.session.active().unwrap().doc.clone();
|
||||
let revision = app.session.active().unwrap().revision;
|
||||
let undo = app.session.active().unwrap().history.undo.len();
|
||||
let mut panel = Panel::new(app, crate::tests::picks::dialogs);
|
||||
panel.room(egui::vec2(1000.0, 1200.0));
|
||||
crate::toolbar::open_options(&mut panel.app(), tool).unwrap();
|
||||
panel.frame();
|
||||
let mut expected = original.clone();
|
||||
if component != "none" {
|
||||
// Focus is an actual accessibility action. A disc click would itself edit the tip.
|
||||
panel.focus("Tip");
|
||||
assert!(panel.focused("Tip"));
|
||||
if component == "angle" {
|
||||
panel.key(Key::ArrowRight, Modifiers::NONE);
|
||||
expected["angle"] = json!(18.0);
|
||||
} else {
|
||||
panel.key(Key::ArrowUp, Modifiers::ALT);
|
||||
expected["roundness"] = json!(27.0);
|
||||
}
|
||||
}
|
||||
let draft = panel.app().dialogs().unwrap().with(|host| host.get::<HostedParamDialog>().unwrap().fields().clone());
|
||||
assert_eq!(draft.number("angle"), expected["angle"].as_f64());
|
||||
assert_eq!(draft.number("roundness"), expected["roundness"].as_f64(), "editing one component must not round its untouched partner");
|
||||
assert_eq!(panel.app().session.tool_options_of(tool), original, "the tool changes only on OK");
|
||||
panel.click(if save { "OK" } else { "Cancel" });
|
||||
panel.frame();
|
||||
panel.frame();
|
||||
assert!(!panel.app().dialogs().unwrap().with(|host| host.is_open::<HostedParamDialog>()));
|
||||
assert_eq!(panel.app().session.tool_options_of(tool), if save { expected } else { original });
|
||||
assert_eq!(panel.app().session.active().unwrap().doc, document);
|
||||
assert_eq!(panel.app().session.active().unwrap().revision, revision);
|
||||
assert_eq!(panel.app().session.active().unwrap().history.undo.len(), undo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The id of the open dialog `key`.
|
||||
fn open_id(app: &VectorcraftApp, key: &str) -> DialogId {
|
||||
app.dialogs()
|
||||
|
||||
Reference in new issue
Block a user