fix(grip): popup sizes to widest label + full-row highlight

The previous single-widget refactor left the column at
`Length::Shrink` and the buttons at `Length::Fill`, which iced
resolves to a zero-width column — the popup degenerated into a
1-pixel vertical line. Set the column to a fixed pixel width
derived from the longest item's label (and restore `width(Fill)`
on the buttons) so the selection highlight covers the full row
instead of just the text glyphs.

Also silences a `dead_code` warning on `GripMenuAction` variants
that the Phase 2 / 3 wiring will consume next.
This commit is contained in:
Hakan Seven committed 2026-05-29 10:00:30 +03:00
1 parent 391aa3a76f
commit 86ca1b7033
2 files changed
+15 -2

No files matched your search

+14 -2
View File
@@ -691,7 +691,20 @@ impl OpenCADStudio {
if !tab.is_start {
let anchor_x = (popup.anchor.x + 12.0).max(0.0);
let anchor_y = (popup.anchor.y + 12.0).max(0.0);
let mut col = column![].spacing(0);
// Size the row to the widest label so the selection
// highlight fills the whole row instead of just the
// text glyphs. ~7 px per character at size 12 + the
// horizontal padding (10 + 10).
let max_len = popup
.items
.iter()
.map(|i| i.label.chars().count())
.max()
.unwrap_or(8) as f32;
let row_w = max_len * 7.0 + 24.0;
let mut col = column![]
.spacing(0)
.width(iced::Length::Fixed(row_w));
for (idx, item) in popup.items.iter().enumerate() {
let is_sel = idx == popup.selected;
let label = item.label;
@@ -727,7 +740,6 @@ impl OpenCADStudio {
}
let menu_panel = container(col)
.padding(2)
.width(iced::Length::Shrink)
.style(|_: &Theme| container::Style {
background: Some(Background::Color(Color {
r: 0.10,
+1
View File
@@ -111,6 +111,7 @@ pub struct GripMenuItem {
/// default no-op-equivalent — picking it just starts the regular
/// stretch drag, identical to clicking the grip with no popup open.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[allow(dead_code)]
pub enum GripMenuAction {
Stretch,
Lengthen,