mirror of
https://github.com/storytold/cadcraft.git
synced 2026-12-02 20:22:15 -05:00
Options: preview and selection effects in Visual Effect Settings (#964)
* Options: preview and selection effects in Visual Effect Settings Selection Preview Effect (Dash / Thicken / Both, PREVIEWEFFECT) as AutoCAD offers it, and Selected Objects Effect (Dashed / Selection color, SELECTIONEFFECT), so neither has to be typed. They stay off the Selection tab itself. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Options test: each Visual Effect Settings choice sets its variable Co-Authored-By: Claude Opus 5.5 <[email protected]> * Tests: the visual effect test sets up the app's headless runtime, as main's UI tests now do Co-Authored-By: Claude Opus 5.5 <[email protected]> * Translations to craft-i18n (AGENTS.md rule 16) The Greek and Ukrainian rows this PR added to the app catalogs are removed; the English keys stay, and show until craft-i18n has them. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Cody Vogt <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2 files changed
+64
-5
No files matched your search
@@ -459,8 +459,11 @@ fn heading(ui: &mut egui::Ui, text: &str) -> egui::Response {
|
||||
ui.label(RichText::new(text).strong())
|
||||
}
|
||||
|
||||
/// Visual Effect Settings: the selection area (window and crossing fills) and the objects the
|
||||
/// cursor never highlights (PREVIEWFILTER). Changes apply at once, as on the Options tabs.
|
||||
/// Visual Effect Settings: how the object under the cursor is highlighted (PREVIEWEFFECT: Dash,
|
||||
/// Thicken or Both, as AutoCAD offers it) and how selected objects are (SELECTIONEFFECT: dashed
|
||||
/// or redrawn in the selection colour), the selection area (window and crossing fills) and the
|
||||
/// objects the cursor never highlights (PREVIEWFILTER). Changes apply at once, as on the Options
|
||||
/// tabs.
|
||||
fn visual_effects(ctx: &egui::Context, st: &cadcraft_engine::Settings, open: &mut bool, changes: &mut Map<String, Value>) {
|
||||
let mut close = false;
|
||||
egui::Window::new(crate::tl!("Visual Effect Settings"))
|
||||
@@ -473,6 +476,23 @@ fn visual_effects(ctx: &egui::Context, st: &cadcraft_engine::Settings, open: &mu
|
||||
.show(ctx, |ui| {
|
||||
ui.columns(2, |cols| {
|
||||
let [left, right] = cols else { return };
|
||||
heading(left, crate::tl!("Selection Preview Effect"));
|
||||
left.horizontal(|ui| {
|
||||
for (v, label) in [(0u8, crate::tl!("Dash")), (1, crate::tl!("Thicken")), (2, crate::tl!("Both"))] {
|
||||
if ui.radio(st.previeweffect == v, label).clicked() {
|
||||
changes.insert("PREVIEWEFFECT".into(), json!(v));
|
||||
}
|
||||
}
|
||||
});
|
||||
heading(left, crate::tl!("Selected Objects Effect"));
|
||||
left.horizontal(|ui| {
|
||||
for (v, label) in [(0u8, crate::tl!("Dashed")), (1, crate::tl!("Selection color"))] {
|
||||
if ui.radio(st.selectioneffect == v, label).clicked() {
|
||||
changes.insert("SELECTIONEFFECT".into(), json!(v));
|
||||
}
|
||||
}
|
||||
});
|
||||
left.add_space(6.0);
|
||||
heading(left, crate::tl!("Selection Area Effect"));
|
||||
let mut area = st.selectionarea;
|
||||
if left.checkbox(&mut area, crate::tl!("Indicate selection area")).changed() {
|
||||
|
||||
@@ -235,15 +235,23 @@ fn selection_highlight_settings_set_save_and_show_in_the_selection_tab() {
|
||||
] {
|
||||
assert!(text.contains(label), "{label} missing from:\n{text}");
|
||||
}
|
||||
// HIGHLIGHT, SELECTIONEFFECT and PREVIEWEFFECT are typed, not offered (as in AutoCAD), so
|
||||
// the highlight can't be switched off or changed by accident.
|
||||
// HIGHLIGHT is typed, not offered (as in AutoCAD), so the highlight can't be switched off by
|
||||
// accident; the effects are in Visual Effect Settings, not on the tab.
|
||||
for label in ["Highlight selected objects", "Preview effect", "Dashed"] {
|
||||
assert!(!text.contains(label), "{label} offered");
|
||||
}
|
||||
// Visual Effect Settings: the selection area and the preview filter.
|
||||
// Visual Effect Settings: the preview and selection effects, the selection area and the
|
||||
// preview filter.
|
||||
ctx.data_mut(|d| d.insert_temp(egui::Id::unique("cc_options_visual_effects"), true));
|
||||
let text = render(&mut a, &ctx);
|
||||
for label in [
|
||||
"Selection Preview Effect",
|
||||
"Dash",
|
||||
"Thicken",
|
||||
"Both",
|
||||
"Selected Objects Effect",
|
||||
"Dashed",
|
||||
"Selection color",
|
||||
"Selection Area Effect",
|
||||
"Indicate selection area",
|
||||
"Window selection color:",
|
||||
@@ -256,6 +264,37 @@ fn selection_highlight_settings_set_save_and_show_in_the_selection_tab() {
|
||||
}
|
||||
}
|
||||
|
||||
/// Visual Effect Settings: each preview and selection effect choice sets its variable.
|
||||
#[test]
|
||||
fn the_visual_effect_choices_set_their_variables() {
|
||||
use egui_kittest::Harness;
|
||||
use egui_kittest::kittest::Queryable;
|
||||
|
||||
let mut a = app();
|
||||
a.cmdline("options");
|
||||
a.ui.dialog = Some("options:selection".into());
|
||||
let mut h =
|
||||
Harness::builder().with_context_setup(cadcraft_ui_egui::framework::install_headless).with_size(egui::vec2(1600.0, 1000.0)).build_ui_state(
|
||||
|ui, app: &mut CadApp| {
|
||||
app.logic(ui.ctx());
|
||||
app.ui(ui);
|
||||
},
|
||||
a,
|
||||
);
|
||||
h.ctx.data_mut(|d| d.insert_temp(egui::Id::unique("cc_options_visual_effects"), true));
|
||||
h.run_steps(2);
|
||||
for (label, v) in [("Thicken", 1), ("Both", 2), ("Dash", 0)] {
|
||||
h.get_by_label(label).click();
|
||||
h.run_steps(2);
|
||||
assert_eq!(h.state().session.settings.previeweffect, v, "{label}");
|
||||
}
|
||||
for (label, v) in [("Dashed", 0), ("Selection color", 1), ("Dashed", 0)] {
|
||||
h.get_by_label(label).click();
|
||||
h.run_steps(2);
|
||||
assert_eq!(h.state().session.settings.selectioneffect, v, "{label}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reset_brings_back_hidden_menu_bar_toolbar_and_status_bar() {
|
||||
// #1240: with the in-window menu bar, the toolbar and the status bar hidden, OPTIONS ▸ Reset
|
||||
|
||||
Reference in new issue
Block a user