Root/
| 1 | #ifndef ICONBUTTON_H |
| 2 | #define ICONBUTTON_H |
| 3 | |
| 4 | #include "gmenu2x.h" |
| 5 | |
| 6 | #include <SDL.h> |
| 7 | |
| 8 | #include <functional> |
| 9 | #include <string> |
| 10 | |
| 11 | class OffscreenSurface; |
| 12 | class Surface; |
| 13 | |
| 14 | |
| 15 | class IconButton { |
| 16 | public: |
| 17 | typedef std::function<void(void)> Action; |
| 18 | |
| 19 | IconButton(GMenu2X& gmenu2x, |
| 20 | const std::string &icon, const std::string &label = "", |
| 21 | Action action = nullptr); |
| 22 | |
| 23 | SDL_Rect getRect() { return rect; } |
| 24 | void setPosition(int x, int y); |
| 25 | |
| 26 | void paint(Surface& s); |
| 27 | |
| 28 | private: |
| 29 | void recalcRects(); |
| 30 | |
| 31 | GMenu2X& gmenu2x; |
| 32 | std::string icon, label; |
| 33 | Action action; |
| 34 | |
| 35 | SDL_Rect rect, iconRect, labelRect; |
| 36 | OffscreenSurface *iconSurface; |
| 37 | }; |
| 38 | |
| 39 | #endif |
| 40 |
Branches:
install_locations
master
opkrun
packages
