Root/src/iconbutton.h

Source at commit 7b10f9448bb9965e94f9a37a59f0999e9c51e68f created 8 years 1 month ago.
By Maarten ter Huurne, Suppress Clang analyzer warnings about dead assignments
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
11class OffscreenSurface;
12class Surface;
13
14
15class IconButton {
16public:
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
28private:
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

Archive Download this file



interactive