]> git.tdb.fi Git - libs/gltk.git/commitdiff
Smarter way of complementing constraint types
authorMikko Rasa <tdb@tdb.fi>
Wed, 12 Jun 2013 09:55:54 +0000 (12:55 +0300)
committerMikko Rasa <tdb@tdb.fi>
Wed, 12 Jun 2013 09:55:54 +0000 (12:55 +0300)
source/layout.cpp
source/layout.h

index 1ffbcdaf87e0a7176176e6e75518c62323fda184..66eb66b8b98c3a1e817a5dcbca9a11116aea3829 100644 (file)
@@ -204,16 +204,7 @@ Layout::Slot &Layout::get_slot_for_widget(Widget &wdg)
 
 Layout::ConstraintType Layout::complement(ConstraintType type)
 {
-       if(type==RIGHT_OF)
-               return LEFT_OF;
-       else if(type==LEFT_OF)
-               return RIGHT_OF;
-       else if(type==ABOVE)
-               return BELOW;
-       else if(type==BELOW)
-               return ABOVE;
-       else
-               return type;
+       return static_cast<ConstraintType>((type&~(SELF_MASK|TARGET_MASK)) | ((type&SELF_MASK)<<2) | ((type&TARGET_MASK)>>2));
 }
 
 void Layout::create_constraint(Widget &src, ConstraintType type, Widget &tgt, int sp)
index 0ea47a11c3bdbcef50821bf619ed361b09d48ad5..43d1ca875c2d01d9e9a60e9e22e554808b43d673 100644 (file)
@@ -57,8 +57,10 @@ private:
                VERTICAL = 1,
                SELF_POS = 2,
                SELF_DIM = 4,
+               SELF_MASK = 6,
                TARGET_POS = 8,
                TARGET_DIM = 16,
+               TARGET_MASK = 24,
                SPACING = 32
        };