refactor(ui): use pin for anchored overlays

This commit is contained in:
Hakan Seven committed 2026-07-28 01:25:39 +03:00
1 parent b9de8940bc
commit ce1091cea5
5 files changed
+51 -98

No files matched your search

+11
View File
@@ -2,6 +2,17 @@
/// Change this to scale the ribbon, layer manager rows, and property panel rows uniformly.
pub const ROW_H: f32 = 26.0;
/// Place `content` at fixed top-left coordinates inside a fill-sized layer.
/// Negative coordinates clamp to the layer edge.
pub fn pin_at<'a, Message: 'a>(
position: iced::Point,
content: impl Into<iced::Element<'a, Message>>,
) -> iced::Element<'a, Message> {
iced::widget::pin(content)
.position(iced::Point::new(position.x.max(0.0), position.y.max(0.0)))
.into()
}
pub mod color_select;
pub mod command_line;
pub mod icons;
+2 -10
View File
@@ -2,7 +2,7 @@
//! two or more overlapping objects. Each row names a candidate; clicking it
//! adds that object to the current selection. Clicking outside dismisses it.
use iced::widget::{button, column, container, mouse_area, opaque, row, text, Space};
use iced::widget::{button, column, container, mouse_area, opaque, text};
use iced::{Background, Border, Color, Element, Fill, Length, Theme};
use crate::app::Message;
@@ -30,15 +30,7 @@ pub fn cycle_popup_overlay(
})
.width(Length::Fixed(150.0));
let positioned = column![
Space::new().height(Length::Fixed(anchor.y.max(0.0))),
row![
Space::new().width(Length::Fixed(anchor.x.max(0.0))),
opaque(panel),
],
]
.width(Fill)
.height(Fill);
let positioned = crate::ui::pin_at(anchor, opaque(panel));
mouse_area(positioned).on_press(Message::CycleCancel).into()
}