mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-06-28 12:39:50 +03:00
The abstraction it provided was so thin that I think it is simpler to just have the code use std::bind directly.
44 lines
698 B
C++
44 lines
698 B
C++
#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();
|
|
|
|
void paint(Surface& s);
|
|
|
|
private:
|
|
void recalcRects();
|
|
|
|
GMenu2X *gmenu2x;
|
|
Touchscreen &ts;
|
|
std::string icon, label;
|
|
Action action;
|
|
|
|
SDL_Rect rect, iconRect, labelRect;
|
|
OffscreenSurface *iconSurface;
|
|
};
|
|
|
|
#endif
|