2010-02-04 13:33:47 +02:00
|
|
|
#ifndef ICONBUTTON_H
|
|
|
|
#define ICONBUTTON_H
|
|
|
|
|
2014-01-16 02:03:15 +02:00
|
|
|
#include "gmenu2x.h"
|
2011-05-09 06:17:25 +03:00
|
|
|
|
2013-08-14 05:21:56 +03:00
|
|
|
#include <SDL.h>
|
2014-08-16 08:07:41 +03:00
|
|
|
|
|
|
|
#include <functional>
|
2011-05-09 06:17:25 +03:00
|
|
|
#include <string>
|
2010-02-04 13:33:47 +02:00
|
|
|
|
2014-08-10 15:21:14 +03:00
|
|
|
class OffscreenSurface;
|
2010-05-02 15:52:46 +03:00
|
|
|
class Surface;
|
2013-08-14 05:21:56 +03:00
|
|
|
class Touchscreen;
|
2010-02-04 13:33:47 +02:00
|
|
|
|
2013-08-14 05:21:56 +03:00
|
|
|
|
|
|
|
class IconButton {
|
2010-02-04 13:33:47 +02:00
|
|
|
public:
|
2014-08-16 08:07:41 +03:00
|
|
|
typedef std::function<void(void)> Action;
|
|
|
|
|
2011-12-23 15:03:05 +02:00
|
|
|
IconButton(GMenu2X *gmenu2x, Touchscreen &ts,
|
2014-08-16 07:35:27 +03:00
|
|
|
const std::string &icon, const std::string &label = "",
|
2014-08-16 08:07:41 +03:00
|
|
|
Action action = nullptr);
|
2010-02-04 13:33:47 +02:00
|
|
|
|
2013-08-14 05:21:56 +03:00
|
|
|
SDL_Rect getRect() { return rect; }
|
|
|
|
void setPosition(int x, int y);
|
2010-02-04 13:33:47 +02:00
|
|
|
|
2013-08-14 05:21:56 +03:00
|
|
|
bool handleTS();
|
2011-10-23 13:37:39 +03:00
|
|
|
|
2014-08-10 05:26:59 +03:00
|
|
|
void paint(Surface& s);
|
2013-08-13 02:47:02 +03:00
|
|
|
|
2011-10-23 13:37:39 +03:00
|
|
|
private:
|
2013-08-14 05:21:56 +03:00
|
|
|
void recalcRects();
|
2011-10-23 13:37:39 +03:00
|
|
|
|
|
|
|
GMenu2X *gmenu2x;
|
2013-08-14 05:21:56 +03:00
|
|
|
Touchscreen &ts;
|
2011-10-23 13:37:39 +03:00
|
|
|
std::string icon, label;
|
2014-08-16 08:07:41 +03:00
|
|
|
Action action;
|
2011-10-23 13:37:39 +03:00
|
|
|
|
2013-08-14 05:21:56 +03:00
|
|
|
SDL_Rect rect, iconRect, labelRect;
|
2014-08-10 15:21:14 +03:00
|
|
|
OffscreenSurface *iconSurface;
|
2010-02-04 13:33:47 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|