From a3674845972c86da69a93de657f9f58cd47ba9fb Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 14 Nov 2026 21:31:56 -0800 Subject: [PATCH] Properties: a Graph section opens Graph Type and Graph Data for a selected graph With one graph selected, or series of one graph picked with Group Selection, the Properties panel shows a Graph section. Graph Type... and Graph Data... open the dialogs of Object > Graph > Type... and Data.... Column... shows when every series it would change draws columns or bars, and Marker... when every one draws lines, scatter points or radar lines; both open their Object > Graph dialogs. The section lives in panels/properties/graph.rs. --- crates/ui-egui/src/i18n/bg.tsv | 2 + crates/ui-egui/src/i18n/bs.tsv | 2 + crates/ui-egui/src/i18n/ca.tsv | 2 + crates/ui-egui/src/i18n/cs.tsv | 2 + crates/ui-egui/src/i18n/da.tsv | 2 + crates/ui-egui/src/i18n/de.tsv | 2 + crates/ui-egui/src/i18n/el.tsv | 2 + crates/ui-egui/src/i18n/es.tsv | 2 + crates/ui-egui/src/i18n/fi.tsv | 2 + crates/ui-egui/src/i18n/fr.tsv | 2 + crates/ui-egui/src/i18n/gu.tsv | 2 + crates/ui-egui/src/i18n/hi.tsv | 2 + crates/ui-egui/src/i18n/hu.tsv | 2 + crates/ui-egui/src/i18n/id.tsv | 2 + crates/ui-egui/src/i18n/it.tsv | 2 + crates/ui-egui/src/i18n/ja.tsv | 2 + crates/ui-egui/src/i18n/ka.tsv | 2 + crates/ui-egui/src/i18n/ko.tsv | 2 + crates/ui-egui/src/i18n/nl.tsv | 2 + crates/ui-egui/src/i18n/pl.tsv | 2 + crates/ui-egui/src/i18n/pt-br.tsv | 2 + crates/ui-egui/src/i18n/ru.tsv | 2 + crates/ui-egui/src/i18n/sv.tsv | 2 + crates/ui-egui/src/i18n/tr.tsv | 2 + crates/ui-egui/src/i18n/uk.tsv | 2 + crates/ui-egui/src/i18n/vi.tsv | 2 + crates/ui-egui/src/i18n/zh-hans.tsv | 2 + crates/ui-egui/src/i18n/zh-hant.tsv | 2 + crates/ui-egui/src/panels/properties.rs | 2 + crates/ui-egui/src/panels/properties/graph.rs | 99 +++++++++++++++++ crates/ui-egui/src/panels/properties/tests.rs | 105 ++++++++++++++++++ docs/target-app-parity.md | 1 + 32 files changed, 263 insertions(+) create mode 100644 crates/ui-egui/src/panels/properties/graph.rs diff --git a/crates/ui-egui/src/i18n/bg.tsv b/crates/ui-egui/src/i18n/bg.tsv index 948b295e17..6fd3094e3b 100644 --- a/crates/ui-egui/src/i18n/bg.tsv +++ b/crates/ui-egui/src/i18n/bg.tsv @@ -1365,6 +1365,8 @@ font-technology Variable Променливи Graph Диаграма Graph Data Данни за диаграма Graph Type Тип диаграма + Graph Type… Тип диаграма… + Graph Data… Данни за диаграма… Graph Design Дизайн на диаграма Graph Marker Маркер на диаграма New Design Нов дизайн diff --git a/crates/ui-egui/src/i18n/bs.tsv b/crates/ui-egui/src/i18n/bs.tsv index f8d6fa263b..6e5081e2b1 100644 --- a/crates/ui-egui/src/i18n/bs.tsv +++ b/crates/ui-egui/src/i18n/bs.tsv @@ -3568,6 +3568,8 @@ theme Appearance Izgled Create Graph Kreiraj grafikon Graph Data Podaci grafikona Graph Type Vrsta grafikona + Graph Type… Vrsta grafikona… + Graph Data… Podaci grafikona… Vector Halftone Vektorski polutonovi spot spot Text Tekst diff --git a/crates/ui-egui/src/i18n/ca.tsv b/crates/ui-egui/src/i18n/ca.tsv index 3ed3ca8331..b27b888ff6 100644 --- a/crates/ui-egui/src/i18n/ca.tsv +++ b/crates/ui-egui/src/i18n/ca.tsv @@ -1896,6 +1896,8 @@ digits Malayalam Malaiàlam Graph Design Disseny del gràfic Graph Marker Marcador del gràfic Graph Type Tipus de gràfic + Graph Type… Tipus de gràfic… + Graph Data… Dades del gràfic… Graphic Gràfic Graphic Pen Ploma gràfica Graphic Pen… Ploma gràfica… diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index 161e235c56..7d9255ae4a 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -3622,6 +3622,8 @@ theme Appearance Motiv Create Graph Vytvořit graf Graph Data Data grafu Graph Type Typ grafu + Graph Type… Typ grafu… + Graph Data… Data grafu… Vector Halftone Vektorový polotón spot přímá Text Text diff --git a/crates/ui-egui/src/i18n/da.tsv b/crates/ui-egui/src/i18n/da.tsv index fd0b7c042e..6f345c26eb 100644 --- a/crates/ui-egui/src/i18n/da.tsv +++ b/crates/ui-egui/src/i18n/da.tsv @@ -3962,6 +3962,8 @@ theme Appearance Udseende Create Graph Opret graf Graph Data Grafdata Graph Type Graftype + Graph Type… Graftype… + Graph Data… Grafdata… Vector Halftone Vektorraster spot spot Text Tekst diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index 2a5f32a5d9..e47b71b0ca 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -1410,6 +1410,8 @@ file-filter Templates Vorlagen Graph Diagramm Graph Data Diagrammdaten Graph Type Diagrammtyp + Graph Type… Diagrammtyp… + Graph Data… Diagrammdaten… Graph Design Diagrammdesign Graph Marker Diagrammmarkierung New Design Neues Design diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index b1b7b4d039..54cf2ec839 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -1340,6 +1340,8 @@ font-technology Variable Μεταβλητές Graph Γράφημα Graph Data Δεδομένα γραφήματος Graph Type Τύπος γραφήματος + Graph Type… Τύπος γραφήματος… + Graph Data… Δεδομένα γραφήματος… Graph Design Σχεδίαση γραφήματος Graph Marker Δείκτης γραφήματος New Design Νέο σχέδιο diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index 5b3c675f7b..79b2a5eb19 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -1419,6 +1419,8 @@ font-technology Variable Variables Graph Gráfico Graph Data Datos del gráfico Graph Type Tipo de gráfico + Graph Type… Tipo de gráfico… + Graph Data… Datos del gráfico… Graph Design Diseño de gráfico Graph Marker Marcador de gráfico New Design Nuevo diseño diff --git a/crates/ui-egui/src/i18n/fi.tsv b/crates/ui-egui/src/i18n/fi.tsv index e77a617c52..1d873a1e32 100644 --- a/crates/ui-egui/src/i18n/fi.tsv +++ b/crates/ui-egui/src/i18n/fi.tsv @@ -3560,6 +3560,8 @@ theme Appearance Ulkoasu Create Graph Luo kaavio Graph Data Kaavion tiedot Graph Type Kaavion tyyppi + Graph Type… Kaavion tyyppi… + Graph Data… Kaavion tiedot… Vector Halftone Vektorirasteri spot spotti Text Teksti diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 2762d2a954..588f1d6701 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -1413,6 +1413,8 @@ font-technology Variable Variables Graph Graphe Graph Data Données du graphe Graph Type Type de graphe + Graph Type… Type de graphe… + Graph Data… Données du graphe… Graph Design Conception de graphe Graph Marker Marqueur de graphe New Design Nouvelle conception diff --git a/crates/ui-egui/src/i18n/gu.tsv b/crates/ui-egui/src/i18n/gu.tsv index 1c96900b2b..3e12ecfc21 100644 --- a/crates/ui-egui/src/i18n/gu.tsv +++ b/crates/ui-egui/src/i18n/gu.tsv @@ -1538,6 +1538,8 @@ Graph Design ગ્રાફ ડિઝાઇન Graph Marker ગ્રાફ માર્કર Graph Type ગ્રાફ પ્રકાર + Graph Type… ગ્રાફ પ્રકાર… + Graph Data… ગ્રાફ ડેટા… Graphic Pen… ગ્રાફિક પેન… Graphic Style ગ્રાફિક સ્ટાઇલ Graphic Style Libraries ગ્રાફિક સ્ટાઇલ લાઇબ્રેરીઓ diff --git a/crates/ui-egui/src/i18n/hi.tsv b/crates/ui-egui/src/i18n/hi.tsv index 548f961f51..c4739db04e 100644 --- a/crates/ui-egui/src/i18n/hi.tsv +++ b/crates/ui-egui/src/i18n/hi.tsv @@ -2113,6 +2113,8 @@ antiAlias Sharp शार्प Graph Design ग्राफ़ डिजाइन Graph Marker ग्राफ़ मार्कर Graph Type ग्राफ़ टाइप + Graph Type… ग्राफ़ टाइप… + Graph Data… ग्राफ़ डेटा… Graphic ग्राफिक Graphic Pen ग्राफ़िक पेन Graphic Pen… ग्राफ़िक पेन… diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index 200b45d1b1..9df28cffb6 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -1764,6 +1764,8 @@ file-filter Templates Sablonok Graph Diagram Graph Data Diagramadatok Graph Type Diagramtípus + Graph Type… Diagramtípus… + Graph Data… Diagramadatok… Select Segments Szakaszok kijelölése Artistic Művészi Film Grain… Filmszemcse… diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index f3dcca3874..6a237d7f8e 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -3353,6 +3353,8 @@ theme Appearance Tampilan Create Graph Buat grafik Graph Data Data grafik Graph Type Jenis grafik + Graph Type… Jenis grafik… + Graph Data… Data grafik… Vector Halftone Halftone vektor spot spot Text Teks diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index 90ec79404c..cd7d4a569e 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -1440,6 +1440,8 @@ file-filter Templates Modelli Graph Grafico Graph Data Dati grafico Graph Type Tipo di grafico + Graph Type… Tipo di grafico… + Graph Data… Dati grafico… Graph Design Design del grafico Graph Marker Indicatore del grafico New Design Nuovo design diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index d98acfa22d..17a6b629e1 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -3856,6 +3856,8 @@ file-filter Templates テンプレート Gradient (. or Shift+.) グラデーション (. または Shift+.) Graph Data グラフデータ Graph Type グラフの種類 + Graph Type… グラフの種類… + Graph Data… グラフデータ… Graph Design グラフのデザイン Graph Marker グラフのマーカー New Design 新規デザイン diff --git a/crates/ui-egui/src/i18n/ka.tsv b/crates/ui-egui/src/i18n/ka.tsv index 794e5454a9..0cb324b42e 100644 --- a/crates/ui-egui/src/i18n/ka.tsv +++ b/crates/ui-egui/src/i18n/ka.tsv @@ -3199,6 +3199,8 @@ theme Appearance იერსახე Create Graph გრაფიკის შექმნა Graph Data გრაფიკის მონაცემები Graph Type გრაფიკის ტიპი + Graph Type… გრაფიკის ტიპი… + Graph Data… გრაფიკის მონაცემები… Vector Halftone ვექტორული ნახევარტონი spot სპოტ Text ტექსტი diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index bb8676df71..946ecd8a62 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -3844,6 +3844,8 @@ file-filter Templates 템플릿 Gradient (. or Shift+.) 그레이디언트 (. 또는 Shift+.) Graph Data 그래프 데이터 Graph Type 그래프 유형 + Graph Type… 그래프 유형… + Graph Data… 그래프 데이터… Graph Design 그래프 디자인 Graph Marker 그래프 마커 New Design 새 디자인 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index a597a03fd0..6366a9e537 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -3871,6 +3871,8 @@ theme Appearance Vormgeving Create Graph Diagram maken Graph Data Diagramgegevens Graph Type Diagramtype + Graph Type… Diagramtype… + Graph Data… Diagramgegevens… Vector Halftone Vectorhalftoon spot spot Text Tekst diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 99ee2080b8..e6c851862e 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -3501,6 +3501,8 @@ theme Appearance Wygląd Create Graph Utwórz wykres Graph Data Dane wykresu Graph Type Typ wykresu + Graph Type… Typ wykresu… + Graph Data… Dane wykresu… Vector Halftone Półton wektorowy spot dodatkowy Text Tekst diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index 677c8e460f..b87ba4d725 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -4964,6 +4964,8 @@ axis Both Ambos Gradient (. or Shift+.) Gradiente (. ou Shift+.) Graph Data Dados do Gráfico Graph Type Tipo de Gráfico + Graph Type… Tipo de Gráfico… + Graph Data… Dados do Gráfico… New Design Novo Design Delete Design Excluir Design Paste Design Colar Design diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index 106343cddd..1bc01a2b57 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -1429,6 +1429,8 @@ file-filter Templates Шаблоны Graph Диаграмма Graph Data Данные диаграммы Graph Type Тип диаграммы + Graph Type… Тип диаграммы… + Graph Data… Данные диаграммы… Graph Design Дизайн диаграммы Graph Marker Маркер диаграммы New Design Новый дизайн diff --git a/crates/ui-egui/src/i18n/sv.tsv b/crates/ui-egui/src/i18n/sv.tsv index cc854aa362..461d06d19c 100644 --- a/crates/ui-egui/src/i18n/sv.tsv +++ b/crates/ui-egui/src/i18n/sv.tsv @@ -1378,6 +1378,8 @@ font-technology Variable Variabla Graph Diagram Graph Data Diagramdata Graph Type Diagramtyp + Graph Type… Diagramtyp… + Graph Data… Diagramdata… Graph Design Diagramdesign Graph Marker Diagrammarkör New Design Ny design diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index f2888a30f0..58c8911190 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -1352,6 +1352,8 @@ font-technology Variable Değişken Graph Grafik Graph Data Grafik Verileri Graph Type Grafik Türü + Graph Type… Grafik Türü… + Graph Data… Grafik Verileri… Graph Design Grafik Tasarımı Graph Marker Grafik İşaretleyici New Design Yeni Tasarım diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index 411b2c3baf..b343a43f91 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -1434,6 +1434,8 @@ file-filter Templates Шаблони Graph Діаграма Graph Data Дані діаграми Graph Type Тип діаграми + Graph Type… Тип діаграми… + Graph Data… Дані діаграми… Graph Design Дизайн діаграми Graph Marker Маркер діаграми New Design Новий дизайн diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index 1460910197..267e822072 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -1684,6 +1684,8 @@ file-filter Templates Mẫu Chop Design Cắt thiết kế Scale Design Co giãn thiết kế Graph Type Loại biểu đồ + Graph Type… Loại biểu đồ… + Graph Data… Dữ liệu biểu đồ… Graphic Đồ họa Graphic Style Kiểu đồ họa Graphic Style Libraries Thư viện kiểu đồ họa diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index 3fe2f9e009..d630d1f627 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -1369,6 +1369,8 @@ file-filter Templates 模板 Graph 图表 Graph Data 图表数据 Graph Type 图表类型 + Graph Type… 图表类型… + Graph Data… 图表数据… Graph Design 图表设计 Graph Marker 图表标记 New Design 新建设计 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index ab7f9d9dd2..2c0f6a4adb 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -1404,6 +1404,8 @@ file-filter Templates 範本 Graph 圖表 Graph Data 圖表資料 Graph Type 圖表類型 + Graph Type… 圖表類型… + Graph Data… 圖表資料… Graph Design 圖表設計 Graph Marker 圖表標記 New Design 新增設計 diff --git a/crates/ui-egui/src/panels/properties.rs b/crates/ui-egui/src/panels/properties.rs index 6195de4b24..d4314302f5 100644 --- a/crates/ui-egui/src/panels/properties.rs +++ b/crates/ui-egui/src/panels/properties.rs @@ -69,6 +69,7 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) { objects_on_path_section(app, ui, &oop); divider(ui); } + graph::section(app, ui); if matches!(first.as_ref().map(|n| &n.kind), Some(NodeKind::Text(_))) { type_sections(app, ui); divider(ui); @@ -1037,6 +1038,7 @@ pub fn type_sections(app: &mut VectorcraftApp, ui: &mut Ui) { } pub(crate) mod dynamic_text; +pub(crate) mod graph; pub(crate) mod vertical_align; #[cfg(test)] diff --git a/crates/ui-egui/src/panels/properties/graph.rs b/crates/ui-egui/src/panels/properties/graph.rs new file mode 100644 index 0000000000..fe86d6e0ac --- /dev/null +++ b/crates/ui-egui/src/panels/properties/graph.rs @@ -0,0 +1,99 @@ +//! The Properties panel's Graph section, for one selected graph or series of one graph picked with +//! Group Selection: Graph Type… and Graph Data… open the dialogs of Object › Graph › Type… and +//! Data… ([Format pie graphs](https://helpx.adobe.com/illustrator/desktop/automate-visualize-data/visualize-data/format-pie-graphs.html) +//! opens Graph Type from the Properties panel). Column… shows when every series it would change +//! draws columns or bars, and Marker… when every one draws lines, scatter points or radar lines; +//! both run the same route as their Object › Graph items. + +use egui::Ui; +use serde_json::json; +use vectorcraft_doc::{Document, GraphKind, MAX_GRAPH_SERIES, NodeId}; + +use crate::VectorcraftApp; +use crate::widgets::{self, divider, section_header}; + +/// The Graph section's optional buttons for the selection. +#[derive(Clone, Copy, Debug, PartialEq)] +pub(crate) struct Shown { + /// Column… takes the series it would change. + pub(crate) column: bool, + /// Marker… takes the series it would change. + pub(crate) marker: bool, +} + +/// What the Graph section shows for the selection; `None` unless everything selected is one graph +/// or lies inside the same graph. +pub(crate) fn shown(app: &VectorcraftApp) -> Option { + let st = app.session.active()?; + let doc = &st.doc; + let mut graph = None; + for id in &st.selection.objects { + let g = graph_of(doc, *id)?; + if graph.is_some_and(|x| x != g) { + return None; + } + graph = Some(g); + } + let graph = graph?; + let spec = doc.node(graph)?.extras().graph.as_deref()?; + let count = spec.rows.iter().map(Vec::len).max().unwrap_or(0).clamp(1, MAX_GRAPH_SERIES); + // The series Column… and Marker… change: those picked with Group Selection when the selection is + // only series, else every series (as `graph.column` and `graph.marker` pick them). + let picked: Option> = st.selection.objects.iter().map(|id| series_of(doc, graph, *id).filter(|i| *i < count)).collect(); + let series = picked.unwrap_or_else(|| (0..count).collect()); + let kinds: Vec = series.iter().map(|i| spec.series_kind(*i)).collect(); + let all = |ks: &[GraphKind]| !kinds.is_empty() && kinds.iter().all(|k| ks.contains(k)); + Some(Shown { + column: all(&[GraphKind::Column, GraphKind::StackedColumn, GraphKind::Bar, GraphKind::StackedBar]), + marker: all(&[GraphKind::Line, GraphKind::Scatter, GraphKind::Radar]), + }) +} + +/// The graph `id` is or lies in. +fn graph_of(doc: &Document, id: NodeId) -> Option { + let mut cur = Some(id); + while let Some(c) = cur { + if doc.node(c).is_some_and(|n| n.extras().graph.is_some()) { + return Some(c); + } + cur = doc.parent_of(c); + } + None +} + +/// The index of the series of `graph` that `id` is or lies in; `None` for the graph itself, its +/// axes and its legend. +fn series_of(doc: &Document, graph: NodeId, id: NodeId) -> Option { + let mut cur = id; + loop { + let parent = doc.parent_of(cur)?; + if parent == graph { + return doc.node(cur)?.extras().series_index.and_then(|i| usize::try_from(i).ok()); + } + cur = parent; + } +} + +/// The Graph section for the selection, with the divider after it; nothing without a graph. +pub(crate) fn section(app: &mut VectorcraftApp, ui: &mut Ui) { + let Some(s) = shown(app) else { return }; + section_header(ui, tl!("Graph")); + let mut buttons = vec![(tl!("Graph Type…"), "graph.setType"), (tl!("Graph Data…"), "graph.setData")]; + if s.column { + buttons.push((tl!("Column…"), "graph.column")); + } + if s.marker { + buttons.push((tl!("Marker…"), "graph.marker")); + } + let w = (ui.available_width() - 6.0) / 2.0; + for pair in buttons.chunks(2) { + ui.horizontal(|ui| { + for (label, id) in pair { + if widgets::flat_button(ui, label, w).clicked() { + crate::menus::invoke(app, id, json!({})); + } + } + }); + } + divider(ui); +} diff --git a/crates/ui-egui/src/panels/properties/tests.rs b/crates/ui-egui/src/panels/properties/tests.rs index 9300619765..b8f702be83 100644 --- a/crates/ui-egui/src/panels/properties/tests.rs +++ b/crates/ui-egui/src/panels/properties/tests.rs @@ -2014,3 +2014,108 @@ fn dynamic_text_rows_follow_the_selected_area_type() { app.run("text.thread.create", json!({})).unwrap(); assert_eq!(dynamic_text::shown(&app).map(|s| (s.on, s.enabled)), Some((Some(false), false))); } + +/// A document with a graph of `kind` and three series, selected → the graph's id. +fn graph_doc(app: &mut VectorcraftApp, kind: &str, x: f64) -> u64 { + if app.session.active().is_none() { + app.run("file.new", json!({"width": 800, "height": 400})).unwrap(); + } + let csv = ",a,b,c\nQ1,1,2,3\nQ2,3,4,5"; + app.run("graph.create", json!({"type": kind, "x": x, "y": 0, "width": 200, "height": 150, "csv": csv})).unwrap()["id"].as_u64().unwrap() +} + +/// The ids of graph `graph`'s series groups, in series order. +fn series_groups(app: &VectorcraftApp, graph: u64) -> Vec { + let st = app.session.active().unwrap(); + let mut groups: Vec<(u32, u64)> = st + .doc + .node(vectorcraft_doc::NodeId(graph)) + .and_then(vectorcraft_doc::Node::children) + .into_iter() + .flatten() + .filter_map(|c| c.extras().series_index.map(|i| (i, c.id.0))) + .collect(); + groups.sort_unstable(); + groups.into_iter().map(|(_, id)| id).collect() +} + +/// One selected column graph has a Graph section with Graph Type…, Graph Data… and Column…, and +/// each button opens its Object › Graph dialog for the graph. +#[test] +fn one_selected_graph_has_a_graph_section_whose_buttons_open_the_graph_dialogs() { + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + graph_doc(&mut app, "column", 0.0); + assert_eq!(graph::shown(&app), Some(graph::Shown { column: true, marker: false })); + let ctx = egui::Context::default(); + let texts = frame(&mut app, &ctx, vec![]); + for label in ["Graph", "Graph Type…", "Graph Data…", "Column…"] { + assert!(texts.iter().any(|(t, _)| t == label), "no {label:?} in {texts:?}"); + } + assert!(!texts.iter().any(|(t, _)| t == "Marker…"), "{texts:?}"); + let press = |app: &mut VectorcraftApp, label: &str| { + let texts = panel_frame(app, &ctx, vec![], graph::section); + let at = texts.iter().find(|(t, _)| t == label).map(|(_, r)| r.center()).unwrap_or_else(|| panic!("no {label:?} in {texts:?}")); + let b = |pressed| Event::PointerButton { pos: at, button: PointerButton::Primary, pressed, modifiers: Default::default() }; + panel_frame(app, &ctx, vec![Event::PointerMoved(at), b(true)], graph::section); + panel_frame(app, &ctx, vec![b(false)], graph::section); + app.ui.dialog.take().unwrap_or_else(|| panic!("{label:?} opened no dialog")) + }; + let d = press(&mut app, "Graph Type…"); + assert_eq!((d.kind.as_str(), d.str("__command")), ("command", "graph.setType".to_string())); + assert_eq!(d.str("type"), "column"); + assert_eq!(press(&mut app, "Graph Data…").kind, crate::dialogs::graph_data::KIND); + assert_eq!(press(&mut app, "Column…").kind, crate::dialogs::graph_design::COLUMN); +} + +/// Column… shows when every series it would change draws columns or bars, Marker… when every one +/// draws lines, scatter points or radar lines: series picked with Group Selection count on their +/// own, and a combined graph selected whole shows neither. +#[test] +fn the_graph_sections_column_and_marker_follow_the_series_they_would_change() { + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + let g = graph_doc(&mut app, "column", 0.0); + app.run("graph.setType", json!({"seriesIndexes": [1], "type": "line"})).unwrap(); + app.run("select.set", json!({"ids": [g]})).unwrap(); + assert_eq!(graph::shown(&app), Some(graph::Shown { column: false, marker: false }), "column and line series"); + let groups = series_groups(&app, g); + assert_eq!(groups.len(), 3, "{groups:?}"); + app.run("select.set", json!({"ids": [groups[1]]})).unwrap(); + assert_eq!(graph::shown(&app), Some(graph::Shown { column: false, marker: true }), "the line series"); + app.run("select.set", json!({"ids": [groups[0], groups[2]]})).unwrap(); + assert_eq!(graph::shown(&app), Some(graph::Shown { column: true, marker: false }), "the column series"); + app.run("select.set", json!({"ids": [groups[0], groups[1]]})).unwrap(); + assert_eq!(graph::shown(&app), Some(graph::Shown { column: false, marker: false }), "one of each"); + for (kind, shown) in [ + ("line", (false, true)), + ("scatter", (false, true)), + ("radar", (false, true)), + ("bar", (true, false)), + ("pie", (false, false)), + ("area", (false, false)), + ] { + let id = graph_doc(&mut app, kind, 300.0); + app.run("select.set", json!({"ids": [id]})).unwrap(); + assert_eq!(graph::shown(&app).map(|s| (s.column, s.marker)), Some(shown), "{kind}"); + app.run("edit.clear", json!({})).unwrap(); + } +} + +/// The Graph section shows only while everything selected is one graph or lies in it. +#[test] +fn the_graph_section_needs_one_graph_selected() { + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + let a = graph_doc(&mut app, "column", 0.0); + let b = graph_doc(&mut app, "column", 300.0); + let rect = app.run("shape.rectangle", json!({"x": 600, "y": 0, "width": 20, "height": 20})).unwrap()["id"].as_u64().unwrap(); + for (ids, what) in [(vec![rect], "a rectangle"), (vec![a, rect], "a graph and a rectangle"), (vec![a, b], "two graphs")] { + app.run("select.set", json!({ "ids": ids })).unwrap(); + assert_eq!(graph::shown(&app), None, "{what}"); + let texts = frame(&mut app, &egui::Context::default(), vec![]); + assert!(!texts.iter().any(|(t, _)| t == "Graph Type…"), "{what}: {texts:?}"); + } + let groups = series_groups(&app, a); + app.run("select.set", json!({"ids": [groups[0], groups[1]]})).unwrap(); + assert!(graph::shown(&app).is_some(), "two series of one graph"); + app.run("select.set", json!({"ids": [groups[0], series_groups(&app, b)[0]]})).unwrap(); + assert_eq!(graph::shown(&app), None, "series of two graphs"); +} diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index f4424700be..f2d51f543c 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -620,6 +620,7 @@ since 2026-10-01. - **`.ai`/EPS graphic styles that paint with a named gradient:** a graphic style library's style (or a file's listed style) whose fill, or the fill or stroke of a style of one paint, paints with one of the file's gradients by name loads with that gradient at the style's angle, fitted to the bounds of each object it is applied to (VectorCraft's own placement; the style stores only the gradient's name and angle). A style naming a gradient the file doesn't define, or painting with a pattern, is still left out. Evidence: `fileio::tests_aiimport::graphic_styles_in_a_ai_library_that_paint_with_a_named_gradient_load_with_it`, `style::tests::a_style_of_one_paint_reads_as_the_fill_and_stroke_its_xd_turns_on`. Scores unchanged. - **`.ai`/EPS type laid out closer to the file's page (#6137):** type from the text document keeps auto leading as auto, each line taking the paragraph's Auto Leading share (key 7) of the largest type on it ([Line and character spacing](https://helpx.adobe.com/illustrator/using/line-character-spacing.html)); the paragraph's hyphenation options (keys 10 to 15) are read; area type of one frame whose last lines the file sets, but which don't fit here, may get a frame taller from its bottom, by its lines' deepest descent plus 0.05 pt and only when that shows more of those lines and no more than the file has (`vectorcraft_text::fit_source_lines`), with a warning when it does: the frame can stay as it is, or show only some of them; and a line a soft return ends is justified as a wrapped line is, a paragraph's last line keeping its alignment. Evidence: `ate::tests::auto_leading_follows_the_size_of_each_line`, `ate::tests::a_paragraph_keeps_its_auto_leading`, `ate::tests::a_paragraph_keeps_its_hyphenation_options`, `ate::tests::the_last_lines_the_file_sets_in_its_frame_show`, `tests::fit_source_lines_keeps_the_last_lines_the_source_sets`, `tests::typo::soft_return_in_justified_text_spreads_like_a_wrapped_line`. Limits: frames grow only for area type of one frame, horizontal, by its lines' deepest descent plus 0.05 pt; type in a font that isn't installed, and hyphenation in a language that isn't imported, still lay out differently. Scores unchanged. - **Graphs saved to `.ai` keep their data and settings:** a grouped column, stacked column, line or area graph is written to a `.ai` file, in either form, with the records the `.ai` reader reads (`crates/eps/src/import/ai/read/graph.rs`, #7311): `%_Gs`, its plot, type, settings, axes and table, its series' groups each tagged `Go`, and `%_GS` ([the specification](https://13thmonkey.org/documentation/fonts/AI7FileFormat.pdf), §17 and appendix A). The file opens again with the same live graph. A graph with settings the reader doesn't keep, graph designs, label formatting, more than 10,000 categories or 256 series, or art the reader doesn't attach a graph to is written as its art, with a warning. `crates/eps/src/legacy_ai/tests.rs` and `crates/eps/src/ai_editing/tests.rs` write and read back each kind of graph; `a_drawn_graph_saved_as_ai_opens_as_a_graph_unless_the_save_warns` checks every graph type the graph tools draw. Scores unchanged. +- **Graph section in the Properties panel:** with one graph selected, or series of one graph picked with Group Selection, the Properties panel shows a Graph section whose Graph Type… and Graph Data… buttons open the dialogs of Object › Graph › Type… and Data… ([Format pie graphs](https://helpx.adobe.com/illustrator/desktop/automate-visualize-data/visualize-data/format-pie-graphs.html)). Column… shows when every series it would change draws columns or bars, and Marker… when every one draws lines, scatter points or radar lines; this is VectorCraft's own rule. Regression tests in `crates/ui-egui/src/panels/properties/tests.rs`. Scores unchanged. - **Selected Grid Repeat handles (#2691):** `tools/src/repeat_grid.rs` tests place the handles outside the grid at zoom 0.5, 1 and 4, preview rows, columns and spacing, leave no undo step for a drag that ends where it began, and give bounding-box handles priority; a headless canvas regression drags the row handle two tiles down in a zoomed view (3 → 5 rows, the source unchanged, one Undo back) and the column-spacing slider. Scores and hours unchanged. - **Selected Mirror Repeat handles:** a headless canvas regression creates the default mirror repeat and drags its Top bounding-box handle where the axis crosses it; the repeat grows vertically while its width stays fixed. Existing mirror-axis checks cover center movement and end-handle hit priority. The focused UI mirror tests pass. Scores and hours unchanged. - **Transform effect options (#885):** Effect › Distort & Transform › Transform… has visible Transform Objects, Transform Patterns and Scale Strokes & Effects checkboxes (`distort.transform` params `objects`, `patterns`, `strokes`; files without them draw as before). With Transform Objects off the geometry stays and makes no copies; Scale Strokes & Effects scales stroke weights, dashes and the fills' and strokes' effect distances by the mean scale, and Transform Patterns moves pattern tiles, each copy `k` by the transformation `k` times. Such objects draw, export and expand through the same per-copy art, so the canvas and Expand Appearance agree (engine `tests_transformfx`, effects `tests_transformfx`, the dialog test). A Transform effect in a fill's or stroke's own effects applies the same options to that fill or stroke: its weight and dashes and its pattern follow the transformation, and with copies each copy is an object of its own; the canvas, export, Expand Appearance and Use Preview Bounds use the same art (effects `tests_transformfx`). The effects listed after it in that fill's or stroke's list keep their own distances and apply to the transformed art and to each copy, as an object's later effects do after the object's Transform effect: a Drop Shadow after it keeps its offset, an Offset Path after it offsets by its own distance, and an SVG filter after it keeps its scale and the origin of its user space. With Transform Objects off, the effects before it keep their distances too. Before, Scale Strokes & Effects scaled a fill's or stroke's later effects by the mean scale, so existing documents with such effects draw differently. Effects apply in the order they are listed ([Appearance attributes](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/apply-graphic-styles/appearance-attributes-in-illustrator.html)); how the two options treat the effects after a fill's or stroke's own Transform effect is VectorCraft's own rule, following that order (effects `tests::rasterfollow::a_fills_own_transform_leaves_the_shadow_after_it`, `tests::rasterfollow::a_fills_own_transform_leaves_the_offset_after_it`, `tests::rasterfollow::a_fills_own_transform_leaves_the_svg_filter_after_it`, `tests::transformfx::a_fills_own_transform_with_scale_strokes_and_effects_leaves_its_later_effects`; engine `plugins::a_transform_after_a_painted_fill_effect_leaves_the_later_shadow_on_every_paint`). Public reference: [Scale objects](https://helpx.adobe.com/illustrator/desktop/manage-objects/reshape-transform-objects/scale-objects.html), [How to apply effects](https://helpx.adobe.com/illustrator/using/effects.html), [Distort and transform effects](https://helpx.adobe.com/illustrator/desktop/manage-objects/reshape-transform-objects/distort-and-transform-effects-in-illustrator.html). Scores and hours unchanged.