diff options
author | Soeren Sandmann <sandmann@daimi.au.dk> | 2003-07-06 13:14:28 +0000 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@src.gnome.org> | 2003-07-06 13:14:28 +0000 |
commit | c8515b2f8d22c9856fc58f71398eea9e13695fb1 (patch) | |
tree | 717fed71a7377b7729c73a610f1eb16463bd130d | |
parent | ba999da1d8528afdb7cf810e626bd1ab3946ff17 (diff) | |
download | gtk+-c8515b2f8d22c9856fc58f71398eea9e13695fb1.tar.gz |
add vertical_padding style property.
Sat Jul 5 10:34:00 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkmenu.c: add vertical_padding style property.
* gtk/gtkmenuitem.c: add style properties toggle_spacing,
arrow_spacing and horizontal_padding. Also center separators and
make them a bit taller.
* gtk/*menuitem.c: use new style properties.
* docs/widget_geometry.txt: Add note about GtkMenuItem
* gtk/gtkstyle.c
(gtk_default_draw_vline, gtk_default_draw_hline):
fix +/-1 errors.
(gtk_default_draw_shadow): draw a black border around menus.
* gtk/gtkvseparator, gtk/gtkhseparator.c, gtk/gtkmenuitem.c: fix
calls to gtk_paint_hline() and gtk_paint_vline() (they take x1,
x2 and y1, y2 respectively, not x, width and y, height).
-rw-r--r-- | ChangeLog | 22 | ||||
-rw-r--r-- | ChangeLog.pre-2-10 | 22 | ||||
-rw-r--r-- | ChangeLog.pre-2-4 | 22 | ||||
-rw-r--r-- | ChangeLog.pre-2-6 | 22 | ||||
-rw-r--r-- | ChangeLog.pre-2-8 | 22 | ||||
-rw-r--r-- | docs/widget_geometry.txt | 32 | ||||
-rw-r--r-- | gtk/gtkcheckmenuitem.c | 42 | ||||
-rw-r--r-- | gtk/gtkhseparator.c | 2 | ||||
-rw-r--r-- | gtk/gtkimagemenuitem.c | 36 | ||||
-rw-r--r-- | gtk/gtkmenu.c | 110 | ||||
-rw-r--r-- | gtk/gtkmenuitem.c | 99 | ||||
-rw-r--r-- | gtk/gtkradiomenuitem.c | 23 | ||||
-rw-r--r-- | gtk/gtkstyle.c | 83 | ||||
-rw-r--r-- | gtk/gtktearoffmenuitem.c | 2 | ||||
-rw-r--r-- | gtk/gtkvseparator.c | 2 |
15 files changed, 469 insertions, 72 deletions
@@ -1,3 +1,25 @@ +Sat Jul 5 10:34:00 2003 Soeren Sandmann <sandmann@daimi.au.dk> + + * gtk/gtkmenu.c: add vertical_padding style property. + + * gtk/gtkmenuitem.c: add style properties toggle_spacing, + arrow_spacing and horizontal_padding. Also center separators and + make them a bit taller. + + * gtk/*menuitem.c: use new style properties. + + * docs/widget_geometry.txt: Add note about GtkMenuItem + + * gtk/gtkstyle.c + (gtk_default_draw_vline, gtk_default_draw_hline): + fix +/-1 errors. + + (gtk_default_draw_shadow): draw a black border around menus. + + * gtk/gtkvseparator, gtk/gtkhseparator.c, gtk/gtkmenuitem.c: fix + calls to gtk_paint_hline() and gtk_paint_vline() (they take x1, + x2 and y1, y2 respectively, not x, width and y, height). + Sat Jul 5 09:55:38 2003 Owen Taylor <otaylor@redhat.com> * gdk/x11/gdkdnd-x11.c (precache_target_list): Lookup diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 0e0a1803ed..a5d59c5ff6 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,25 @@ +Sat Jul 5 10:34:00 2003 Soeren Sandmann <sandmann@daimi.au.dk> + + * gtk/gtkmenu.c: add vertical_padding style property. + + * gtk/gtkmenuitem.c: add style properties toggle_spacing, + arrow_spacing and horizontal_padding. Also center separators and + make them a bit taller. + + * gtk/*menuitem.c: use new style properties. + + * docs/widget_geometry.txt: Add note about GtkMenuItem + + * gtk/gtkstyle.c + (gtk_default_draw_vline, gtk_default_draw_hline): + fix +/-1 errors. + + (gtk_default_draw_shadow): draw a black border around menus. + + * gtk/gtkvseparator, gtk/gtkhseparator.c, gtk/gtkmenuitem.c: fix + calls to gtk_paint_hline() and gtk_paint_vline() (they take x1, + x2 and y1, y2 respectively, not x, width and y, height). + Sat Jul 5 09:55:38 2003 Owen Taylor <otaylor@redhat.com> * gdk/x11/gdkdnd-x11.c (precache_target_list): Lookup diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 0e0a1803ed..a5d59c5ff6 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,25 @@ +Sat Jul 5 10:34:00 2003 Soeren Sandmann <sandmann@daimi.au.dk> + + * gtk/gtkmenu.c: add vertical_padding style property. + + * gtk/gtkmenuitem.c: add style properties toggle_spacing, + arrow_spacing and horizontal_padding. Also center separators and + make them a bit taller. + + * gtk/*menuitem.c: use new style properties. + + * docs/widget_geometry.txt: Add note about GtkMenuItem + + * gtk/gtkstyle.c + (gtk_default_draw_vline, gtk_default_draw_hline): + fix +/-1 errors. + + (gtk_default_draw_shadow): draw a black border around menus. + + * gtk/gtkvseparator, gtk/gtkhseparator.c, gtk/gtkmenuitem.c: fix + calls to gtk_paint_hline() and gtk_paint_vline() (they take x1, + x2 and y1, y2 respectively, not x, width and y, height). + Sat Jul 5 09:55:38 2003 Owen Taylor <otaylor@redhat.com> * gdk/x11/gdkdnd-x11.c (precache_target_list): Lookup diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 0e0a1803ed..a5d59c5ff6 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,25 @@ +Sat Jul 5 10:34:00 2003 Soeren Sandmann <sandmann@daimi.au.dk> + + * gtk/gtkmenu.c: add vertical_padding style property. + + * gtk/gtkmenuitem.c: add style properties toggle_spacing, + arrow_spacing and horizontal_padding. Also center separators and + make them a bit taller. + + * gtk/*menuitem.c: use new style properties. + + * docs/widget_geometry.txt: Add note about GtkMenuItem + + * gtk/gtkstyle.c + (gtk_default_draw_vline, gtk_default_draw_hline): + fix +/-1 errors. + + (gtk_default_draw_shadow): draw a black border around menus. + + * gtk/gtkvseparator, gtk/gtkhseparator.c, gtk/gtkmenuitem.c: fix + calls to gtk_paint_hline() and gtk_paint_vline() (they take x1, + x2 and y1, y2 respectively, not x, width and y, height). + Sat Jul 5 09:55:38 2003 Owen Taylor <otaylor@redhat.com> * gdk/x11/gdkdnd-x11.c (precache_target_list): Lookup diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 0e0a1803ed..a5d59c5ff6 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,25 @@ +Sat Jul 5 10:34:00 2003 Soeren Sandmann <sandmann@daimi.au.dk> + + * gtk/gtkmenu.c: add vertical_padding style property. + + * gtk/gtkmenuitem.c: add style properties toggle_spacing, + arrow_spacing and horizontal_padding. Also center separators and + make them a bit taller. + + * gtk/*menuitem.c: use new style properties. + + * docs/widget_geometry.txt: Add note about GtkMenuItem + + * gtk/gtkstyle.c + (gtk_default_draw_vline, gtk_default_draw_hline): + fix +/-1 errors. + + (gtk_default_draw_shadow): draw a black border around menus. + + * gtk/gtkvseparator, gtk/gtkhseparator.c, gtk/gtkmenuitem.c: fix + calls to gtk_paint_hline() and gtk_paint_vline() (they take x1, + x2 and y1, y2 respectively, not x, width and y, height). + Sat Jul 5 09:55:38 2003 Owen Taylor <otaylor@redhat.com> * gdk/x11/gdkdnd-x11.c (precache_target_list): Lookup diff --git a/docs/widget_geometry.txt b/docs/widget_geometry.txt index c7076f251e..882ecbb944 100644 --- a/docs/widget_geometry.txt +++ b/docs/widget_geometry.txt @@ -2,6 +2,38 @@ This file is some notes about how different widgets are drawn. ============= +GtkMenuItem + +============= + +arrowspacing +togglespacing +horizontal_padding + + B + ------------------ + A C D E G A ++----+----------+-----+----------------------+----+-----------+----+ +| | | | ^ | | | | +| | | | | | | | | +| | | | | | | | | +| | | | | | | | | +| | icon | | child | G | | | | +| | | | | | | | | +| | | | | | | | | +| | | | | | | | | +| | | | v | | | | ++----+----------+-----+----------------------+----+-----------+----+ + +A: horizontal_padding +B: width of icon or indicator + toggle_spacing +C: toggle_spacing +D: child's requested size +E: arrow spacing (if the item has a submenu +G: child's requested height (also used for width of arrow field + +============= + GtkOptionMenu: ============= diff --git a/gtk/gtkcheckmenuitem.c b/gtk/gtkcheckmenuitem.c index 269b1efe88..26f1b2a46b 100644 --- a/gtk/gtkcheckmenuitem.c +++ b/gtk/gtkcheckmenuitem.c @@ -231,9 +231,15 @@ static void gtk_check_menu_item_toggle_size_request (GtkMenuItem *menu_item, gint *requisition) { + guint toggle_spacing; + g_return_if_fail (GTK_IS_CHECK_MENU_ITEM (menu_item)); - - *requisition = CHECK_TOGGLE_SIZE; + + gtk_widget_style_get (GTK_WIDGET (menu_item), + "toggle_spacing", &toggle_spacing, + NULL); + + *requisition = CHECK_TOGGLE_SIZE + toggle_spacing; } void @@ -348,20 +354,42 @@ gtk_real_check_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item, GtkShadowType shadow_type; gint width, height; gint x, y; - gint offset; if (GTK_WIDGET_DRAWABLE (check_menu_item)) { + guint offset; + guint toggle_size; + guint toggle_spacing; + guint horizontal_padding; + widget = GTK_WIDGET (check_menu_item); + gtk_widget_style_get (GTK_WIDGET (check_menu_item), + "toggle_spacing", &toggle_spacing, + "horizontal_padding", &horizontal_padding, + NULL); + width = 8; height = 8; + + toggle_size = GTK_MENU_ITEM (check_menu_item)->toggle_size; + offset = GTK_CONTAINER (check_menu_item)->border_width + widget->style->xthickness; + offset = GTK_CONTAINER (check_menu_item)->border_width + - widget->style->xthickness + 2; - if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) - x = widget->allocation.x + offset; + widget->style->xthickness + 2; + + if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) + { + x = widget->allocation.x + offset + horizontal_padding + + (toggle_size - toggle_spacing - width) / 2; + } else - x = widget->allocation.x + widget->allocation.width - width - offset; + { + x = widget->allocation.x + widget->allocation.width - + offset - horizontal_padding - toggle_size + toggle_spacing + + (toggle_size - toggle_spacing - width) / 2; + } + y = widget->allocation.y + (widget->allocation.height - height) / 2; if (check_menu_item->active || diff --git a/gtk/gtkhseparator.c b/gtk/gtkhseparator.c index 66b5aad453..fab4f43c02 100644 --- a/gtk/gtkhseparator.c +++ b/gtk/gtkhseparator.c @@ -93,7 +93,7 @@ gtk_hseparator_expose (GtkWidget *widget, gtk_paint_hline (widget->style, widget->window, GTK_STATE_NORMAL, &event->area, widget, "hseparator", widget->allocation.x, - widget->allocation.x + widget->allocation.width, + widget->allocation.x + widget->allocation.width - 1, widget->allocation.y + (widget->allocation.height - widget->style->ythickness) / 2); diff --git a/gtk/gtkimagemenuitem.c b/gtk/gtkimagemenuitem.c index f12dd540ba..9dd1376d2a 100644 --- a/gtk/gtkimagemenuitem.c +++ b/gtk/gtkimagemenuitem.c @@ -185,7 +185,15 @@ gtk_image_menu_item_toggle_size_request (GtkMenuItem *menu_item, GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (menu_item); if (image_menu_item->image) - *requisition = image_menu_item->image->requisition.width; + { + guint toggle_spacing; + + gtk_widget_style_get (GTK_WIDGET (menu_item), + "toggle_spacing", &toggle_spacing, + NULL); + + *requisition = image_menu_item->image->requisition.width + toggle_spacing; + } else *requisition = 0; } @@ -237,6 +245,12 @@ gtk_image_menu_item_size_allocate (GtkWidget *widget, { gint width, height, x, y, offset; GtkAllocation child_allocation; + guint horizontal_padding, toggle_spacing; + + gtk_widget_style_get (widget, + "horizontal_padding", &horizontal_padding, + "toggle_spacing", &toggle_spacing, + NULL); /* Man this is lame hardcoding action, but I can't * come up with a solution that's really better. @@ -245,14 +259,22 @@ gtk_image_menu_item_size_allocate (GtkWidget *widget, width = image_menu_item->image->requisition.width; height = image_menu_item->image->requisition.height; offset = GTK_CONTAINER (image_menu_item)->border_width + - widget->style->xthickness; + widget->style->xthickness; if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) - x = offset + (GTK_MENU_ITEM (image_menu_item)->toggle_size - width) / 2; - else - x = widget->allocation.width - - GTK_MENU_ITEM (image_menu_item)->toggle_size - offset + - (GTK_MENU_ITEM (image_menu_item)->toggle_size - width) / 2; + { + x = offset + horizontal_padding + + (GTK_MENU_ITEM (image_menu_item)->toggle_size - + toggle_spacing - width) / 2; + } + else + { + x = widget->allocation.width - offset - horizontal_padding - + GTK_MENU_ITEM (image_menu_item)->toggle_size + toggle_spacing + + (GTK_MENU_ITEM (image_menu_item)->toggle_size - + toggle_spacing - width) / 2; + } + y = (widget->allocation.height - height) / 2; child_allocation.width = width; diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c index 16346263db..806115101c 100644 --- a/gtk/gtkmenu.c +++ b/gtk/gtkmenu.c @@ -265,6 +265,15 @@ gtk_menu_class_init (GtkMenuClass *class) "", G_PARAM_READABLE | G_PARAM_WRITABLE)); + gtk_widget_class_install_style_property (widget_class, + g_param_spec_int ("vertical-padding", + _("Vertical Padding"), + _("Extra space at the top and bottom of the menu"), + 0, + G_MAXINT, + 1, + G_PARAM_READABLE)); + object_class->destroy = gtk_menu_destroy; widget_class->realize = gtk_menu_realize; @@ -1489,7 +1498,8 @@ gtk_menu_realize (GtkWidget *widget) GtkMenu *menu; GtkWidget *child; GList *children; - + guint vertical_padding; + g_return_if_fail (GTK_IS_MENU (widget)); menu = GTK_MENU (widget); @@ -1514,9 +1524,13 @@ gtk_menu_realize (GtkWidget *widget) gdk_window_set_user_data (widget->window, widget); border_width = GTK_CONTAINER (widget)->border_width; + + gtk_widget_style_get (GTK_WIDGET (menu), + "vertical-padding", &vertical_padding, + NULL); attributes.x = border_width + widget->style->xthickness; - attributes.y = border_width + widget->style->ythickness; + attributes.y = border_width + widget->style->ythickness + vertical_padding; attributes.width = MAX (1, widget->allocation.width - attributes.x * 2); attributes.height = MAX (1, widget->allocation.height - attributes.y * 2); @@ -1533,7 +1547,7 @@ gtk_menu_realize (GtkWidget *widget) attributes.x = 0; attributes.y = 0; - attributes.height = MAX (1, widget->requisition.height - (border_width + widget->style->ythickness) * 2); + attributes.height = MAX (1, widget->requisition.height - (border_width + widget->style->ythickness + vertical_padding) * 2); menu->bin_window = gdk_window_new (menu->view_window, &attributes, attributes_mask); gdk_window_set_user_data (menu->bin_window, menu); @@ -1648,6 +1662,7 @@ gtk_menu_size_request (GtkWidget *widget, GList *children; guint max_toggle_size; guint max_accel_width; + guint vertical_padding; GtkRequisition child_requisition; g_return_if_fail (GTK_IS_MENU (widget)); @@ -1689,11 +1704,15 @@ gtk_menu_size_request (GtkWidget *widget, max_accel_width = MAX (max_accel_width, GTK_MENU_ITEM (child)->accelerator_width); } } - + requisition->width += max_toggle_size + max_accel_width; requisition->width += (GTK_CONTAINER (menu)->border_width + widget->style->xthickness) * 2; - requisition->height += (GTK_CONTAINER (menu)->border_width + + + gtk_widget_style_get (GTK_WIDGET (menu), + "vertical-padding", &vertical_padding, + NULL); + requisition->height += (GTK_CONTAINER (menu)->border_width + vertical_padding + widget->style->ythickness) * 2; menu->toggle_size = max_toggle_size; @@ -1715,6 +1734,7 @@ gtk_menu_size_allocate (GtkWidget *widget, GList *children; gint x, y; gint width, height; + guint vertical_padding; g_return_if_fail (GTK_IS_MENU (widget)); g_return_if_fail (allocation != NULL); @@ -1724,9 +1744,13 @@ gtk_menu_size_allocate (GtkWidget *widget, widget->allocation = *allocation; - x = GTK_CONTAINER (menu)->border_width + widget->style->xthickness; - y = GTK_CONTAINER (menu)->border_width + widget->style->ythickness; + gtk_widget_style_get (GTK_WIDGET (menu), + "vertical-padding", &vertical_padding, + NULL); + x = GTK_CONTAINER (menu)->border_width + widget->style->xthickness; + y = GTK_CONTAINER (menu)->border_width + widget->style->ythickness + vertical_padding; + width = MAX (1, allocation->width - x * 2); height = MAX (1, allocation->height - y * 2); @@ -1776,6 +1800,7 @@ gtk_menu_size_allocate (GtkWidget *widget, gtk_menu_item_toggle_size_allocate (GTK_MENU_ITEM (child), menu->toggle_size); + gtk_widget_size_allocate (child, &child_allocation); gtk_widget_queue_draw (child); @@ -1838,17 +1863,25 @@ gtk_menu_paint (GtkWidget *widget, GtkMenu *menu; gint width, height; gint border_x, border_y; + guint vertical_padding; g_return_if_fail (GTK_IS_MENU (widget)); menu = GTK_MENU (widget); + + gtk_widget_style_get (GTK_WIDGET (menu), + "vertical-padding", &vertical_padding, + NULL); border_x = GTK_CONTAINER (widget)->border_width + widget->style->xthickness; - border_y = GTK_CONTAINER (widget)->border_width + widget->style->ythickness; + border_y = GTK_CONTAINER (widget)->border_width + widget->style->ythickness + vertical_padding; gdk_drawable_get_size (widget->window, &width, &height); if (event->window == widget->window) { + gint arrow_space = MENU_SCROLL_ARROW_HEIGHT - 2 * widget->style->ythickness; + gint arrow_size = 0.7 * arrow_space; + gtk_paint_box (widget->style, widget->window, GTK_STATE_NORMAL, @@ -1865,7 +1898,7 @@ gtk_menu_paint (GtkWidget *widget, NULL, widget, "menu", border_x, border_y, - width - 2*border_x, + width - 2 * border_x, MENU_SCROLL_ARROW_HEIGHT); gtk_paint_arrow (widget->style, @@ -1873,13 +1906,12 @@ gtk_menu_paint (GtkWidget *widget, menu->upper_arrow_prelight ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL, GTK_SHADOW_OUT, - NULL, widget, "menu", + NULL, widget, "menu_scroll_arrow_up", GTK_ARROW_UP, TRUE, - width / 2 - MENU_SCROLL_ARROW_HEIGHT / 2 + 1, - 2 * border_y + 1, - MENU_SCROLL_ARROW_HEIGHT - 2 * border_y - 2, - MENU_SCROLL_ARROW_HEIGHT - 2 * border_y - 2); + (width - arrow_size ) / 2, + border_y + widget->style->ythickness + (arrow_space - arrow_size)/2, + arrow_size, arrow_size); } if (menu->lower_arrow_visible && !menu->tearoff_active) @@ -1891,7 +1923,7 @@ gtk_menu_paint (GtkWidget *widget, GTK_SHADOW_OUT, NULL, widget, "menu", border_x, - height - border_y - MENU_SCROLL_ARROW_HEIGHT + 1, + height - border_y - MENU_SCROLL_ARROW_HEIGHT, width - 2*border_x, MENU_SCROLL_ARROW_HEIGHT); @@ -1900,13 +1932,13 @@ gtk_menu_paint (GtkWidget *widget, menu->lower_arrow_prelight ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL, GTK_SHADOW_OUT, - NULL, widget, "menu", + NULL, widget, "menu_scroll_arrow_down", GTK_ARROW_DOWN, TRUE, - width / 2 - MENU_SCROLL_ARROW_HEIGHT / 2 + 1, - height - MENU_SCROLL_ARROW_HEIGHT + 1, - MENU_SCROLL_ARROW_HEIGHT - 2 * border_y - 2, - MENU_SCROLL_ARROW_HEIGHT - 2 * border_y - 2); + (width - arrow_size) / 2, + height - border_y - MENU_SCROLL_ARROW_HEIGHT + + widget->style->ythickness + (arrow_space - arrow_size)/2, + arrow_size, arrow_size); } } } @@ -2242,13 +2274,19 @@ gtk_menu_handle_scrolling (GtkMenu *menu, gboolean enter) GdkRectangle rect; gboolean in_arrow; gboolean scroll_fast = FALSE; + guint vertical_padding; menu_shell = GTK_MENU_SHELL (menu); gdk_window_get_pointer (GTK_WIDGET (menu)->window, &x, &y, NULL); gdk_drawable_get_size (GTK_WIDGET (menu)->window, &width, &height); - border = GTK_CONTAINER (menu)->border_width + GTK_WIDGET (menu)->style->ythickness; + gtk_widget_style_get (GTK_WIDGET (menu), + "vertical-padding", &vertical_padding, + NULL); + + border = GTK_CONTAINER (menu)->border_width + + GTK_WIDGET (menu)->style->ythickness + vertical_padding; if (menu->upper_arrow_visible && !menu->tearoff_active) { @@ -2783,6 +2821,7 @@ gtk_menu_scroll_to (GtkMenu *menu, gint border_width; gboolean last_visible; gint menu_height; + guint vertical_padding; widget = GTK_WIDGET (menu); @@ -2800,13 +2839,18 @@ gtk_menu_scroll_to (GtkMenu *menu, view_width = widget->allocation.width; view_height = widget->allocation.height; + gtk_widget_style_get (GTK_WIDGET (menu), + "vertical-padding", &vertical_padding, + NULL); + border_width = GTK_CONTAINER (menu)->border_width; view_width -= (border_width + widget->style->xthickness) * 2; - view_height -= (border_width + widget->style->ythickness) * 2; - menu_height = widget->requisition.height - (border_width + widget->style->ythickness) * 2; + view_height -= (border_width + widget->style->ythickness + vertical_padding) * 2; + menu_height = widget->requisition.height - + (border_width + widget->style->ythickness + vertical_padding) * 2; x = border_width + widget->style->xthickness; - y = border_width + widget->style->ythickness; + y = border_width + widget->style->ythickness + vertical_padding; if (!menu->tearoff_active) { @@ -2823,7 +2867,10 @@ gtk_menu_scroll_to (GtkMenu *menu, /* If we hid the upper arrow, possibly remove timeout */ if (menu->scroll_step < 0) - gtk_menu_stop_scrolling (menu); + { + gtk_menu_stop_scrolling (menu); + gtk_widget_queue_draw (GTK_WIDGET (menu)); + } } last_visible = menu->lower_arrow_visible; @@ -2839,7 +2886,10 @@ gtk_menu_scroll_to (GtkMenu *menu, /* If we hid the lower arrow, possibly remove timeout */ if (menu->scroll_step > 0) - gtk_menu_stop_scrolling (menu); + { + gtk_menu_stop_scrolling (menu); + gtk_widget_queue_draw (GTK_WIDGET (menu)); + } } if (menu->upper_arrow_visible) @@ -2926,10 +2976,16 @@ gtk_menu_scroll_item_visible (GtkMenuShell *menu_shell, if (compute_child_offset (menu, menu_item, &child_offset, &child_height, &last_child)) { + guint vertical_padding; + y = menu->scroll_offset; gdk_drawable_get_size (GTK_WIDGET (menu)->window, &width, &height); - height -= 2*GTK_CONTAINER (menu)->border_width + 2*GTK_WIDGET (menu)->style->ythickness; + gtk_widget_style_get (GTK_WIDGET (menu), + "vertical-padding", &vertical_padding, + NULL); + + height -= 2*GTK_CONTAINER (menu)->border_width + 2*GTK_WIDGET (menu)->style->ythickness + 2*vertical_padding; if (child_offset < y) { diff --git a/gtk/gtkmenuitem.c b/gtk/gtkmenuitem.c index c18550bfe2..9eba559729 100644 --- a/gtk/gtkmenuitem.c +++ b/gtk/gtkmenuitem.c @@ -35,12 +35,8 @@ #include "gtkmenuitem.h" #include "gtkseparatormenuitem.h" - -#define BORDER_SPACING 3 - #define MENU_ITEM_CLASS(w) GTK_MENU_ITEM_CLASS (GTK_OBJECT (w)->klass) - enum { ACTIVATE, ACTIVATE_ITEM, @@ -211,6 +207,33 @@ gtk_menu_item_class_init (GtkMenuItemClass *klass) GTK_SHADOW_NONE, G_PARAM_READABLE), gtk_rc_property_parse_enum); + + gtk_widget_class_install_style_property (widget_class, + g_param_spec_int ("horizontal_padding", + "Horizontal Padding", + "Padding to left and right of the menu item", + 0, + G_MAXINT, + 3, + G_PARAM_READABLE)); + + gtk_widget_class_install_style_property (widget_class, + g_param_spec_int ("toggle_spacing", + "Icon Spacing", + "Space between icon and label", + 0, + G_MAXINT, + 5, + G_PARAM_READABLE)); + + gtk_widget_class_install_style_property (widget_class, + g_param_spec_int ("arrow_spacing", + "Arrow Spacing", + "Space between label and arrow", + 0, + G_MAXINT, + 10, + G_PARAM_READABLE)); } static void @@ -449,16 +472,20 @@ gtk_menu_item_size_request (GtkWidget *widget, GtkMenuItem *menu_item; GtkBin *bin; guint accel_width; + guint horizontal_padding; g_return_if_fail (GTK_IS_MENU_ITEM (widget)); g_return_if_fail (requisition != NULL); + gtk_widget_style_get (widget, + "horizontal padding", &horizontal_padding, + NULL); + bin = GTK_BIN (widget); menu_item = GTK_MENU_ITEM (widget); requisition->width = (GTK_CONTAINER (widget)->border_width + - widget->style->xthickness + - BORDER_SPACING) * 2; + widget->style->xthickness + horizontal_padding) * 2; requisition->height = (GTK_CONTAINER (widget)->border_width + widget->style->ythickness) * 2; @@ -472,7 +499,21 @@ gtk_menu_item_size_request (GtkWidget *widget, requisition->height += child_requisition.height; if (menu_item->submenu && menu_item->show_submenu_indicator) - requisition->width += child_requisition.height; + { + guint arrow_spacing; + + gtk_widget_style_get (widget, + "arrow_spacing", &arrow_spacing, + NULL); + + requisition->width += child_requisition.height; + requisition->width += arrow_spacing; + } + } + else + { + /* separator item */ + requisition->height += 4; } accel_width = 0; @@ -504,10 +545,15 @@ gtk_menu_item_size_allocate (GtkWidget *widget, if (bin->child) { GtkRequisition child_requisition; + guint horizontal_padding; + + gtk_widget_style_get (widget, + "horizontal_padding", &horizontal_padding, + NULL); child_allocation.x = (GTK_CONTAINER (widget)->border_width + widget->style->xthickness + - BORDER_SPACING); + horizontal_padding); child_allocation.y = (GTK_CONTAINER (widget)->border_width + widget->style->ythickness); child_allocation.width = MAX (1, (gint)allocation->width - child_allocation.x * 2); @@ -649,29 +695,36 @@ gtk_menu_item_paint (GtkWidget *widget, gint arrow_x, arrow_y; gint arrow_size; gint arrow_extent; + guint horizontal_padding; GtkTextDirection direction; GtkArrowType arrow_type; direction = gtk_widget_get_direction (widget); + gtk_widget_style_get (widget, + "horizontal_padding", &horizontal_padding, + NULL); + gtk_widget_get_child_requisition (GTK_BIN (menu_item)->child, &child_requisition); arrow_size = child_requisition.height - 2 * widget->style->ythickness; - arrow_extent = arrow_size * 0.6; + arrow_extent = arrow_size * 0.8; shadow_type = GTK_SHADOW_OUT; if (state_type == GTK_STATE_PRELIGHT) shadow_type = GTK_SHADOW_IN; - if (direction == GTK_TEXT_DIR_LTR) { - arrow_x = x + width - 1 - arrow_size + (arrow_size - arrow_extent) / 2; - arrow_type = GTK_ARROW_RIGHT; - } - else { - arrow_x = x + 1 + (arrow_size - arrow_extent) / 2; - arrow_type = GTK_ARROW_LEFT; - } + if (direction == GTK_TEXT_DIR_LTR) + { + arrow_x = x + width - horizontal_padding - arrow_extent; + arrow_type = GTK_ARROW_RIGHT; + } + else + { + arrow_x = x + horizontal_padding; + arrow_type = GTK_ARROW_LEFT; + } arrow_y = y + (height - arrow_extent) / 2; @@ -684,10 +737,18 @@ gtk_menu_item_paint (GtkWidget *widget, } else if (!GTK_BIN (menu_item)->child) { + guint horizontal_padding; + + gtk_widget_style_get (widget, + "horizontal_padding", &horizontal_padding, + NULL); + gtk_paint_hline (widget->style, widget->window, GTK_STATE_NORMAL, area, widget, "menuitem", - widget->allocation.x, widget->allocation.width, - widget->allocation.y); + widget->allocation.x + horizontal_padding + widget->style->xthickness, + widget->allocation.x + widget->allocation.width - horizontal_padding - widget->style->xthickness - 1, + widget->allocation.y + (widget->allocation.height - + widget->style->ythickness) / 2); } } } diff --git a/gtk/gtkradiomenuitem.c b/gtk/gtkradiomenuitem.c index 87ac5052e4..4d7ba5f7fa 100644 --- a/gtk/gtkradiomenuitem.c +++ b/gtk/gtkradiomenuitem.c @@ -312,16 +312,35 @@ gtk_radio_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item, if (GTK_WIDGET_DRAWABLE (check_menu_item)) { + guint horizontal_padding; + guint toggle_spacing; + guint toggle_size; + widget = GTK_WIDGET (check_menu_item); + gtk_widget_style_get (GTK_WIDGET (check_menu_item), + "toggle_spacing", &toggle_spacing, + "horizontal_padding", &horizontal_padding, + NULL); + width = 8; height = 8; + toggle_size = GTK_MENU_ITEM (check_menu_item)->toggle_size; offset = GTK_CONTAINER (check_menu_item)->border_width + widget->style->xthickness + 2; + if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) - x = widget->allocation.x + offset; + { + x = widget->allocation.x + offset + horizontal_padding + + (toggle_size - toggle_spacing - width) / 2; + } else - x = widget->allocation.x + widget->allocation.width - width - offset; + { + x = widget->allocation.x + widget->allocation.width - + offset - horizontal_padding - toggle_size + toggle_spacing + + (toggle_size - toggle_spacing - width) / 2; + } + y = widget->allocation.y + (widget->allocation.height - height) / 2; if (check_menu_item->active || diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index 2fb5f049e3..674069c676 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -35,6 +35,7 @@ #include "gtkthemes.h" #include "gtkiconfactory.h" #include "gtksettings.h" /* _gtk_settings_parse_convert() */ +#include "gtkhandlebox.h" #define LIGHTNESS_MULT 1.3 #define DARKNESS_MULT 0.7 @@ -2264,15 +2265,15 @@ gtk_default_draw_hline (GtkStyle *style, { for (i = 0; i < thickness_dark; i++) { - gdk_draw_line (window, style->light_gc[state_type], x2 - i - 1, y + i, x2, y + i); gdk_draw_line (window, style->dark_gc[state_type], x1, y + i, x2 - i - 1, y + i); + gdk_draw_line (window, style->light_gc[state_type], x2 - i, y + i, x2, y + i); } y += thickness_dark; for (i = 0; i < thickness_light; i++) { gdk_draw_line (window, style->dark_gc[state_type], x1, y + i, x1 + thickness_light - i - 1, y + i); - gdk_draw_line (window, style->light_gc[state_type], x1 + thickness_light - i - 1, y + i, x2, y + i); + gdk_draw_line (window, style->light_gc[state_type], x1 + thickness_light - i, y + i, x2, y + i); } } @@ -2311,15 +2312,15 @@ gtk_default_draw_vline (GtkStyle *style, gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area); } for (i = 0; i < thickness_dark; i++) - { - gdk_draw_line (window, style->light_gc[state_type], x + i, y2 - i - 1, x + i, y2); + { gdk_draw_line (window, style->dark_gc[state_type], x + i, y1, x + i, y2 - i - 1); + gdk_draw_line (window, style->light_gc[state_type], x + i, y2 - i, x + i, y2); } x += thickness_dark; for (i = 0; i < thickness_light; i++) { - gdk_draw_line (window, style->dark_gc[state_type], x + i, y1, x + i, y1 + thickness_light - i); + gdk_draw_line (window, style->dark_gc[state_type], x + i, y1, x + i, y1 + thickness_light - i - 1); gdk_draw_line (window, style->light_gc[state_type], x + i, y1 + thickness_light - i, x + i, y2); } if (area) @@ -2329,7 +2330,6 @@ gtk_default_draw_vline (GtkStyle *style, } } - static void draw_thin_shadow (GtkStyle *style, GdkWindow *window, @@ -2436,6 +2436,66 @@ draw_spinbutton_shadow (GtkStyle *style, } static void +draw_menu_shadow (GtkStyle *style, + GdkWindow *window, + GtkStateType state, + GdkRectangle *area, + gint x, + gint y, + gint width, + gint height) +{ + if (style->ythickness > 0) + { + if (style->ythickness > 1) + { + gdk_draw_line (window, style->dark_gc[state], + x + 1, y + height - 2, x + width - 2, y + height - 2); + gdk_draw_line (window, style->black_gc, + x, y + height - 1, x + width - 1, y + height - 1); + } + else + { + gdk_draw_line (window, style->dark_gc[state], + x + 1, y + height - 1, x + width - 1, y + height - 1); + } + } + + if (style->xthickness > 0) + { + if (style->xthickness > 1) + { + gdk_draw_line (window, style->dark_gc[state], + x + width - 2, y + 1, x + width - 2, y + height - 2); + + gdk_draw_line (window, style->black_gc, + x + width - 1, y, x + width - 1, y + height - 1); + } + else + { + gdk_draw_line (window, style->dark_gc[state], + x + width - 1, y + 1, x + width - 1, y + height - 1); + } + } + + /* Light around top and left */ + + if (style->ythickness > 0) + gdk_draw_line (window, style->black_gc, + x, y, x + width - 2, y); + if (style->xthickness > 0) + gdk_draw_line (window, style->black_gc, + x, y, x, y + height - 2); + + if (style->ythickness > 1) + gdk_draw_line (window, style->light_gc[state], + x + 1, y + 1, x + width - 3, y + 1); + if (style->xthickness > 1) + gdk_draw_line (window, style->light_gc[state], + x + 1, y + 1, x + 1, y + height - 3); +} + +static void gtk_default_draw_shadow (GtkStyle *style, GdkWindow *window, GtkStateType state_type, @@ -2483,6 +2543,12 @@ gtk_default_draw_shadow (GtkStyle *style, return; } } + + if (shadow_type == GTK_SHADOW_OUT && detail && strcmp (detail, "menu") == 0) + { + draw_menu_shadow (style, window, state_type, area, x, y, width, height); + return; + } sanitize_size (window, &width, &height); @@ -3034,6 +3100,9 @@ gtk_default_draw_arrow (GtkStyle *style, && gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) x = original_x + original_width - width; + if (detail && strcmp (detail, "menu_scroll_arrow_up") == 0) + y++; + if (state == GTK_STATE_INSENSITIVE) draw_arrow (window, style->white_gc, area, arrow_type, x + 1, y + 1, width, height); @@ -6472,7 +6541,7 @@ style_unrealize_cursor_gcs (GtkStyle *style) static GdkGC * make_cursor_gc (GtkWidget *widget, const gchar *property_name, - GdkColor *fallback) + const GdkColor *fallback) { GdkGCValues gc_values; GdkGCValuesMask gc_values_mask; diff --git a/gtk/gtktearoffmenuitem.c b/gtk/gtktearoffmenuitem.c index 0b5c58d1e4..fce5fd7068 100644 --- a/gtk/gtktearoffmenuitem.c +++ b/gtk/gtktearoffmenuitem.c @@ -118,7 +118,7 @@ gtk_tearoff_menu_item_size_request (GtkWidget *widget, } else { - requisition->height += widget->style->ythickness; + requisition->height += widget->style->ythickness + 4; } } diff --git a/gtk/gtkvseparator.c b/gtk/gtkvseparator.c index f546e0db85..c3791d134b 100644 --- a/gtk/gtkvseparator.c +++ b/gtk/gtkvseparator.c @@ -93,7 +93,7 @@ gtk_vseparator_expose (GtkWidget *widget, gtk_paint_vline (widget->style, widget->window, GTK_STATE_NORMAL, &event->area, widget, "vseparator", widget->allocation.y, - widget->allocation.y + widget->allocation.height, + widget->allocation.y + widget->allocation.height - 1, widget->allocation.x + (widget->allocation.width - widget->style->xthickness) / 2); |