mirror of
https://github.com/storytold/cadcraft.git
synced 2026-12-02 02:38:30 -06:00
Address attribute editor review
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
//! The Edit Attributes dialog (Enhanced Attribute Editor): ATTEDIT / EATTEDIT typed or started
|
||||
//! The Attribute Editor dialog: ATTEDIT / EATTEDIT typed or started
|
||||
//! from a menu while one block reference with attributes is selected. It lists each attribute's
|
||||
//! tag, prompt and value; Apply and OK run `attedit {handle, at}` with the values changed (one
|
||||
//! undo step each). With nothing suitable selected ATTEDIT asks at the command line instead, and
|
||||
@@ -125,13 +125,19 @@ fn edited(app: &CadApp) -> Option<Handle> {
|
||||
(Some(st.uid) == app.attedit.doc && st.doc.entity(h).is_some()).then_some(h)
|
||||
}
|
||||
|
||||
/// ATTEDIT / EATTEDIT opens the dialog when one editable reference is selected and the command
|
||||
/// line is idle. Let the engine start an interactive command when another command is active.
|
||||
/// ATTEDIT / EATTEDIT opens the dialog when one editable reference is selected.
|
||||
pub fn route(app: &mut CadApp, id: &str, params: &Value) -> Option<Result<Value, String>> {
|
||||
if !matches!(id, "attedit" | "ate" | "eattedit") || !params.is_null() || app.session.prompting() {
|
||||
if !matches!(id, "attedit" | "ate" | "eattedit") || !params.is_null() {
|
||||
return None;
|
||||
}
|
||||
let h = selected_reference(app)?;
|
||||
if app.session.prompting() {
|
||||
app.session.cancel();
|
||||
}
|
||||
if app.session.prompting() {
|
||||
app.session.echo(crate::tl!("ATTEDIT: another command is still active."));
|
||||
return Some(Err("another command is still active".into()));
|
||||
}
|
||||
app.session.echo(format!("Command: {}", id.to_ascii_uppercase()));
|
||||
open(app, h, None).then_some(Ok(Value::Null))
|
||||
}
|
||||
@@ -190,8 +196,8 @@ pub fn dialog(app: &mut CadApp, ctx: &egui::Context, open: &mut bool) {
|
||||
let t = Tokens::get();
|
||||
let mut choice: Option<&str> = None;
|
||||
let st = &mut app.attedit;
|
||||
egui::Window::new(crate::tl!("Enhanced Attribute Editor"))
|
||||
.id(egui::Id::unique("Enhanced Attribute Editor"))
|
||||
egui::Window::new(crate::tl!("Attribute Editor"))
|
||||
.id(egui::Id::unique("Attribute Editor"))
|
||||
.open(open)
|
||||
.collapsible(false)
|
||||
.resizable(true)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! Block attributes from the UI: Edit Attributes on a selected block reference opens the Enhanced
|
||||
//! Block attributes from the UI: Edit Attributes on a selected block reference opens the
|
||||
//! Attribute Editor, and the Properties palette lists the attributes in their own group.
|
||||
|
||||
use cadcraft_engine::Session;
|
||||
@@ -120,7 +120,7 @@ fn edit_attributes_on_a_selected_reference_opens_the_dialog() {
|
||||
app.logic(&ctx);
|
||||
painted(&mut app, &ctx);
|
||||
let text = painted(&mut app, &ctx);
|
||||
for s in ["Enhanced Attribute Editor", "Number", "NOTE", "OK", "Apply"] {
|
||||
for s in ["Attribute Editor", "Number", "NOTE", "OK", "Apply"] {
|
||||
assert!(text.contains(s), "{s} missing from:\n{text}");
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ fn edit_attributes_on_a_selected_reference_opens_the_dialog() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_attribute_menu_uses_the_command_line_when_another_command_is_active() {
|
||||
fn the_attribute_menu_cancels_an_active_command_and_opens_the_editor() {
|
||||
for command in ["attedit", "eattedit"] {
|
||||
let (mut app, handle) = app_with_reference();
|
||||
app.start("line");
|
||||
@@ -143,8 +143,9 @@ fn the_attribute_menu_uses_the_command_line_when_another_command_is_active() {
|
||||
|
||||
menus::activate(&mut app, command);
|
||||
|
||||
assert!(app.ui.dialog.is_none(), "the editor must not open over the active prompt");
|
||||
assert_eq!(app.session.running.as_ref().map(|running| running.id.as_str()), Some("attedit"));
|
||||
assert_eq!(app.ui.dialog.as_deref(), Some("attedit"));
|
||||
assert!(!app.session.prompting(), "the earlier command was cancelled");
|
||||
assert_eq!(app.attedit.handle, Some(handle));
|
||||
assert_eq!(value(&app, handle, "NOTE"), "n");
|
||||
}
|
||||
}
|
||||
@@ -176,7 +177,7 @@ fn an_attribute_with_line_breaks_can_be_edited_with_the_keyboard() {
|
||||
harness.run();
|
||||
|
||||
assert_eq!(harness.state().attedit.rows[1].typed, "first\nsecond");
|
||||
let editor = harness.get_by_role_and_label(Role::Window, "Enhanced Attribute Editor");
|
||||
let editor = harness.get_by_role_and_label(Role::Window, "Attribute Editor");
|
||||
editor.get_by_role_and_label(Role::MultilineTextInput, "NOTE");
|
||||
editor.get_by_role_and_label(Role::TextInput, "NO");
|
||||
editor.get_by_label("Apply").click();
|
||||
@@ -544,7 +545,7 @@ fn equal_tag_and_value_attributes_are_told_apart_by_place() {
|
||||
assert!(told_the_value_was_not_applied(&harness), "the user is told: {:?}", harness.state().session.log.last());
|
||||
}
|
||||
|
||||
/// The Enhanced Attribute Editor draws the same line: a reorder that leaves every tag and value
|
||||
/// The Attribute Editor draws the same line: a reorder that leaves every tag and value
|
||||
/// in place, but moves the attributes, is a stale dialog too.
|
||||
#[test]
|
||||
fn a_stale_dialog_tells_equal_tag_and_value_attributes_apart_by_place() {
|
||||
@@ -604,7 +605,7 @@ fn a_pending_properties_value_does_not_follow_a_reorder_only_a_hidden_property_s
|
||||
assert!(told_the_value_was_not_applied(&harness), "the user is told: {:?}", harness.state().session.log.last());
|
||||
}
|
||||
|
||||
/// The Enhanced Attribute Editor draws the same line: a reorder that leaves every field it shows
|
||||
/// The Attribute Editor draws the same line: a reorder that leaves every field it shows
|
||||
/// in place, but swaps the attributes' text heights, is a stale dialog too.
|
||||
#[test]
|
||||
fn a_stale_dialog_tells_attributes_apart_by_a_property_it_does_not_show() {
|
||||
@@ -1,4 +1,5 @@
|
||||
mod animation_effects;
|
||||
mod attedit_dialog;
|
||||
mod block_description_palette;
|
||||
mod chrome_geometry;
|
||||
mod clipboard_between_drawings;
|
||||
|
||||
Reference in New Issue
Block a user