X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=flower%2Finclude%2Fdirection.hh;h=dff546749756d42526123a9d85df929e566a6149;hb=cb0b407e567feca71cbc5f9479a06b266c69a26c;hp=6fe5efcc19c8f446ebd16e63584dd146f056c8da;hpb=f93e4199873c91ae32f0e84a610d14853dc379df;p=lilypond.git diff --git a/flower/include/direction.hh b/flower/include/direction.hh index 6fe5efcc19..dff5467497 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 @@ -20,6 +20,7 @@ #ifndef DIRECTION_HH #define DIRECTION_HH +#include #include "axis.hh" enum Direction @@ -49,27 +50,19 @@ enum Direction }; inline Direction -other_dir (Direction const d) +operator - (Direction d) { - return (Direction) (-d); + return Direction (- static_cast (d)); // cast avoids recursion } -inline Direction -operator - (Direction const d) -{ - return other_dir (d); -} +#define UP_and_DOWN(d) \ + Direction d = UP; d != CENTER; d = (d == UP ? DOWN : CENTER) -// huh? -inline Direction -flip (Direction *i) -{ - if (*i == (Direction)1) - *i = (Direction) - 1; - else if (*i == (Direction) - 1) - *i = (Direction)1; - return *i; -} +#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 @@ -78,11 +71,9 @@ flip (Direction *i) template T minmax (Direction d, T a, T b) { if (d == UP) - return max (a, b); + return std::max (a, b); else - return min (a, b); + return std::min (a, b); } -// String direction_string (Direction, Axis); - #endif // DIRECTION_HH