[Commits] [SCM] claws branch, master, updated. 3.14.0-132-gaaa7ab7

ticho at claws-mail.org ticho at claws-mail.org
Sat Nov 5 12:21:11 CET 2016


The branch, master has been updated
       via  aaa7ab7d3e7388bab55dadb1407f6a80b598b6ea (commit)
      from  2193529a58210cc79a07051e721f624c086d4121 (commit)

Summary of changes:
 src/gtk/gtkcmclist.c |   36 ++++++++++++++++++++++++++++++++++++
 src/gtk/gtkcmclist.h |    6 ++++++
 src/gtk/gtkutils.c   |    8 +++++++-
 3 files changed, 49 insertions(+), 1 deletion(-)


- Log -----------------------------------------------------------------
commit aaa7ab7d3e7388bab55dadb1407f6a80b598b6ea
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Sat Nov 5 12:18:53 2016 +0100

    Minimize scrolling in gtkut_ctree_node_move_if_on_the_edge().
    
    Instead of scrolling to get the target row to the middle of
    the viewport (offset 0.5), scroll to offsets 0.2 or 0.8 if
    the target row is above or below current viewport,
    respectively. This makes it consistent with scrolling when
    the target row is only partially visible.

diff --git a/src/gtk/gtkcmclist.c b/src/gtk/gtkcmclist.c
index e58f8c5..853f5ce 100644
--- a/src/gtk/gtkcmclist.c
+++ b/src/gtk/gtkcmclist.c
@@ -3310,6 +3310,42 @@ gtk_cmclist_row_is_visible (GtkCMCList *clist,
   return GTK_VISIBILITY_FULL;
 }
 
+gboolean
+gtk_cmclist_row_is_above_viewport (GtkCMCList *clist,
+				gint row)
+{
+	cm_return_val_if_fail(GTK_IS_CMCLIST (clist), 0);
+
+	if (row < 0 || row >= clist->rows)
+		return FALSE;
+
+	if (clist->row_height == 0)
+		return FALSE;
+
+	if (row < ROW_FROM_YPIXEL (clist, 0))
+		return TRUE;
+
+	return FALSE;
+}
+
+gboolean
+gtk_cmclist_row_is_below_viewport (GtkCMCList *clist,
+				gint row)
+{
+	cm_return_val_if_fail(GTK_IS_CMCLIST (clist), 0);
+
+	if (row < 0 || row >= clist->rows)
+		return FALSE;
+
+	if (clist->row_height == 0)
+		return FALSE;
+
+	if (row > ROW_FROM_YPIXEL (clist, clist->clist_window_height))
+		return TRUE;
+
+	return FALSE;
+}
+
 void
 gtk_cmclist_set_foreground (GtkCMCList       *clist,
 			  gint            row,
diff --git a/src/gtk/gtkcmclist.h b/src/gtk/gtkcmclist.h
index 4d2bc5a..e3c1f09 100644
--- a/src/gtk/gtkcmclist.h
+++ b/src/gtk/gtkcmclist.h
@@ -567,6 +567,12 @@ void gtk_cmclist_moveto (GtkCMCList *clist,
 GtkVisibility gtk_cmclist_row_is_visible (GtkCMCList *clist,
 					gint      row);
 
+/* returns whether the row is above or below current viewport */
+gboolean gtk_cmclist_row_is_above_viewport (GtkCMCList *clist,
+					gint row);
+gboolean gtk_cmclist_row_is_below_viewport (GtkCMCList *clist,
+					gint row);
+
 /* returns the cell type */
 GtkCMCellType gtk_cmclist_get_cell_type (GtkCMCList *clist,
 				     gint      row,
diff --git a/src/gtk/gtkutils.c b/src/gtk/gtkutils.c
index 15503f8..4500e0a 100644
--- a/src/gtk/gtkutils.c
+++ b/src/gtk/gtkutils.c
@@ -232,6 +232,7 @@ void gtkut_ctree_node_move_if_on_the_edge(GtkCMCTree *ctree, GtkCMCTreeNode *nod
 	GtkCMCList *clist = GTK_CMCLIST(ctree);
 	gint row;
 	GtkVisibility row_visibility, prev_row_visibility, next_row_visibility;
+	gfloat row_align;
 
 	cm_return_if_fail(ctree != NULL);
 	cm_return_if_fail(node != NULL);
@@ -244,7 +245,12 @@ void gtkut_ctree_node_move_if_on_the_edge(GtkCMCTree *ctree, GtkCMCTreeNode *nod
 	next_row_visibility = gtk_cmclist_row_is_visible(clist, row + 1);
 
 	if (row_visibility == GTK_VISIBILITY_NONE) {
-		gtk_cmclist_moveto(clist, row, -1, 0.5, 0);
+		row_align = 0.5;
+		if (gtk_cmclist_row_is_above_viewport(clist, row))
+			row_align = 0.2;
+		else if (gtk_cmclist_row_is_below_viewport(clist, row))
+			row_align = 0.8;
+		gtk_cmclist_moveto(clist, row, -1, row_align, 0);
 		return;
 	}
 	if (row_visibility == GTK_VISIBILITY_FULL &&

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list