LEFT | RIGHT |
1 /* | 1 /* |
2 This file is part of LilyPond, the GNU music typesetter. | 2 This file is part of LilyPond, the GNU music typesetter. |
3 | 3 |
4 Copyright (C) 1997--2012 Han-Wen Nienhuys <hanwen@xs4all.nl> | 4 Copyright (C) 1997--2012 Han-Wen Nienhuys <hanwen@xs4all.nl> |
5 | 5 |
6 LilyPond is free software: you can redistribute it and/or modify | 6 LilyPond is free software: you can redistribute it and/or modify |
7 it under the terms of the GNU General Public License as published by | 7 it under the terms of the GNU General Public License as published by |
8 the Free Software Foundation, either version 3 of the License, or | 8 the Free Software Foundation, either version 3 of the License, or |
9 (at your option) any later version. | 9 (at your option) any later version. |
10 | 10 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 { | 53 { |
54 return (Direction) (-d); | 54 return (Direction) (-d); |
55 } | 55 } |
56 | 56 |
57 inline Direction | 57 inline Direction |
58 operator - (Direction const d) | 58 operator - (Direction const d) |
59 { | 59 { |
60 return other_dir (d); | 60 return other_dir (d); |
61 } | 61 } |
62 | 62 |
| 63 // to be deleted soon (after coping with issues 2491 and 2493 |
| 64 inline Direction |
| 65 flip (Direction *i) |
| 66 { |
| 67 if (*i == (Direction)1) |
| 68 *i = (Direction) - 1; |
| 69 else if (*i == (Direction) - 1) |
| 70 *i = (Direction)1; |
| 71 return *i; |
| 72 } |
63 | 73 |
64 #define UP_and_DOWN(d) \ | 74 #define UP_and_DOWN(d) \ |
65 Direction d = UP; d != CENTER; d = (d == UP ? DOWN : CENTER) | 75 Direction d = UP; d != CENTER; d = (d == UP ? DOWN : CENTER) |
66 | 76 |
67 #define DOWN_and_UP(d) \ | 77 #define DOWN_and_UP(d) \ |
68 Direction d = DOWN; d != CENTER; d = (d == DOWN ? UP : CENTER) | 78 Direction d = DOWN; d != CENTER; d = (d == DOWN ? UP : CENTER) |
69 | 79 |
70 #define LEFT_and_RIGHT(d) \ | 80 #define LEFT_and_RIGHT(d) \ |
71 Direction d = LEFT; d != CENTER; d = (d == LEFT ? RIGHT : CENTER) | 81 Direction d = LEFT; d != CENTER; d = (d == LEFT ? RIGHT : CENTER) |
72 | 82 |
73 | 83 |
74 /** | 84 /** |
75 if d > 0: the max operator | 85 if d > 0: the max operator |
76 if d < 0: the min operator | 86 if d < 0: the min operator |
77 */ | 87 */ |
78 template<class T> T minmax (Direction d, T a, T b) | 88 template<class T> T minmax (Direction d, T a, T b) |
79 { | 89 { |
80 if (d == UP) | 90 if (d == UP) |
81 return max (a, b); | 91 return max (a, b); |
82 else | 92 else |
83 return min (a, b); | 93 return min (a, b); |
84 } | 94 } |
85 | 95 |
86 // String direction_string (Direction, Axis); | 96 // String direction_string (Direction, Axis); |
87 | 97 |
88 #endif // DIRECTION_HH | 98 #endif // DIRECTION_HH |
LEFT | RIGHT |