diff options
Diffstat (limited to 'src/preview/PreviewView.cpp')
| -rw-r--r-- | src/preview/PreviewView.cpp | 59 |
1 files changed, 53 insertions, 6 deletions
diff --git a/src/preview/PreviewView.cpp b/src/preview/PreviewView.cpp index b6b2e02..0eb29b6 100644 --- a/src/preview/PreviewView.cpp +++ b/src/preview/PreviewView.cpp @@ -13,9 +13,21 @@ #include "simulation/SaveRenderer.h" #include "interface/Point.h" #include "interface/Window.h" +#include "interface/Textbox.h" #include "Style.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(): ui::Window(ui::Point(-1, -1), ui::Point((XRES/2)+200, (YRES/2)+150)), savePreview(NULL), @@ -24,7 +36,10 @@ PreviewView::PreviewView(): commentsVel(0), maxOffset(0), commentsBegin(true), - commentsEnd(false) + commentsEnd(false), + addCommentBox(NULL), + submitCommentButton(NULL), + commentBoxHeight(20) { class OpenAction: public ui::ButtonAction { @@ -118,8 +133,9 @@ 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-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; + 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->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); @@ -289,7 +305,7 @@ void PreviewView::displayComments(int yOffset) tempUsername->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; tempUsername->Appearance.VerticalAlign = ui::Appearance::AlignBottom; currentY += 16; - if(currentY > Size.Y || usernameY < 0) + if(currentY > Size.Y-commentBoxHeight || usernameY < 0) { delete tempUsername; if(currentY > Size.Y) @@ -308,7 +324,7 @@ void PreviewView::displayComments(int yOffset) tempComment->SetTextColour(ui::Colour(180, 180, 180)); currentY += tempComment->Size.Y+4; - if(currentY > Size.Y || commentY < 0) + if(currentY > Size.Y-commentBoxHeight || commentY < 0) { delete tempComment; 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) { 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; commentsEnd = false; commentsOffset = 0; |
