-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathButton.h
More file actions
30 lines (26 loc) · 688 Bytes
/
Button.h
File metadata and controls
30 lines (26 loc) · 688 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#pragma once
#include "template.h"
#include "surface.h"
#include "input.h"
#include "UIElement.h"
#include "UIContainer.h"
#include <functional>
class Button : public UIElement
{
public:
Button(UIContainer::Anchor anchor, Tmpl8::vec2 relPos, Tmpl8::Sprite* sprite, float scale, std::function<void()> func);
virtual bool HandleInput(Tmpl8::vec2 mousePos) override;
virtual void Draw(Tmpl8::Surface* screen, Tmpl8::vec2 position) override;
void SetStatus(int status);
void SetFunc(std::function<void()> func) { this->func = func; }
private:
enum ButtonState {
INACTIVE,
HOVERING,
FOCUSED
};
Tmpl8::Sprite* sprite;
float scale;
std::function<void()> func;
int status;
};