feat(ui): anchor every ribbon dropdown and status-bar popup to its widget, flipping at window edges

All ribbon dropdowns (tool dropdowns, undo/redo history, and the layer /
colour / linetype / lineweight / style combos) and all status-bar popups
(scale, units, OSNAP, isolate, filter, customization menu, layout list)
now open directly at their widget instead of at a layout-estimated
position, and flip to the other side when the panel would cross a window
edge.

Each dropdown/pill widget is wrapped in a transparent PosReport that
records its screen bounds into a thread-local map on draw. The overlays
read those bounds:
- Ribbon: Ribbon::dd_anchor(id, panel_w, win_w) returns
  (align_right, h_pad, top); position_ribbon_dropdown places the panel
  below the widget, flipping right-aligned near the right edge.
- Status bar: popup builders take (pill_bounds, win_size) and call
  popup::position_statusbar_popup / popup_anchor, opening just above the
  pill and flipping left/right at the window edge.

The window size is now tracked (win_size, set on WindowResized). The old
layout estimators compute_dropdown_left / compute_layer_combo_left /
compute_prop_combo_left / compute_history_dropdown_left and
osnap_popup_right_offset are deleted.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-07-05 18:51:54 +03:00
1 parent 56e48b8d0f
commit 39043e6e56
13 files changed
+310 -383

No files matched your search

+24 -6
View File
@@ -1262,13 +1262,14 @@ impl OpenCADStudio {
.width(Fill)
.height(Fill);
let win = self.win_size;
let sb_pill = crate::ui::wrap_bar::dropdown_bounds;
let snap_layer: Element<'_, Message> = if self.snap_popup_open {
crate::ui::popup::snap_popup::snap_popup_overlay(
&self.snapper,
crate::ui::statusbar::osnap_popup_right_offset(
&self.statusbar_config,
tab.scene.viewport_count(),
),
sb_pill(crate::ui::statusbar::SB_OSNAP_ID),
win,
)
} else {
iced::widget::Space::new().width(0).height(0).into()
@@ -1281,13 +1282,19 @@ impl OpenCADStudio {
tab.scene.annotation_scale,
tab.scene.first_viewport_scale(),
tab.scene.scale_list(),
sb_pill(crate::ui::statusbar::SB_SCALE_ID),
win,
)
} else {
iced::widget::Space::new().width(0).height(0).into()
};
let statusbar_menu_layer: Element<'_, Message> = if self.statusbar_menu_open {
crate::ui::statusbar::statusbar_menu::statusbar_menu_overlay(&self.statusbar_config)
crate::ui::statusbar::statusbar_menu::statusbar_menu_overlay(
&self.statusbar_config,
sb_pill(crate::ui::statusbar::SB_MENU_ID),
win,
)
} else {
iced::widget::Space::new().width(0).height(0).into()
};
@@ -1296,13 +1303,19 @@ impl OpenCADStudio {
crate::ui::statusbar::statusbar_menu::layout_list_overlay(
&tab.scene.layout_names(),
&tab.scene.current_layout,
sb_pill(crate::ui::statusbar::SB_LAYOUTLIST_ID),
win,
)
} else {
iced::widget::Space::new().width(0).height(0).into()
};
let units_layer: Element<'_, Message> = if self.units_popup_open {
crate::ui::popup::units_popup::units_popup_overlay(tab.scene.document.header.insertion_units)
crate::ui::popup::units_popup::units_popup_overlay(
tab.scene.document.header.insertion_units,
sb_pill(crate::ui::statusbar::SB_UNITS_ID),
win,
)
} else {
iced::widget::Space::new().width(0).height(0).into()
};
@@ -1311,6 +1324,8 @@ impl OpenCADStudio {
crate::ui::popup::isolate_popup::isolate_popup_overlay(
!tab.scene.selected.is_empty(),
tab.scene.is_isolation_active(),
sb_pill(crate::ui::statusbar::SB_ISOLATE_ID),
win,
)
} else {
iced::widget::Space::new().width(0).height(0).into()
@@ -1326,6 +1341,8 @@ impl OpenCADStudio {
crate::ui::popup::selection_filter_popup::selection_filter_popup_overlay(
types,
&tab.scene.selection_filter,
sb_pill(crate::ui::statusbar::SB_FILTER_ID),
win,
)
} else {
iced::widget::Space::new().width(0).height(0).into()
@@ -1336,6 +1353,7 @@ impl OpenCADStudio {
.dropdown_overlay(
&history_dropdown_labels(&self.tabs[self.active_tab].history.undo_stack),
&history_dropdown_labels(&self.tabs[self.active_tab].history.redo_stack),
self.win_size,
)
.unwrap_or_else(|| iced::widget::Space::new().width(0).height(0).into());