From: Mikko Rasa Date: Wed, 12 Jun 2013 09:55:54 +0000 (+0300) Subject: Smarter way of complementing constraint types X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=a7776a50f9c3bf8d3a61af56f6d11b0721209582;p=libs%2Fgltk.git Smarter way of complementing constraint types --- diff --git a/source/layout.cpp b/source/layout.cpp index 1ffbcda..66eb66b 100644 --- a/source/layout.cpp +++ b/source/layout.cpp @@ -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((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) diff --git a/source/layout.h b/source/layout.h index 0ea47a1..43d1ca8 100644 --- a/source/layout.h +++ b/source/layout.h @@ -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 };