[gtk+/wip/attachment-rectangle] menu: add resize_attachment_rectangle ()
- From: William Hua <williamhua src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/attachment-rectangle] menu: add resize_attachment_rectangle ()
- Date: Tue, 25 Aug 2015 15:14:48 +0000 (UTC)
commit e413f55c0ab13408494781b9f674cbc2b7ea10b8
Author: William Hua <william hua canonical com>
Date: Tue Aug 25 16:13:27 2015 +0100
menu: add resize_attachment_rectangle ()
gtk/gtkmenu.c | 94 ++++++++++++++++++++++-----------------------------------
1 files changed, 36 insertions(+), 58 deletions(-)
---
diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c
index b5f6b2f..611ea1c 100644
--- a/gtk/gtkmenu.c
+++ b/gtk/gtkmenu.c
@@ -4516,6 +4516,40 @@ gtk_menu_deactivate (GtkMenuShell *menu_shell)
}
static void
+resize_attachment_rectangle (GdkRectangle *rectangle,
+ const GtkBorder *border,
+ GdkAttachmentOptions options)
+{
+ switch (options & GDK_ATTACHMENT_ATTACH_MASK)
+ {
+ case GDK_ATTACHMENT_ATTACH_TOP_EDGE:
+ case GDK_ATTACHMENT_ATTACH_BOTTOM_EDGE:
+ rectangle->y += border->bottom;
+ rectangle->height -= border->top + border->bottom;
+
+ if (options & GDK_ATTACHMENT_ALIGN_MASK)
+ {
+ rectangle->x -= border->left;
+ rectangle->width += border->left + border->right;
+ }
+
+ break;
+ case GDK_ATTACHMENT_ATTACH_LEFT_EDGE:
+ case GDK_ATTACHMENT_ATTACH_RIGHT_EDGE:
+ rectangle->x += border->right;
+ rectangle->width -= border->left + border->right;
+
+ if (options & GDK_ATTACHMENT_ALIGN_MASK)
+ {
+ rectangle->y -= border->top;
+ rectangle->height += border->top + border->bottom;
+ }
+
+ break;
+ }
+}
+
+static void
gtk_menu_position (GtkMenu *menu,
gboolean set_scroll_offset)
{
@@ -4554,35 +4588,7 @@ gtk_menu_position (GtkMenu *menu,
}
allocation = priv->attach_rect;
-
- switch (priv->attach_options & GDK_ATTACHMENT_ATTACH_MASK)
- {
- case GDK_ATTACHMENT_ATTACH_TOP_EDGE:
- case GDK_ATTACHMENT_ATTACH_BOTTOM_EDGE:
- allocation.y += border.bottom;
- allocation.height -= border.top + border.bottom;
-
- if (priv->attach_options & GDK_ATTACHMENT_ALIGN_MASK)
- {
- allocation.x -= border.left;
- allocation.width += border.left + border.right;
- }
-
- break;
- case GDK_ATTACHMENT_ATTACH_LEFT_EDGE:
- case GDK_ATTACHMENT_ATTACH_RIGHT_EDGE:
- allocation.x += border.right;
- allocation.width -= border.left + border.right;
-
- if (priv->attach_options & GDK_ATTACHMENT_ALIGN_MASK)
- {
- allocation.y -= border.top;
- allocation.height += border.top + border.bottom;
- }
-
- break;
- }
-
+ resize_attachment_rectangle (&allocation, &border, priv->attach_options);
gdk_window_set_attachment_rectangle (menu_window, &parent_origin, &allocation,
priv->attach_options);
return;
}
@@ -4597,35 +4603,7 @@ gtk_menu_position (GtkMenu *menu,
gdk_window_get_root_coords (parent_window, allocation.x, allocation.y, &allocation.x,
&allocation.y);
allocation.x -= parent_origin.x;
allocation.y -= parent_origin.y;
-
- switch (priv->attach_options & GDK_ATTACHMENT_ATTACH_MASK)
- {
- case GDK_ATTACHMENT_ATTACH_TOP_EDGE:
- case GDK_ATTACHMENT_ATTACH_BOTTOM_EDGE:
- allocation.y += border.bottom;
- allocation.height -= border.top + border.bottom;
-
- if (priv->attach_options & GDK_ATTACHMENT_ALIGN_MASK)
- {
- allocation.x -= border.left;
- allocation.width += border.left + border.right;
- }
-
- break;
- case GDK_ATTACHMENT_ATTACH_LEFT_EDGE:
- case GDK_ATTACHMENT_ATTACH_RIGHT_EDGE:
- allocation.x += border.right;
- allocation.width -= border.left + border.right;
-
- if (priv->attach_options & GDK_ATTACHMENT_ALIGN_MASK)
- {
- allocation.y -= border.top;
- allocation.height += border.top + border.bottom;
- }
-
- break;
- }
-
+ resize_attachment_rectangle (&allocation, &border, priv->attach_options);
gdk_window_set_attachment_rectangle (menu_window, &parent_origin, &allocation,
priv->attach_options);
return;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]