]> git.tdb.fi Git - libs/gltk.git/commitdiff
Some cleanup in Layout
authorMikko Rasa <tdb@tdb.fi>
Mon, 26 Nov 2012 19:04:36 +0000 (21:04 +0200)
committerMikko Rasa <tdb@tdb.fi>
Mon, 26 Nov 2012 19:04:36 +0000 (21:04 +0200)
source/layout.cpp
source/layout.h

index b4c3a0eccd38883ac83beb7b863a62b6d3a52b6b..6cf7b348a4dc5c753f0d5bd7574cc39c477ed365 100644 (file)
@@ -44,7 +44,7 @@ public:
 
        Row add_row();
        Row operator[](unsigned);
-       Row get_object_row();
+       Row get_objective_row();
        bool solve();
        float get_variable(unsigned);
 private:
@@ -228,7 +228,6 @@ void Layout::update()
 
        for(list<Slot *>::iterator i=slots.begin(); i!=slots.end(); ++i)
                (*i)->widget.set_geometry((*i)->geom);
-
 }
 
 void Layout::solve_constraints(int dir)
@@ -243,8 +242,8 @@ void Layout::solve_constraints(int dir)
        float weight = slots.size();
        for(list<Slot *>::iterator i=slots.begin(); i!=slots.end(); ++i)
        {
-               linprog.get_object_row()[(*i)->index*5] = ((*i)->*(ptrs.packing)).gravity/weight;
-               linprog.get_object_row()[(*i)->index*5+1] = (((*i)->*(ptrs.packing)).expand ? weight : -1);
+               linprog.get_objective_row()[(*i)->index*5] = ((*i)->*(ptrs.packing)).gravity/weight;
+               linprog.get_objective_row()[(*i)->index*5+1] = (((*i)->*(ptrs.packing)).expand ? weight : -1);
 
                {
                        // Prevent the widget from going past the container's low edge.
@@ -276,7 +275,6 @@ void Layout::solve_constraints(int dir)
                constraints are always added in pairs, so it's only necessary to create a
                row for one half. */
                for(list<Constraint>::iterator j=(*i)->constraints.begin(); j!=(*i)->constraints.end(); ++j)
-               {
                        if((j->type&1)==dir && j->type!=BELOW && j->type!=LEFT_OF)
                        {
                                LinearProgram::Row row = linprog.add_row();
@@ -291,7 +289,6 @@ void Layout::solve_constraints(int dir)
                                if(j->type&SPACING)
                                        row.back() = this->*(ptrs.spacing);
                        }
-               }
        }
 
        if(!linprog.solve())
@@ -353,7 +350,7 @@ Layout::LinearProgram::Row Layout::LinearProgram::operator[](unsigned r)
        return Row(*this, r);
 }
 
-Layout::LinearProgram::Row Layout::LinearProgram::get_object_row()
+Layout::LinearProgram::Row Layout::LinearProgram::get_objective_row()
 {
        return Row(*this, 0);
 }
@@ -438,7 +435,7 @@ unsigned Layout::LinearProgram::find_minimal_ratio(unsigned c)
        /* Pick the row with the minimum ratio between the constant column and the
        pivot column.  This ensures that when the pivot column is made basic, values
        in the constant column stay positive.
-       
+
        The use of n_rows instead of the true size of the column is intentional,
        since the relocated objective row must be ignored in phase 1. */
        float best = numeric_limits<float>::infinity();
@@ -453,7 +450,7 @@ unsigned Layout::LinearProgram::find_minimal_ratio(unsigned c)
                                row = i;
                        }
                }
-       
+
        return row;
 }
 
@@ -472,14 +469,11 @@ void Layout::LinearProgram::make_basic_column(unsigned c, unsigned r)
                        }
 
                        float scale = columns[i].values[r]/columns[c].values[r];
-                       
+
+                       columns[i].values[r] = scale;
                        for(unsigned j=0; j<columns[i].values.size(); ++j)
-                       {
-                               if(j==r)
-                                       columns[i].values[j] = scale;
-                               else
+                               if(j!=r)
                                        columns[i].values[j] -= scale*columns[c].values[j];
-                       }
                }
 
        columns[c].basic = r;
index 7d53470624cf7c7d925ef247fd7f96692babc175..582bc1b0f685297b053ca73e38044aef592d777b 100644 (file)
@@ -147,8 +147,6 @@ public:
        void update();
 
 protected:
-       void find_constraint_group(Slot &, ConstraintType, std::set<Slot *> &);
-       void sort_slots(std::list<Slot *> &, ConstraintType);
        void solve_constraints(int);
 };