]> git.donarmstrong.com Git - lilypond.git/blob - flower/include/direction.hh
5400a5220d727e635f6647e429af6aec725eb761
[lilypond.git] / flower / include / direction.hh
1 /*
2   direction.hh -- declare Direction
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1997--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #ifndef DIRECTION_HH
10 #define DIRECTION_HH
11
12 #include "axis.hh"
13
14 enum Direction
15   {
16     UP = 1,
17     DOWN=-1,
18     LEFT=-1,
19     RIGHT = 1,
20     MIN=-1,
21     MAX = 1,
22     CENTER = 0,
23     SMALLER=-1,
24     BIGGER = 1,
25     START = -1,
26     STOP = 1,
27
28     /*
29       This is necessary to safely write loops,
30       since
31
32       dir <= RIGHT
33
34       is otherwise transformed into true unconditionally.
35     */
36     DIRECTION_LIMIT = 2,
37     DIRECTION_NEG_LIMIT = -2,
38   };
39
40 inline Direction
41 other_dir (Direction const d)
42 {
43   return (Direction) (-d);
44 }
45
46 inline Direction
47 operator - (Direction const d)
48 {
49   return other_dir (d);
50 }
51
52 // huh?
53 inline Direction
54 flip (Direction *i)
55 {
56   if (*i == (Direction)1)
57     *i = (Direction) - 1;
58   else if (*i == (Direction) - 1)
59     *i = (Direction)1;
60   return *i;
61 }
62
63 /**
64    if d > 0: the max operator
65    if d < 0: the min operator
66 */
67 template<class T> T minmax (Direction d, T, T);
68
69 // String direction_string (Direction, Axis);
70
71 #endif // DIRECTION_HH