diff options
author | Kristian Rietveld <kris@gtk.org> | 2003-08-21 19:37:09 +0000 |
---|---|---|
committer | Kristian Rietveld <kristian@src.gnome.org> | 2003-08-21 19:37:09 +0000 |
commit | fe2d7cb957fbec6ed3369462083751519e523feb (patch) | |
tree | 0f4366a45abb07d7062e83f8afcd0f9294ce3a5e | |
parent | 6fc502b1c035fa65f91ada3939fc54623f56d000 (diff) | |
download | gdk-pixbuf-fe2d7cb957fbec6ed3369462083751519e523feb.tar.gz |
Fix option menu scrolling (#119821, Owen Taylor).
Thu Aug 21 21:27:45 2003 Kristian Rietveld <kris@gtk.org>
Fix option menu scrolling (#119821, Owen Taylor).
* gtk/gtkmenu.c (gtk_menu_scroll_to): remove logic introduced
by #80484 and the CLAMP,
(get_menu_height): new function,
(gtk_menu_real_move_scroll): sort of moved the CLAMP here to correct
new_offset to handle page up/down right.
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | ChangeLog.pre-2-10 | 10 | ||||
-rw-r--r-- | ChangeLog.pre-2-4 | 10 | ||||
-rw-r--r-- | ChangeLog.pre-2-6 | 10 | ||||
-rw-r--r-- | ChangeLog.pre-2-8 | 10 | ||||
-rw-r--r-- | gtk/gtkmenu.c | 31 |
6 files changed, 76 insertions, 5 deletions
@@ -1,3 +1,13 @@ +Thu Aug 21 21:27:45 2003 Kristian Rietveld <kris@gtk.org> + + Fix option menu scrolling (#119821, Owen Taylor). + + * gtk/gtkmenu.c (gtk_menu_scroll_to): remove logic introduced + by #80484 and the CLAMP, + (get_menu_height): new function, + (gtk_menu_real_move_scroll): sort of moved the CLAMP here to correct + new_offset to handle page up/down right. + Thu Aug 21 15:17:42 2003 Owen Taylor <otaylor@redhat.com> * gdk/x11/gdkkeys-x11.c: Change the interpretation diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 5e1b46df0..8d2723e5d 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,13 @@ +Thu Aug 21 21:27:45 2003 Kristian Rietveld <kris@gtk.org> + + Fix option menu scrolling (#119821, Owen Taylor). + + * gtk/gtkmenu.c (gtk_menu_scroll_to): remove logic introduced + by #80484 and the CLAMP, + (get_menu_height): new function, + (gtk_menu_real_move_scroll): sort of moved the CLAMP here to correct + new_offset to handle page up/down right. + Thu Aug 21 15:17:42 2003 Owen Taylor <otaylor@redhat.com> * gdk/x11/gdkkeys-x11.c: Change the interpretation diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 5e1b46df0..8d2723e5d 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,13 @@ +Thu Aug 21 21:27:45 2003 Kristian Rietveld <kris@gtk.org> + + Fix option menu scrolling (#119821, Owen Taylor). + + * gtk/gtkmenu.c (gtk_menu_scroll_to): remove logic introduced + by #80484 and the CLAMP, + (get_menu_height): new function, + (gtk_menu_real_move_scroll): sort of moved the CLAMP here to correct + new_offset to handle page up/down right. + Thu Aug 21 15:17:42 2003 Owen Taylor <otaylor@redhat.com> * gdk/x11/gdkkeys-x11.c: Change the interpretation diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 5e1b46df0..8d2723e5d 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,13 @@ +Thu Aug 21 21:27:45 2003 Kristian Rietveld <kris@gtk.org> + + Fix option menu scrolling (#119821, Owen Taylor). + + * gtk/gtkmenu.c (gtk_menu_scroll_to): remove logic introduced + by #80484 and the CLAMP, + (get_menu_height): new function, + (gtk_menu_real_move_scroll): sort of moved the CLAMP here to correct + new_offset to handle page up/down right. + Thu Aug 21 15:17:42 2003 Owen Taylor <otaylor@redhat.com> * gdk/x11/gdkkeys-x11.c: Change the interpretation diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 5e1b46df0..8d2723e5d 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,13 @@ +Thu Aug 21 21:27:45 2003 Kristian Rietveld <kris@gtk.org> + + Fix option menu scrolling (#119821, Owen Taylor). + + * gtk/gtkmenu.c (gtk_menu_scroll_to): remove logic introduced + by #80484 and the CLAMP, + (get_menu_height): new function, + (gtk_menu_real_move_scroll): sort of moved the CLAMP here to correct + new_offset to handle page up/down right. + Thu Aug 21 15:17:42 2003 Owen Taylor <otaylor@redhat.com> * gdk/x11/gdkkeys-x11.c: Change the interpretation diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c index a2caf81d0..8ca31f0d9 100644 --- a/gtk/gtkmenu.c +++ b/gtk/gtkmenu.c @@ -2818,7 +2818,7 @@ gtk_menu_scroll_to (GtkMenu *menu, if (!menu->tearoff_active) { last_visible = menu->upper_arrow_visible; - menu->upper_arrow_visible = (view_height < menu_height && offset > 0); + menu->upper_arrow_visible = offset > 0; if (menu->upper_arrow_visible) view_height -= MENU_SCROLL_ARROW_HEIGHT; @@ -2834,7 +2834,7 @@ gtk_menu_scroll_to (GtkMenu *menu, } last_visible = menu->lower_arrow_visible; - menu->lower_arrow_visible = (view_height < menu_height && offset < menu_height - view_height); + menu->lower_arrow_visible = offset < menu_height - view_height; if (menu->lower_arrow_visible) view_height -= MENU_SCROLL_ARROW_HEIGHT; @@ -2853,8 +2853,6 @@ gtk_menu_scroll_to (GtkMenu *menu, y += MENU_SCROLL_ARROW_HEIGHT; } - offset = CLAMP (offset, 0, menu_height - view_height); - /* Scroll the menu: */ if (GTK_WIDGET_REALIZED (menu)) gdk_window_move (menu->bin_window, 0, -offset); @@ -3172,6 +3170,24 @@ child_at (GtkMenu *menu, return child; } +static gint +get_menu_height (GtkMenu *menu) +{ + gint height; + GtkWidget *widget = GTK_WIDGET (menu); + + height = widget->requisition.height; + height -= (GTK_CONTAINER (widget)->border_width + widget->style->ythickness) * 2; + + if (menu->upper_arrow_visible && !menu->tearoff_active) + height -= MENU_SCROLL_ARROW_HEIGHT; + + if (menu->lower_arrow_visible && !menu->tearoff_active) + height -= MENU_SCROLL_ARROW_HEIGHT; + + return height; +} + static void gtk_menu_real_move_scroll (GtkMenu *menu, GtkScrollType type) @@ -3185,6 +3201,7 @@ gtk_menu_real_move_scroll (GtkMenu *menu, { gint page_size = get_visible_size (menu); gint old_offset; + gint new_offset; gint child_offset = 0; gboolean old_upper_arrow_visible; gint step; @@ -3206,7 +3223,11 @@ gtk_menu_real_move_scroll (GtkMenu *menu, menu_shell->ignore_enter = TRUE; old_upper_arrow_visible = menu->upper_arrow_visible && !menu->tearoff_active; old_offset = menu->scroll_offset; - gtk_menu_scroll_to (menu, menu->scroll_offset + step); + + new_offset = menu->scroll_offset + step; + new_offset = CLAMP (new_offset, 0, get_menu_height (menu) - page_size); + + gtk_menu_scroll_to (menu, new_offset); if (menu_shell->active_menu_item) { |