]> git.tdb.fi Git - libs/gltk.git/commitdiff
Don't try to solve if container is smaller than its margins
authorMikko Rasa <tdb@tdb.fi>
Tue, 27 Nov 2012 21:52:39 +0000 (23:52 +0200)
committerMikko Rasa <tdb@tdb.fi>
Tue, 27 Nov 2012 21:56:17 +0000 (23:56 +0200)
Attempting that would cause unsigneds to wrap around to very large values
and cause a weird solution.

source/layout.cpp

index 34afd7284a35878b409dd95f8b4bc34ebd6c4299..f89e407cf7f4d3b61d08831c0f71693b68b27760 100644 (file)
@@ -232,6 +232,10 @@ void Layout::solve_constraints(int dir)
 {
        Pointers &ptrs = pointers[dir&VERTICAL];
 
+       const Geometry &geom = container->get_geometry();
+       if(geom.*(ptrs.dim)<margin.*(ptrs.low_margin)+margin.*(ptrs.high_margin))
+               return;
+
        /* Set up a linear program to solve the constraints.  The program matrix has
        five columns for each widget, and one constant column.  The first and second
        columns of a widget are its position and dimension, respectively.  The
@@ -257,7 +261,7 @@ void Layout::solve_constraints(int dir)
                        row[(*i)->index*5] = 1;
                        row[(*i)->index*5+1] = 1;
                        row[(*i)->index*5+3] = 1;
-                       row.back() = container->get_geometry().*(ptrs.dim)-margin.*(ptrs.high_margin);
+                       row.back() = geom.*(ptrs.dim)-margin.*(ptrs.high_margin);
                }
 
                {