forked from 1b-agent/opencadstudio-upstream
fix(statusbar): open the layout context menu at the clicked tab
The right-click menu was pinned to the screen's bottom-left corner. Each layout tab now records its screen bounds through a PosReport wrapper (which learned runtime-built ids for the dynamic tab names), and the menu anchors next to the clicked tab via the shared status-bar popup positioning, falling back to the left edge only when no bounds were recorded (#428). Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
1 parent
8821bb7131
commit
d6b1307a0e
4 files changed
+30
-20
No files matched your search
+1
-1
@@ -1505,7 +1505,7 @@ impl OpenCADStudio {
|
||||
.unwrap_or_else(|| iced::widget::Space::new().width(0).height(0).into());
|
||||
|
||||
let layout_ctx_layer: Element<'_, Message> = if let Some(name) = &self.layout_context_menu {
|
||||
layout_context_menu_overlay(name)
|
||||
layout_context_menu_overlay(name, win)
|
||||
} else {
|
||||
iced::widget::Space::new().width(0).height(0).into()
|
||||
};
|
||||
|
||||
+7
-11
@@ -935,7 +935,7 @@ pub(super) fn viewport_context_menu_overlay(
|
||||
|
||||
/// A small right-click context menu rendered above the status bar.
|
||||
/// The `name` is the layout tab that was right-clicked.
|
||||
pub(super) fn layout_context_menu_overlay(name: &str) -> Element<'_, Message> {
|
||||
pub(super) fn layout_context_menu_overlay(name: &str, win: (f32, f32)) -> Element<'_, Message> {
|
||||
const MENU_BG: Color = Color {
|
||||
r: 0.17,
|
||||
g: 0.17,
|
||||
@@ -1009,16 +1009,12 @@ pub(super) fn layout_context_menu_overlay(name: &str) -> Element<'_, Message> {
|
||||
.on_press(Message::LayoutContextMenuClose)
|
||||
.on_right_press(Message::LayoutContextMenuClose);
|
||||
|
||||
// Position the menu above the status bar at the left.
|
||||
let positioned = container(menu)
|
||||
.align_bottom(Fill)
|
||||
.align_left(Fill)
|
||||
.padding(iced::Padding {
|
||||
top: 0.0,
|
||||
right: 0.0,
|
||||
bottom: 30.0,
|
||||
left: 8.0,
|
||||
});
|
||||
// Anchor the menu above the status bar next to the right-clicked tab —
|
||||
// its bounds were recorded by the tab's PosReport wrapper (#428). A
|
||||
// missing report (shouldn't happen) falls back to the left edge.
|
||||
let pill = crate::ui::wrap_bar::dropdown_bounds(&format!("SB_LAYOUT_TAB:{name}"));
|
||||
let positioned =
|
||||
crate::ui::popup::position_statusbar_popup(menu.into(), pill, win, 160.0, false);
|
||||
|
||||
stack![catcher, positioned].into()
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user