]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/layout.cpp
Smarter way of complementing constraint types
[libs/gltk.git] / source / layout.cpp
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)