summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-08-25 17:11:36 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-08-25 17:11:36 (GMT)
commite88fca8aa1d4b0c585b50abf501ce733d1645f05 (patch)
tree4bb6e1f6fad1a55fe65c46cc4146c911897cc9c5 /src
parent5c293ba9bfca884e309a5fa7f67497eddd7e6643 (diff)
downloadpowder-e88fca8aa1d4b0c585b50abf501ce733d1645f05.zip
powder-e88fca8aa1d4b0c585b50abf501ce733d1645f05.tar.gz
Save ID copying for preview
Diffstat (limited to 'src')
-rw-r--r--src/interface/Textbox.cpp13
-rw-r--r--src/interface/Textbox.h1
-rw-r--r--src/preview/PreviewController.cpp9
-rw-r--r--src/preview/PreviewController.h1
-rw-r--r--src/preview/PreviewView.cpp30
-rw-r--r--src/preview/PreviewView.h3
6 files changed, 46 insertions, 11 deletions
diff --git a/src/interface/Textbox.cpp b/src/interface/Textbox.cpp
index 159c326..603fa23 100644
--- a/src/interface/Textbox.cpp
+++ b/src/interface/Textbox.cpp
@@ -19,7 +19,8 @@ Textbox::Textbox(Point position, Point size, std::string textboxText, std::strin
limit(std::string::npos),
inputType(All),
keyDown(0),
- characterDown(0)
+ characterDown(0),
+ ReadOnly(false)
{
placeHolder = textboxPlaceholder;
@@ -268,12 +269,12 @@ void Textbox::OnVKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
copySelection();
return;
}
- if(ctrl && key == 'v')
+ if(ctrl && key == 'v' && !ReadOnly)
{
pasteIntoSelection();
return;
}
- if(ctrl && key == 'x' && !masked)
+ if(ctrl && key == 'x' && !masked && !ReadOnly)
{
cutSelection();
return;
@@ -307,6 +308,8 @@ void Textbox::OnVKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
ClearSelection();
break;
case KEY_DELETE:
+ if(ReadOnly)
+ break;
if(HasSelection())
{
if(getLowerSelectionBound() < 0 || getHigherSelectionBound() > backingText.length())
@@ -326,6 +329,8 @@ void Textbox::OnVKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
ClearSelection();
break;
case KEY_BACKSPACE:
+ if(ReadOnly)
+ break;
if(HasSelection())
{
if(getLowerSelectionBound() < 0 || getHigherSelectionBound() > backingText.length())
@@ -351,7 +356,7 @@ void Textbox::OnVKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
ClearSelection();
break;
}
- if(CharacterValid(character))
+ if(CharacterValid(character) && !ReadOnly)
{
if(HasSelection())
{
diff --git a/src/interface/Textbox.h b/src/interface/Textbox.h
index a43a7e5..7d06111 100644
--- a/src/interface/Textbox.h
+++ b/src/interface/Textbox.h
@@ -20,6 +20,7 @@ class Textbox : public Label
{
friend class TextboxAction;
public:
+ bool ReadOnly;
enum ValidInput { All, Numeric, Number };
Textbox(Point position, Point size, std::string textboxText = "", std::string textboxPlaceholder = "");
virtual ~Textbox();
diff --git a/src/preview/PreviewController.cpp b/src/preview/PreviewController.cpp
index b81ccda..651db32 100644
--- a/src/preview/PreviewController.cpp
+++ b/src/preview/PreviewController.cpp
@@ -124,12 +124,9 @@ void PreviewController::FavouriteSave()
void PreviewController::OpenInBrowser()
{
- if(previewModel->GetSave())
- {
- std::stringstream uriStream;
- uriStream << "http://" << SERVER << "/Browse/View.html?ID=" << previewModel->GetSave()->id;
- OpenURI(uriStream.str());
- }
+ std::stringstream uriStream;
+ uriStream << "http://" << SERVER << "/Browse/View.html?ID=" << saveId;
+ OpenURI(uriStream.str());
}
void PreviewController::NextCommentPage()
diff --git a/src/preview/PreviewController.h b/src/preview/PreviewController.h
index e6b8caa..c04a07f 100644
--- a/src/preview/PreviewController.h
+++ b/src/preview/PreviewController.h
@@ -25,6 +25,7 @@ class PreviewController: public ClientListener {
ControllerCallback * callback;
public:
virtual void NotifyAuthUserChanged(Client * sender);
+ inline int SaveID() { return saveId; };
bool HasExited;
PreviewController(int saveID, ControllerCallback * callback);
diff --git a/src/preview/PreviewView.cpp b/src/preview/PreviewView.cpp
index 5b7952b..c0aacf9 100644
--- a/src/preview/PreviewView.cpp
+++ b/src/preview/PreviewView.cpp
@@ -155,15 +155,45 @@ PreviewView::PreviewView():
authorDateLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; authorDateLabel->Appearance.VerticalAlign = ui::Appearance::AlignBottom;
AddComponent(authorDateLabel);
+
pageInfo = new ui::Label(ui::Point((XRES/2) + 5, Size.Y+1), ui::Point(Size.X-((XRES/2) + 10), 15), "Page 1 of 1");
pageInfo->Appearance.HorizontalAlign = ui::Appearance::AlignCentre; authorDateLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
+ saveIDTextbox = new ui::Textbox(ui::Point((XRES/2)-55, Size.Y-40), ui::Point(50, 16), "0000000");
+ saveIDTextbox->Appearance.HorizontalAlign = ui::Appearance::AlignCentre;
+ saveIDTextbox->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
+ saveIDTextbox->ReadOnly = true;
+ AddComponent(saveIDTextbox);
+
+ class CopyIDAction: public ui::ButtonAction
+ {
+ PreviewView * v;
+ public:
+ CopyIDAction(PreviewView * v_){ v = v_; }
+ virtual void ActionCallback(ui::Button * sender)
+ {
+ clipboard_push_text((char*)v->saveIDTextbox->GetText().c_str());
+ }
+ };
+
+ ui::Button * tempButton = new ui::Button(ui::Point((XRES/2)-130, Size.Y-40), ui::Point(70, 16), "Copy Save ID");
+ tempButton->Appearance.HorizontalAlign = ui::Appearance::AlignCentre;
+ tempButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
+ tempButton->SetActionCallback(new CopyIDAction(this));
+ AddComponent(tempButton);
+
commentsPanel = new ui::ScrollPanel(ui::Point((XRES/2)+1, 1), ui::Point((Size.X-(XRES/2))-2, Size.Y-commentBoxHeight));
AddComponent(commentsPanel);
AddComponent(pageInfo);
}
+void PreviewView::AttachController(PreviewController * controller)
+{
+ c = controller;
+ saveIDTextbox->SetText(format::NumberToString<int>(c->SaveID()));
+}
+
void PreviewView::commentBoxAutoHeight()
{
if(!addCommentBox)
diff --git a/src/preview/PreviewView.h b/src/preview/PreviewView.h
index 5e777fb..7fb9ff5 100644
--- a/src/preview/PreviewView.h
+++ b/src/preview/PreviewView.h
@@ -41,6 +41,7 @@ class PreviewView: public ui::Window {
ui::Label * authorDateLabel;
ui::Label * pageInfo;
ui::Label * saveDescriptionLabel;
+ ui::Textbox * saveIDTextbox;
ui::ScrollPanel * commentsPanel;
std::vector<SaveComment> comments;
std::vector<ui::Component*> commentComponents;
@@ -59,7 +60,7 @@ class PreviewView: public ui::Window {
void commentBoxAutoHeight();
void submitComment();
public:
- void AttachController(PreviewController * controller) { c = controller;}
+ void AttachController(PreviewController * controller);
PreviewView();
void NotifySaveChanged(PreviewModel * sender);
void NotifyCommentsChanged(PreviewModel * sender);