From effefd28156b8ad5aff067f3031fd4b7627a2d5c Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Wed, 9 Jan 2002 06:49:52 +0000 Subject: Bumped version number to 0.19.99.0. Bumped GAL_CURRENT. Reset 2002-01-09 Christopher James Lahey * configure.in: Bumped version number to 0.19.99.0. Bumped GAL_CURRENT. Reset GAL_REVISION. From gal/e-table/ChangeLog: 2002-01-09 Christopher James Lahey * e-table.c, e-table.h (scroll_timeout), e-tree.c (scroll_timeout): Made these handle horizontal scrolling during drags. svn path=/trunk/; revision=15272 --- widgets/table/e-tree.c | 66 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 22 deletions(-) (limited to 'widgets/table/e-tree.c') diff --git a/widgets/table/e-tree.c b/widgets/table/e-tree.c index db68daff11..4e1154f44f 100644 --- a/widgets/table/e-tree.c +++ b/widgets/table/e-tree.c @@ -99,6 +99,13 @@ enum { ARG_UNIFORM_ROW_HEIGHT, }; +enum { + ET_SCROLL_UP = 1 << 0, + ET_SCROLL_DOWN = 1 << 1, + ET_SCROLL_LEFT = 1 << 2, + ET_SCROLL_RIGHT = 1 << 3 +}; + struct ETreePriv { ETreeModel *model; ETreeSorted *sorted; @@ -142,7 +149,7 @@ struct ETreePriv { guint horizontal_scrolling : 1; - guint scroll_down : 1; + guint scroll_direction : 4; guint do_drag : 1; @@ -219,7 +226,7 @@ static void et_drag_data_received(GtkWidget *widget, static gint et_focus (GtkContainer *container, GtkDirectionType direction); static void scroll_off (ETree *et); -static void scroll_on (ETree *et, gboolean down); +static void scroll_on (ETree *et, guint scroll_direction); static void hover_off (ETree *et); static void hover_on (ETree *et, int x, int y); @@ -2294,22 +2301,31 @@ static gboolean scroll_timeout (gpointer data) { ETree *et = data; - int dy; - GtkAdjustment *v; - double value; + int dx = 0, dy = 0; + GtkAdjustment *v, *h; + double vvalue, hvalue; - if (et->priv->scroll_down) - dy = 20; - else - dy = -20; + if (et->priv->scroll_direction & ET_SCROLL_DOWN) + dy += 20; + if (et->priv->scroll_direction & ET_SCROLL_UP) + dy -= 20; + + if (et->priv->scroll_direction & ET_SCROLL_RIGHT) + dx += 20; + if (et->priv->scroll_direction & ET_SCROLL_LEFT) + dx -= 20; + h = GTK_LAYOUT(et->priv->table_canvas)->hadjustment; v = GTK_LAYOUT(et->priv->table_canvas)->vadjustment; - value = v->value; + hvalue = h->value; + vvalue = v->value; + gtk_adjustment_set_value(h, CLAMP(h->value + dx, h->lower, h->upper - h->page_size)); gtk_adjustment_set_value(v, CLAMP(v->value + dy, v->lower, v->upper - v->page_size)); - if (v->value != value) + if (h->value != hvalue || + v->value != vvalue) do_drag_motion(et, et->priv->last_drop_context, et->priv->last_drop_x, @@ -2321,12 +2337,12 @@ scroll_timeout (gpointer data) } static void -scroll_on (ETree *et, gboolean down) +scroll_on (ETree *et, guint scroll_direction) { - if (et->priv->scroll_idle_id == 0 || down != et->priv->scroll_down) { + if (et->priv->scroll_idle_id == 0 || scroll_direction != et->priv->scroll_direction) { if (et->priv->scroll_idle_id != 0) g_source_remove (et->priv->scroll_idle_id); - et->priv->scroll_down = down; + et->priv->scroll_direction = scroll_direction; et->priv->scroll_idle_id = g_timeout_add (100, scroll_timeout, et); } } @@ -2339,7 +2355,7 @@ scroll_off (ETree *et) et->priv->scroll_idle_id = 0; } } - + static gboolean hover_timeout (gpointer data) { @@ -2478,6 +2494,7 @@ et_drag_motion(GtkWidget *widget, ETree *et) { int ret_val; + guint direction = 0; et->priv->last_drop_x = x; et->priv->last_drop_y = y; @@ -2503,14 +2520,19 @@ et_drag_motion(GtkWidget *widget, x -= widget->allocation.x; y -= widget->allocation.y; - if (y < 20 || y > widget->allocation.height - 20) { - if (y < 20) - scroll_on (et, FALSE); - else - scroll_on (et, TRUE); - } else { + if (y < 20) + direction |= ET_SCROLL_UP; + if (y > widget->allocation.height - 20) + direction |= ET_SCROLL_DOWN; + if (x < 20) + direction |= ET_SCROLL_LEFT; + if (x > widget->allocation.width - 20) + direction |= ET_SCROLL_RIGHT; + + if (direction != 0) + scroll_on (et, direction); + else scroll_off (et); - } return ret_val; } -- cgit