[gtk/wip/otte/bitset: 15/23] listbase: Move a common function from the children into GtkListBase
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/bitset: 15/23] listbase: Move a common function from the children into GtkListBase
- Date: Fri, 26 Jun 2020 03:18:05 +0000 (UTC)
commit 3b8ef140217fc70418deb612d86a55337cb3405c
Author: Benjamin Otte <otte redhat com>
Date: Wed Jun 24 04:49:21 2020 +0200
listbase: Move a common function from the children into GtkListBase
We want to use it for the rubberband later.
gtk/gtkgridview.c | 39 +------------------------------------
gtk/gtklistbase.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++
gtk/gtklistbaseprivate.h | 9 ++++++++-
gtk/gtklistview.c | 39 +------------------------------------
4 files changed, 60 insertions(+), 77 deletions(-)
---
diff --git a/gtk/gtkgridview.c b/gtk/gtkgridview.c
index 5b2a381c69..5fde3eb895 100644
--- a/gtk/gtkgridview.c
+++ b/gtk/gtkgridview.c
@@ -687,43 +687,6 @@ cell_set_size (Cell *cell,
gtk_rb_tree_node_mark_dirty (cell);
}
-static void
-gtk_grid_view_size_allocate_child (GtkGridView *self,
- GtkWidget *child,
- int x,
- int y,
- int width,
- int height)
-{
- GtkAllocation child_allocation;
-
- if (gtk_list_base_get_orientation (GTK_LIST_BASE (self)) == GTK_ORIENTATION_VERTICAL)
- {
- child_allocation.x = x;
- child_allocation.y = y;
- child_allocation.width = width;
- child_allocation.height = height;
- }
- else if (_gtk_widget_get_direction (GTK_WIDGET (self)) == GTK_TEXT_DIR_LTR)
- {
- child_allocation.x = y;
- child_allocation.y = x;
- child_allocation.width = height;
- child_allocation.height = width;
- }
- else
- {
- int mirror_point = gtk_widget_get_width (GTK_WIDGET (self));
-
- child_allocation.x = mirror_point - y - height;
- child_allocation.y = x;
- child_allocation.width = height;
- child_allocation.height = width;
- }
-
- gtk_widget_size_allocate (child, &child_allocation, -1);
-}
-
static int
gtk_grid_view_compute_total_height (GtkGridView *self)
{
@@ -873,7 +836,7 @@ gtk_grid_view_size_allocate (GtkWidget *widget,
{
row_height += cell->size;
- gtk_grid_view_size_allocate_child (self,
+ gtk_list_base_size_allocate_child (GTK_LIST_BASE (self),
cell->parent.widget,
x + ceil (self->column_width * i),
y,
diff --git a/gtk/gtklistbase.c b/gtk/gtklistbase.c
index c18db8a5dc..70036eedf3 100644
--- a/gtk/gtklistbase.c
+++ b/gtk/gtklistbase.c
@@ -1337,6 +1337,56 @@ update_autoscroll (GtkListBase *self,
remove_autoscroll (self);
}
+/**
+ * gtk_list_base_size_allocate_child:
+ * @self: The listbase
+ * @child:
+ * @x: top left coordinate in the across direction
+ * @y: top right coordinate in the along direction
+ * @width: size in the across direction
+ * @height: size in the along direction
+ *
+ * Allocates a child widget in the list coordinate system,
+ * but with the coordinates already offset by the scroll
+ * offset.
+ **/
+void
+gtk_list_base_size_allocate_child (GtkListBase *self,
+ GtkWidget *child,
+ int x,
+ int y,
+ int width,
+ int height)
+{
+ GtkAllocation child_allocation;
+
+ if (gtk_list_base_get_orientation (GTK_LIST_BASE (self)) == GTK_ORIENTATION_VERTICAL)
+ {
+ child_allocation.x = x;
+ child_allocation.y = y;
+ child_allocation.width = width;
+ child_allocation.height = height;
+ }
+ else if (_gtk_widget_get_direction (GTK_WIDGET (self)) == GTK_TEXT_DIR_LTR)
+ {
+ child_allocation.x = y;
+ child_allocation.y = x;
+ child_allocation.width = height;
+ child_allocation.height = width;
+ }
+ else
+ {
+ int mirror_point = gtk_widget_get_width (GTK_WIDGET (self));
+
+ child_allocation.x = mirror_point - y - height;
+ child_allocation.y = x;
+ child_allocation.width = height;
+ child_allocation.height = width;
+ }
+
+ gtk_widget_size_allocate (child, &child_allocation, -1);
+}
+
void
gtk_list_base_allocate_rubberband (GtkListBase *self)
{
diff --git a/gtk/gtklistbaseprivate.h b/gtk/gtklistbaseprivate.h
index 7cf0504a43..87df14d2d2 100644
--- a/gtk/gtklistbaseprivate.h
+++ b/gtk/gtklistbaseprivate.h
@@ -99,10 +99,17 @@ gboolean gtk_list_base_grab_focus_on_item (GtkListBase
gboolean select,
gboolean modify,
gboolean extend);
+
void gtk_list_base_set_enable_rubberband (GtkListBase *self,
gboolean enable);
gboolean gtk_list_base_get_enable_rubberband (GtkListBase *self);
-
void gtk_list_base_allocate_rubberband (GtkListBase *self);
+void gtk_list_base_size_allocate_child (GtkListBase *self,
+ GtkWidget *child,
+ int x,
+ int y,
+ int width,
+ int height);
+
#endif /* __GTK_LIST_BASE_PRIVATE_H__ */
diff --git a/gtk/gtklistview.c b/gtk/gtklistview.c
index 484f5b172c..b34b216e71 100644
--- a/gtk/gtklistview.c
+++ b/gtk/gtklistview.c
@@ -553,43 +553,6 @@ gtk_list_view_measure (GtkWidget *widget,
gtk_list_view_measure_across (widget, orientation, for_size, minimum, natural);
}
-static void
-gtk_list_view_size_allocate_child (GtkListView *self,
- GtkWidget *child,
- int x,
- int y,
- int width,
- int height)
-{
- GtkAllocation child_allocation;
-
- if (gtk_list_base_get_orientation (GTK_LIST_BASE (self)) == GTK_ORIENTATION_VERTICAL)
- {
- child_allocation.x = x;
- child_allocation.y = y;
- child_allocation.width = width;
- child_allocation.height = height;
- }
- else if (_gtk_widget_get_direction (GTK_WIDGET (self)) == GTK_TEXT_DIR_LTR)
- {
- child_allocation.x = y;
- child_allocation.y = x;
- child_allocation.width = height;
- child_allocation.height = width;
- }
- else
- {
- int mirror_point = gtk_widget_get_width (GTK_WIDGET (self));
-
- child_allocation.x = mirror_point - y - height;
- child_allocation.y = x;
- child_allocation.width = height;
- child_allocation.height = width;
- }
-
- gtk_widget_size_allocate (child, &child_allocation, -1);
-}
-
static void
gtk_list_view_size_allocate (GtkWidget *widget,
int width,
@@ -685,7 +648,7 @@ gtk_list_view_size_allocate (GtkWidget *widget,
{
if (row->parent.widget)
{
- gtk_list_view_size_allocate_child (self,
+ gtk_list_base_size_allocate_child (GTK_LIST_BASE (self),
row->parent.widget,
x,
y,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]