[gtk/wip/otte/matrix: 4/5] widget: Make gtk_widget_allocate() take a GtkMatrix
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/matrix: 4/5] widget: Make gtk_widget_allocate() take a GtkMatrix
- Date: Tue, 19 Feb 2019 07:27:13 +0000 (UTC)
commit 80be6ec08d7786a68caf7ad20771d5cddc613413
Author: Benjamin Otte <otte redhat com>
Date: Tue Feb 19 08:11:42 2019 +0100
widget: Make gtk_widget_allocate() take a GtkMatrix
We can reason about GtkMatrix way better - and determine its category or
do equality checks.
gtk/gtkwidget.c | 47 ++++++++++++++++++++++++++++-------------------
gtk/gtkwidget.h | 2 +-
gtk/gtkwidgetprivate.h | 2 +-
3 files changed, 30 insertions(+), 21 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 2b84290df4..0762ca8d49 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -47,8 +47,9 @@
#include "gtkgesturesingle.h"
#include "gtkgestureswipe.h"
#include "gtkintl.h"
-#include "gtkmarshalers.h"
#include "gtkmain.h"
+#include "gtkmarshalers.h"
+#include "gtkmatrix.h"
#include "gtkmenu.h"
#include "gtkpopover.h"
#include "gtkprivate.h"
@@ -4152,15 +4153,20 @@ gtk_widget_size_allocate (GtkWidget *widget,
const GtkAllocation *allocation,
int baseline)
{
- graphene_matrix_t transform;
+ GtkMatrix *transform;
+
+ if (allocation->x || allocation->y)
+ transform = gtk_matrix_translate (NULL, &GRAPHENE_POINT_INIT (allocation->x, allocation->y));
+ else
+ transform = NULL;
- graphene_matrix_init_translate (&transform,
- &GRAPHENE_POINT3D_INIT (allocation->x, allocation->y, 0));
gtk_widget_allocate (widget,
allocation->width,
allocation->height,
baseline,
- &transform);
+ transform);
+
+ gtk_matrix_unref (transform);
}
/**
@@ -4169,7 +4175,7 @@ gtk_widget_size_allocate (GtkWidget *widget,
* @width: New width of @widget
* @height: New height of @widget
* @baseline: New baseline of @widget, or -1
- * @transform: Transformation to be applied to @widget
+ * @transform: (tranisfer none): Transformation to be applied to @widget
*
* This function is only used by #GtkWidget subclasses, to assign a size,
* position and (optionally) baseline to their child widgets.
@@ -4181,11 +4187,11 @@ gtk_widget_size_allocate (GtkWidget *widget,
* For a version that does not take a transform, see gtk_widget_size_allocate()
*/
void
-gtk_widget_allocate (GtkWidget *widget,
- int width,
- int height,
- int baseline,
- const graphene_matrix_t *transform)
+gtk_widget_allocate (GtkWidget *widget,
+ int width,
+ int height,
+ int baseline,
+ GtkMatrix *transform)
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
GdkRectangle adjusted;
@@ -4197,11 +4203,13 @@ gtk_widget_allocate (GtkWidget *widget,
gint min_width, min_height;
GtkCssStyle *style;
GtkBorder margin, border, padding;
+ graphene_matrix_t computed;
+#ifdef G_ENABLE_DEBUG
GdkDisplay *display;
+#endif
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (baseline >= -1);
- g_return_if_fail (transform != NULL);
gtk_widget_push_verify_invariants (widget);
@@ -4231,11 +4239,11 @@ gtk_widget_allocate (GtkWidget *widget,
baseline_changed = priv->allocated_size_baseline != baseline;
size_changed = (priv->allocated_width != width ||
priv->allocated_height != height);
- transform_changed = memcmp (&priv->allocated_transform,
- transform,
- sizeof (graphene_matrix_t)) != 0;
+ transform_changed = !gtk_matrix_equal (priv->allocated_transform, transform);
- graphene_matrix_init_from_matrix (&priv->allocated_transform, transform);
+ gtk_matrix_ref (transform);
+ gtk_matrix_unref (priv->allocated_transform);
+ priv->allocated_transform = transform;
priv->allocated_width = width;
priv->allocated_height = height;
priv->allocated_size_baseline = baseline;
@@ -4325,7 +4333,8 @@ gtk_widget_allocate (GtkWidget *widget,
baseline -= margin.top + border.top + padding.top;
graphene_matrix_init_translate (&priv->transform, &GRAPHENE_POINT3D_INIT (adjusted.x, adjusted.y, 0));
- graphene_matrix_multiply (&priv->transform, transform, &priv->transform);
+ gtk_matrix_compute (transform, &computed);
+ graphene_matrix_multiply (&priv->transform, &computed, &priv->transform);
if (!alloc_needed && !size_changed && !baseline_changed)
{
@@ -6229,7 +6238,7 @@ _gtk_widget_set_visible_flag (GtkWidget *widget,
if (!visible)
{
- graphene_matrix_init_identity (&priv->allocated_transform);
+ g_clear_pointer (&priv->allocated_transform, gtk_matrix_unref);
priv->allocated_width = 0;
priv->allocated_height = 0;
priv->allocated_size_baseline = 0;
@@ -11872,7 +11881,7 @@ gtk_widget_ensure_allocate (GtkWidget *widget)
priv->allocated_width,
priv->allocated_height,
priv->allocated_size_baseline,
- &priv->allocated_transform);
+ priv->allocated_transform);
}
else if (priv->alloc_needed_on_child)
{
diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h
index 057be5662f..d2fa6b7711 100644
--- a/gtk/gtkwidget.h
+++ b/gtk/gtkwidget.h
@@ -416,7 +416,7 @@ void gtk_widget_allocate (GtkWidget *widget,
int width,
int height,
int baseline,
- const graphene_matrix_t *transform);
+ GtkMatrix *transform);
GDK_AVAILABLE_IN_ALL
GtkSizeRequestMode gtk_widget_get_request_mode (GtkWidget *widget);
diff --git a/gtk/gtkwidgetprivate.h b/gtk/gtkwidgetprivate.h
index 31356ae5a5..6908ec9360 100644
--- a/gtk/gtkwidgetprivate.h
+++ b/gtk/gtkwidgetprivate.h
@@ -144,7 +144,7 @@ struct _GtkWidgetPrivate
GtkStyleContext *context;
/* The widget's allocated size */
- graphene_matrix_t allocated_transform;
+ GtkMatrix *allocated_transform;
int allocated_width;
int allocated_height;
gint allocated_size_baseline;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]