refactor: accept size in popup helper and add offset
This commit is contained in:
parent
7a9ecb1082
commit
8d4e7e1cf1
1 changed files with 8 additions and 6 deletions
|
|
@ -36,6 +36,7 @@ where
|
||||||
pub fn get_popup_settings(
|
pub fn get_popup_settings(
|
||||||
parent: iced_native::window::Id,
|
parent: iced_native::window::Id,
|
||||||
id: iced_native::window::Id,
|
id: iced_native::window::Id,
|
||||||
|
size: (u32, u32),
|
||||||
width_padding: Option<i32>,
|
width_padding: Option<i32>,
|
||||||
height_padding: Option<i32>,
|
height_padding: Option<i32>,
|
||||||
) -> SctkPopupSettings {
|
) -> SctkPopupSettings {
|
||||||
|
|
@ -57,11 +58,11 @@ pub fn get_popup_settings(
|
||||||
Err(_) => Some(12),
|
Err(_) => Some(12),
|
||||||
})
|
})
|
||||||
.unwrap_or(16);
|
.unwrap_or(16);
|
||||||
let (anchor, gravity) = match anchor {
|
let (offset, anchor, gravity) = match anchor {
|
||||||
PanelAnchor::Left => (Anchor::Right, Gravity::Right),
|
PanelAnchor::Left => ((8, 0), Anchor::Right, Gravity::Right),
|
||||||
PanelAnchor::Right => (Anchor::Left, Gravity::Left),
|
PanelAnchor::Right => ((-8, 0), Anchor::Left, Gravity::Left),
|
||||||
PanelAnchor::Top => (Anchor::Bottom, Gravity::Bottom),
|
PanelAnchor::Top => ((0, -8), Anchor::Bottom, Gravity::Bottom),
|
||||||
PanelAnchor::Bottom => (Anchor::Top, Gravity::Top),
|
PanelAnchor::Bottom => ((0, 8), Anchor::Top, Gravity::Top),
|
||||||
};
|
};
|
||||||
SctkPopupSettings {
|
SctkPopupSettings {
|
||||||
parent,
|
parent,
|
||||||
|
|
@ -69,7 +70,8 @@ pub fn get_popup_settings(
|
||||||
positioner: SctkPositioner {
|
positioner: SctkPositioner {
|
||||||
anchor,
|
anchor,
|
||||||
gravity,
|
gravity,
|
||||||
size: (200, 200),
|
offset,
|
||||||
|
size,
|
||||||
anchor_rect: Rectangle {
|
anchor_rect: Rectangle {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 0,
|
y: 0,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue