mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-25 09:24:34 +00:00
Dimension: a set arrowHead matches its Arrow Style entry
Through ui.dialog.set, a built-in arrowHead now sets both values of its Arrow Style entry, as the menu does: Slash sets arrowStyle tick and clears arrowHead, so the saved options match a menu pick of Tick. The Target arrowhead gets an arrowhead row in the ca, es, hu, it, ko, ru and uk catalogs, whose plain Target row names a destination or an object rather than the shape.
This commit is contained in:
@@ -611,7 +611,7 @@ pub fn accepts_field(d: &Dialog, field: &str) -> bool {
|
||||
/// A Graph Data Column Width set this way sets every column, as Cell Style's does. An Import PDF
|
||||
/// `allPages` set this way to the other pick sets Import PDF pages as links back to its default.
|
||||
/// A Dimension Tool Options `arrowStyle` set this way clears `arrowHead`, and a built-in
|
||||
/// `arrowHead` set this way sets the `arrowStyle` of its Arrow Style entry, as that menu does.
|
||||
/// `arrowHead` set this way sets both values of its Arrow Style entry, as that menu does.
|
||||
pub fn set_field(d: &mut Dialog, field: String, value: Value) {
|
||||
if d.kind == brush_options::KIND {
|
||||
brush_art_options::note_set(d, &field);
|
||||
@@ -625,8 +625,8 @@ pub fn set_field(d: &mut Dialog, field: String, value: Value) {
|
||||
if d.kind == import_pdf::KIND {
|
||||
import_pdf::note_set(d, &field, &value);
|
||||
}
|
||||
if d.kind == dimension::KIND {
|
||||
dimension::note_set(d, &field, &value);
|
||||
if d.kind == dimension::KIND && dimension::note_set(d, &field, &value) {
|
||||
return;
|
||||
}
|
||||
if d.kind == "preferences" {
|
||||
crate::prefs_dialog::note_set(d, &field, &value);
|
||||
|
||||
@@ -77,22 +77,27 @@ pub fn open(app: &mut VectorcraftApp) -> Result<Value, String> {
|
||||
}
|
||||
|
||||
/// For `ui.dialog.set`, as the Arrow Style menu sets them: an `arrowStyle` set alone draws that
|
||||
/// style's own head, and a built-in head set as `arrowHead` takes the arrow style of its Arrow
|
||||
/// Style entry (`tick` for `Slash`, `filled` for `Barbed`).
|
||||
pub(super) fn note_set(d: &mut Dialog, field: &str, value: &Value) {
|
||||
/// style's own head, and a built-in head set as `arrowHead` sets both values of its Arrow Style
|
||||
/// entry (`tick` with no `arrowHead` for `Slash`, `filled` with `Barbed` for `Barbed`). Returns
|
||||
/// whether it set the field itself.
|
||||
pub(super) fn note_set(d: &mut Dialog, field: &str, value: &Value) -> bool {
|
||||
match field {
|
||||
"arrowStyle" => {
|
||||
d.fields.insert("arrowHead".into(), Value::Null);
|
||||
false
|
||||
}
|
||||
"arrowHead" => {
|
||||
let head = built_in_head(value);
|
||||
if let Some(ch) = arrow_choices().into_iter().find(|ch| head.is_some() && ch.drawn() == head)
|
||||
&& let Ok(style) = serde_json::to_value(ch.style)
|
||||
&& let (Ok(style), Ok(head)) = (serde_json::to_value(ch.style), serde_json::to_value(&ch.head))
|
||||
{
|
||||
d.fields.insert("arrowStyle".into(), style);
|
||||
d.fields.insert("arrowHead".into(), head);
|
||||
return true;
|
||||
}
|
||||
false
|
||||
}
|
||||
_ => {}
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -473,11 +478,11 @@ mod tests {
|
||||
super::super::confirm(&mut app).unwrap();
|
||||
let style = serde_json::from_value::<DimensionOptions>(app.session.tool_options_of("dimension")["style"].clone()).unwrap();
|
||||
assert_eq!((style.arrow_style, style.arrowhead()), (ArrowStyle::Filled, Some(Arrowhead::Barbed)));
|
||||
// The head of an older style takes that style, as its menu entry does.
|
||||
// The head of an older style sets that style and no `arrowHead`, as its menu entry does.
|
||||
open(&mut app).unwrap();
|
||||
let d = app.ui.dialog.as_mut().unwrap();
|
||||
super::super::set_field(d, "arrowHead".into(), json!("Slash"));
|
||||
assert_eq!(d.fields["arrowStyle"], "tick");
|
||||
assert_eq!((&d.fields["arrowStyle"], &d.fields["arrowHead"]), (&json!("tick"), &Value::Null));
|
||||
}
|
||||
|
||||
/// A selected dimension shows its style in Properties, with Apply to All and Set as Default.
|
||||
|
||||
@@ -457,6 +457,7 @@ antiAlias Sharp Nítid
|
||||
Bar Graph Tool Eina de gràfic de barres
|
||||
Barbed Amb pues
|
||||
arrowhead Feather Ploma
|
||||
arrowhead Target Diana
|
||||
Bas Relief Baix relleu
|
||||
Bas Relief… Baix relleu…
|
||||
Base Along: Base al llarg de:
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -6227,6 +6227,7 @@ effect Regular Regular
|
||||
Arrow (open) Flecha (abierta)
|
||||
Barbed Con púas
|
||||
arrowhead Feather Emplumado
|
||||
arrowhead Target Diana
|
||||
Half Arrow (left) Media flecha (izquierda)
|
||||
Half Arrow (right) Media flecha (derecha)
|
||||
Concave Cóncava
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -410,6 +410,7 @@ font-technology Variable Változó
|
||||
Bar Graph Tool Sávdiagram
|
||||
Barbed Szakállas
|
||||
arrowhead Feather Tollazat
|
||||
arrowhead Target Céltábla
|
||||
Baseline Alapvonal
|
||||
Baseline (Standard) Alapvonali (szabványos)
|
||||
Baseline Optimized Alapvonali, optimalizált
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -7409,6 +7409,7 @@ anchor Points: Punti:
|
||||
Arrow (open) Freccia (aperta)
|
||||
Barbed Uncinata
|
||||
arrowhead Feather Piuma
|
||||
arrowhead Target Bersaglio
|
||||
Half Arrow (left) Mezza freccia (sinistra)
|
||||
Half Arrow (right) Mezza freccia (destra)
|
||||
Double Bar Doppia barra
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -7381,6 +7381,7 @@ anchor Points: 포인트:
|
||||
Arrow (open) 화살표 (윤곽)
|
||||
Barbed 미늘
|
||||
arrowhead Feather 깃털
|
||||
arrowhead Target 과녁
|
||||
Half Arrow (left) 반쪽 화살표 (왼쪽)
|
||||
Half Arrow (right) 반쪽 화살표 (오른쪽)
|
||||
Double Bar 이중 막대
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -7358,6 +7358,7 @@ axis Y Axis Ось Y
|
||||
Bar Черта
|
||||
Barbed С зазубриной
|
||||
arrowhead Feather Перо
|
||||
arrowhead Target Мишень
|
||||
Baseline (Standard) Базовый (стандартный)
|
||||
Baseline Optimized Базовый оптимизированный
|
||||
Bicubic Бикубическая
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -681,6 +681,9 @@ fn built_in_arrowhead_names_are_in_complete_catalogs() {
|
||||
use vectorcraft_doc::Arrowhead;
|
||||
let names = distinct(Arrowhead::ALL.iter().map(|h| h.label().to_string()).collect());
|
||||
assert_eq!(names.len(), 41, "{names:?}");
|
||||
// Spanish's plain Target row names a destination; its arrowhead row names the shape.
|
||||
let es = crate::i18n::Lang::from_code("es").expect("es registered");
|
||||
assert_eq!(crate::i18n::tr_ctx(es, "arrowhead", "Target"), "Diana");
|
||||
let bad = lacking(&names, |c, n| c.contextual("arrowhead", n).is_some() || (n != "Feather" && c.plain(n).is_some()));
|
||||
assert!(bad.is_empty(), "{}", bad.join("\n"));
|
||||
}
|
||||
|
||||
@@ -7391,6 +7391,7 @@ anchor Points: Точки:
|
||||
Arrow (open) Стрілка (контурна)
|
||||
Barbed Зазубрена
|
||||
arrowhead Feather Оперення
|
||||
arrowhead Target Мішень
|
||||
Half Arrow (left) Половина стрілки (ліворуч)
|
||||
Half Arrow (right) Половина стрілки (праворуч)
|
||||
Double Bar Подвійна смуга
|
||||
|
||||
|
Can't render this file because it is too large.
|
Reference in New Issue
Block a user