[gtk/matthiasc/for-master: 3/7] columnview: Make resize cursors reliable
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master: 3/7] columnview: Make resize cursors reliable
- Date: Mon, 19 Oct 2020 13:48:34 +0000 (UTC)
commit 1976df1e54562a1e007f823bc2cb89702097848b
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Oct 19 08:28:24 2020 -0400
columnview: Make resize cursors reliable
Ensure that the column resize cursor stays in place
for the duration of the resize drag. This is a bit
annoying, since the implicit grab can end up on the
header of a different column from the one we are
resizing, so just set the cursor on all column headers.
gtk/gtkcolumnview.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
---
diff --git a/gtk/gtkcolumnview.c b/gtk/gtkcolumnview.c
index 66ff4c4d96..eea3bb2571 100644
--- a/gtk/gtkcolumnview.c
+++ b/gtk/gtkcolumnview.c
@@ -895,6 +895,25 @@ header = gtk_column_view_column_get_header (column);
return graphene_rect_contains_point (&rect, &(graphene_point_t) { x, y});
}
+static void
+set_resize_cursor (GtkColumnView *self,
+ gboolean set)
+{
+ int i, n;
+
+ n = g_list_model_get_n_items (G_LIST_MODEL (self->columns));
+ for (i = 0; i < n; i++)
+ {
+ GtkColumnViewColumn *column = g_list_model_get_item (G_LIST_MODEL (self->columns), i);
+ GtkWidget *header = gtk_column_view_column_get_header (column);
+ if (set)
+ gtk_widget_set_cursor_from_name (header, "col-resize");
+ else
+ gtk_widget_set_cursor (header, NULL);
+ g_object_unref (column);
+ }
+}
+
static void
header_drag_begin (GtkGestureDrag *gesture,
double start_x,
@@ -933,7 +952,10 @@ header_drag_begin (GtkGestureDrag *gesture,
self->drag_x = start_x - size;
self->in_column_resize = TRUE;
+ set_resize_cursor (self, TRUE);
+
g_object_unref (column);
+
break;
}
}
@@ -981,6 +1003,7 @@ header_drag_end (GtkGestureDrag *gesture,
if (self->in_column_resize)
{
+ set_resize_cursor (self, FALSE);
self->in_column_resize = FALSE;
}
else if (self->in_column_reorder)
@@ -1117,6 +1140,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]