Last change
on this file since ca188cc was e1f88a9, checked in by Dmitry Portnoy <dmitry.portnoy@…>, 5 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
|
Rev | Line | |
---|
[e1f88a9] | 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 |
|
---|
| 12 | class Button : public UIElement {
|
---|
| 13 | public:
|
---|
| 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 |
|
---|
| 25 | private:
|
---|
| 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.