[gtk/prop-list: 3/5] columnviewcolumn: Add reordering helpers



commit b3077bd39b979f3db861ed5a47cbe67906760c48
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Dec 20 17:19:55 2019 -0500

    columnviewcolumn: Add reordering helpers
    
    Add helper functions that let us temporarily
    give a different allocation to headers, and
    get access to the header widget. These will
    be used to implement interactive column
    reordering in GtkColumnView.

 gtk/gtkcolumnviewcolumn.c        | 40 ++++++++++++++++++++++++++++++++++++++++
 gtk/gtkcolumnviewcolumnprivate.h |  9 +++++++++
 2 files changed, 49 insertions(+)
---
diff --git a/gtk/gtkcolumnviewcolumn.c b/gtk/gtkcolumnviewcolumn.c
index bcd73bd733..98a0223683 100644
--- a/gtk/gtkcolumnviewcolumn.c
+++ b/gtk/gtkcolumnviewcolumn.c
@@ -60,6 +60,7 @@ struct _GtkColumnViewColumn
   int natural_size_request;
   int allocation_offset;
   int allocation_size;
+  int header_position;
 
   int fixed_width;
 
@@ -442,6 +443,7 @@ gtk_column_view_column_allocate (GtkColumnViewColumn *self,
 {
   self->allocation_offset = offset;
   self->allocation_size = size;
+  self->header_position = offset;
 }
 
 void
@@ -865,3 +867,41 @@ gtk_column_view_column_in_resize_rect (GtkColumnViewColumn *self,
 
   return graphene_rect_contains_point (&rect, &(graphene_point_t) { x, y});
 }
+
+gboolean
+gtk_column_view_column_in_header (GtkColumnViewColumn *self,
+                                  double               x,
+                                  double               y)
+{
+  graphene_rect_t rect;
+
+  if (!gtk_widget_compute_bounds (self->header, GTK_WIDGET (self->view), &rect))
+    return FALSE;
+
+  return graphene_rect_contains_point (&rect, &(graphene_point_t) { x, y});
+}
+
+void
+gtk_column_view_column_set_header_position (GtkColumnViewColumn *self,
+                                            int                  offset)
+{
+  self->header_position = offset;
+}
+
+void
+gtk_column_view_column_get_header_allocation (GtkColumnViewColumn *self,
+                                              int                 *offset,
+                                              int                 *size)
+{
+  if (offset)
+    *offset = self->header_position;
+
+  if (size)
+    *size = self->allocation_size;
+}
+
+GtkWidget *
+gtk_column_view_column_get_header (GtkColumnViewColumn *self)
+{
+  return self->header;
+}
diff --git a/gtk/gtkcolumnviewcolumnprivate.h b/gtk/gtkcolumnviewcolumnprivate.h
index a4b588252f..999bf94d2e 100644
--- a/gtk/gtkcolumnviewcolumnprivate.h
+++ b/gtk/gtkcolumnviewcolumnprivate.h
@@ -50,5 +50,14 @@ void                    gtk_column_view_column_notify_sort              (GtkColu
 gboolean                gtk_column_view_column_in_resize_rect           (GtkColumnViewColumn    *self,
                                                                          double                  x,
                                                                          double                  y);
+gboolean                gtk_column_view_column_in_header                (GtkColumnViewColumn    *self,
+                                                                         double                  x,
+                                                                         double                  y);
+void                    gtk_column_view_column_set_header_position      (GtkColumnViewColumn    *self,
+                                                                         int                     offset);
+void                    gtk_column_view_column_get_header_allocation    (GtkColumnViewColumn    *self,
+                                                                         int                    *offset,
+                                                                         int                    *size);
+GtkWidget *             gtk_column_view_column_get_header               (GtkColumnViewColumn    *self);
 
 #endif  /* __GTK_COLUMN_VIEW_COLUMN_PRIVATE_H__ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]