mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-10 18:34:21 +02:00
Add comment box to save preview - doesn't work yet
This commit is contained in:
@@ -211,11 +211,31 @@ void Client::notifyUpdateAvailable()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Client::notifyAuthUserChanged()
|
||||||
|
{
|
||||||
|
for (std::vector<ClientListener*>::iterator iterator = listeners.begin(), end = listeners.end(); iterator != end; ++iterator)
|
||||||
|
{
|
||||||
|
(*iterator)->NotifyAuthUserChanged(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Client::AddListener(ClientListener * listener)
|
void Client::AddListener(ClientListener * listener)
|
||||||
{
|
{
|
||||||
listeners.push_back(listener);
|
listeners.push_back(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Client::RemoveListener(ClientListener * listener)
|
||||||
|
{
|
||||||
|
for (std::vector<ClientListener*>::iterator iterator = listeners.begin(), end = listeners.end(); iterator != end; ++iterator)
|
||||||
|
{
|
||||||
|
if((*iterator) == listener)
|
||||||
|
{
|
||||||
|
listeners.erase(iterator);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Client::Shutdown()
|
void Client::Shutdown()
|
||||||
{
|
{
|
||||||
ClearThumbnailRequests();
|
ClearThumbnailRequests();
|
||||||
@@ -256,6 +276,7 @@ Client::~Client()
|
|||||||
void Client::SetAuthUser(User user)
|
void Client::SetAuthUser(User user)
|
||||||
{
|
{
|
||||||
authUser = user;
|
authUser = user;
|
||||||
|
notifyAuthUserChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
User Client::GetAuthUser()
|
User Client::GetAuthUser()
|
||||||
|
@@ -67,6 +67,7 @@ private:
|
|||||||
void updateStamps();
|
void updateStamps();
|
||||||
static vector<std::string> explodePropertyString(std::string property);
|
static vector<std::string> explodePropertyString(std::string property);
|
||||||
void notifyUpdateAvailable();
|
void notifyUpdateAvailable();
|
||||||
|
void notifyAuthUserChanged();
|
||||||
|
|
||||||
//Config file handle
|
//Config file handle
|
||||||
json::Object configDocument;
|
json::Object configDocument;
|
||||||
@@ -79,6 +80,7 @@ public:
|
|||||||
~Client();
|
~Client();
|
||||||
|
|
||||||
void AddListener(ClientListener * listener);
|
void AddListener(ClientListener * listener);
|
||||||
|
void RemoveListener(ClientListener * listener);
|
||||||
|
|
||||||
RequestStatus ExecVote(int saveID, int direction);
|
RequestStatus ExecVote(int saveID, int direction);
|
||||||
RequestStatus UploadSave(SaveInfo * save);
|
RequestStatus UploadSave(SaveInfo * save);
|
||||||
|
@@ -16,6 +16,7 @@ public:
|
|||||||
virtual ~ClientListener() {}
|
virtual ~ClientListener() {}
|
||||||
|
|
||||||
virtual void NotifyUpdateAvailable(Client * sender) {}
|
virtual void NotifyUpdateAvailable(Client * sender) {}
|
||||||
|
virtual void NotifyAuthUserChanged(Client * sender) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -8,13 +8,15 @@
|
|||||||
|
|
||||||
using namespace ui;
|
using namespace ui;
|
||||||
|
|
||||||
Textbox::Textbox(Point position, Point size, std::string textboxText):
|
Textbox::Textbox(Point position, Point size, std::string textboxText, std::string textboxPlaceholder):
|
||||||
Label(position, size, ""),
|
Label(position, size, ""),
|
||||||
actionCallback(NULL),
|
actionCallback(NULL),
|
||||||
masked(false),
|
masked(false),
|
||||||
border(true),
|
border(true),
|
||||||
mouseDown(false)
|
mouseDown(false)
|
||||||
{
|
{
|
||||||
|
placeHolder = textboxPlaceholder;
|
||||||
|
|
||||||
SetText(textboxText);
|
SetText(textboxText);
|
||||||
cursor = text.length();
|
cursor = text.length();
|
||||||
}
|
}
|
||||||
@@ -231,6 +233,10 @@ void Textbox::Draw(const Point& screenPos)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if(!text.length())
|
||||||
|
{
|
||||||
|
g->drawtext(screenPos.X+textPosition.X, screenPos.Y+textPosition.Y, placeHolder, textColour.Red, textColour.Green, textColour.Blue, 170);
|
||||||
|
}
|
||||||
if(border) g->drawrect(screenPos.X, screenPos.Y, Size.X, Size.Y, 160, 160, 160, 255);
|
if(border) g->drawrect(screenPos.X, screenPos.Y, Size.X, Size.Y, 160, 160, 160, 255);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -25,8 +25,9 @@ protected:
|
|||||||
int cursor, cursorPosition;
|
int cursor, cursorPosition;
|
||||||
TextboxAction *actionCallback;
|
TextboxAction *actionCallback;
|
||||||
std::string backingText;
|
std::string backingText;
|
||||||
|
std::string placeHolder;
|
||||||
public:
|
public:
|
||||||
Textbox(Point position, Point size, std::string textboxText);
|
Textbox(Point position, Point size, std::string textboxText = "", std::string textboxPlaceholder = "");
|
||||||
virtual ~Textbox();
|
virtual ~Textbox();
|
||||||
|
|
||||||
virtual void SetDisplayText(std::string text);
|
virtual void SetDisplayText(std::string text);
|
||||||
|
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "LoginController.h"
|
#include "LoginController.h"
|
||||||
#include "client/User.h"
|
#include "client/User.h"
|
||||||
|
#include "client/Client.h"
|
||||||
|
|
||||||
LoginController::LoginController(ControllerCallback * callback):
|
LoginController::LoginController(ControllerCallback * callback):
|
||||||
HasExited(false)
|
HasExited(false)
|
||||||
@@ -40,6 +41,10 @@ void LoginController::Exit()
|
|||||||
}
|
}
|
||||||
if(callback)
|
if(callback)
|
||||||
callback->ControllerExit();
|
callback->ControllerExit();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Client::Ref().SetAuthUser(loginModel->GetUser());
|
||||||
|
}
|
||||||
HasExited = true;
|
HasExited = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -12,11 +12,13 @@
|
|||||||
#include "PreviewModel.h"
|
#include "PreviewModel.h"
|
||||||
#include "PreviewModelException.h"
|
#include "PreviewModelException.h"
|
||||||
#include "dialogues/ErrorMessage.h"
|
#include "dialogues/ErrorMessage.h"
|
||||||
|
#include "login/LoginController.h"
|
||||||
#include "Controller.h"
|
#include "Controller.h"
|
||||||
|
|
||||||
PreviewController::PreviewController(int saveID, ControllerCallback * callback):
|
PreviewController::PreviewController(int saveID, ControllerCallback * callback):
|
||||||
HasExited(false),
|
HasExited(false),
|
||||||
saveId(saveID)
|
saveId(saveID),
|
||||||
|
loginWindow(NULL)
|
||||||
{
|
{
|
||||||
previewModel = new PreviewModel();
|
previewModel = new PreviewModel();
|
||||||
previewView = new PreviewView();
|
previewView = new PreviewView();
|
||||||
@@ -25,11 +27,24 @@ PreviewController::PreviewController(int saveID, ControllerCallback * callback):
|
|||||||
|
|
||||||
previewModel->UpdateSave(saveID, 0);
|
previewModel->UpdateSave(saveID, 0);
|
||||||
|
|
||||||
|
if(Client::Ref().GetAuthUser().ID)
|
||||||
|
{
|
||||||
|
previewModel->SetCommentBoxEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
Client::Ref().AddListener(this);
|
||||||
|
|
||||||
this->callback = callback;
|
this->callback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreviewController::Update()
|
void PreviewController::Update()
|
||||||
{
|
{
|
||||||
|
if(loginWindow && loginWindow->HasExited == true)
|
||||||
|
{
|
||||||
|
delete loginWindow;
|
||||||
|
loginWindow = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
previewModel->Update();
|
previewModel->Update();
|
||||||
@@ -45,6 +60,17 @@ void PreviewController::Update()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PreviewController::ShowLogin()
|
||||||
|
{
|
||||||
|
loginWindow = new LoginController();
|
||||||
|
ui::Engine::Ref().ShowWindow(loginWindow->GetView());
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreviewController::NotifyAuthUserChanged(Client * sender)
|
||||||
|
{
|
||||||
|
previewModel->SetCommentBoxEnabled(sender->GetAuthUser().ID);
|
||||||
|
}
|
||||||
|
|
||||||
SaveInfo * PreviewController::GetSave()
|
SaveInfo * PreviewController::GetSave()
|
||||||
{
|
{
|
||||||
return previewModel->GetSave();
|
return previewModel->GetSave();
|
||||||
@@ -114,6 +140,7 @@ PreviewController::~PreviewController() {
|
|||||||
{
|
{
|
||||||
ui::Engine::Ref().CloseWindow();
|
ui::Engine::Ref().CloseWindow();
|
||||||
}
|
}
|
||||||
|
Client::Ref().RemoveListener(this);
|
||||||
delete previewModel;
|
delete previewModel;
|
||||||
delete previewView;
|
delete previewView;
|
||||||
if(callback)
|
if(callback)
|
||||||
|
@@ -12,21 +12,27 @@
|
|||||||
#include "preview/PreviewView.h"
|
#include "preview/PreviewView.h"
|
||||||
#include "Controller.h"
|
#include "Controller.h"
|
||||||
#include "client/SaveInfo.h"
|
#include "client/SaveInfo.h"
|
||||||
|
#include "client/ClientListener.h"
|
||||||
|
|
||||||
|
class LoginController;
|
||||||
class PreviewModel;
|
class PreviewModel;
|
||||||
class PreviewView;
|
class PreviewView;
|
||||||
class PreviewController {
|
class PreviewController: public ClientListener {
|
||||||
int saveId;
|
int saveId;
|
||||||
PreviewModel * previewModel;
|
PreviewModel * previewModel;
|
||||||
PreviewView * previewView;
|
PreviewView * previewView;
|
||||||
|
LoginController * loginWindow;
|
||||||
ControllerCallback * callback;
|
ControllerCallback * callback;
|
||||||
public:
|
public:
|
||||||
|
virtual void NotifyAuthUserChanged(Client * sender);
|
||||||
|
|
||||||
bool HasExited;
|
bool HasExited;
|
||||||
PreviewController(int saveID, ControllerCallback * callback);
|
PreviewController(int saveID, ControllerCallback * callback);
|
||||||
void Exit();
|
void Exit();
|
||||||
void DoOpen();
|
void DoOpen();
|
||||||
void OpenInBrowser();
|
void OpenInBrowser();
|
||||||
void Report(std::string message);
|
void Report(std::string message);
|
||||||
|
void ShowLogin();
|
||||||
bool GetDoOpen();
|
bool GetDoOpen();
|
||||||
SaveInfo * GetSave();
|
SaveInfo * GetSave();
|
||||||
PreviewView * GetView() { return previewView; }
|
PreviewView * GetView() { return previewView; }
|
||||||
|
@@ -21,7 +21,8 @@ PreviewModel::PreviewModel():
|
|||||||
updateSaveCommentsWorking(false),
|
updateSaveCommentsWorking(false),
|
||||||
updateSaveCommentsFinished(false),
|
updateSaveCommentsFinished(false),
|
||||||
commentsTotal(0),
|
commentsTotal(0),
|
||||||
commentsPageNumber(1)
|
commentsPageNumber(1),
|
||||||
|
commentBoxEnabled(false)
|
||||||
{
|
{
|
||||||
// TODO Auto-generated constructor stub
|
// TODO Auto-generated constructor stub
|
||||||
|
|
||||||
@@ -77,6 +78,20 @@ void PreviewModel::SetFavourite(bool favourite)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PreviewModel::GetCommentBoxEnabled()
|
||||||
|
{
|
||||||
|
return commentBoxEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreviewModel::SetCommentBoxEnabled(bool enabledState)
|
||||||
|
{
|
||||||
|
if(enabledState != commentBoxEnabled)
|
||||||
|
{
|
||||||
|
commentBoxEnabled = enabledState;
|
||||||
|
notifyCommentBoxEnabledChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PreviewModel::UpdateSave(int saveID, int saveDate)
|
void PreviewModel::UpdateSave(int saveID, int saveDate)
|
||||||
{
|
{
|
||||||
this->tSaveID = saveID;
|
this->tSaveID = saveID;
|
||||||
@@ -189,6 +204,14 @@ void PreviewModel::notifySaveChanged()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PreviewModel::notifyCommentBoxEnabledChanged()
|
||||||
|
{
|
||||||
|
for(int i = 0; i < observers.size(); i++)
|
||||||
|
{
|
||||||
|
observers[i]->NotifyCommentBoxEnabledChanged(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PreviewModel::notifyCommentsPageChanged()
|
void PreviewModel::notifyCommentsPageChanged()
|
||||||
{
|
{
|
||||||
for(int i = 0; i < observers.size(); i++)
|
for(int i = 0; i < observers.size(); i++)
|
||||||
@@ -210,6 +233,7 @@ void PreviewModel::AddObserver(PreviewView * observer) {
|
|||||||
observer->NotifySaveChanged(this);
|
observer->NotifySaveChanged(this);
|
||||||
observer->NotifyCommentsChanged(this);
|
observer->NotifyCommentsChanged(this);
|
||||||
observer->NotifyCommentsPageChanged(this);
|
observer->NotifyCommentsPageChanged(this);
|
||||||
|
observer->NotifyCommentBoxEnabledChanged(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreviewModel::Update()
|
void PreviewModel::Update()
|
||||||
|
@@ -27,6 +27,7 @@ struct SaveData
|
|||||||
class PreviewView;
|
class PreviewView;
|
||||||
class PreviewModel {
|
class PreviewModel {
|
||||||
bool doOpen;
|
bool doOpen;
|
||||||
|
bool commentBoxEnabled;
|
||||||
vector<PreviewView*> observers;
|
vector<PreviewView*> observers;
|
||||||
SaveInfo * save;
|
SaveInfo * save;
|
||||||
vector<char> saveDataBuffer;
|
vector<char> saveDataBuffer;
|
||||||
@@ -34,6 +35,7 @@ class PreviewModel {
|
|||||||
void notifySaveChanged();
|
void notifySaveChanged();
|
||||||
void notifySaveCommentsChanged();
|
void notifySaveCommentsChanged();
|
||||||
void notifyCommentsPageChanged();
|
void notifyCommentsPageChanged();
|
||||||
|
void notifyCommentBoxEnabledChanged();
|
||||||
|
|
||||||
//Background retrieval
|
//Background retrieval
|
||||||
int tSaveID;
|
int tSaveID;
|
||||||
@@ -66,6 +68,9 @@ public:
|
|||||||
SaveInfo * GetSave();
|
SaveInfo * GetSave();
|
||||||
std::vector<SaveComment*> * GetComments();
|
std::vector<SaveComment*> * GetComments();
|
||||||
|
|
||||||
|
bool GetCommentBoxEnabled();
|
||||||
|
void SetCommentBoxEnabled(bool enabledState);
|
||||||
|
|
||||||
bool GetCommentsLoaded();
|
bool GetCommentsLoaded();
|
||||||
int GetCommentsPageNum();
|
int GetCommentsPageNum();
|
||||||
int GetCommentsPageCount();
|
int GetCommentsPageCount();
|
||||||
|
@@ -13,9 +13,21 @@
|
|||||||
#include "simulation/SaveRenderer.h"
|
#include "simulation/SaveRenderer.h"
|
||||||
#include "interface/Point.h"
|
#include "interface/Point.h"
|
||||||
#include "interface/Window.h"
|
#include "interface/Window.h"
|
||||||
|
#include "interface/Textbox.h"
|
||||||
#include "Style.h"
|
#include "Style.h"
|
||||||
#include "search/Thumbnail.h"
|
#include "search/Thumbnail.h"
|
||||||
|
|
||||||
|
class PreviewView::LoginAction: public ui::ButtonAction
|
||||||
|
{
|
||||||
|
PreviewView * v;
|
||||||
|
public:
|
||||||
|
LoginAction(PreviewView * v_){ v = v_; }
|
||||||
|
virtual void ActionCallback(ui::Button * sender)
|
||||||
|
{
|
||||||
|
v->c->ShowLogin();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
PreviewView::PreviewView():
|
PreviewView::PreviewView():
|
||||||
ui::Window(ui::Point(-1, -1), ui::Point((XRES/2)+200, (YRES/2)+150)),
|
ui::Window(ui::Point(-1, -1), ui::Point((XRES/2)+200, (YRES/2)+150)),
|
||||||
savePreview(NULL),
|
savePreview(NULL),
|
||||||
@@ -24,7 +36,10 @@ PreviewView::PreviewView():
|
|||||||
commentsVel(0),
|
commentsVel(0),
|
||||||
maxOffset(0),
|
maxOffset(0),
|
||||||
commentsBegin(true),
|
commentsBegin(true),
|
||||||
commentsEnd(false)
|
commentsEnd(false),
|
||||||
|
addCommentBox(NULL),
|
||||||
|
submitCommentButton(NULL),
|
||||||
|
commentBoxHeight(20)
|
||||||
{
|
{
|
||||||
class OpenAction: public ui::ButtonAction
|
class OpenAction: public ui::ButtonAction
|
||||||
{
|
{
|
||||||
@@ -118,8 +133,9 @@ PreviewView::PreviewView():
|
|||||||
authorDateLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; authorDateLabel->Appearance.VerticalAlign = ui::Appearance::AlignBottom;
|
authorDateLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; authorDateLabel->Appearance.VerticalAlign = ui::Appearance::AlignBottom;
|
||||||
AddComponent(authorDateLabel);
|
AddComponent(authorDateLabel);
|
||||||
|
|
||||||
pageInfo = new ui::Label(ui::Point((XRES/2) + 5, Size.Y-15), ui::Point(Size.X-((XRES/2) + 10), 15), "Page 1 of 1");
|
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;
|
pageInfo->Appearance.HorizontalAlign = ui::Appearance::AlignCentre; authorDateLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
|
||||||
|
|
||||||
AddComponent(pageInfo);
|
AddComponent(pageInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,7 +165,7 @@ void PreviewView::OnDraw()
|
|||||||
g->draw_image(savePreview->Data, (Position.X+1)+(((XRES/2)-savePreview->Size.X)/2), (Position.Y+1)+(((YRES/2)-savePreview->Size.Y)/2), savePreview->Size.X, savePreview->Size.Y, 255);
|
g->draw_image(savePreview->Data, (Position.X+1)+(((XRES/2)-savePreview->Size.X)/2), (Position.Y+1)+(((YRES/2)-savePreview->Size.Y)/2), savePreview->Size.X, savePreview->Size.Y, 255);
|
||||||
}
|
}
|
||||||
g->drawrect(Position.X, Position.Y, (XRES/2)+1, (YRES/2)+1, 255, 255, 255, 100);
|
g->drawrect(Position.X, Position.Y, (XRES/2)+1, (YRES/2)+1, 255, 255, 255, 100);
|
||||||
g->draw_line(Position.X+XRES/2, Position.Y+1, Position.X+XRES/2, Position.Y+Size.Y-2, 200, 200, 200, 255);
|
g->draw_line(Position.X+1+XRES/2, Position.Y+1, Position.X+XRES/2, Position.Y+Size.Y-2, 200, 200, 200, 255);
|
||||||
|
|
||||||
|
|
||||||
g->draw_line(Position.X+1, Position.Y+12+YRES/2, Position.X-1+XRES/2, Position.Y+12+YRES/2, 100, 100, 100,255);
|
g->draw_line(Position.X+1, Position.Y+12+YRES/2, Position.X-1+XRES/2, Position.Y+12+YRES/2, 100, 100, 100,255);
|
||||||
@@ -289,7 +305,7 @@ void PreviewView::displayComments(int yOffset)
|
|||||||
tempUsername->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; tempUsername->Appearance.VerticalAlign = ui::Appearance::AlignBottom;
|
tempUsername->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; tempUsername->Appearance.VerticalAlign = ui::Appearance::AlignBottom;
|
||||||
currentY += 16;
|
currentY += 16;
|
||||||
|
|
||||||
if(currentY > Size.Y || usernameY < 0)
|
if(currentY > Size.Y-commentBoxHeight || usernameY < 0)
|
||||||
{
|
{
|
||||||
delete tempUsername;
|
delete tempUsername;
|
||||||
if(currentY > Size.Y)
|
if(currentY > Size.Y)
|
||||||
@@ -308,7 +324,7 @@ void PreviewView::displayComments(int yOffset)
|
|||||||
tempComment->SetTextColour(ui::Colour(180, 180, 180));
|
tempComment->SetTextColour(ui::Colour(180, 180, 180));
|
||||||
currentY += tempComment->Size.Y+4;
|
currentY += tempComment->Size.Y+4;
|
||||||
|
|
||||||
if(currentY > Size.Y || commentY < 0)
|
if(currentY > Size.Y-commentBoxHeight || commentY < 0)
|
||||||
{
|
{
|
||||||
delete tempComment;
|
delete tempComment;
|
||||||
if(currentY > Size.Y)
|
if(currentY > Size.Y)
|
||||||
@@ -323,6 +339,37 @@ void PreviewView::displayComments(int yOffset)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PreviewView::NotifyCommentBoxEnabledChanged(PreviewModel * sender)
|
||||||
|
{
|
||||||
|
if(addCommentBox)
|
||||||
|
{
|
||||||
|
RemoveComponent(addCommentBox);
|
||||||
|
addCommentBox = NULL;
|
||||||
|
delete addCommentBox;
|
||||||
|
}
|
||||||
|
if(submitCommentButton)
|
||||||
|
{
|
||||||
|
RemoveComponent(submitCommentButton);
|
||||||
|
submitCommentButton = NULL;
|
||||||
|
delete submitCommentButton;
|
||||||
|
}
|
||||||
|
if(sender->GetCommentBoxEnabled())
|
||||||
|
{
|
||||||
|
addCommentBox = new ui::Textbox(ui::Point((XRES/2)+4, Size.Y-19), ui::Point(Size.X-(XRES/2)-48, 17), "", "Add Comment");
|
||||||
|
addCommentBox->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
|
||||||
|
AddComponent(addCommentBox);
|
||||||
|
submitCommentButton = new ui::Button(ui::Point(Size.X-40, Size.Y-19), ui::Point(40, 19), "Submit");
|
||||||
|
//submitCommentButton->Enabled = false;
|
||||||
|
AddComponent(submitCommentButton);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
submitCommentButton = new ui::Button(ui::Point(XRES/2, Size.Y-19), ui::Point(Size.X-(XRES/2), 19), "Login to comment");
|
||||||
|
submitCommentButton->SetActionCallback(new LoginAction(this));
|
||||||
|
AddComponent(submitCommentButton);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PreviewView::NotifyCommentsPageChanged(PreviewModel * sender)
|
void PreviewView::NotifyCommentsPageChanged(PreviewModel * sender)
|
||||||
{
|
{
|
||||||
std::stringstream pageInfoStream;
|
std::stringstream pageInfoStream;
|
||||||
@@ -361,7 +408,7 @@ void PreviewView::NotifyCommentsChanged(PreviewModel * sender)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
maxOffset = (maxY-Size.Y)+16;
|
maxOffset = (maxY-(Size.Y-commentBoxHeight))+16;
|
||||||
commentsBegin = true;
|
commentsBegin = true;
|
||||||
commentsEnd = false;
|
commentsEnd = false;
|
||||||
commentsOffset = 0;
|
commentsOffset = 0;
|
||||||
|
@@ -16,16 +16,20 @@
|
|||||||
#include "interface/Button.h"
|
#include "interface/Button.h"
|
||||||
#include "search/Thumbnail.h"
|
#include "search/Thumbnail.h"
|
||||||
#include "interface/Label.h"
|
#include "interface/Label.h"
|
||||||
|
#include "interface/Textbox.h"
|
||||||
|
|
||||||
class PreviewModel;
|
class PreviewModel;
|
||||||
class PreviewController;
|
class PreviewController;
|
||||||
class PreviewView: public ui::Window {
|
class PreviewView: public ui::Window {
|
||||||
|
class LoginAction;
|
||||||
PreviewController * c;
|
PreviewController * c;
|
||||||
Thumbnail * savePreview;
|
Thumbnail * savePreview;
|
||||||
ui::Button * openButton;
|
ui::Button * openButton;
|
||||||
ui::Button * browserOpenButton;
|
ui::Button * browserOpenButton;
|
||||||
ui::Button * favButton;
|
ui::Button * favButton;
|
||||||
ui::Button * reportButton;
|
ui::Button * reportButton;
|
||||||
|
ui::Button * submitCommentButton;
|
||||||
|
ui::Textbox * addCommentBox;
|
||||||
ui::Label * saveNameLabel;
|
ui::Label * saveNameLabel;
|
||||||
ui::Label * authorDateLabel;
|
ui::Label * authorDateLabel;
|
||||||
ui::Label * pageInfo;
|
ui::Label * pageInfo;
|
||||||
@@ -43,6 +47,8 @@ class PreviewView: public ui::Window {
|
|||||||
float commentsOffset;
|
float commentsOffset;
|
||||||
float commentsVel;
|
float commentsVel;
|
||||||
|
|
||||||
|
int commentBoxHeight;
|
||||||
|
|
||||||
void displayComments(int yOffset);
|
void displayComments(int yOffset);
|
||||||
public:
|
public:
|
||||||
void AttachController(PreviewController * controller) { c = controller;}
|
void AttachController(PreviewController * controller) { c = controller;}
|
||||||
@@ -50,6 +56,7 @@ public:
|
|||||||
void NotifySaveChanged(PreviewModel * sender);
|
void NotifySaveChanged(PreviewModel * sender);
|
||||||
void NotifyCommentsChanged(PreviewModel * sender);
|
void NotifyCommentsChanged(PreviewModel * sender);
|
||||||
void NotifyCommentsPageChanged(PreviewModel * sender);
|
void NotifyCommentsPageChanged(PreviewModel * sender);
|
||||||
|
void NotifyCommentBoxEnabledChanged(PreviewModel * sender);
|
||||||
virtual void OnDraw();
|
virtual void OnDraw();
|
||||||
virtual void DoDraw();
|
virtual void DoDraw();
|
||||||
virtual void OnTick(float dt);
|
virtual void OnTick(float dt);
|
||||||
|
Reference in New Issue
Block a user