X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=flower%2Finclude%2Fdirection.hh;h=de13ef4ca8a6341ea7ce843f22fdc76e00f982bb;hb=4b448c212466623191bc1781da092c7c8ddb6c53;hp=befd0aa2ac207e4f2a18208a45bbf0ddb611047b;hpb=17d3559fc93cd3b2cc2afbc240abbe11874373c6;p=lilypond.git diff --git a/flower/include/direction.hh b/flower/include/direction.hh index befd0aa2ac..de13ef4ca8 100644 --- a/flower/include/direction.hh +++ b/flower/include/direction.hh @@ -1,7 +1,7 @@ /* This file is part of LilyPond, the GNU music typesetter. - Copyright (C) 1997--2011 Han-Wen Nienhuys + Copyright (C) 1997--2015 Han-Wen Nienhuys LilyPond is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,53 +23,45 @@ #include "axis.hh" enum Direction - { - UP = 1, - DOWN=-1, - LEFT=-1, - RIGHT = 1, - MIN=-1, - MAX = 1, - CENTER = 0, - SMALLER=-1, - BIGGER = 1, - START = -1, - STOP = 1, - - /* - This is necessary to safely write loops, - since - - dir <= RIGHT - - is otherwise transformed into true unconditionally. - */ - DIRECTION_LIMIT = 2, - DIRECTION_NEG_LIMIT = -2, - }; - -inline Direction -other_dir (Direction const d) { - return (Direction) (-d); -} + UP = 1, + DOWN = -1, + LEFT = -1, + RIGHT = 1, + MIN = -1, + MAX = 1, + CENTER = 0, + SMALLER = -1, + BIGGER = 1, + START = -1, + STOP = 1, + + /* + This is necessary to safely write loops, + since + + dir <= RIGHT + + is otherwise transformed into true unconditionally. + */ + DIRECTION_LIMIT = 2, + DIRECTION_NEG_LIMIT = -2, +}; inline Direction -operator - (Direction const d) +operator - (Direction d) { - return other_dir (d); + return Direction (- static_cast (d)); // cast avoids recursion } -// huh? -inline Direction -flip (Direction *i) -{ - if (*i == (Direction)1) - *i = (Direction) - 1; - else if (*i == (Direction) - 1) - *i = (Direction)1; - return *i; -} +#define UP_and_DOWN(d) \ + Direction d = UP; d != CENTER; d = (d == UP ? DOWN : CENTER) + +#define DOWN_and_UP(d) \ + Direction d = DOWN; d != CENTER; d = (d == DOWN ? UP : CENTER) + +#define LEFT_and_RIGHT(d) \ + Direction d = LEFT; d != CENTER; d = (d == LEFT ? RIGHT : CENTER) /** if d > 0: the max operator @@ -83,6 +75,4 @@ template T minmax (Direction d, T a, T b) return min (a, b); } -// String direction_string (Direction, Axis); - #endif // DIRECTION_HH