diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-04-06 23:45:24 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-04-06 23:45:24 (GMT) |
| commit | bbfbb81086897d50b67bf1494ac150eb607add72 (patch) | |
| tree | 80bab3ddb1f62f847f12947bc81fac2c091669b8 /src/interface | |
| parent | 8f8de875c6f7a68a3e47252a8653abb72fd398c1 (diff) | |
| download | powder-bbfbb81086897d50b67bf1494ac150eb607add72.zip powder-bbfbb81086897d50b67bf1494ac150eb607add72.tar.gz | |
Confirmation Dialogue, Save selection and multi-delete
Diffstat (limited to 'src/interface')
| -rw-r--r-- | src/interface/Component.cpp | 1 | ||||
| -rw-r--r-- | src/interface/SaveButton.cpp | 36 | ||||
| -rw-r--r-- | src/interface/SaveButton.h | 9 |
3 files changed, 43 insertions, 3 deletions
diff --git a/src/interface/Component.cpp b/src/interface/Component.cpp index 0efc2b1..5db7acc 100644 --- a/src/interface/Component.cpp +++ b/src/interface/Component.cpp @@ -148,5 +148,4 @@ void Component::OnMouseWheelInside(int localx, int localy, int d) Component::~Component() { - } diff --git a/src/interface/SaveButton.cpp b/src/interface/SaveButton.cpp index d044ef6..338ef96 100644 --- a/src/interface/SaveButton.cpp +++ b/src/interface/SaveButton.cpp @@ -17,7 +17,9 @@ SaveButton::SaveButton(Point position, Point size, Save * save): isMouseInside(false), isButtonDown(false), actionCallback(NULL), - voteColour(255, 0, 0) + voteColour(255, 0, 0), + selectable(false), + selected(false) { if(save->votesUp==0) voteRatio = 0.0f; @@ -93,6 +95,11 @@ void SaveButton::Draw(const Point& screenPos) float scaleFactor; ui::Point thumbBoxSize(0, 0); + if(selected && selectable) + { + g->fillrect(screenPos.X, screenPos.Y, Size.X, Size.Y, 100, 170, 255, 100); + } + if(thumbnail) { thumbBoxSize = ui::Point(thumbnail->Size.X, thumbnail->Size.Y); @@ -136,6 +143,14 @@ void SaveButton::Draw(const Point& screenPos) g->drawtext(screenPos.X+(Size.X-Graphics::textwidth((char *)save->name.c_str()))/2, screenPos.Y+Size.Y - 21, save->name, 180, 180, 180, 255); g->drawtext(screenPos.X+(Size.X-Graphics::textwidth((char *)save->userName.c_str()))/2, screenPos.Y+Size.Y - 10, save->userName, 100, 130, 160, 255); } + + if(isMouseInside && selectable) + { + g->clearrect(screenPos.X+(Size.X-20), screenPos.Y+6, 14, 14); + g->drawrect(screenPos.X+(Size.X-20), screenPos.Y+6, 14, 14, 255, 255, 255, 255); + if(selected) + g->fillrect(screenPos.X+(Size.X-18), screenPos.Y+8, 10, 10, 255, 255, 255, 255); + } } void SaveButton::OnMouseUnclick(int x, int y, unsigned int button) @@ -145,6 +160,13 @@ void SaveButton::OnMouseUnclick(int x, int y, unsigned int button) return; //left click only! } + if(x>=Size.X-20 && y>=6 && y<=20 && x<=Size.X-6 && selectable) + { + selected = !selected; + DoSelection(); + return; + } + if(isButtonDown) { DoAction(); @@ -155,7 +177,13 @@ void SaveButton::OnMouseUnclick(int x, int y, unsigned int button) void SaveButton::OnMouseClick(int x, int y, unsigned int button) { + if(button !=1 && selectable) + { + selected = !selected; + DoSelection(); + } if(button != 1) return; //left click only! + isButtonDown = true; } @@ -175,6 +203,12 @@ void SaveButton::DoAction() actionCallback->ActionCallback(this); } +void SaveButton::DoSelection() +{ + if(selectable) + actionCallback->SelectedCallback(this); +} + void SaveButton::SetActionCallback(SaveButtonAction * action) { actionCallback = action; diff --git a/src/interface/SaveButton.h b/src/interface/SaveButton.h index d4b2570..de1b6ed 100644 --- a/src/interface/SaveButton.h +++ b/src/interface/SaveButton.h @@ -16,6 +16,7 @@ class SaveButtonAction { public: virtual void ActionCallback(ui::SaveButton * sender) {} + virtual void SelectedCallback(ui::SaveButton * sender) {} virtual ~SaveButtonAction() {} }; @@ -36,12 +37,18 @@ public: virtual void Draw(const Point& screenPos); virtual void Tick(float dt); + void SetSelected(bool selected_) { selected = selected_; } + bool GetSelected() { return selected; } + void SetSelectable(bool selectable_) { selectable = selectable_; } + bool GetSelectable() { return selectable; } + Save * GetSave() { return save; } inline bool GetState() { return state; } virtual void DoAction(); + virtual void DoSelection(); void SetActionCallback(SaveButtonAction * action); protected: - bool isButtonDown, state, isMouseInside; + bool isButtonDown, state, isMouseInside, selected, selectable; float voteRatio; Colour voteColour; SaveButtonAction * actionCallback; |
