/
SaveButton.h
84 lines (71 loc) · 2.3 KB
/
SaveButton.h
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#ifndef SAVEBUTTON_H_
#define SAVEBUTTON_H_
#include "common/String.h"
#include "Component.h"
#include "client/SaveFile.h"
#include "client/SaveInfo.h"
#include "client/requestbroker/RequestListener.h"
#include "graphics/Graphics.h"
#include "gui/interface/Colour.h"
namespace ui
{
class SaveButton;
class SaveButtonAction
{
public:
virtual void ActionCallback(ui::SaveButton * sender) {}
virtual void AltActionCallback(ui::SaveButton * sender) {}
virtual void AltActionCallback2(ui::SaveButton * sender) {}
virtual void SelectedCallback(ui::SaveButton * sender) {}
virtual ~SaveButtonAction() {}
};
class SaveButton : public Component, public RequestListener
{
SaveFile * file;
SaveInfo * save;
VideoBuffer * thumbnail;
ui::Point thumbSize = ui::Point(0, 0);
String name;
String votesString;
String votesBackground;
String votesBackground2;
int voteBarHeightUp;
int voteBarHeightDown;
bool wantsDraw;
bool waitingForThumb;
bool isMouseInsideAuthor;
bool isMouseInsideHistory;
bool showVotes;
public:
SaveButton(Point position, Point size, SaveInfo * save);
SaveButton(Point position, Point size, SaveFile * file);
virtual ~SaveButton();
void OnMouseClick(int x, int y, unsigned int button) override;
void OnMouseUnclick(int x, int y, unsigned int button) override;
void OnMouseEnter(int x, int y) override;
void OnMouseLeave(int x, int y) override;
void OnMouseMovedInside(int x, int y, int dx, int dy) override;
void AddContextMenu(int menuType);
void OnContextMenuAction(int item) override;
void Draw(const Point& screenPos) override;
void Tick(float dt) override;
void OnResponseReady(void * imagePtr, int identifier) override;
void SetSelected(bool selected_) { selected = selected_; }
bool GetSelected() { return selected; }
void SetSelectable(bool selectable_) { selectable = selectable_; }
bool GetSelectable() { return selectable; }
void SetShowVotes(bool showVotes_) { showVotes = showVotes_; }
SaveInfo * GetSave() { return save; }
SaveFile * GetSaveFile() { return file; }
inline bool GetState() { return state; }
void DoAction();
void DoAltAction();
void DoAltAction2();
void DoSelection();
void SetActionCallback(SaveButtonAction * action);
protected:
bool isButtonDown, state, isMouseInside, selected, selectable;
SaveButtonAction * actionCallback;
};
}
#endif /* BUTTON_H_ */