mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2025-01-14 22:01:05 +02:00
742444c919
It was only used to share implementation between IconButton and Link. However, there was only one non-trivial method, handleTS(), and that method used a different code path for each use case: doubleClick was always false for IconButton and always true for Link. So the total amount of code was actually reduced by eliminating this code sharing. The main motivation for this split is that I can now freely refactor Link without having to worry about IconButton.
41 lines
617 B
C++
41 lines
617 B
C++
#ifndef ICONBUTTON_H
|
|
#define ICONBUTTON_H
|
|
|
|
#include "delegate.h"
|
|
|
|
#include <SDL.h>
|
|
#include <string>
|
|
|
|
class GMenu2X;
|
|
class Surface;
|
|
class Touchscreen;
|
|
|
|
|
|
class IconButton {
|
|
public:
|
|
IconButton(GMenu2X *gmenu2x, Touchscreen &ts,
|
|
const std::string &icon, const std::string &label = "");
|
|
|
|
void setAction(function_t action);
|
|
|
|
SDL_Rect getRect() { return rect; }
|
|
void setPosition(int x, int y);
|
|
|
|
bool handleTS();
|
|
|
|
void paint();
|
|
|
|
private:
|
|
void recalcRects();
|
|
|
|
GMenu2X *gmenu2x;
|
|
Touchscreen &ts;
|
|
std::string icon, label;
|
|
function_t action;
|
|
|
|
SDL_Rect rect, iconRect, labelRect;
|
|
Surface *iconSurface;
|
|
};
|
|
|
|
#endif
|