[gtk+] widget: Allow 0×0 allocations
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] widget: Allow 0×0 allocations
- Date: Fri, 6 Oct 2017 12:38:03 +0000 (UTC)
commit 3b9aa2f8d9e5468e9852504d98293174bd45a3f4
Author: Timm Bäder <mail baedert org>
Date: Fri Oct 6 11:16:35 2017 +0200
widget: Allow 0×0 allocations
Don't MAX the allocations with 1 anymore.
gtk/gtkbox.c | 14 +++++++-------
gtk/gtkwidget.c | 29 +++++++++++------------------
2 files changed, 18 insertions(+), 25 deletions(-)
---
diff --git a/gtk/gtkbox.c b/gtk/gtkbox.c
index 8655cc5..344ea52 100644
--- a/gtk/gtkbox.c
+++ b/gtk/gtkbox.c
@@ -530,7 +530,7 @@ gtk_box_size_allocate (GtkWidget *widget,
int child_allocation_width;
int child_minimum_height, child_natural_height;
- child_allocation_width = MAX (1, child_size);
+ child_allocation_width = child_size;
child_minimum_baseline = -1;
child_natural_baseline = -1;
@@ -560,7 +560,7 @@ gtk_box_size_allocate (GtkWidget *widget,
* and any of the child widgets explicitly request one */
if (baseline == -1 && have_baseline)
{
- gint height = MAX (1, allocation->height);
+ gint height = allocation->height;
/* TODO: This is purely based on the minimum baseline, when things fit we should
use the natural one? */
@@ -585,7 +585,7 @@ gtk_box_size_allocate (GtkWidget *widget,
if (private->orientation == GTK_ORIENTATION_HORIZONTAL)
{
child_allocation.y = allocation->y;
- child_allocation.height = MAX (1, allocation->height);
+ child_allocation.height = allocation->height;
if (packing == GTK_PACK_START)
x = allocation->x;
else
@@ -594,7 +594,7 @@ gtk_box_size_allocate (GtkWidget *widget,
else
{
child_allocation.x = allocation->x;
- child_allocation.width = MAX (1, allocation->width);
+ child_allocation.width = allocation->width;
if (packing == GTK_PACK_START)
y = allocation->y;
else
@@ -625,7 +625,7 @@ gtk_box_size_allocate (GtkWidget *widget,
/* Assign the child's position. */
if (private->orientation == GTK_ORIENTATION_HORIZONTAL)
{
- child_allocation.width = MAX (1, child_size);
+ child_allocation.width = child_size;
child_allocation.x = x;
if (packing == GTK_PACK_START)
@@ -645,7 +645,7 @@ gtk_box_size_allocate (GtkWidget *widget,
}
else /* (private->orientation == GTK_ORIENTATION_VERTICAL) */
{
- child_allocation.height = MAX (1, child_size);
+ child_allocation.height = child_size;
child_allocation.y = y;
if (packing == GTK_PACK_START)
@@ -1180,7 +1180,7 @@ gtk_box_compute_size_for_opposing_orientation (GtkBox *box,
}
}
- child_size = MAX (1, child_size);
+ child_size = child_size;
child_minimum_baseline = child_natural_baseline = -1;
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index d5e65b6..f663dac 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -3786,8 +3786,8 @@ gtk_widget_init (GTypeInstance *instance, gpointer g_class)
priv->name = NULL;
priv->allocation.x = -1;
priv->allocation.y = -1;
- priv->allocation.width = 1;
- priv->allocation.height = 1;
+ priv->allocation.width = 0;
+ priv->allocation.height = 0;
priv->clip = priv->allocation;
priv->user_alpha = 255;
priv->alpha = 255;
@@ -4021,12 +4021,10 @@ gtk_widget_unparent (GtkWidget *widget)
gtk_widget_queue_resize (priv->parent);
/* Reset the width and height here, to force reallocation if we
- * get added back to a new parent. This won't work if our new
- * allocation is smaller than 1x1 and we actually want a size of 1x1...
- * (would 0x0 be OK here?)
+ * get added back to a new parent.
*/
- priv->allocation.width = 1;
- priv->allocation.height = 1;
+ priv->allocation.width = 0;
+ priv->allocation.height = 0;
if (_gtk_widget_get_realized (widget))
gtk_widget_unrealize (widget);
@@ -5322,7 +5320,7 @@ invalidate:
*
* In this function, the allocation and baseline may be adjusted. The given
* allocation will be forced to be bigger than the widget's minimum size,
- * as well as at least 1×1 in size.
+ * as well as at least 0×0 in size.
*
* Since: 3.10
**/
@@ -5487,10 +5485,10 @@ gtk_widget_size_allocate (GtkWidget *widget,
g_warning ("gtk_widget_size_allocate(): attempt to allocate widget with width %d and height %d",
real_allocation.width,
real_allocation.height);
- }
- real_allocation.width = MAX (real_allocation.width, 1);
- real_allocation.height = MAX (real_allocation.height, 1);
+ real_allocation.width = 0;
+ real_allocation.height = 0;
+ }
baseline_changed = priv->allocated_baseline != baseline;
size_changed = (priv->allocation.width != real_allocation.width ||
@@ -7923,8 +7921,8 @@ _gtk_widget_set_visible_flag (GtkWidget *widget,
{
priv->allocation.x = -1;
priv->allocation.y = -1;
- priv->allocation.width = 1;
- priv->allocation.height = 1;
+ priv->allocation.width = 0;
+ priv->allocation.height = 0;
memset (&priv->clip, 0, sizeof (priv->clip));
memset (&priv->allocated_size, 0, sizeof (priv->allocated_size));
priv->allocated_size_baseline = 0;
@@ -9604,11 +9602,6 @@ gtk_widget_set_size_request (GtkWidget *widget,
g_return_if_fail (width >= -1);
g_return_if_fail (height >= -1);
- if (width == 0)
- width = 1;
- if (height == 0)
- height = 1;
-
gtk_widget_set_usize_internal (widget, width, height);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]