summaryrefslogtreecommitdiff
path: root/src/interface/SaveButton.h
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-11-17 19:44:09 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-11-17 19:44:09 (GMT)
commit058a2edd75debbd0297f92572316daa704bd379f (patch)
treead303f091f9a08b209b91eb34a9fcad996a3de69 /src/interface/SaveButton.h
parente3594aba9e05c6865d396418c028049cda92c2f3 (diff)
parent7a21ae192fe19868539956f3fe28e62b2c7c4429 (diff)
downloadpowder-058a2edd75debbd0297f92572316daa704bd379f.zip
powder-058a2edd75debbd0297f92572316daa704bd379f.tar.gz
Merge branch 'master' of github.com:FacialTurd/PowderToypp
Diffstat (limited to 'src/interface/SaveButton.h')
-rw-r--r--src/interface/SaveButton.h83
1 files changed, 83 insertions, 0 deletions
diff --git a/src/interface/SaveButton.h b/src/interface/SaveButton.h
new file mode 100644
index 0000000..74dbc00
--- /dev/null
+++ b/src/interface/SaveButton.h
@@ -0,0 +1,83 @@
+#ifndef SAVEBUTTON_H_
+#define SAVEBUTTON_H_
+
+#include <string>
+
+#include "Component.h"
+#include "client/SaveFile.h"
+#include "client/SaveInfo.h"
+#include "client/ThumbnailListener.h"
+#include "graphics/Graphics.h"
+#include "search/Thumbnail.h"
+#include "interface/Colour.h"
+
+namespace ui
+{
+class SaveButton;
+class SaveButtonAction
+{
+public:
+ virtual void ActionCallback(ui::SaveButton * sender) {}
+ virtual void AuthorActionCallback(ui::SaveButton * sender) {}
+ virtual void HistoryActionCallback(ui::SaveButton * sender) {}
+ virtual void SelectedCallback(ui::SaveButton * sender) {}
+ virtual ~SaveButtonAction() {}
+};
+
+class SaveButton : public Component, public ThumbnailListener
+{
+ SaveFile * file;
+ SaveInfo * save;
+ Thumbnail * thumbnail;
+ std::string name;
+ std::string votesString;
+ std::string votesBackground;
+ std::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();
+
+ virtual void OnMouseClick(int x, int y, unsigned int button);
+ virtual void OnMouseUnclick(int x, int y, unsigned int button);
+
+ virtual void OnMouseEnter(int x, int y);
+ virtual void OnMouseLeave(int x, int y);
+
+ virtual void OnMouseMovedInside(int x, int y, int dx, int dy);
+
+ virtual void OnContextMenuAction(int item);
+
+ virtual void Draw(const Point& screenPos);
+ virtual void Tick(float dt);
+
+ virtual void OnThumbnailReady(Thumbnail * thumb);
+
+ 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; }
+ virtual void DoAction();
+ virtual void DoAuthorAction();
+ virtual void DoHistoryAction();
+ virtual void DoSelection();
+ void SetActionCallback(SaveButtonAction * action);
+protected:
+ bool isButtonDown, state, isMouseInside, selected, selectable;
+ SaveButtonAction * actionCallback;
+};
+}
+#endif /* BUTTON_H_ */
+