mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-15 13:10:08 +00:00
listbase: Don't use adjustments for autoscrolling
Don't consult the adjustments when determining scroll deltas. It isn't necessary.
This commit is contained in:
parent
c659a231d6
commit
02b293b59c
@ -1251,23 +1251,36 @@ autoscroll_cb (GtkWidget *widget,
|
||||
GtkListBase *self = data;
|
||||
GtkListBasePrivate *priv = gtk_list_base_get_instance_private (self);
|
||||
double value;
|
||||
double delta_x, delta_y;
|
||||
|
||||
value = gtk_adjustment_get_value (priv->adjustment[GTK_ORIENTATION_HORIZONTAL]);
|
||||
gtk_adjustment_set_value (priv->adjustment[GTK_ORIENTATION_HORIZONTAL], value + priv->autoscroll_delta_x);
|
||||
|
||||
delta_x = gtk_adjustment_get_value (priv->adjustment[GTK_ORIENTATION_HORIZONTAL]) - value;
|
||||
|
||||
value = gtk_adjustment_get_value (priv->adjustment[GTK_ORIENTATION_VERTICAL]);
|
||||
gtk_adjustment_set_value (priv->adjustment[GTK_ORIENTATION_VERTICAL], value + priv->autoscroll_delta_y);
|
||||
|
||||
delta_y = gtk_adjustment_get_value (priv->adjustment[GTK_ORIENTATION_VERTICAL]) - value;
|
||||
|
||||
if (priv->rubberband)
|
||||
{
|
||||
priv->rubberband->x2 += priv->autoscroll_delta_x;
|
||||
priv->rubberband->y2 += priv->autoscroll_delta_y;
|
||||
priv->rubberband->x2 += delta_x;
|
||||
priv->rubberband->y2 += delta_y;
|
||||
gtk_list_base_update_rubberband_selection (self);
|
||||
}
|
||||
|
||||
gtk_widget_queue_draw (GTK_WIDGET (self));
|
||||
|
||||
return G_SOURCE_CONTINUE;
|
||||
if (delta_x != 0 || delta_y != 0)
|
||||
{
|
||||
return G_SOURCE_CONTINUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
priv->autoscroll_id = 0;
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1303,29 +1316,27 @@ update_autoscroll (GtkListBase *self,
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
GtkListBasePrivate *priv = gtk_list_base_get_instance_private (self);
|
||||
double value, page_size, upper;
|
||||
double width, height;
|
||||
double delta_x, delta_y;
|
||||
|
||||
value = gtk_adjustment_get_value (priv->adjustment[GTK_ORIENTATION_HORIZONTAL]);
|
||||
page_size = gtk_adjustment_get_page_size (priv->adjustment[GTK_ORIENTATION_HORIZONTAL]);
|
||||
upper = gtk_adjustment_get_upper (priv->adjustment[GTK_ORIENTATION_HORIZONTAL]);
|
||||
width = gtk_widget_get_width (GTK_WIDGET (self));
|
||||
|
||||
if (x < SCROLL_EDGE_SIZE && value > 0)
|
||||
if (x < SCROLL_EDGE_SIZE)
|
||||
delta_x = - (SCROLL_EDGE_SIZE - x)/3.0;
|
||||
else if (page_size - x < SCROLL_EDGE_SIZE && value + page_size < upper)
|
||||
delta_x = (SCROLL_EDGE_SIZE - (page_size - x))/3.0;
|
||||
else if (width - x < SCROLL_EDGE_SIZE)
|
||||
delta_x = (SCROLL_EDGE_SIZE - (width - x))/3.0;
|
||||
else
|
||||
delta_x = 0;
|
||||
|
||||
value = gtk_adjustment_get_value (priv->adjustment[GTK_ORIENTATION_VERTICAL]);
|
||||
page_size = gtk_adjustment_get_page_size (priv->adjustment[GTK_ORIENTATION_VERTICAL]);
|
||||
upper = gtk_adjustment_get_upper (priv->adjustment[GTK_ORIENTATION_VERTICAL]);
|
||||
if (gtk_widget_get_direction (GTK_WIDGET (self)) == GTK_TEXT_DIR_RTL)
|
||||
delta_x = - delta_x;
|
||||
|
||||
if (y < SCROLL_EDGE_SIZE && value > 0)
|
||||
height = gtk_widget_get_height (GTK_WIDGET (self));
|
||||
|
||||
if (y < SCROLL_EDGE_SIZE)
|
||||
delta_y = - (SCROLL_EDGE_SIZE - y)/3.0;
|
||||
else if (page_size - y < SCROLL_EDGE_SIZE && value + page_size < upper)
|
||||
delta_y = (SCROLL_EDGE_SIZE - (page_size - y))/3.0;
|
||||
else if (height - y < SCROLL_EDGE_SIZE)
|
||||
delta_y = (SCROLL_EDGE_SIZE - (height - y))/3.0;
|
||||
else
|
||||
delta_y = 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user