]> Pileus Git - ~andy/gtk/commitdiff
new properties "horizontal-offset" and "vertical-offset" that determines
authorSoeren Sandmann <sandmann@daimi.au.dk>
Sat, 12 Jul 2003 23:25:14 +0000 (23:25 +0000)
committerSøren Sandmann Pedersen <ssp@src.gnome.org>
Sat, 12 Jul 2003 23:25:14 +0000 (23:25 +0000)
Sun Jul 13 01:37:51 2003  Soeren Sandmann  <sandmann@daimi.au.dk>

* gtk/gtkmenu.c (gtk_menu_class_init): new properties
"horizontal-offset" and "vertical-offset" that determines the
position of the menu when it is a submenu.

* gtk/gtkmenuitem.c (gtk_menu_item_position_menu): position
submenus according to new vertical- and horizontal-offset
properties.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkmenu.c
gtk/gtkmenuitem.c

index 7cbdc0e9da3605dafe9f38cf9e68a4cad549f4e6..ad0d87b3b915ff966594c664fd0d595482b12f3c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Sun Jul 13 01:37:51 2003  Soeren Sandmann  <sandmann@daimi.au.dk>
+
+       * gtk/gtkmenu.c (gtk_menu_class_init): new properties
+       "horizontal-offset" and "vertical-offset" that determines the
+       position of the menu when it is a submenu. 
+
+       * gtk/gtkmenuitem.c (gtk_menu_item_position_menu): position
+       submenus according to new vertical- and horizontal-offset
+       properties.
+
 Sat Jul 12 16:16:04 2003  Kristian Rietveld  <kris@gtk.org>
 
        Merged from stable.
index 7cbdc0e9da3605dafe9f38cf9e68a4cad549f4e6..ad0d87b3b915ff966594c664fd0d595482b12f3c 100644 (file)
@@ -1,3 +1,13 @@
+Sun Jul 13 01:37:51 2003  Soeren Sandmann  <sandmann@daimi.au.dk>
+
+       * gtk/gtkmenu.c (gtk_menu_class_init): new properties
+       "horizontal-offset" and "vertical-offset" that determines the
+       position of the menu when it is a submenu. 
+
+       * gtk/gtkmenuitem.c (gtk_menu_item_position_menu): position
+       submenus according to new vertical- and horizontal-offset
+       properties.
+
 Sat Jul 12 16:16:04 2003  Kristian Rietveld  <kris@gtk.org>
 
        Merged from stable.
index 7cbdc0e9da3605dafe9f38cf9e68a4cad549f4e6..ad0d87b3b915ff966594c664fd0d595482b12f3c 100644 (file)
@@ -1,3 +1,13 @@
+Sun Jul 13 01:37:51 2003  Soeren Sandmann  <sandmann@daimi.au.dk>
+
+       * gtk/gtkmenu.c (gtk_menu_class_init): new properties
+       "horizontal-offset" and "vertical-offset" that determines the
+       position of the menu when it is a submenu. 
+
+       * gtk/gtkmenuitem.c (gtk_menu_item_position_menu): position
+       submenus according to new vertical- and horizontal-offset
+       properties.
+
 Sat Jul 12 16:16:04 2003  Kristian Rietveld  <kris@gtk.org>
 
        Merged from stable.
index 7cbdc0e9da3605dafe9f38cf9e68a4cad549f4e6..ad0d87b3b915ff966594c664fd0d595482b12f3c 100644 (file)
@@ -1,3 +1,13 @@
+Sun Jul 13 01:37:51 2003  Soeren Sandmann  <sandmann@daimi.au.dk>
+
+       * gtk/gtkmenu.c (gtk_menu_class_init): new properties
+       "horizontal-offset" and "vertical-offset" that determines the
+       position of the menu when it is a submenu. 
+
+       * gtk/gtkmenuitem.c (gtk_menu_item_position_menu): position
+       submenus according to new vertical- and horizontal-offset
+       properties.
+
 Sat Jul 12 16:16:04 2003  Kristian Rietveld  <kris@gtk.org>
 
        Merged from stable.
index 7cbdc0e9da3605dafe9f38cf9e68a4cad549f4e6..ad0d87b3b915ff966594c664fd0d595482b12f3c 100644 (file)
@@ -1,3 +1,13 @@
+Sun Jul 13 01:37:51 2003  Soeren Sandmann  <sandmann@daimi.au.dk>
+
+       * gtk/gtkmenu.c (gtk_menu_class_init): new properties
+       "horizontal-offset" and "vertical-offset" that determines the
+       position of the menu when it is a submenu. 
+
+       * gtk/gtkmenuitem.c (gtk_menu_item_position_menu): position
+       submenus according to new vertical- and horizontal-offset
+       properties.
+
 Sat Jul 12 16:16:04 2003  Kristian Rietveld  <kris@gtk.org>
 
        Merged from stable.
index 806115101cdb9386369a167fbaf1e10e9b4a3618..81907cfd066d301fe570feea40128f66a1a78720 100644 (file)
@@ -274,6 +274,24 @@ gtk_menu_class_init (GtkMenuClass *class)
                                                             1,
                                                             G_PARAM_READABLE));
 
