Open Parameters directly and prepare SolidCraft 0.3.0
This commit is contained in:
1 parent
4af2d06007
commit
d8beaedfa4
7 files changed
+72
-16
No files matched your search
@@ -240,6 +240,12 @@ pub fn paint(p: &Painter, r: Rect, name: &str, ink: Color32, fill: Color32, acce
|
||||
pen.arrow((12.0, 12.0), (12.0 + 9.0 * dx, 12.0 + 9.0 * dy), a);
|
||||
}
|
||||
}
|
||||
"configuration_table" => {
|
||||
pen.poly(&[(3.0, 4.0), (21.0, 4.0), (21.0, 20.0), (3.0, 20.0)], pen.fill, ink);
|
||||
pen.line(&[(3.0, 9.0), (21.0, 9.0)], a);
|
||||
pen.line(&[(3.0, 14.0), (21.0, 14.0)], ink);
|
||||
pen.line(&[(9.0, 4.0), (9.0, 20.0)], ink);
|
||||
}
|
||||
"params" => {
|
||||
pen.line(&[(8.0, 20.0), (9.0, 8.0), (10.0, 5.0), (13.0, 4.0)], ink);
|
||||
pen.line(&[(6.0, 11.0), (12.0, 11.0)], ink);
|
||||
|
||||
@@ -481,9 +481,19 @@ pub fn toolbar(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
} else {
|
||||
(t.border, t.panel_header, t.border)
|
||||
};
|
||||
let icon = if c.id == "sketch.finish" { "finish" } else { c.icon };
|
||||
let icon = match c.id {
|
||||
"sketch.finish" => "finish",
|
||||
"config.table" => "configuration_table",
|
||||
_ => c.icon,
|
||||
};
|
||||
icons::paint(&painter, br.shrink(6.0), icon, ink, fill, acc);
|
||||
let tr_label = app.tr_label(c.label);
|
||||
let label = match c.id {
|
||||
"parameters.change" if *panel == "CONFIGURE" => "Parameters",
|
||||
"config.table" if *panel == "CONFIGURE" => "Configurations",
|
||||
_ => c.label,
|
||||
};
|
||||
let tr_label = app.tr_label(label);
|
||||
resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled() && info.enabled, tr_label));
|
||||
let tip = match &info.disabled_reason {
|
||||
Some(why) => format!("{}\n{why}", tr_label),
|
||||
None => format!("{}{}", tr_label, c.shortcut.map(|k| format!(" ({k})")).unwrap_or_default()),
|
||||
|
||||
@@ -100,6 +100,7 @@ pub fn panels(tab: &str) -> Option<&'static [&'static str]> {
|
||||
/// to the registry.
|
||||
pub fn layout<'a>(tab: &str, panel: &str, specs: &[&'a CommandSpec]) -> Option<(Vec<&'a CommandSpec>, usize)> {
|
||||
let (ids, promoted, own_tab): (&[&str], usize, &str) = match (tab, panel) {
|
||||
("SOLID", "CONFIGURE") => (&["parameters.change", "config.table"], 2, tab),
|
||||
("SOLID" | "SHEET METAL" | "PLASTIC", "ASSEMBLE") => (ASSEMBLE, 3, tab),
|
||||
("SHEET METAL", "CREATE") => (SHEET_CREATE, 3, tab),
|
||||
("SHEET METAL", "MODIFY") => (SHEET_MODIFY, 2, tab),
|
||||
@@ -146,6 +147,38 @@ mod tests {
|
||||
layout(tab, panel, &specs).map(|(v, _)| v.iter().map(|c| c.id).collect()).unwrap_or_default()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn configure_header_clicks_open_parameters_and_configurations_separately() {
|
||||
use serde_json::json;
|
||||
let mut h = crate::scenario::Harness::new();
|
||||
let commands = ids("SOLID", "CONFIGURE");
|
||||
assert_eq!(&commands[..2], &["parameters.change", "config.table"]);
|
||||
assert!(commands.contains(&"config.configure"), "Configure remains available in the dropdown");
|
||||
h.step(&json!({"widget":"Parameters"})).unwrap();
|
||||
assert!(h.app.params.is_some(), "the ordinary Parameters button opens the editor");
|
||||
assert!(h.app.dialog.is_none());
|
||||
assert!(h.widget("User Parameters").is_some());
|
||||
assert!(h.widget("Model Parameters").is_some());
|
||||
// Exercise the editor's Add button, not a script-only parameter command.
|
||||
let parameters = h.app.params.as_mut().unwrap();
|
||||
parameters.new_name = "width".into();
|
||||
parameters.new_expr = "25 mm".into();
|
||||
h.frames(3);
|
||||
h.step(&json!({"widget":"Add"})).unwrap();
|
||||
let values = h.app.session.execute("parameters.list", &json!({})).unwrap();
|
||||
assert!(values["parameters"].as_array().unwrap().iter().any(|p| p["name"] == "width" && p["value"] == 25.0));
|
||||
h.step(&json!({"click":{"handle":"params:close"}})).unwrap();
|
||||
assert!(h.app.params.is_none());
|
||||
h.step(&json!({"widget":"Configurations"})).unwrap();
|
||||
assert!(h.app.params.is_none());
|
||||
assert!(matches!(
|
||||
h.app.dialog.as_ref().map(|d| &d.kind),
|
||||
Some(crate::dialogs::Kind::Motion(crate::dialogs_motion::Mo::Configurations { .. }))
|
||||
));
|
||||
assert!(h.widget("Add Column").is_some());
|
||||
assert!(h.widget("Add Row").is_some());
|
||||
}
|
||||
|
||||
/// Fusion's layout: joints on every tab's ASSEMBLE panel, sheet metal and plastic tabs
|
||||
/// reach the shared solid commands, the plastic rules sit on SETUP.
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user