mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-11 03:43:29 +00:00
G5: size UI Frames so default 9-slice keeps round corners
Button and Bar were shorter than 4x their corner radius, so the default guides cut through the curves on a vertical resize.
This commit is contained in:
@@ -199,10 +199,12 @@ fn basic_shapes() -> SymbolLibrary {
|
||||
|
||||
/// UI Frames: panel, button and bar HUD chrome with default 9-slice guides (original art).
|
||||
fn ui_frames() -> SymbolLibrary {
|
||||
// Heights keep default 9-slice (0.25) past each corner radius so a vertical resize
|
||||
// stretches only the flat middle, not the curves.
|
||||
let frames = [
|
||||
("Panel", Rect::new(-48.0, -36.0, 48.0, 36.0), 10.0, "#2b3340", "#8aa0b8"),
|
||||
("Button", Rect::new(-36.0, -14.0, 36.0, 14.0), 8.0, "#3a6ea5", "#d7e6f5"),
|
||||
("Bar", Rect::new(-56.0, -10.0, 56.0, 10.0), 10.0, "#1f6b4a", "#b7e0c9"),
|
||||
("Button", Rect::new(-36.0, -18.0, 36.0, 18.0), 8.0, "#3a6ea5", "#d7e6f5"),
|
||||
("Bar", Rect::new(-56.0, -24.0, 56.0, 24.0), 10.0, "#1f6b4a", "#b7e0c9"),
|
||||
];
|
||||
let mut doc = Document::new(100.0, 100.0);
|
||||
for (name, rect, radius, fill_hex, edge_hex) in frames {
|
||||
|
||||
@@ -105,13 +105,23 @@ fn ui_frames_symbols_carry_default_nine_slice_when_added() {
|
||||
let lib = run(&mut s, "symbol.library", json!({"library": "ui-frames"}));
|
||||
let names: Vec<&str> = lib["symbols"].as_array().unwrap().iter().map(|x| x["name"].as_str().unwrap()).collect();
|
||||
assert_eq!(names, ["Panel", "Button", "Bar"]);
|
||||
let r = run(&mut s, "symbol.addFromLibrary", json!({"library": "ui-frames", "name": "Panel", "place": true, "x": 100.0, "y": 100.0}));
|
||||
assert_eq!(r["added"], json!(["Panel"]));
|
||||
assert!(r["placed"].as_u64().is_some());
|
||||
let mut placed = Vec::new();
|
||||
for (i, name) in names.iter().enumerate() {
|
||||
let r = run(
|
||||
&mut s,
|
||||
"symbol.addFromLibrary",
|
||||
json!({"library": "ui-frames", "name": name, "place": true, "x": 100.0 + 80.0 * i as f64, "y": 100.0}),
|
||||
);
|
||||
assert_eq!(r["added"], json!([name]));
|
||||
placed.push(r["placed"].as_u64().unwrap());
|
||||
}
|
||||
let d = doc(&s);
|
||||
for name in &names {
|
||||
assert!(d.symbol_nine_slice(name).is_some(), "{name} should have 9-slice guides");
|
||||
}
|
||||
assert_eq!(d.symbol_nine_slice("Panel"), Some(vectorcraft_doc::SymbolNineSlice::default()));
|
||||
assert!(matches!(
|
||||
d.node(NodeId(r["placed"].as_u64().unwrap())).map(|n| &n.kind),
|
||||
d.node(NodeId(placed[0])).map(|n| &n.kind),
|
||||
Some(NodeKind::SymbolInstance { symbol, .. }) if symbol == "Panel"
|
||||
));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user