source: opengl-game/gui/button.hpp@ 5081b9a

feature/imgui-sdl
Last change on this file since 5081b9a was d8cf709, checked in by Dmitry Portnoy <dportnoy@…>, 4 years ago

Change UIEvent to also include the original event from the UI library the game gui is currently using, such as SDL or GLFW.

  • Property mode set to 100644
File size: 779 bytes
Line 
1#ifndef _BUTTON_HPP
2#define _BUTTON_HPP
3
4#include <string>
5
6#include <SDL2/SDL.h>
7
8#include "../game-gui.hpp"
9
10#include "ui-element.hpp"
11
12class Button : public UIElement {
13public:
14 Button(string label, int x, int y, int padding, uint32_t color, uint32_t textColor,
15 VulkanGame& gameInfo, SDL_Renderer& renderer,
16 void (*onMouseClick)(VulkanGame& gameInfo),
17 void (*onMouseEnter)(UIElement& element),
18 void (*onMouseLeave)(UIElement& element));
19 ~Button() override;
20
21 void init() override;
22 void render(int x, int y) override;
23 void handleEvent(GameEvent& e) override;
24
25private:
26 int labelWidth, labelHeight;
27 uint32_t color, focusColor;
28 bool focused;
29 SDL_Texture* labelTexture = nullptr;
30 VulkanGame& gameInfo;
31};
32
33#endif // _BUTTON_HPP
Note: See TracBrowser for help on using the repository browser.