forked from dgcor/DGEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScrollable.h
More file actions
executable file
·56 lines (42 loc) · 1.9 KB
/
Copy pathScrollable.h
File metadata and controls
executable file
·56 lines (42 loc) · 1.9 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
#pragma once
#include <memory>
#include "SFML/View2.h"
#include "UIObject.h"
#include "Utils/ElapsedTime.h"
class Scrollable : public UIObject
{
private:
std::weak_ptr<UIObject> uiObj;
View2 view;
std::shared_ptr<Action> completeAction;
ElapsedTime elapsedTime;
float height{ 0.f };
float offset{ 0.f };
bool loop{ false };
bool pause{ false };
bool visible{ true };
public:
Scrollable(std::weak_ptr<UIObject> uiObj_, const sf::Time& speed)
: uiObj(uiObj_), elapsedTime(speed) {}
void reset();
void setSpeed(const sf::Time& speed) noexcept { elapsedTime.timeout = speed; }
void setOffset(float offset_) noexcept { offset = offset_; }
void setLoop(bool loop_) noexcept { loop = loop_; }
void setPause(bool pause_) noexcept { pause = pause_; }
std::shared_ptr<Action> getAction(uint16_t nameHash16) const noexcept override;
bool setAction(uint16_t nameHash16, const std::shared_ptr<Action>& action) noexcept override;
Anchor getAnchor() const noexcept override { return view.getAnchor(); }
void setAnchor(const Anchor anchor) noexcept override { view.setAnchor(anchor); }
void updateSize(const Game& game) override;
const sf::Vector2f& DrawPosition() const noexcept override { return view.getPosition(); }
const sf::Vector2f& Position() const noexcept override { return view.getPosition(); }
void Position(const sf::Vector2f& position) noexcept override { view.setPosition(position); }
sf::Vector2f Size() const noexcept override { return view.getSize(); }
void Size(const sf::Vector2f& size) override { view.setSize(size); }
bool Visible() const noexcept override { return visible; }
void Visible(bool visible_) noexcept override { visible = visible_; }
void draw(const Game& game, sf::RenderTarget& target) const override;
void update(Game& game) override;
void updateView(const Game& game) { view.update(game); }
bool getProperty(const std::string_view prop, Variable& var) const override;
};