Thu Aug 21 21:27:45 2003 Kristian Rietveld <kris@gtk.org>A

Merge from stable.

	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.
This commit is contained in:
Kristian Rietveld
2003-08-21 19:42:44 +00:00
parent c7c5a7ddaa
commit 0321556d15
6 changed files with 86 additions and 5 deletions

View File

@ -1,3 +1,15 @@
Thu Aug 21 21:27:45 2003 Kristian Rietveld <kris@gtk.org>A
Merge from stable.
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> Thu Aug 21 15:17:42 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkkeys-x11.c: Change the interpretation * gdk/x11/gdkkeys-x11.c: Change the interpretation

View File

@ -1,3 +1,15 @@
Thu Aug 21 21:27:45 2003 Kristian Rietveld <kris@gtk.org>A
Merge from stable.
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> Thu Aug 21 15:17:42 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkkeys-x11.c: Change the interpretation * gdk/x11/gdkkeys-x11.c: Change the interpretation

View File

@ -1,3 +1,15 @@
Thu Aug 21 21:27:45 2003 Kristian Rietveld <kris@gtk.org>A
Merge from stable.
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> Thu Aug 21 15:17:42 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkkeys-x11.c: Change the interpretation * gdk/x11/gdkkeys-x11.c: Change the interpretation

View File

@ -1,3 +1,15 @@
Thu Aug 21 21:27:45 2003 Kristian Rietveld <kris@gtk.org>A
Merge from stable.
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> Thu Aug 21 15:17:42 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkkeys-x11.c: Change the interpretation * gdk/x11/gdkkeys-x11.c: Change the interpretation

View File

@ -1,3 +1,15 @@
Thu Aug 21 21:27:45 2003 Kristian Rietveld <kris@gtk.org>A
Merge from stable.
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> Thu Aug 21 15:17:42 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkkeys-x11.c: Change the interpretation * gdk/x11/gdkkeys-x11.c: Change the interpretation

View File

@ -2990,7 +2990,7 @@ gtk_menu_scroll_to (GtkMenu *menu,
if (!menu->tearoff_active) if (!menu->tearoff_active)
{ {
last_visible = menu->upper_arrow_visible; 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) if (menu->upper_arrow_visible)
view_height -= MENU_SCROLL_ARROW_HEIGHT; view_height -= MENU_SCROLL_ARROW_HEIGHT;
@ -3009,7 +3009,7 @@ gtk_menu_scroll_to (GtkMenu *menu,
} }
last_visible = menu->lower_arrow_visible; 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) if (menu->lower_arrow_visible)
view_height -= MENU_SCROLL_ARROW_HEIGHT; view_height -= MENU_SCROLL_ARROW_HEIGHT;
@ -3031,8 +3031,6 @@ gtk_menu_scroll_to (GtkMenu *menu,
y += MENU_SCROLL_ARROW_HEIGHT; y += MENU_SCROLL_ARROW_HEIGHT;
} }
offset = CLAMP (offset, 0, menu_height - view_height);
/* Scroll the menu: */ /* Scroll the menu: */
if (GTK_WIDGET_REALIZED (menu)) if (GTK_WIDGET_REALIZED (menu))
gdk_window_move (menu->bin_window, 0, -offset); gdk_window_move (menu->bin_window, 0, -offset);
@ -3356,6 +3354,24 @@ child_at (GtkMenu *menu,
return child; 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 static void
gtk_menu_real_move_scroll (GtkMenu *menu, gtk_menu_real_move_scroll (GtkMenu *menu,
GtkScrollType type) GtkScrollType type)
@ -3369,6 +3385,7 @@ gtk_menu_real_move_scroll (GtkMenu *menu,
{ {
gint page_size = get_visible_size (menu); gint page_size = get_visible_size (menu);
gint old_offset; gint old_offset;
gint new_offset;
gint child_offset = 0; gint child_offset = 0;
gboolean old_upper_arrow_visible; gboolean old_upper_arrow_visible;
gint step; gint step;
@ -3390,7 +3407,11 @@ gtk_menu_real_move_scroll (GtkMenu *menu,
menu_shell->ignore_enter = TRUE; menu_shell->ignore_enter = TRUE;
old_upper_arrow_visible = menu->upper_arrow_visible && !menu->tearoff_active; old_upper_arrow_visible = menu->upper_arrow_visible && !menu->tearoff_active;
old_offset = menu->scroll_offset; 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) if (menu_shell->active_menu_item)
{ {