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:
parent
391aa3a76f
commit
86ca1b7033
2 changed files with 15 additions and 2 deletions
|
|
@ -691,7 +691,20 @@ impl OpenCADStudio {
|
||||||
if !tab.is_start {
|
if !tab.is_start {
|
||||||
let anchor_x = (popup.anchor.x + 12.0).max(0.0);
|
let anchor_x = (popup.anchor.x + 12.0).max(0.0);
|
||||||
let anchor_y = (popup.anchor.y + 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() {
|
for (idx, item) in popup.items.iter().enumerate() {
|
||||||
let is_sel = idx == popup.selected;
|
let is_sel = idx == popup.selected;
|
||||||
let label = item.label;
|
let label = item.label;
|
||||||
|
|
@ -727,7 +740,6 @@ impl OpenCADStudio {
|
||||||
}
|
}
|
||||||
let menu_panel = container(col)
|
let menu_panel = container(col)
|
||||||
.padding(2)
|
.padding(2)
|
||||||
.width(iced::Length::Shrink)
|
|
||||||
.style(|_: &Theme| container::Style {
|
.style(|_: &Theme| container::Style {
|
||||||
background: Some(Background::Color(Color {
|
background: Some(Background::Color(Color {
|
||||||
r: 0.10,
|
r: 0.10,
|
||||||
|
|
|
||||||
|
|
@ -111,6 +111,7 @@ pub struct GripMenuItem {
|
||||||
/// default no-op-equivalent — picking it just starts the regular
|
/// default no-op-equivalent — picking it just starts the regular
|
||||||
/// stretch drag, identical to clicking the grip with no popup open.
|
/// stretch drag, identical to clicking the grip with no popup open.
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||||
|
#[allow(dead_code)]
|
||||||
pub enum GripMenuAction {
|
pub enum GripMenuAction {
|
||||||
Stretch,
|
Stretch,
|
||||||
Lengthen,
|
Lengthen,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue