]> git.tdb.fi Git - libs/gltk.git/commitdiff
Initial implementation of middle gravity
authorMikko Rasa <tdb@tdb.fi>
Sat, 15 Dec 2012 16:23:25 +0000 (18:23 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sat, 15 Dec 2012 16:23:25 +0000 (18:23 +0200)
This implementation is unsuitable for centering a group of widgets.  I
have a better one in mind, but no time to implement it now.

source/layout.cpp

index d5437f0b0a29ed04c1ce000534174fd0d9b9fa12..bfe46c47f8b1dcd683238532bdd0fc7497185879 100644 (file)
@@ -304,6 +304,16 @@ void Layout::solve_constraints(int dir, SolveMode mode)
                        row.back() = geom.*(ptrs.dim)-margin.*(ptrs.high_margin);
                }
 
+               if(((*i)->*(ptrs.packing)).gravity==0)
+               {
+                       /* This forces the widget's distance from the left and right edge of
+                       the container to be equal.  It's a bit of a hack, but more time and
+                       thought is needed for a better solution. */
+                       LinearProgram::Row row = linprog.add_row();
+                       row[(*i)->index*5+2] = 1;
+                       row[(*i)->index*5+3] = -1;
+               }
+
                {
                        /* Only allow the widget's dimension to increase.  The geometry has
                        previously been set to the smallest allowable size. */