mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-24 22:34:09 +00:00
#7078: expose dimension extension styles in Properties
This commit is contained in:
@@ -311,6 +311,12 @@ pub fn properties_section(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
changed |= color(ui, &mut f, "lineColor");
|
||||
});
|
||||
ui.horizontal(|ui| changed |= choose(ui, &mut f, "arrowStyle", "Arrow Style:", ARROWS));
|
||||
widgets::section_header(ui, tl!("Extension Lines"));
|
||||
ui.horizontal(|ui| {
|
||||
changed |= number(ui, &mut f, "extensionWeight", "Line Weight:", (0.1, 100.0), "pt");
|
||||
changed |= color(ui, &mut f, "extensionColor");
|
||||
});
|
||||
widgets::section_header(ui, tl!("Dimension Text"));
|
||||
ui.horizontal(|ui| {
|
||||
changed |= number(ui, &mut f, "fontSize", "Font Size:", (1.0, 1000.0), "pt");
|
||||
changed |= color(ui, &mut f, "textColor");
|
||||
|
||||
@@ -0,0 +1,528 @@
|
||||
//! Selected Dimension extension-line controls through the real Properties panel.
|
||||
#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
|
||||
|
||||
use egui::accesskit::{Node, NodeId as AccessId, Role};
|
||||
use egui::{Event, Modifiers, PointerButton, Pos2, RawInput, Rect, vec2};
|
||||
use serde_json::json;
|
||||
use vectorcraft_color::{Color, Paint};
|
||||
use vectorcraft_doc::{NodeId, NodeKind, dimension::Dimension};
|
||||
use vectorcraft_engine::Session;
|
||||
use vectorcraft_ui_egui::VectorcraftApp;
|
||||
|
||||
fn frame(app: &mut VectorcraftApp, ctx: &egui::Context, events: Vec<Event>) -> egui::FullOutput {
|
||||
let mut raw = RawInput { events, focused: true, screen_rect: Some(Rect::from_min_size(Pos2::ZERO, vec2(1800.0, 1500.0))), ..Default::default() };
|
||||
app.raw_input_hook(ctx, &mut raw);
|
||||
ctx.run_ui(raw, |ui| {
|
||||
app.tick(ui.ctx());
|
||||
app.ui(ui);
|
||||
})
|
||||
}
|
||||
|
||||
fn snapshot(app: &mut VectorcraftApp, ctx: &egui::Context) -> Vec<(AccessId, Node)> {
|
||||
let mut nodes = Vec::new();
|
||||
for _ in 0..4 {
|
||||
let mut output = frame(app, ctx, vec![]);
|
||||
nodes = output.platform_output.accesskit_update.map(|update| update.nodes).unwrap_or_default();
|
||||
output.textures_delta.clear();
|
||||
}
|
||||
nodes
|
||||
}
|
||||
|
||||
fn named(node: &Node, text: &str) -> bool {
|
||||
node.label() == Some(text) || node.value() == Some(text)
|
||||
}
|
||||
|
||||
fn number(node: &Node) -> Option<f64> {
|
||||
node.numeric_value().or_else(|| {
|
||||
// range_field displays the suffix without a space, for example "0.5pt".
|
||||
let text = node.value()?.trim();
|
||||
text.strip_suffix("pt").unwrap_or(text).trim().parse().ok()
|
||||
})
|
||||
}
|
||||
|
||||
fn click_named(app: &mut VectorcraftApp, ctx: &egui::Context, label: &str) {
|
||||
let nodes = snapshot(app, ctx);
|
||||
let bounds = nodes
|
||||
.iter()
|
||||
.find(|(_, node)| node.label() == Some(label))
|
||||
.and_then(|(_, node)| node.bounds())
|
||||
.unwrap_or_else(|| panic!("missing real UI button: {label}"));
|
||||
let at = egui::pos2(((bounds.x0 + bounds.x1) * 0.5) as f32, ((bounds.y0 + bounds.y1) * 0.5) as f32);
|
||||
frame(app, ctx, vec![Event::ModifiersChanged(Modifiers::NONE), Event::PointerMoved(at)]).textures_delta.clear();
|
||||
for pressed in [true, false] {
|
||||
frame(app, ctx, vec![Event::PointerButton { pos: at, button: PointerButton::Primary, pressed, modifiers: Modifiers::NONE }])
|
||||
.textures_delta
|
||||
.clear();
|
||||
}
|
||||
let _ = snapshot(app, ctx);
|
||||
}
|
||||
|
||||
/// Both real controls must sit in the Extension Lines row, rather than in another panel or dialog.
|
||||
fn extension_controls(nodes: &[(AccessId, Node)]) -> Option<(AccessId, AccessId)> {
|
||||
let heading = nodes.iter().find(|(_, node)| named(node, "Extension Lines"))?.1.bounds()?;
|
||||
let in_row = |node: &Node| {
|
||||
node.bounds().is_some_and(|b| {
|
||||
let y = (b.y0 + b.y1) * 0.5;
|
||||
y >= heading.y1 && y <= heading.y1 + 60.0 && b.x0 >= heading.x0 - 2.0
|
||||
})
|
||||
};
|
||||
let weight = nodes.iter().find_map(|(label_id, label)| {
|
||||
if !named(label, "Line Weight:") || !in_row(label) {
|
||||
return None;
|
||||
}
|
||||
nodes
|
||||
.iter()
|
||||
.find(|(_, input)| input.labelled_by().contains(label_id) && number(input).is_some_and(|v| (v - 0.5).abs() < 1e-9))
|
||||
.map(|(id, _)| *id)
|
||||
})?;
|
||||
let color = nodes.iter().find(|(_, node)| node.role() == Role::ColorWell && in_row(node) && node.value() == Some("#000000ff"))?.0;
|
||||
Some((weight, color))
|
||||
}
|
||||
|
||||
fn recipe(app: &VectorcraftApp, id: NodeId) -> Dimension {
|
||||
app.session.active().unwrap().doc.node(id).unwrap().extras().dimension.as_deref().unwrap().clone()
|
||||
}
|
||||
|
||||
fn generated_styles(app: &VectorcraftApp, id: NodeId, extensions: [u8; 3], weight: f64) {
|
||||
let state = app.session.active().unwrap();
|
||||
let children = state.doc.node(id).unwrap().children().unwrap();
|
||||
let paths: Vec<_> = children.iter().filter(|node| matches!(&node.kind, NodeKind::Path { .. })).collect();
|
||||
assert_eq!(paths.len(), 3, "two extension paths and the main dimension line");
|
||||
for extension in &paths[..2] {
|
||||
let stroke = extension.appearance.stroke().unwrap();
|
||||
assert_eq!(stroke.width, weight);
|
||||
assert_eq!(stroke.paint, Paint::solid(Color::rgb8(extensions[0], extensions[1], extensions[2])));
|
||||
}
|
||||
let main = paths[2].appearance.stroke().unwrap();
|
||||
assert_eq!(main.width, 2.1);
|
||||
assert_eq!(main.paint, Paint::solid(Color::rgb8(255, 0, 0)));
|
||||
let text = children.iter().find(|node| matches!(&node.kind, NodeKind::Text(_))).unwrap();
|
||||
assert_eq!(text.appearance.fill().unwrap().paint, Paint::solid(Color::rgb8(0, 0, 255)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn selected_dimension_properties_exposes_extension_weight_and_color() {
|
||||
vectorcraft_ui_egui::i18n::set_current(vectorcraft_ui_egui::i18n::Lang::EN);
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
app.run("file.new", json!({"width": 400, "height": 300})).unwrap();
|
||||
app.run("paint.setFill", json!({"color": "#d0d0d0"})).unwrap();
|
||||
app.run("shape.ellipse", json!({"x": 100, "y": 129.435, "width": 41.13, "height": 41.13})).unwrap();
|
||||
let made = app
|
||||
.run(
|
||||
"dimension.create",
|
||||
json!({"a": [100,150], "b": [141.13,150], "orientation": "horizontal", "offset": -25,
|
||||
"options": {"units": "pt", "precision": 2, "lineWeight": 2.1, "lineColor": [255,0,0], "textColor": [0,0,255],
|
||||
"extensionWeight": 0.5, "extensionColor": [0,0,0]}}),
|
||||
)
|
||||
.unwrap();
|
||||
let id = NodeId(made["id"].as_u64().unwrap());
|
||||
assert!(made["label"].as_str().unwrap().contains("41.13"));
|
||||
let original = recipe(&app, id);
|
||||
assert!((original.length - 41.13).abs() < 1e-9);
|
||||
generated_styles(&app, id, [0, 0, 0], 0.5);
|
||||
let document = app.session.active().unwrap().doc.clone();
|
||||
let paint = app.session.paint.clone();
|
||||
|
||||
// Backend/artwork control only: it is restored before testing the missing selected UI route.
|
||||
let mut control = original.options.clone();
|
||||
control.extension_weight = 0.35;
|
||||
control.extension_color = [128, 128, 128];
|
||||
app.run("dimension.update", json!({"ids": [id.0], "options": control})).unwrap();
|
||||
generated_styles(&app, id, [128, 128, 128], 0.35);
|
||||
let changed = recipe(&app, id);
|
||||
assert_eq!((changed.a, changed.b, changed.offset, changed.length), (original.a, original.b, original.offset, original.length));
|
||||
assert_eq!(changed.label().unwrap(), original.label().unwrap());
|
||||
app.run("edit.undo", json!({})).unwrap();
|
||||
assert_eq!(app.session.active().unwrap().doc, document);
|
||||
assert_eq!(recipe(&app, id), original);
|
||||
assert_eq!(app.session.paint, paint);
|
||||
|
||||
app.ui.task_bar = false;
|
||||
app.ui.view.rulers = false;
|
||||
app.canvas.worker_started = true;
|
||||
let ctx = egui::Context::default();
|
||||
ctx.enable_accesskit();
|
||||
// Positive UI control: Tool Options already exposes extensions. Close it through its real
|
||||
// Cancel button so its heading and controls cannot satisfy the final Properties assertion.
|
||||
app.run("tool.options", json!({"tool": "dimension"})).unwrap();
|
||||
let tool_options = snapshot(&mut app, &ctx);
|
||||
assert!(tool_options.iter().any(|(_, node)| named(node, "Dimension Tool Options")));
|
||||
if extension_controls(&tool_options).is_none() {
|
||||
let header = tool_options.iter().find(|(_, node)| named(node, "Extension Lines")).and_then(|(_, node)| node.bounds());
|
||||
for (id, node) in &tool_options {
|
||||
let row = header.is_some_and(|h| {
|
||||
node.bounds().is_some_and(|b| {
|
||||
let y = (b.y0 + b.y1) * 0.5;
|
||||
y >= h.y1 && y <= h.y1 + 60.0 && b.x0 >= h.x0 - 2.0
|
||||
})
|
||||
});
|
||||
if row || !node.labelled_by().is_empty() {
|
||||
eprintln!(
|
||||
"CONTROL {id:?} role={:?} label={:?} value={:?} numeric={:?} labelled_by={:?} bounds={:?}",
|
||||
node.role(),
|
||||
node.label(),
|
||||
node.value(),
|
||||
node.numeric_value(),
|
||||
node.labelled_by(),
|
||||
node.bounds()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
assert!(extension_controls(&tool_options).is_some(), "the existing Tool Options route has both extension controls");
|
||||
click_named(&mut app, &ctx, "Cancel");
|
||||
assert!(app.ui.dialog.is_none());
|
||||
app.select_tool("selection");
|
||||
app.run("select.set", json!({"ids": [id.0]})).unwrap();
|
||||
app.run("window.panel", json!({"panel": "properties"})).unwrap();
|
||||
let properties = snapshot(&mut app, &ctx);
|
||||
assert!(!properties.iter().any(|(_, node)| named(node, "Dimension Tool Options")));
|
||||
for label in ["Dimension", "Line Weight:", "Font Size:", "Apply to All", "Set as Default"] {
|
||||
assert!(properties.iter().any(|(_, node)| named(node, label)), "actual selected Properties baseline control: {label}");
|
||||
}
|
||||
assert!(properties.iter().any(|(_, node)| number(node).is_some_and(|v| (v - 2.1).abs() < 1e-9)), "the selected main-line weight is visible");
|
||||
for value in ["#ff0000ff", "#0000ffff"] {
|
||||
assert!(
|
||||
properties.iter().any(|(_, node)| node.role() == Role::ColorWell && node.value() == Some(value)),
|
||||
"main-line/text color control: {value}"
|
||||
);
|
||||
}
|
||||
assert_eq!(recipe(&app, id), original);
|
||||
assert_eq!(app.session.active().unwrap().doc, document);
|
||||
assert_eq!(app.session.paint, paint);
|
||||
|
||||
assert!(
|
||||
extension_controls(&properties).is_some(),
|
||||
"selected Properties must expose Extension Lines with an independent weight input and color control; Tool Options is closed"
|
||||
);
|
||||
}
|
||||
|
||||
fn fixture() -> (VectorcraftApp, egui::Context, NodeId) {
|
||||
vectorcraft_ui_egui::i18n::set_current(vectorcraft_ui_egui::i18n::Lang::EN);
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
app.run("file.new", json!({"width": 400, "height": 300})).unwrap();
|
||||
app.run("paint.setFill", json!({"color": "#d0d0d0"})).unwrap();
|
||||
app.run("shape.ellipse", json!({"x": 100, "y": 129.435, "width": 41.13, "height": 41.13})).unwrap();
|
||||
let made = app
|
||||
.run(
|
||||
"dimension.create",
|
||||
json!({"a": [100,150], "b": [141.13,150], "orientation": "horizontal", "offset": -25,
|
||||
"options": {"units": "pt", "precision": 2, "lineWeight": 2.1, "lineColor": [255,0,0], "textColor": [0,0,255],
|
||||
"extensionWeight": 0.5, "extensionColor": [0,0,0]}}),
|
||||
)
|
||||
.unwrap();
|
||||
let id = NodeId(made["id"].as_u64().unwrap());
|
||||
app.ui.task_bar = false;
|
||||
app.ui.view.rulers = false;
|
||||
app.session.prefs.monitor_profile_display = false;
|
||||
app.canvas.worker_started = true;
|
||||
let ctx = egui::Context::default();
|
||||
ctx.enable_accesskit();
|
||||
ctx.all_styles_mut(|style| style.visuals.numeric_color_space = egui::style::NumericColorSpace::GammaByte);
|
||||
let _ = snapshot(&mut app, &ctx);
|
||||
let view = app.view_mut().unwrap();
|
||||
view.zoom = 8.0;
|
||||
view.center = vectorcraft_geom::Point::new(120.565, 140.0);
|
||||
view.rotation = 0.0;
|
||||
select_properties(&mut app, &ctx, id);
|
||||
(app, ctx, id)
|
||||
}
|
||||
|
||||
fn select_properties(app: &mut VectorcraftApp, ctx: &egui::Context, id: NodeId) {
|
||||
app.select_tool("selection");
|
||||
app.run("select.set", json!({"ids": [id.0]})).unwrap();
|
||||
app.run("window.panel", json!({"panel": "properties"})).unwrap();
|
||||
let nodes = snapshot(app, ctx);
|
||||
assert!(nodes.iter().any(|(_, node)| named(node, "Apply to All")));
|
||||
}
|
||||
|
||||
fn click_at(app: &mut VectorcraftApp, ctx: &egui::Context, at: Pos2) {
|
||||
frame(app, ctx, vec![Event::ModifiersChanged(Modifiers::NONE), Event::PointerMoved(at)]).textures_delta.clear();
|
||||
for pressed in [true, false] {
|
||||
frame(app, ctx, vec![Event::PointerButton { pos: at, button: PointerButton::Primary, pressed, modifiers: Modifiers::NONE }])
|
||||
.textures_delta
|
||||
.clear();
|
||||
}
|
||||
let _ = snapshot(app, ctx);
|
||||
}
|
||||
|
||||
fn node_center(nodes: &[(AccessId, Node)], id: AccessId) -> Pos2 {
|
||||
let b = nodes.iter().find(|(candidate, _)| *candidate == id).unwrap().1.bounds().unwrap();
|
||||
egui::pos2(((b.x0 + b.x1) * 0.5) as f32, ((b.y0 + b.y1) * 0.5) as f32)
|
||||
}
|
||||
|
||||
fn key(app: &mut VectorcraftApp, ctx: &egui::Context, key: egui::Key, modifiers: Modifiers) {
|
||||
for pressed in [true, false] {
|
||||
frame(app, ctx, vec![Event::ModifiersChanged(modifiers), Event::Key { key, physical_key: Some(key), pressed, repeat: false, modifiers }])
|
||||
.textures_delta
|
||||
.clear();
|
||||
}
|
||||
}
|
||||
|
||||
fn type_at(app: &mut VectorcraftApp, ctx: &egui::Context, at: Pos2, text: &str) {
|
||||
click_at(app, ctx, at);
|
||||
key(app, ctx, egui::Key::A, Modifiers { ctrl: true, command: true, ..Modifiers::NONE });
|
||||
frame(app, ctx, vec![Event::ModifiersChanged(Modifiers::NONE), Event::Text(text.into())]).textures_delta.clear();
|
||||
key(app, ctx, egui::Key::Enter, Modifiers::NONE);
|
||||
let _ = snapshot(app, ctx);
|
||||
}
|
||||
|
||||
fn extension_pair(nodes: &[(AccessId, Node)], weight: f64, color: &str) -> (AccessId, AccessId) {
|
||||
let heading = nodes.iter().find(|(_, node)| named(node, "Extension Lines")).unwrap().1.bounds().unwrap();
|
||||
let in_row = |node: &Node| {
|
||||
node.bounds().is_some_and(|b| {
|
||||
let y = (b.y0 + b.y1) * 0.5;
|
||||
y >= heading.y1 && y <= heading.y1 + 60.0 && b.x0 >= heading.x0 - 2.0
|
||||
})
|
||||
};
|
||||
let input = nodes
|
||||
.iter()
|
||||
.find_map(|(label_id, label)| {
|
||||
if !named(label, "Line Weight:") || !in_row(label) {
|
||||
return None;
|
||||
}
|
||||
nodes
|
||||
.iter()
|
||||
.find(|(_, input)| input.labelled_by().contains(label_id) && number(input).is_some_and(|v| (v - weight).abs() < 1e-9))
|
||||
.map(|(id, _)| *id)
|
||||
})
|
||||
.expect("the selected extension weight's actual input");
|
||||
let color = nodes
|
||||
.iter()
|
||||
.find(|(_, node)| node.role() == Role::ColorWell && in_row(node) && node.value() == Some(color))
|
||||
.expect("the selected extension ColorWell")
|
||||
.0;
|
||||
(input, color)
|
||||
}
|
||||
|
||||
fn edit_weight(app: &mut VectorcraftApp, ctx: &egui::Context, old: f64, color: &str, next: &str) {
|
||||
let nodes = snapshot(app, ctx);
|
||||
let (input, _) = extension_pair(&nodes, old, color);
|
||||
type_at(app, ctx, node_center(&nodes, input), next);
|
||||
}
|
||||
|
||||
fn edit_gray(app: &mut VectorcraftApp, ctx: &egui::Context, weight: f64) -> serde_json::Value {
|
||||
let nodes = snapshot(app, ctx);
|
||||
let (input, color) = extension_pair(&nodes, weight, "#000000ff");
|
||||
let control_bounds = json!({"weight": format!("{:?}", nodes.iter().find(|(id, _)| *id == input).unwrap().1.bounds()),
|
||||
"color": format!("{:?}", nodes.iter().find(|(id, _)| *id == color).unwrap().1.bounds())});
|
||||
click_at(app, ctx, node_center(&nodes, color));
|
||||
// The pinned egui picker uses existing R/G/B DragValues (prefix names), not a hex field.
|
||||
for channel in ["R", "G", "B"] {
|
||||
let nodes = snapshot(app, ctx);
|
||||
let id = nodes.iter().find(|(_, node)| node.label() == Some(channel)).unwrap_or_else(|| panic!("actual picker channel {channel}")).0;
|
||||
type_at(app, ctx, node_center(&nodes, id), "128");
|
||||
}
|
||||
key(app, ctx, egui::Key::Escape, Modifiers::NONE);
|
||||
let _ = snapshot(app, ctx);
|
||||
control_bounds
|
||||
}
|
||||
|
||||
fn geometry(dimension: &Dimension) -> serde_json::Value {
|
||||
let mut value = serde_json::to_value(dimension).unwrap();
|
||||
value.as_object_mut().unwrap().remove("options");
|
||||
value
|
||||
}
|
||||
|
||||
/// Capture the actual canvas texture using ordinary view changes to request a full upload.
|
||||
fn capture(app: &mut VectorcraftApp, ctx: &egui::Context) -> (vectorcraft_render::Rendered, vectorcraft_geom::Affine) {
|
||||
let center = app.view().unwrap().center;
|
||||
app.view_mut().unwrap().center.x += 1.0;
|
||||
frame(app, ctx, vec![]).textures_delta.clear();
|
||||
app.view_mut().unwrap().center = center;
|
||||
let mut output = frame(app, ctx, vec![]);
|
||||
let texture = app.canvas.texture.as_ref().unwrap().id();
|
||||
let upload =
|
||||
output.textures_delta.set.iter().find(|(id, _)| **id == texture).and_then(|(_, updates)| updates.last()).expect("actual CPU canvas upload");
|
||||
assert!(upload.pos.is_none(), "the view change requests a full texture");
|
||||
let egui::ImageData::Color(image) = &upload.image;
|
||||
let rendered = vectorcraft_render::Rendered {
|
||||
width: image.width() as u32,
|
||||
height: image.height() as u32,
|
||||
pixels: image.pixels.iter().flat_map(|color| color.to_array()).collect(),
|
||||
};
|
||||
let cache = app.canvas.key.as_ref().unwrap();
|
||||
assert!(cache.pixel.is_none());
|
||||
assert_eq!(cache.doc, app.session.active().unwrap().uid as usize);
|
||||
assert_eq!(cache.revision, app.session.active().unwrap().revision);
|
||||
assert_eq!((cache.w, cache.h), (rendered.width, rendered.height));
|
||||
// The existing frame_view mapping, bound to this actual upload's public cache key.
|
||||
let transform = vectorcraft_geom::Affine::translate((f64::from(cache.w) / 2.0, f64::from(cache.h) / 2.0))
|
||||
* vectorcraft_geom::Affine::rotate(cache.rot.to_radians())
|
||||
* vectorcraft_geom::Affine::scale(cache.zoom * f64::from(cache.ppp))
|
||||
* vectorcraft_geom::Affine::translate((-cache.cx, -cache.cy));
|
||||
output.textures_delta.clear();
|
||||
(rendered, transform)
|
||||
}
|
||||
|
||||
fn extension_coverage(image: &vectorcraft_render::Rendered, transform: vectorcraft_geom::Affine, x: f64, rgb: [u8; 3]) -> f64 {
|
||||
let point = transform * vectorcraft_geom::Point::new(x, 137.5);
|
||||
let (x, y) = (point.x.floor() as usize, point.y.floor() as usize);
|
||||
assert!(x >= 6 && x + 6 < image.width as usize && y < image.height as usize);
|
||||
let mut coverage = 0.0;
|
||||
let mut solid = false;
|
||||
for column in x - 6..=x + 6 {
|
||||
let at = (y * image.width as usize + column) * 4;
|
||||
let pixel = &image.pixels[at..at + 4];
|
||||
coverage += f64::from(pixel[3]) / 255.0;
|
||||
solid |= pixel[3] == 255 && pixel[..3] == rgb;
|
||||
}
|
||||
assert!(solid, "actual extension midpoint has the expected opaque color {rgb:?}");
|
||||
coverage
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn properties_edits_both_extensions_preserves_main_text_and_roundtrips_editable_recipe() {
|
||||
let (mut app, ctx, id) = fixture();
|
||||
let original = recipe(&app, id);
|
||||
let selection = app.session.active().unwrap().selection.clone();
|
||||
let paint = app.session.paint.clone();
|
||||
let (before, before_xf) = capture(&mut app, &ctx);
|
||||
edit_weight(&mut app, &ctx, 0.5, "#000000ff", "0.35");
|
||||
let weighted = recipe(&app, id);
|
||||
assert_eq!(weighted.options.extension_weight, 0.35);
|
||||
assert_eq!(geometry(&weighted), geometry(&original));
|
||||
generated_styles(&app, id, [0, 0, 0], 0.35);
|
||||
app.run("edit.undo", json!({})).unwrap();
|
||||
assert_eq!(recipe(&app, id), original);
|
||||
generated_styles(&app, id, [0, 0, 0], 0.5);
|
||||
app.run("edit.redo", json!({})).unwrap();
|
||||
assert_eq!(recipe(&app, id), weighted);
|
||||
let _ = snapshot(&mut app, &ctx);
|
||||
let controls = edit_gray(&mut app, &ctx, 0.35);
|
||||
let edited = recipe(&app, id);
|
||||
let mut expected = original.clone();
|
||||
expected.options.extension_weight = 0.35;
|
||||
expected.options.extension_color = [128, 128, 128];
|
||||
assert_eq!(edited, expected, "only the selected independent extension fields change");
|
||||
generated_styles(&app, id, [128, 128, 128], 0.35);
|
||||
assert_eq!(app.session.active().unwrap().selection, selection);
|
||||
assert_eq!(app.session.paint, paint);
|
||||
let (after, after_xf) = capture(&mut app, &ctx);
|
||||
for x in [100.0, 141.13] {
|
||||
let old = extension_coverage(&before, before_xf, x, [0, 0, 0]);
|
||||
let new = extension_coverage(&after, after_xf, x, [128, 128, 128]);
|
||||
assert!(new < old, "both actual extension lines become thinner: {new} < {old}");
|
||||
}
|
||||
for rgb in [[255, 0, 0], [0, 0, 255]] {
|
||||
for image in [&before, &after] {
|
||||
assert!(
|
||||
image.pixels.as_chunks::<4>().0.iter().any(|pixel| pixel[3] == 255 && pixel[..3] == rgb),
|
||||
"main/text color remains on the actual canvas: {rgb:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
if let Some(dir) = std::env::var_os("VECTORCRAFT_DIMENSION_EVIDENCE") {
|
||||
let dir = std::path::PathBuf::from(dir);
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
std::fs::write(dir.join("before.png"), before.to_png().unwrap()).unwrap();
|
||||
std::fs::write(dir.join("after.png"), after.to_png().unwrap()).unwrap();
|
||||
std::fs::write(
|
||||
dir.join("binding.json"),
|
||||
serde_json::to_vec_pretty(&json!({"doc": app.session.active().unwrap().uid,
|
||||
"target": id.0, "revision": app.session.active().unwrap().revision, "recipe": edited, "controls": controls}))
|
||||
.unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
// Use the existing native save/open commands in memory; no asset file is needed.
|
||||
let saved = app.run("document.save", json!({"format": "vectorcraft", "preview": false})).unwrap();
|
||||
let data = saved["dataBase64"].as_str().expect("an untitled native save returns bytes");
|
||||
app.run("document.open", json!({"name": "dimension.vectorcraft", "dataBase64": data})).unwrap();
|
||||
assert_eq!(recipe(&app, id), edited);
|
||||
select_properties(&mut app, &ctx, id);
|
||||
edit_weight(&mut app, &ctx, 0.35, "#808080ff", "0.6");
|
||||
assert_eq!(recipe(&app, id).options.extension_weight, 0.6, "the native recipe remains editable through Properties");
|
||||
assert_eq!(geometry(&recipe(&app, id)), geometry(&edited));
|
||||
generated_styles(&app, id, [128, 128, 128], 0.6);
|
||||
assert_eq!(app.session.paint, paint);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn properties_apply_all_copies_full_style_to_editable_dimensions_and_undoes_as_one_edit() {
|
||||
let (mut app, ctx, id) = fixture();
|
||||
let other = NodeId(
|
||||
app.run(
|
||||
"dimension.create",
|
||||
json!({"a": [200,150], "b": [241.13,150], "offset": -30,
|
||||
"options": {"lineWeight": 1.3, "lineColor": [0,128,0], "extensionWeight": 0.8, "extensionColor": [0,128,0]}}),
|
||||
)
|
||||
.unwrap()["id"]
|
||||
.as_u64()
|
||||
.unwrap(),
|
||||
);
|
||||
let locked = NodeId(
|
||||
app.run(
|
||||
"dimension.create",
|
||||
json!({"a": [100,220], "b": [141.13,220], "offset": -20,
|
||||
"options": {"lineWeight": 1.7, "lineColor": [192,0,192], "extensionWeight": 0.9, "extensionColor": [192,0,192]}}),
|
||||
)
|
||||
.unwrap()["id"]
|
||||
.as_u64()
|
||||
.unwrap(),
|
||||
);
|
||||
app.run("object.lock", json!({"ids": [locked.0]})).unwrap();
|
||||
let other_original = recipe(&app, other);
|
||||
let locked_original = recipe(&app, locked);
|
||||
select_properties(&mut app, &ctx, id);
|
||||
edit_weight(&mut app, &ctx, 0.5, "#000000ff", "0.35");
|
||||
let _ = edit_gray(&mut app, &ctx, 0.35);
|
||||
assert_eq!(recipe(&app, other), other_original, "selected edits do not change an unselected dimension");
|
||||
assert_eq!(recipe(&app, locked), locked_original);
|
||||
let selected = recipe(&app, id);
|
||||
let before = app.session.active().unwrap().doc.clone();
|
||||
let undo = app.session.active().unwrap().history.undo.len();
|
||||
let paint = app.session.paint.clone();
|
||||
click_named(&mut app, &ctx, "Apply to All");
|
||||
assert_eq!(recipe(&app, other).options, selected.options, "Apply to All copies the complete style, not only extensions");
|
||||
assert_eq!(geometry(&recipe(&app, other)), geometry(&other_original));
|
||||
assert_eq!(recipe(&app, locked), locked_original, "the locked control is untouched");
|
||||
assert_eq!(recipe(&app, id), selected);
|
||||
assert_eq!(app.session.active().unwrap().history.undo.len(), undo + 1);
|
||||
let after = app.session.active().unwrap().doc.clone();
|
||||
app.run("edit.undo", json!({})).unwrap();
|
||||
assert_eq!(app.session.active().unwrap().doc, before);
|
||||
app.run("edit.redo", json!({})).unwrap();
|
||||
assert_eq!(app.session.active().unwrap().doc, after);
|
||||
assert_eq!(app.session.paint, paint);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn properties_set_default_is_inherited_by_an_options_free_new_dimension() {
|
||||
let (mut app, ctx, id) = fixture();
|
||||
let other = NodeId(
|
||||
app.run("dimension.create", json!({"a": [200,150], "b": [241.13,150], "options": {"extensionWeight": 0.8}})).unwrap()["id"].as_u64().unwrap(),
|
||||
);
|
||||
let other_original = recipe(&app, other);
|
||||
select_properties(&mut app, &ctx, id);
|
||||
edit_weight(&mut app, &ctx, 0.5, "#000000ff", "0.35");
|
||||
let _ = edit_gray(&mut app, &ctx, 0.35);
|
||||
let selected = recipe(&app, id);
|
||||
let document = app.session.active().unwrap().doc.clone();
|
||||
let history = (app.session.active().unwrap().history.undo.len(), app.session.active().unwrap().history.redo.len());
|
||||
let paint = app.session.paint.clone();
|
||||
click_named(&mut app, &ctx, "Set as Default");
|
||||
assert_eq!(app.session.active().unwrap().doc, document, "setting tool defaults does not apply them to existing dimensions");
|
||||
assert_eq!((app.session.active().unwrap().history.undo.len(), app.session.active().unwrap().history.redo.len()), history);
|
||||
assert_eq!(recipe(&app, other), other_original);
|
||||
app.run("window.panel.close", json!({"panel": "properties"})).unwrap();
|
||||
app.run("tool.options", json!({"tool": "dimension"})).unwrap();
|
||||
assert_eq!(app.ui.dialog.as_ref().unwrap().fields["extensionWeight"], json!(0.35));
|
||||
assert_eq!(app.ui.dialog.as_ref().unwrap().fields["extensionColor"], json!([128, 128, 128]));
|
||||
// Enter is this modal's legitimate Save action; Tab commits only the focused draft field.
|
||||
let nodes = snapshot(&mut app, &ctx);
|
||||
let (input, _) = extension_pair(&nodes, 0.35, "#808080ff");
|
||||
click_at(&mut app, &ctx, node_center(&nodes, input));
|
||||
key(&mut app, &ctx, egui::Key::A, Modifiers { ctrl: true, command: true, ..Modifiers::NONE });
|
||||
frame(&mut app, &ctx, vec![Event::ModifiersChanged(Modifiers::NONE), Event::Text("0.9".into())]).textures_delta.clear();
|
||||
key(&mut app, &ctx, egui::Key::Tab, Modifiers::NONE);
|
||||
let _ = snapshot(&mut app, &ctx);
|
||||
assert_eq!(app.ui.dialog.as_ref().unwrap().fields["extensionWeight"], json!(0.9), "Tool Options edits a draft until Save");
|
||||
click_named(&mut app, &ctx, "Cancel");
|
||||
let new = NodeId(app.run("dimension.create", json!({"a": [100,220], "b": [141.13,220], "offset": -20})).unwrap()["id"].as_u64().unwrap());
|
||||
assert_eq!(recipe(&app, new).options, selected.options, "no explicit options: new dimensions inherit the full style");
|
||||
assert_eq!(recipe(&app, id), selected);
|
||||
assert_eq!(recipe(&app, other), other_original);
|
||||
assert_eq!(app.session.paint, paint);
|
||||
}
|
||||
+3
-2
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+3
-1
@@ -1,6 +1,6 @@
|
||||
# UI and interaction parity
|
||||
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-16 · **Change:** minor (Recolor Artwork follow-up (#8031, remaining #4028): native Lab input, picker swatch libraries and Assign-row menus; UI interaction regression coverage; scores and estimates unchanged; previously: #8005: the Color spectrum fills a resized panel; scores and estimates unchanged; previously: Pencil continuation, straight-line and closing cursors; scores and estimates unchanged; previously: Graphic Styles list fills a taller panel, #2992; scores and estimates unchanged; previously: library panels' lists fill a taller panel, #2992; scores and estimates unchanged; previously: Swatches list fills a taller panel, #1638; scores and estimates unchanged; previously: icon-strip flyouts also resize from the top edge and the canvas-side top corner, keeping the moved top in workspaces (storytold/craft-libs#1094); scores and estimates unchanged; previously: macOS: the canvas cursor stays after the pointer moves, #6362; scores and estimates unchanged; previously minor: Remove Background in the Contextual Task Bar, Properties › Quick Actions and the Control bar; previously minor: Ruler origin: the corner drag snaps as a drawn point does; previously minor: Live Paint Bucket fills faces crossed in one drag (#6373); previously: #6404: transform-aware Eyedropper character copying; scores and estimates unchanged; previously: Outline view: images and gradient meshes are picked on what Outline draws, so a click inside them reaches the path behind, #6437; previously minor: a middle-click on a document tab closes it, #6506; previously minor: Blob Brush: a round tip's preview is the outline of the area it adds, round at both ends, as the stroke it commits (#4343); scores and estimates unchanged; previously:; ruler double-click adds a guide at the pointer, #5239; G5: Inventory Icons built-in symbol library (four built-ins); previously minor: files that record no units open in Preferences › Units › General, #5820; previously minor: interim macOS cursor delivery, #2292; native validation pending; scores and estimates unchanged; Control bar › Snapping includes the existing Snap to Glyph and Alignment Guides toggles (#6164); scores and estimates unchanged; floating tab groups collapse into the side icon rail and opened rail panels fold back into it, #5925 in part; numeric fields step on wheel hover without taking keyboard focus, #5949; Character Styles panel: a double-click on a style's row opens its Character Style Options; the dialog keeps a fixed width and scrolls its sections, so its buttons stay on screen; Selection QoL: marquee modes and visible feedback, #5313; #3380 deletion-only review follow-up: independent survivors keep gradient placement, owned subpaths avoid discarded copies, and contracts/status/evidence are clarified; endpoint highlighting remains open; scores and estimates unchanged; Drop Shadow and glow dialogs: spinner arrows, #5367, #5368; Stroke Weight Up and Down shortcuts, #5797; Layers: Rename (`ui.rename`) opens the name field of the selected layer, group or object, #5324; Properties in Edit Artboards: Transform section above the Artboards section, #5219; scrubby labels: the Control bar's Stroke: and Opacity: links and the Properties panel's Stroke link scrub their fields, #4088; Properties: Quick Actions has Repeat Options for one selected repeat, #5181; Direct Selection: Shift-click picks several blend spine points, which drag together, #5285; Direct Selection: Cmd/Ctrl held lends the Selection tool and shows its bounding box, #3901; Join tool trims two crossing open paths and joins them at the crossing, #5844; Control bar: Paragraph: link and Align left/center/right while type is selected, #5372; shape tools: a press on the selection's centre point moves it and one in the rotate zone outside a box corner turns it, #5477; scores and estimates unchanged) · **Target:** Adobe Illustrator 2026 (30.x; Units › East Asian Type acts, with Q and Ha units; scores unchanged)
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-17 · **Change:** minor (selected Dimension extension-line color and weight in Properties (#7078; four focused UI regressions passed); scores and estimates unchanged; previously: Recolor Artwork follow-up (#8031, remaining #4028): native Lab input, picker swatch libraries and Assign-row menus; UI interaction regression coverage; scores and estimates unchanged; previously: #8005: the Color spectrum fills a resized panel; scores and estimates unchanged; previously: Pencil continuation, straight-line and closing cursors; scores and estimates unchanged; previously: Graphic Styles list fills a taller panel, #2992; scores and estimates unchanged; previously: library panels' lists fill a taller panel, #2992; scores and estimates unchanged; previously: Swatches list fills a taller panel, #1638; scores and estimates unchanged; previously: icon-strip flyouts also resize from the top edge and the canvas-side top corner, keeping the moved top in workspaces (storytold/craft-libs#1094); scores and estimates unchanged; previously: macOS: the canvas cursor stays after the pointer moves, #6362; scores and estimates unchanged; previously minor: Remove Background in the Contextual Task Bar, Properties › Quick Actions and the Control bar; previously minor: Ruler origin: the corner drag snaps as a drawn point does; previously minor: Live Paint Bucket fills faces crossed in one drag (#6373); previously: #6404: transform-aware Eyedropper character copying; scores and estimates unchanged; previously: Outline view: images and gradient meshes are picked on what Outline draws, so a click inside them reaches the path behind, #6437; previously minor: a middle-click on a document tab closes it, #6506; previously minor: Blob Brush: a round tip's preview is the outline of the area it adds, round at both ends, as the stroke it commits (#4343); scores and estimates unchanged; previously:; ruler double-click adds a guide at the pointer, #5239; G5: Inventory Icons built-in symbol library (four built-ins); previously minor: files that record no units open in Preferences › Units › General, #5820; previously minor: interim macOS cursor delivery, #2292; native validation pending; scores and estimates unchanged; Control bar › Snapping includes the existing Snap to Glyph and Alignment Guides toggles (#6164); scores and estimates unchanged; floating tab groups collapse into the side icon rail and opened rail panels fold back into it, #5925 in part; numeric fields step on wheel hover without taking keyboard focus, #5949; Character Styles panel: a double-click on a style's row opens its Character Style Options; the dialog keeps a fixed width and scrolls its sections, so its buttons stay on screen; Selection QoL: marquee modes and visible feedback, #5313; #3380 deletion-only review follow-up: independent survivors keep gradient placement, owned subpaths avoid discarded copies, and contracts/status/evidence are clarified; endpoint highlighting remains open; scores and estimates unchanged; Drop Shadow and glow dialogs: spinner arrows, #5367, #5368; Stroke Weight Up and Down shortcuts, #5797; Layers: Rename (`ui.rename`) opens the name field of the selected layer, group or object, #5324; Properties in Edit Artboards: Transform section above the Artboards section, #5219; scrubby labels: the Control bar's Stroke: and Opacity: links and the Properties panel's Stroke link scrub their fields, #4088; Properties: Quick Actions has Repeat Options for one selected repeat, #5181; Direct Selection: Shift-click picks several blend spine points, which drag together, #5285; Direct Selection: Cmd/Ctrl held lends the Selection tool and shows its bounding box, #3901; Join tool trims two crossing open paths and joins them at the crossing, #5844; Control bar: Paragraph: link and Align left/center/right while type is selected, #5372; shape tools: a press on the selection's centre point moves it and one in the rotate zone outside a box corner turns it, #5477; scores and estimates unchanged) · **Target:** Adobe Illustrator 2026 (30.x; Units › East Asian Type acts, with Q and Ha units; scores unchanged)
|
||||
>
|
||||
> Tech Circuit update (2026-11-14): three original procedural brushes; ten built-in brush libraries (G5).
|
||||
>
|
||||
@@ -385,6 +385,7 @@ next unit in the order a right-click on a ruler lists them, from Feet back to Po
|
||||
|
||||
| Interaction | Status | Evidence |
|
||||
|---|---|---|
|
||||
| Properties › Dimension edits extension-line color and weight independently of the main line and label | done | #7078; the selected editable dimension keeps its recipe. Both extensions share the settings; Apply to All copies the complete style to editable dimensions, and Set as Default supplies the complete style to newly created dimensions without explicit options. Four cases in `crates/ui-egui/tests/dimension_extension_properties.rs` cover actual numeric/color input, both canvas extension lines, unchanged main-line/label styling, locked and unselected controls, full-style Apply to All and defaults for new dimensions, Undo/Redo, and native save/reopen with further Properties editing. Existing CMYK conversion is unchanged. |
|
||||
| Ordinary Save refused by filesystem permissions/read-only storage offers Save As | focused UI regressions passed; native acceptance pending | #6146; `io::tests_read_only_save`; same name/format suggested; unchanged format keeps options, changed format opens its Save options; Documents folder, UID-bound continuation; cancellation and automation isolation |
|
||||
| Selection artwork drag hovers a visible document tab to activate it, then drops editable artwork on its canvas | done | `tests_document_drag`, `edit.dropSelection`, lossless resource and one-step Undo regressions; a release over another document's tiled pane copies it there too (`canvas::panes` tests), and so does a release over a floating window drawn inside the main window (`doc_windows` tests); overflow-menu drag and floating OS windows remain separate |
|
||||
| A document tab dragged along the tab strip moves its document; a line marks where it goes, the current document and every document's view stay as they were, and a drag off the strip still floats it | done | #5663, [public source](https://helpx.adobe.com/illustrator/using/customizing-workspace.html); `document.move`; `tests::tab_reorder`, `chrome::tests` (drop index with floating and view tabs), `engine` `tests::document_move` |
|
||||
@@ -561,6 +562,7 @@ before release (#6373). [Paint faces and edges](https://helpx.adobe.com/illustra
|
||||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-11-17 | minor | Properties › Dimension (#7078): expose the existing independent extension-line color and weight for the selected editable dimension; retain full-style Apply to All and Set as Default. Four focused UI regressions, strict scoped Clippy and formatting passed; scores and estimates unchanged. |
|
||||
| 2026-11-16 | minor | Recolor Artwork follow-up (#8031, remaining #4028): native Lab input, picker swatch libraries and Assign-row menus; UI interaction regression coverage; scores and estimates unchanged. |
|
||||
| 2026-11-16 | minor | Recolor Artwork › Assign: native Lab entry in the Color Picker, swatch libraries access in the picker, and row context menu options (Pick from Swatches, Limit to Library) (#4028). Scores and estimates unchanged. |
|
||||
| 2026-11-16 | minor | Color panel: the spectrum fills the vertical space of a resized panel, with options shown or hidden (#8005). Compact auto-fit flyouts and embedded mixers keep their existing size. Evidence: panels::color::tests::the_spectrum_grows_with_the_color_panel. Scores and estimates unchanged. |
|
||||
|
||||
Reference in New Issue
Block a user