| 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_GUI_MOUSECURSOR_HPP |
| 18 | #define |
| 19 | |
| 20 | #include <string> |
| 21 | #include <vector> |
| 22 | |
| 23 | #include "sprite/sprite_ptr.hpp" |
| 24 | #include "util/currenton.hpp" |
| 25 | #include "video/surface_ptr.hpp" |
| 26 | |
| 27 | class DrawingContext; |
| 28 | |
| 29 | enum class MouseCursorState |
| 30 | { |
| 31 | NORMAL, |
| 32 | CLICK, |
| 33 | LINK, |
| 34 | HIDE |
| 35 | }; |
| 36 | |
| 37 | /** Mouse cursor. |
| 38 | Used to create mouse cursors. |
| 39 | The mouse cursors can be animated |
| 40 | and can be used in four different states. */ |
| 41 | class MouseCursor final : public Currenton<MouseCursor> |
| 42 | { |
| 43 | public: |
| 44 | static MouseCursor* current() { return current_; } |
| 45 | static void set_current(MouseCursor* pcursor) { current_ = pcursor; } |
| 46 | |
| 47 | private: |
| 48 | static MouseCursor* current_; |
| 49 | |
| 50 | public: |
| 51 | MouseCursor(SpritePtr sprite); |
| 52 | |
| 53 | void draw(DrawingContext& context); |
| 54 | |
| 55 | void set_state(MouseCursorState state); |
| 56 | void set_icon(SurfacePtr icon); |
| 57 | |
| 58 | private: |
| 59 | void apply_state(MouseCursorState state); |
| 60 | |
| 61 | private: |
| 62 | MouseCursorState m_state; |
| 63 | MouseCursorState m_applied_state; |
| 64 | SpritePtr m_sprite; |
| 65 | SurfacePtr m_icon; |
| 66 | |
| 67 | private: |
| 68 | MouseCursor(const MouseCursor&) = delete; |
| 69 | MouseCursor& operator=(const MouseCursor&) = delete; |
| 70 | }; |
| 71 | |
| 72 | #endif |
| 73 | |
| 74 | /* EOF */ |
| 75 | |