+  gtk_widget_class_install_style_property (widget_class,
+                                          g_param_spec_int ("vertical-offset",
+                                                            _("Vertical Offset"),
+                                                            _("When the menu is a submenu, position it this number of pixels offset vertically"),
+                                                            G_MININT,
+                                                            G_MAXINT,
+                                                            0,
+                                                            G_PARAM_READABLE));
+
+  gtk_widget_class_install_style_property (widget_class,
+                                          g_param_spec_int ("horizontal-offset",
+                                                            _("Horizontal Offset"),
+                                                            _("When the menu is a submenu, position it this number of pixels offset horizontally"),
+                                                            G_MININT,
+                                                            G_MAXINT,
+                                                            -2,
+                                                            G_PARAM_READABLE));
+
   object_class->destroy = gtk_menu_destroy;
   
   widget_class->realize = gtk_menu_realize;
index a2a98a9cda581ae1ff9bca91f9775d9e78aeaae3..eca9b46629c7398c0d3d1aca416ea549826bdf15 100644 (file)
@@ -971,6 +971,23 @@ gtk_menu_item_popup_submenu (gpointer data)
                    0);
 }
 
+static void
+get_offsets (GtkMenu *menu,
+            gint    *horizontal_offset,
+            gint    *vertical_offset)
+{
+  gint vertical_padding;
+  
+  gtk_widget_style_get (GTK_WIDGET (menu),
+                       "horizontal_offset", horizontal_offset,
+                       "vertical_offset", vertical_offset,
+                       "vertical_padding", &vertical_padding,
+                       NULL);
+
+  *vertical_offset -= GTK_WIDGET (menu)->style->ythickness;
+  *vertical_offset -= vertical_padding;
+}
+
 static void
 gtk_menu_item_position_menu (GtkMenu  *menu,
                             gint     *x,
@@ -987,6 +1004,9 @@ gtk_menu_item_position_menu (GtkMenu  *menu,
   GtkTextDirection direction;
   GdkRectangle monitor;
   gint monitor_num;
+  gint horizontal_offset;
+  gint vertical_offset;
+  gint parent_xthickness;
 
   g_return_if_fail (menu != NULL);
   g_return_if_fail (x != NULL);
@@ -995,6 +1015,9 @@ gtk_menu_item_position_menu (GtkMenu  *menu,
   menu_item = GTK_MENU_ITEM (user_data);
   widget = GTK_WIDGET (user_data);
 
+  if (push_in)
+    *push_in = FALSE;
+
   direction = gtk_widget_get_direction (widget);
 
   twidth = GTK_WIDGET (menu)->requisition.width;
@@ -1015,6 +1038,8 @@ gtk_menu_item_position_menu (GtkMenu  *menu,
   tx += widget->allocation.x;
   ty += widget->allocation.y;
 
+  get_offsets (menu, &horizontal_offset, &vertical_offset);
+  
   switch (menu_item->submenu_placement)
     {
     case GTK_TOP_BOTTOM:
@@ -1038,6 +1063,7 @@ gtk_menu_item_position_menu (GtkMenu  *menu,
 
     case GTK_LEFT_RIGHT:
       parent_menu_item = GTK_MENU (widget->parent)->parent_menu_item;
+      parent_xthickness = widget->parent->style->xthickness;
       if (parent_menu_item && 
          !GTK_MENU (widget->parent)->torn_off && 
          !GTK_MENU_SHELL (menu)->active)
@@ -1050,28 +1076,28 @@ gtk_menu_item_position_menu (GtkMenu  *menu,
       switch (menu_item->submenu_direction)
        {
        case GTK_DIRECTION_LEFT:
-         if ((tx - twidth) >= monitor.x)
-           tx -= twidth;
+         if ((tx - twidth - parent_xthickness - horizontal_offset) >= monitor.x)
+           tx -= twidth + parent_xthickness + horizontal_offset;
          else
            {
              menu_item->submenu_direction = GTK_DIRECTION_RIGHT;
-             tx += widget->allocation.width - 5;
+             tx += widget->allocation.width + parent_xthickness + horizontal_offset;
            }
          break;
 
        case GTK_DIRECTION_RIGHT:
-         if ((tx + widget->allocation.width + twidth - 5) <= monitor.x + monitor.width)
-           tx += widget->allocation.width - 5;
+         if ((tx + widget->allocation.width + parent_xthickness + horizontal_offset + twidth) <= monitor.x + monitor.width)
+           tx += widget->allocation.width + parent_xthickness + horizontal_offset;
          else
            {
              menu_item->submenu_direction = GTK_DIRECTION_LEFT;
-             tx -= twidth;
+             tx -= twidth + parent_xthickness + horizontal_offset;
            }
          break;
        }
 
-      ty += widget->allocation.height / 4;
-
+      ty += vertical_offset;
+      
       /* If the height of the menu doesn't fit we move it upward. */
       ty = CLAMP (ty, monitor.y, MAX (monitor.y, monitor.y + monitor.height - theight));
       break;