From 8d4e7e1cf16ffd9b47ae72088cb2131f0f9c01a7 Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Tue, 15 Nov 2022 11:22:27 +0100 Subject: [PATCH] refactor: accept size in popup helper and add offset --- src/applet/mod.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/applet/mod.rs b/src/applet/mod.rs index 14ba6f1..9ac33ca 100644 --- a/src/applet/mod.rs +++ b/src/applet/mod.rs @@ -36,6 +36,7 @@ where pub fn get_popup_settings( parent: iced_native::window::Id, id: iced_native::window::Id, + size: (u32, u32), width_padding: Option, height_padding: Option, ) -> SctkPopupSettings { @@ -57,11 +58,11 @@ pub fn get_popup_settings( Err(_) => Some(12), }) .unwrap_or(16); - let (anchor, gravity) = match anchor { - PanelAnchor::Left => (Anchor::Right, Gravity::Right), - PanelAnchor::Right => (Anchor::Left, Gravity::Left), - PanelAnchor::Top => (Anchor::Bottom, Gravity::Bottom), - PanelAnchor::Bottom => (Anchor::Top, Gravity::Top), + let (offset, anchor, gravity) = match anchor { + PanelAnchor::Left => ((8, 0), Anchor::Right, Gravity::Right), + PanelAnchor::Right => ((-8, 0), Anchor::Left, Gravity::Left), + PanelAnchor::Top => ((0, -8), Anchor::Bottom, Gravity::Bottom), + PanelAnchor::Bottom => ((0, 8), Anchor::Top, Gravity::Top), }; SctkPopupSettings { parent, @@ -69,7 +70,8 @@ pub fn get_popup_settings( positioner: SctkPositioner { anchor, gravity, - size: (200, 200), + offset, + size, anchor_rect: Rectangle { x: 0, y: 0,