[gtk+/gtk-3-8] GtkOverlay: Respect overlay child min size



commit e495d318cb0ebe1341ae6272f2ed6d1aefc6f206
Author: Alexander Larsson <alexl redhat com>
Date:   Thu Mar 28 13:24:04 2013 +0100

    GtkOverlay: Respect overlay child min size
    
    Never allocate an overlayed child less than its minimum request.
    If the minimum doesn't fit we will gracefully clip via the
    widget window.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=696623

 gtk/gtkoverlay.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtkoverlay.c b/gtk/gtkoverlay.c
index d87e977..c69e104 100644
--- a/gtk/gtkoverlay.c
+++ b/gtk/gtkoverlay.c
@@ -372,15 +372,15 @@ gtk_overlay_get_child_position (GtkOverlay    *overlay,
                                 GtkAllocation *alloc)
 {
   GtkAllocation main_alloc;
-  GtkRequisition req;
+  GtkRequisition min, req;
   GtkAlign halign;
   GtkTextDirection direction;
 
   gtk_overlay_get_main_widget_allocation (overlay, &main_alloc);
-  gtk_widget_get_preferred_size (widget, NULL, &req);
+  gtk_widget_get_preferred_size (widget, &min, &req);
 
   alloc->x = main_alloc.x;
-  alloc->width = MIN (main_alloc.width, req.width);
+  alloc->width = MAX (min.width, MIN (main_alloc.width, req.width));
 
   direction = gtk_widget_get_direction (widget);
 
@@ -391,7 +391,7 @@ gtk_overlay_get_child_position (GtkOverlay    *overlay,
       /* nothing to do */
       break;
     case GTK_ALIGN_FILL:
-      alloc->width = main_alloc.width;
+      alloc->width = MAX (alloc->width, main_alloc.width);
       break;
     case GTK_ALIGN_CENTER:
       alloc->x += main_alloc.width / 2 - req.width / 2;
@@ -402,7 +402,7 @@ gtk_overlay_get_child_position (GtkOverlay    *overlay,
     }
 
   alloc->y = main_alloc.y;
-  alloc->height = MIN (main_alloc.height, req.height);
+  alloc->height = MAX  (min.height, MIN (main_alloc.height, req.height));
 
   switch (gtk_widget_get_valign (widget))
     {
@@ -410,7 +410,7 @@ gtk_overlay_get_child_position (GtkOverlay    *overlay,
       /* nothing to do */
       break;
     case GTK_ALIGN_FILL:
-      alloc->height = main_alloc.height;
+      alloc->height = MAX (alloc->height, main_alloc.height);
       break;
     case GTK_ALIGN_CENTER:
       alloc->y += main_alloc.height / 2 - req.height / 2;


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