summaryrefslogtreecommitdiff
path: root/src/interface
diff options
context:
space:
mode:
authorjacob1 <jfu614@gmail.com>2013-01-07 16:56:48 (GMT)
committer jacob1 <jfu614@gmail.com>2013-01-07 16:56:48 (GMT)
commit323dae959ad168b634599b27802fb03598305c81 (patch)
treecea0fb4d328d51ce0f0e5a6c64775231e768dbc0 /src/interface
parent659c3677aa159912518f8cd541adfae6dce6dcdc (diff)
downloadpowder-323dae959ad168b634599b27802fb03598305c81.zip
powder-323dae959ad168b634599b27802fb03598305c81.tar.gz
local save deletion and renaming with the right click context menu
Diffstat (limited to 'src/interface')
-rw-r--r--src/interface/SaveButton.cpp45
-rw-r--r--src/interface/SaveButton.h9
2 files changed, 34 insertions, 20 deletions
diff --git a/src/interface/SaveButton.cpp b/src/interface/SaveButton.cpp
index eb2640b..c5840c8 100644
--- a/src/interface/SaveButton.cpp
+++ b/src/interface/SaveButton.cpp
@@ -28,12 +28,6 @@ SaveButton::SaveButton(Point position, Point size, SaveInfo * save):
isMouseInsideHistory(false),
showVotes(false)
{
- menu = new ContextMenu(this);
- menu->AddItem(ContextMenuItem("Open", 0, true));
- menu->AddItem(ContextMenuItem("Select", 1, true));
- menu->AddItem(ContextMenuItem("View History", 2, true));
- menu->AddItem(ContextMenuItem("More by this user", 3, true));
-
if(save)
{
name = save->name;
@@ -303,15 +297,34 @@ void SaveButton::OnMouseUnclick(int x, int y, unsigned int button)
if(isButtonDown)
{
isButtonDown = false;
- if(isMouseInsideAuthor)
- DoAuthorAction();
- else if(isMouseInsideHistory)
- DoHistoryAction();
+ if(isMouseInsideHistory)
+ DoAltAction();
+ else if(isMouseInsideAuthor)
+ DoAltAction2();
else
DoAction();
}
}
+void SaveButton::AddContextMenu(int menuType)
+{
+ if (menuType == 0) //Save browser
+ {
+ menu = new ContextMenu(this);
+ menu->AddItem(ContextMenuItem("Open", 0, true));
+ menu->AddItem(ContextMenuItem("Select", 1, true));
+ menu->AddItem(ContextMenuItem("View History", 2, true));
+ menu->AddItem(ContextMenuItem("More by this user", 3, true));
+ }
+ else if (menuType == 1) //Local save browser
+ {
+ menu = new ContextMenu(this);
+ menu->AddItem(ContextMenuItem("Open", 0, true));
+ menu->AddItem(ContextMenuItem("Rename", 2, true));
+ menu->AddItem(ContextMenuItem("Delete", 3, true));
+ }
+}
+
void SaveButton::OnContextMenuAction(int item)
{
switch(item)
@@ -324,10 +337,10 @@ void SaveButton::OnContextMenuAction(int item)
DoSelection();
break;
case 2:
- DoHistoryAction();
+ DoAltAction();
break;
case 3:
- DoAuthorAction();
+ DoAltAction2();
break;
}
}
@@ -376,16 +389,16 @@ void SaveButton::OnMouseLeave(int x, int y)
isMouseInsideHistory = false;
}
-void SaveButton::DoHistoryAction()
+void SaveButton::DoAltAction()
{
if(actionCallback)
- actionCallback->HistoryActionCallback(this);
+ actionCallback->AltActionCallback(this);
}
-void SaveButton::DoAuthorAction()
+void SaveButton::DoAltAction2()
{
if(actionCallback)
- actionCallback->AuthorActionCallback(this);
+ actionCallback->AltActionCallback2(this);
}
void SaveButton::DoAction()
diff --git a/src/interface/SaveButton.h b/src/interface/SaveButton.h
index 74dbc00..7a75973 100644
--- a/src/interface/SaveButton.h
+++ b/src/interface/SaveButton.h
@@ -18,8 +18,8 @@ class SaveButtonAction
{
public:
virtual void ActionCallback(ui::SaveButton * sender) {}
- virtual void AuthorActionCallback(ui::SaveButton * sender) {}
- virtual void HistoryActionCallback(ui::SaveButton * sender) {}
+ virtual void AltActionCallback(ui::SaveButton * sender) {}
+ virtual void AltActionCallback2(ui::SaveButton * sender) {}
virtual void SelectedCallback(ui::SaveButton * sender) {}
virtual ~SaveButtonAction() {}
};
@@ -53,6 +53,7 @@ public:
virtual void OnMouseMovedInside(int x, int y, int dx, int dy);
+ void AddContextMenu(int menuType);
virtual void OnContextMenuAction(int item);
virtual void Draw(const Point& screenPos);
@@ -70,8 +71,8 @@ public:
SaveFile * GetSaveFile() { return file; }
inline bool GetState() { return state; }
virtual void DoAction();
- virtual void DoAuthorAction();
- virtual void DoHistoryAction();
+ virtual void DoAltAction();
+ virtual void DoAltAction2();
virtual void DoSelection();
void SetActionCallback(SaveButtonAction * action);
protected: