Merge main into feat/pict-export

This commit is contained in:
dotCooCoo committed 2026-12-05 09:17:38 -08:00
commit be9e3cc116
6 files changed
+35 -2

No files matched your search

+1 -1
View File
@@ -42,7 +42,7 @@ pub(crate) use data::{apply_csv, graph_csv_from_file, parse_csv};
#[cfg(test)]
use data::{fmt_value, to_csv};
pub(crate) use designs::{holds_designs, redraw_detached, redraw_symbols_with_designs, redraw_with_designs, refresh_graphs, series_drawn_designs};
pub use edit::{GraphTypeSubject, graph_type_subject};
pub use edit::{GraphTypeSubject, graph_type_subject, has_graph_selection};
pub(crate) use edit::{edit_graph_art, graphs_holding, keep_placed};
pub use generate::calculated_axes;
#[cfg(test)]
+5
View File
@@ -200,6 +200,11 @@ pub(super) fn target(s: &Session, p: &Value, cmd: &str) -> Result<NodeId> {
Err(bad(cmd, "select a graph"))
}
/// Whether a graph command can find a graph from the current selection.
pub fn has_graph_selection(s: &Session) -> bool {
target(s, &Value::Null, "graph.setData").is_ok()
}
pub(super) fn spec_of(s: &Session, id: NodeId) -> Result<GraphSpec> {
s.doc()?.doc.node(id).and_then(|n| n.extras().graph.as_deref().cloned()).ok_or(EngineError::NoNode(id))
}
+1 -1
View File
@@ -36,7 +36,7 @@ pub use cmd::create::constrain_click;
pub use cmd::distortcmds::{perspective_click, width_point_pair};
pub use cmd::flare::flare_settings;
pub use cmd::gradient::{GradientEditPaints, StopOwner};
pub use cmd::graph::{GraphTypeSubject, calculated_axes as graph_calculated_axes, graph_type_subject};
pub use cmd::graph::{GraphTypeSubject, calculated_axes as graph_calculated_axes, graph_type_subject, has_graph_selection};
pub use cmd::params::{check_keys, check_params};
pub use cmd::pathops::{HAIRLINE_SLIVER_WIDTH, HAIRLINE_SLIVER_WIDTH_RANGE, auto_simplify_level, can_outline_stroke};
pub use cmd::rasterfx::{export_pdf, flatten_raster_effects};
+1
View File
@@ -325,6 +325,7 @@ antiAlias Sharp 锐利
Brush Options… 画笔选项…
Options of Selected Object… 所选对象的选项…
Options of Selected Object 所选对象的选项
Check for Updates… 检查更新…
@msg no path painted with a brush is selected 未选择用画笔绘制的路径
@msg the selected paths are painted with brushes of different types 所选路径使用了不同类型的画笔
@msg give `params` or `reset`, not both 请提供 `params` 或 `reset`,不能同时提供
Can't render this file because it is too large.
+3
View File
@@ -300,6 +300,9 @@ pub(crate) fn why_off(app: &VectorcraftApp, id: &str) -> Option<Option<String>>
}
if let Some(c) = vectorcraft_engine::find_command(id) {
return match (c.enabled)(&app.session) {
Ok(()) if matches!(id, "graph.setData" | "graph.setType" | "graph.column" | "graph.marker") => {
(!vectorcraft_engine::has_graph_selection(&app.session)).then(|| Some("select a graph".into()))
}
Ok(()) => None,
// The system clipboard's contents can be pasted into an open document with an empty
// internal clipboard.
+24
View File
@@ -1231,6 +1231,30 @@ fn app_with_a_rectangle() -> VectorcraftApp {
app
}
#[test]
fn graph_menu_requires_a_live_graph_and_explicit_ids_still_work() {
let mut app = app_with_a_rectangle();
let rectangle = app.session.active().unwrap().selection.objects[0];
let commands = ["graph.setData", "graph.setType", "graph.column", "graph.marker"];
assert!(commands.iter().all(|id| !enabled(&app, id)));
assert!(enabled(&app, "graph.design"));
let graph = app.run("graph.create", json!({"type": "column", "x": 100, "y": 100, "width": 200, "height": 120})).unwrap();
let graph = vectorcraft_doc::NodeId(graph["id"].as_u64().unwrap());
let state = app.session.active().unwrap();
let member = state.doc.node(graph).unwrap().children().unwrap()[0].id;
assert!(commands.iter().all(|id| enabled(&app, id)));
app.run("select.set", json!({"ids": [member.0]})).unwrap();
assert!(commands.iter().all(|id| enabled(&app, id)));
app.run("select.none", json!({})).unwrap();
assert!(commands.iter().all(|id| !enabled(&app, id)));
app.run("select.set", json!({"ids": [rectangle.0]})).unwrap();
let data = app.session.execute("graph.setData", &json!({"id": graph.0})).unwrap();
assert!(data["csv"].is_string());
assert_eq!(app.session.active().unwrap().selection.objects, [rectangle]);
}
/// The in-window Edit menu draws Undo and Redo with the step's name, as the History panel lists it.
#[test]
fn the_edit_menu_draws_undo_and_redo_with_the_step_name() {