From a7776a50f9c3bf8d3a61af56f6d11b0721209582 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Wed, 12 Jun 2013 12:55:54 +0300 Subject: [PATCH] Smarter way of complementing constraint types --- source/layout.cpp | 11 +---------- source/layout.h | 2 ++ 2 files changed, 3 insertions(+), 10 deletions(-) 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 }; -- 2.43.0