feat(selection): highlight opacity and extra width (#1823)

Options > Selection gains "Selection highlight opacity" and "Selection
highlight extra width". Below full opacity the object's own colour
shows through the highlight. The selection overlay draws with its own
copy of the frame uniforms: transparency on, and every line widened by
the extra width. Drawings opened at startup now get the selection
colour settings too; they used to keep the defaults until a setting
changed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Hakan SevenandClaude Opus 5.5 committed 2026-10-16 01:07:23 +03:00
1 parent 977135fbbd
commit 38d81bf838
38 files changed
+247 -89

No files matched your search

+14 -9
View File
@@ -357,6 +357,11 @@ pub struct ModelSpaceThemeConfig {
pub selection_crossing_color: u8,
/// SELECTIONEFFECTCOLOR: ACI index for selected entities highlight (0 = Theme Primary, 1..=255 = ACI).
pub selection_highlight_color: u8,
/// Selection highlight opacity in percent (10–100); below 100 the
/// object's own colour shows through.
pub selection_highlight_opacity: u8,
/// Extra screen pixels the selection highlight is drawn wider (0–6).
pub selection_highlight_widen: u8,
/// SELECTIONEFFECT: whether selected objects glow with solid highlight (true) or dash (false).
pub selection_effect: bool,
/// SELECTIONPREVIEW bitmask: 1 = idle, 2 = during a command, 3 = both.
@@ -386,6 +391,8 @@ impl Default for ModelSpaceThemeConfig {
selection_window_color: 0,
selection_crossing_color: 0,
selection_highlight_color: 0,
selection_highlight_opacity: 100,
selection_highlight_widen: 0,
selection_effect: true,
selection_preview: 3,
grip_size: 5,
@@ -437,15 +444,13 @@ impl ModelSpaceThemeConfig {
/// Resolve active selection highlight overlay color as [f32; 4].
pub fn resolve_selection_color(&self) -> [f32; 4] {
if self.selection_highlight_color == 0 {
crate::scene::model::wire_model::WireModel::SELECTED
} else if let Some((r, g, b)) =
codec::types::aci_table::aci_to_rgb(self.selection_highlight_color)
{
[r as f32 / 255.0, g as f32 / 255.0, b as f32 / 255.0, 1.0]
} else {
crate::scene::model::wire_model::WireModel::SELECTED
}
let mut color = codec::types::aci_table::aci_to_rgb(self.selection_highlight_color)
.filter(|_| self.selection_highlight_color != 0)
.map_or(crate::scene::model::wire_model::WireModel::SELECTED, |(r, g, b)| {
[r as f32 / 255.0, g as f32 / 255.0, b as f32 / 255.0, 1.0]
});
color[3] = f32::from(self.selection_highlight_opacity.clamp(10, 100)) / 100.0;
color
}
}
+2
View File
@@ -2674,6 +2674,8 @@ pub enum Message {
SelectionAreaToggled(bool),
/// Change Selection Area opacity percentage (0–100, SELECTIONAREAOPACITY).
SelectionOpacityChanged(u8),
SelectionHighlightOpacityChanged(u8),
SelectionHighlightWidenChanged(u8),
/// Change Window selection color ACI index (0 = Theme Primary, 1..=255 = ACI).
SelectionWindowColorChanged(u8),
/// Change Crossing selection color ACI index (0 = Theme Success, 1..=255 = ACI).
+9 -1
View File
@@ -1278,6 +1278,9 @@ impl OpenCADStudio {
return;
}
tab.scene.model_lineweight_scale = self.lineweight_display_scale as f32 / 100.0;
tab.scene.selection_color = self.model_space.resolve_selection_color();
tab.scene.selection_effect = self.model_space.selection_effect;
tab.scene.selection_widen = f32::from(self.model_space.selection_highlight_widen.min(6));
if bg.is_none() && paper_bg.is_none() {
return;
}
@@ -1551,6 +1554,7 @@ impl OpenCADStudio {
let paper_bg = self.model_space.resolve_paper_bg();
let sel_color = self.model_space.resolve_selection_color();
let sel_effect = self.model_space.selection_effect;
let sel_widen = f32::from(self.model_space.selection_highlight_widen.min(6));
self.default_bg_color = Some(model_bg);
self.default_paper_bg_color = Some(paper_bg);
@@ -1563,10 +1567,14 @@ impl OpenCADStudio {
tab.scene.paper_bg_color = paper_bg;
tab.scene.selection_color = sel_color;
tab.scene.selection_effect = sel_effect;
let old_sel_widen = std::mem::replace(&mut tab.scene.selection_widen, sel_widen);
tab.bg_color = Some(model_bg);
tab.paper_bg_color = Some(paper_bg);
if old_sel_color != sel_color || old_sel_effect != sel_effect {
if old_sel_color != sel_color
|| old_sel_effect != sel_effect
|| old_sel_widen != sel_widen
{
tab.scene.selection_generation = tab.scene.selection_generation.wrapping_add(1);
}
+14
View File
@@ -9175,6 +9175,20 @@ impl OpenCADStudio {
Task::none()
}
Message::SelectionHighlightOpacityChanged(opacity) => {
self.model_space.selection_highlight_opacity = opacity.clamp(10, 100);
self.sync_model_space_theme(false);
self.persist_settings_if_changed();
Task::none()
}
Message::SelectionHighlightWidenChanged(widen) => {
self.model_space.selection_highlight_widen = widen.min(6);
self.sync_model_space_theme(false);
self.persist_settings_if_changed();
Task::none()
}
Message::GripSizeChanged(size) => {
self.model_space.grip_size = size.clamp(1, 25);
self.sync_model_space_theme(false);