source: opengl-game/gui/button.hpp@ 670c09a

feature/imgui-sdl
Last change on this file since 670c09a was e1f88a9, checked in by Dmitry Portnoy <dmitry.portnoy@…>, 4 years ago

Create a system to draw and switch between different screens, a Screen class, a MainScreen class that extends it, and some classes for UI elements that can be added to screens.

  • Property mode set to 100644
File size: 777 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(UIEvent& 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.