Created
October 11, 2015 16:33
-
-
Save mattdangerw/b1c4ea1c8a5afacb07a9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From bfb1b394c54072ad003064c6d8bc65b27366647c Mon Sep 17 00:00:00 2001 | |
From: Matt Watson <mattdangerw@gmail.com> | |
Date: Sun, 11 Oct 2015 12:20:48 -0400 | |
Subject: [PATCH] gtkwidget: add css margin support | |
--- | |
gtk/gtkwidget.c | 35 +++++++++++++++++++++++------------ | |
1 file changed, 23 insertions(+), 12 deletions(-) | |
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c | |
index ab5f461..e039d3e 100644 | |
--- a/gtk/gtkwidget.c | |
+++ b/gtk/gtkwidget.c | |
@@ -6295,11 +6295,18 @@ gtk_widget_real_adjust_size_allocation (GtkWidget *widget, | |
gint *allocated_size) | |
{ | |
GtkWidgetPrivate *priv = widget->priv; | |
+ GtkStyleContext *context; | |
+ GtkBorder margin; | |
+ | |
+ context = gtk_widget_get_style_context (widget); | |
+ gtk_style_context_get_margin (context, | |
+ gtk_widget_get_state_flags (widget), | |
+ &margin); | |
if (orientation == GTK_ORIENTATION_HORIZONTAL) | |
{ | |
- adjust_for_margin (priv->margin.left, | |
- priv->margin.right, | |
+ adjust_for_margin (priv->margin.left + margin.left, | |
+ priv->margin.right + margin.right, | |
minimum_size, natural_size, | |
allocated_pos, allocated_size); | |
adjust_for_align (effective_align (priv->halign, _gtk_widget_get_direction (widget)), | |
@@ -6307,8 +6314,8 @@ gtk_widget_real_adjust_size_allocation (GtkWidget *widget, | |
} | |
else | |
{ | |
- adjust_for_margin (priv->margin.top, | |
- priv->margin.bottom, | |
+ adjust_for_margin (priv->margin.top + margin.top, | |
+ priv->margin.bottom + margin.bottom, | |
minimum_size, natural_size, | |
allocated_pos, allocated_size); | |
adjust_for_align (effective_align (priv->valign, GTK_TEXT_DIR_NONE), | |
@@ -12374,6 +12381,9 @@ gtk_widget_real_adjust_size_request (GtkWidget *widget, | |
gint *natural_size) | |
{ | |
GtkWidgetPrivate *priv = widget->priv; | |
+ GtkStyleContext *context; | |
+ GtkBorder margin; | |
+ gint total_margin; | |
if (orientation == GTK_ORIENTATION_HORIZONTAL && priv->width > 0) | |
*minimum_size = MAX (*minimum_size, priv->width); | |
@@ -12386,16 +12396,17 @@ gtk_widget_real_adjust_size_request (GtkWidget *widget, | |
*/ | |
*natural_size = MAX (*natural_size, *minimum_size); | |
+ context = gtk_widget_get_style_context (widget); | |
+ gtk_style_context_get_margin (context, | |
+ gtk_widget_get_state_flags (widget), | |
+ &margin); | |
+ | |
if (orientation == GTK_ORIENTATION_HORIZONTAL) | |
- { | |
- *minimum_size += priv->margin.left + priv->margin.right; | |
- *natural_size += priv->margin.left + priv->margin.right; | |
- } | |
+ total_margin = priv->margin.left + priv->margin.right + margin.left + margin.right; | |
else | |
- { | |
- *minimum_size += priv->margin.top + priv->margin.bottom; | |
- *natural_size += priv->margin.top + priv->margin.bottom; | |
- } | |
+ total_margin = priv->margin.top + priv->margin.left + margin.top + margin.left; | |
+ *minimum_size += total_margin; | |
+ *natural_size += total_margin; | |
} | |
static void | |
-- | |
2.1.4 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment