1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-06-30 21:13:51 +03:00
gmenu2x/src/iconbutton.h

44 lines
698 B
C
Raw Normal View History

#ifndef ICONBUTTON_H
#define ICONBUTTON_H
#include "gmenu2x.h"
#include <SDL.h>
#include <functional>
#include <string>
class OffscreenSurface;
class Surface;
class Touchscreen;
class IconButton {
public:
typedef std::function<void(void)> Action;
IconButton(GMenu2X *gmenu2x, Touchscreen &ts,
const std::string &icon, const std::string &label = "",
Action action = nullptr);
SDL_Rect getRect() { return rect; }
void setPosition(int x, int y);
bool handleTS();
2011-10-23 13:37:39 +03:00
void paint(Surface& s);
2011-10-23 13:37:39 +03:00
private:
void recalcRects();
2011-10-23 13:37:39 +03:00
GMenu2X *gmenu2x;
Touchscreen &ts;
2011-10-23 13:37:39 +03:00
std::string icon, label;
Action action;
2011-10-23 13:37:39 +03:00
SDL_Rect rect, iconRect, labelRect;
OffscreenSurface *iconSurface;
};
#endif