From 815194201203afd6fa59e650e1007a355c829544 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 15 Dec 2012 18:23:25 +0200 Subject: [PATCH] Initial implementation of middle gravity 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 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/source/layout.cpp b/source/layout.cpp index d5437f0..bfe46c4 100644 --- a/source/layout.cpp +++ b/source/layout.cpp @@ -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. */ -- 2.45.2