[gtk/matthiasc/for-master: 2/2] columnview: Fix some issues with column resizing
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master: 2/2] columnview: Fix some issues with column resizing
- Date: Mon, 19 Oct 2020 01:48:59 +0000 (UTC)
commit 62d62cd6a0064c4a82a8af37eaa1564bfc98707d
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Oct 18 21:29:08 2020 -0400
columnview: Fix some issues with column resizing
Ensure that we place the resize rectangle at the visible
right edge of the column, not where the allocation ends
(we clip the header drawing, after all).
Make it so that for overlapping resize rectangles (with
very narrow columns), we prefer the narrow column, so you
can regrow a column after shrinking it all the way.
Finally, ensure that the column resize cursor stays in
place for the duration of the resize drag (the implicit
grab was interfering with this).
Related: #3274
gtk/gtkcolumnview.c | 28 +++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtkcolumnview.c b/gtk/gtkcolumnview.c
index d2b73fe105..ae7ffd82aa 100644
--- a/gtk/gtkcolumnview.c
+++ b/gtk/gtkcolumnview.c
@@ -862,12 +862,16 @@ gtk_column_view_in_resize_rect (GtkColumnView *self,
{
GtkWidget *header;
graphene_rect_t rect;
+ int width;
header = gtk_column_view_column_get_header (column);
if (!gtk_widget_compute_bounds (header, self->header, &rect))
return FALSE;
+ gtk_column_view_column_get_allocation (column, NULL, &width);
+ rect.size.width = width;
+
rect.origin.x += rect.size.width - DRAG_WIDTH / 2;
rect.size.width = DRAG_WIDTH;
@@ -902,7 +906,7 @@ header_drag_begin (GtkGestureDrag *gesture,
self->drag_pos = -1;
n = g_list_model_get_n_items (G_LIST_MODEL (self->columns));
- for (i = 0; !self->in_column_resize && i < n; i++)
+ for (i = n - 1; !self->in_column_resize && i >= 0; i--)
{
GtkColumnViewColumn *column = g_list_model_get_item (G_LIST_MODEL (self->columns), i);
@@ -929,9 +933,22 @@ header_drag_begin (GtkGestureDrag *gesture,
self->drag_x = start_x - size;
self->in_column_resize = TRUE;
+ gtk_widget_set_cursor_from_name (gtk_column_view_column_get_header (column), "col-resize");
+
g_object_unref (column);
break;
}
+ }
+
+ for (i = 0; !self->in_column_resize && i < n; i++)
+ {
+ GtkColumnViewColumn *column = g_list_model_get_item (G_LIST_MODEL (self->columns), i);
+
+ if (!gtk_column_view_column_get_visible (column))
+ {
+ g_object_unref (column);
+ continue;
+ }
if (gtk_column_view_get_reorderable (self) &&
gtk_column_view_in_header (self, column, start_x, start_y))
@@ -966,6 +983,12 @@ header_drag_end (GtkGestureDrag *gesture,
if (self->in_column_resize)
{
+ GtkColumnViewColumn *column;
+
+ column = g_list_model_get_item (G_LIST_MODEL (self->columns), self->drag_pos);
+ gtk_widget_set_cursor (gtk_column_view_column_get_header (column), NULL);
+ g_object_unref (column);
+
self->in_column_resize = FALSE;
}
else if (self->in_column_reorder)
@@ -1102,6 +1125,9 @@ header_motion (GtkEventControllerMotion *controller,
gboolean cursor_set = FALSE;
int i, n;
+ if (self->in_column_resize)
+ return;
+
n = g_list_model_get_n_items (G_LIST_MODEL (self->columns));
for (i = 0; i < n; i++)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]