forked from AuroraMiddleware/gtk
New internal function returning a good step value for the mouse wheel. For
Sun Feb 29 19:04:33 2004 Soeren Sandmann <sandmann@daimi.au.dk> * gtk/gtkrange.c (_gtk_range_get_wheel_delta): New internal function returning a good step value for the mouse wheel. For scrollbars, base the step on page_size^(2/3), for other ranges, use 2 * step_increment. * gtk/gtkrange.c (gtk_range_scroll_event): Use it here ... * gtk/gtkscrolledwindow.c (gtk_scrolled_window_scroll_event): ... and here. * gtk/gtkmenu.c (gtk_menu_leave_notify): Fix a warning.
This commit is contained in:
parent
fc29c1a2fb
commit
41dfb5ec46
14
ChangeLog
14
ChangeLog
@ -1,3 +1,17 @@
|
||||
Sun Feb 29 19:04:33 2004 Soeren Sandmann <sandmann@daimi.au.dk>
|
||||
|
||||
* gtk/gtkrange.c (_gtk_range_get_wheel_delta): New internal
|
||||
function returning a good step value for the mouse wheel. For
|
||||
scrollbars, base the step on page_size^(2/3), for other ranges,
|
||||
use 2 * step_increment.
|
||||
|
||||
* gtk/gtkrange.c (gtk_range_scroll_event): Use it here ...
|
||||
|
||||
* gtk/gtkscrolledwindow.c (gtk_scrolled_window_scroll_event):
|
||||
... and here.
|
||||
|
||||
* gtk/gtkmenu.c (gtk_menu_leave_notify): Fix a warning.
|
||||
|
||||
Sun Feb 29 01:51:27 2004 Jonathan Blandford <jrb@gnome.org>
|
||||
|
||||
* gtk/gtkfilechooserembed.c
|
||||
|
@ -1,3 +1,17 @@
|
||||
Sun Feb 29 19:04:33 2004 Soeren Sandmann <sandmann@daimi.au.dk>
|
||||
|
||||
* gtk/gtkrange.c (_gtk_range_get_wheel_delta): New internal
|
||||
function returning a good step value for the mouse wheel. For
|
||||
scrollbars, base the step on page_size^(2/3), for other ranges,
|
||||
use 2 * step_increment.
|
||||
|
||||
* gtk/gtkrange.c (gtk_range_scroll_event): Use it here ...
|
||||
|
||||
* gtk/gtkscrolledwindow.c (gtk_scrolled_window_scroll_event):
|
||||
... and here.
|
||||
|
||||
* gtk/gtkmenu.c (gtk_menu_leave_notify): Fix a warning.
|
||||
|
||||
Sun Feb 29 01:51:27 2004 Jonathan Blandford <jrb@gnome.org>
|
||||
|
||||
* gtk/gtkfilechooserembed.c
|
||||
|
@ -1,3 +1,17 @@
|
||||
Sun Feb 29 19:04:33 2004 Soeren Sandmann <sandmann@daimi.au.dk>
|
||||
|
||||
* gtk/gtkrange.c (_gtk_range_get_wheel_delta): New internal
|
||||
function returning a good step value for the mouse wheel. For
|
||||
scrollbars, base the step on page_size^(2/3), for other ranges,
|
||||
use 2 * step_increment.
|
||||
|
||||
* gtk/gtkrange.c (gtk_range_scroll_event): Use it here ...
|
||||
|
||||
* gtk/gtkscrolledwindow.c (gtk_scrolled_window_scroll_event):
|
||||
... and here.
|
||||
|
||||
* gtk/gtkmenu.c (gtk_menu_leave_notify): Fix a warning.
|
||||
|
||||
Sun Feb 29 01:51:27 2004 Jonathan Blandford <jrb@gnome.org>
|
||||
|
||||
* gtk/gtkfilechooserembed.c
|
||||
|
@ -1,3 +1,17 @@
|
||||
Sun Feb 29 19:04:33 2004 Soeren Sandmann <sandmann@daimi.au.dk>
|
||||
|
||||
* gtk/gtkrange.c (_gtk_range_get_wheel_delta): New internal
|
||||
function returning a good step value for the mouse wheel. For
|
||||
scrollbars, base the step on page_size^(2/3), for other ranges,
|
||||
use 2 * step_increment.
|
||||
|
||||
* gtk/gtkrange.c (gtk_range_scroll_event): Use it here ...
|
||||
|
||||
* gtk/gtkscrolledwindow.c (gtk_scrolled_window_scroll_event):
|
||||
... and here.
|
||||
|
||||
* gtk/gtkmenu.c (gtk_menu_leave_notify): Fix a warning.
|
||||
|
||||
Sun Feb 29 01:51:27 2004 Jonathan Blandford <jrb@gnome.org>
|
||||
|
||||
* gtk/gtkfilechooserembed.c
|
||||
|
@ -1,3 +1,17 @@
|
||||
Sun Feb 29 19:04:33 2004 Soeren Sandmann <sandmann@daimi.au.dk>
|
||||
|
||||
* gtk/gtkrange.c (_gtk_range_get_wheel_delta): New internal
|
||||
function returning a good step value for the mouse wheel. For
|
||||
scrollbars, base the step on page_size^(2/3), for other ranges,
|
||||
use 2 * step_increment.
|
||||
|
||||
* gtk/gtkrange.c (gtk_range_scroll_event): Use it here ...
|
||||
|
||||
* gtk/gtkscrolledwindow.c (gtk_scrolled_window_scroll_event):
|
||||
... and here.
|
||||
|
||||
* gtk/gtkmenu.c (gtk_menu_leave_notify): Fix a warning.
|
||||
|
||||
Sun Feb 29 01:51:27 2004 Jonathan Blandford <jrb@gnome.org>
|
||||
|
||||
* gtk/gtkfilechooserembed.c
|
||||
|
@ -2880,7 +2880,7 @@ gtk_menu_leave_notify (GtkWidget *widget,
|
||||
gtk_menu_set_submenu_navigation_region (menu, menu_item, event);
|
||||
return TRUE;
|
||||
}
|
||||
else if (menu_item == menu_shell->active_menu_item)
|
||||
else if (menu_item == GTK_MENU_ITEM (menu_shell->active_menu_item))
|
||||
{
|
||||
/* We are leaving an active menu item with nonactive submenu.
|
||||
* Deselect it so we don't surprise the user with by popping
|
||||
|
@ -26,11 +26,13 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include "gtkintl.h"
|
||||
#include "gtkmain.h"
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtkrange.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkscrollbar.h"
|
||||
|
||||
#define SCROLL_INITIAL_DELAY 250 /* must hold button this long before ... */
|
||||
#define SCROLL_LATER_DELAY 100 /* ... it starts repeating at this rate */
|
||||
@ -1364,6 +1366,39 @@ gtk_range_button_release (GtkWidget *widget,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* _gtk_range_get_wheel_delta:
|
||||
* @range: a #GtkRange
|
||||
* @direction: A #GdkScrollDirection
|
||||
*
|
||||
* Returns a good step value for the mouse wheel.
|
||||
*
|
||||
* Return value: A good step value for the mouse wheel.
|
||||
*
|
||||
* Since: 2.4
|
||||
**/
|
||||
gdouble
|
||||
_gtk_range_get_wheel_delta (GtkRange *range,
|
||||
GdkScrollDirection direction)
|
||||
{
|
||||
GtkAdjustment *adj = range->adjustment;
|
||||
gdouble delta;
|
||||
|
||||
if (GTK_IS_SCROLLBAR (range))
|
||||
delta = pow (adj->page_size, 2.0 / 3.0);
|
||||
else
|
||||
delta = adj->step_increment * 2;
|
||||
|
||||
if (direction == GDK_SCROLL_UP ||
|
||||
direction == GDK_SCROLL_LEFT)
|
||||
delta = - delta;
|
||||
|
||||
if (range->inverted)
|
||||
delta = - delta;
|
||||
|
||||
return delta;
|
||||
}
|
||||
|
||||
static gint
|
||||
gtk_range_scroll_event (GtkWidget *widget,
|
||||
GdkEventScroll *event)
|
||||
@ -1373,16 +1408,11 @@ gtk_range_scroll_event (GtkWidget *widget,
|
||||
if (GTK_WIDGET_REALIZED (range))
|
||||
{
|
||||
GtkAdjustment *adj = GTK_RANGE (range)->adjustment;
|
||||
gdouble increment = ((event->direction == GDK_SCROLL_UP ||
|
||||
event->direction == GDK_SCROLL_LEFT) ?
|
||||
-adj->page_increment / 2:
|
||||
adj->page_increment / 2);
|
||||
|
||||
if (range->inverted)
|
||||
increment = -increment;
|
||||
|
||||
gtk_range_internal_set_value (range, adj->value + increment);
|
||||
gdouble delta;
|
||||
|
||||
delta = _gtk_range_get_wheel_delta (range, event->direction);
|
||||
gtk_range_internal_set_value (range, adj->value + delta);
|
||||
|
||||
/* Policy DELAYED makes sense with scroll events,
|
||||
* but DISCONTINUOUS doesn't, so we update immediately
|
||||
* for DISCONTINUOUS
|
||||
|
@ -149,6 +149,8 @@ void gtk_range_set_value (GtkRange *range,
|
||||
gdouble value);
|
||||
gdouble gtk_range_get_value (GtkRange *range);
|
||||
|
||||
gdouble _gtk_range_get_wheel_delta (GtkRange *range,
|
||||
GdkScrollDirection direction);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -24,6 +24,7 @@
|
||||
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#include "gtkbindings.h"
|
||||
#include "gtkmarshalers.h"
|
||||
@ -1226,14 +1227,12 @@ gtk_scrolled_window_scroll_event (GtkWidget *widget,
|
||||
if (range && GTK_WIDGET_VISIBLE (range))
|
||||
{
|
||||
GtkAdjustment *adj = GTK_RANGE (range)->adjustment;
|
||||
gdouble new_value;
|
||||
gdouble delta, new_value;
|
||||
|
||||
if (event->direction == GDK_SCROLL_UP || event->direction == GDK_SCROLL_LEFT)
|
||||
new_value = adj->value - adj->page_increment / 2;
|
||||
else
|
||||
new_value = adj->value + adj->page_increment / 2;
|
||||
delta = _gtk_range_get_wheel_delta (GTK_RANGE (range), event->direction);
|
||||
|
||||
new_value = CLAMP (new_value, adj->lower, adj->upper - adj->page_size);
|
||||
new_value = CLAMP (adj->value + delta, adj->lower, adj->upper - adj->page_size);
|
||||
|
||||
gtk_adjustment_set_value (adj, new_value);
|
||||
|
||||
return TRUE;
|
||||
|
Loading…
Reference in New Issue
Block a user