forked from dgcor/DGEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButton.h
More file actions
executable file
·62 lines (53 loc) · 2.26 KB
/
Copy pathButton.h
File metadata and controls
executable file
·62 lines (53 loc) · 2.26 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#pragma once
#include "InputEvent.h"
#include <memory>
#include "SFML/Audio/SoundBuffer.hpp"
#include "SFML/System/Clock.hpp"
#include "UIObject.h"
class Button : public virtual UIObject
{
protected:
std::shared_ptr<Action> clickAction;
std::shared_ptr<Action> rightClickAction;
std::shared_ptr<Action> doubleClickAction;
std::shared_ptr<Action> clickDragAction;
std::shared_ptr<Action> clickInAction;
std::shared_ptr<Action> clickOutAction;
std::shared_ptr<Action> focusAction;
std::shared_ptr<Action> hoverEnterAction;
std::shared_ptr<Action> hoverLeaveAction;
const sf::SoundBuffer* clickSound{ nullptr };
const sf::SoundBuffer* focusSound{ nullptr };
sf::Clock mouseDblClickClock;
bool enabled{ true };
bool focusEnable{ false };
bool focusOnClick{ false };
bool hovered{ false };
bool clickUp{ false };
bool beingDragged{ false };
bool wasLeftClicked{ false };
bool wasRightClicked{ false };
InputEventType captureInputEvents{ InputEventType::None };
void onHover(Game& game, bool contains);
void onMouseButtonPressed(Game& game, bool contains);
void onMouseButtonReleased(Game& game, bool contains);
void onMouseMoved(Game& game);
void onTouchBegan(Game& game, bool contains);
void onTouchEnded(Game& game, bool contains);
void updateEvents(Game& game, bool contains);
public:
InputEventType getCaptureInputEvents() const noexcept { return captureInputEvents; }
void setCaptureInputEvents(InputEventType e) noexcept { captureInputEvents = e; }
std::shared_ptr<Action> getAction(uint16_t nameHash16) const noexcept override;
bool setAction(uint16_t nameHash16, const std::shared_ptr<Action>& action) noexcept override;
bool click(Game& game, bool playSound);
void enable(bool enable) noexcept { enabled = enable; }
void focus(Game& game) const;
void focusEnabled(bool focusOnClick_) noexcept { focusEnable = true; focusOnClick = focusOnClick_; }
bool isEnabled() const noexcept { return enabled; }
void setClickSound(const sf::SoundBuffer* buffer) noexcept { clickSound = buffer; }
void setClickUp(bool clickUp_) noexcept { clickUp = clickUp_; }
void setFocusSound(const sf::SoundBuffer* buffer) noexcept { focusSound = buffer; }
virtual void setColor(const sf::Color& color_) = 0;
bool getProperty(const std::string_view prop, Variable& var) const override;
};