Keep dead Tux small, resolves bug#638 and issue#5
[supertux.git] / src / object / anchor_point.hpp
1 //  SuperTux
2 //  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
3 //
4 //  This program is free software: you can redistribute it and/or modify
5 //  it under the terms of the GNU General Public License as published by
6 //  the Free Software Foundation, either version 3 of the License, or
7 //  (at your option) any later version.
8 //
9 //  This program is distributed in the hope that it will be useful,
10 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 //  GNU General Public License for more details.
13 //
14 //  You should have received a copy of the GNU General Public License
15 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 #ifndef HEADER_SUPERTUX_OBJECT_ANCHOR_POINT_HPP
18 #define HEADER_SUPERTUX_OBJECT_ANCHOR_POINT_HPP
19
20 #include <string>
21
22 #include "math/vector.hpp"
23
24 class Rectf;
25
26 enum AnchorPoint {
27   ANCHOR_H_MASK = 0x00f0,
28   ANCHOR_TOP    = 0x0010,
29   ANCHOR_BOTTOM = 0x0020,
30   ANCHOR_V_MASK = 0x000f,
31   ANCHOR_LEFT   = 0x0001,
32   ANCHOR_RIGHT  = 0x0002,
33   ANCHOR_MIDDLE = 0x0000,
34
35   ANCHOR_TOP_LEFT = ANCHOR_TOP | ANCHOR_LEFT,
36   ANCHOR_TOP_RIGHT = ANCHOR_TOP | ANCHOR_RIGHT,
37   ANCHOR_BOTTOM_LEFT = ANCHOR_BOTTOM | ANCHOR_LEFT,
38   ANCHOR_BOTTOM_RIGHT = ANCHOR_BOTTOM | ANCHOR_RIGHT
39 };
40
41 std::string anchor_point_to_string(AnchorPoint point);
42 AnchorPoint string_to_anchor_point(const std::string& str);
43 Vector get_anchor_pos(const Rectf& rect, AnchorPoint point);
44 Vector get_anchor_pos(const Rectf& destrect, float width, float height,
45                       AnchorPoint point);
46
47 #endif
48
49 /* EOF */