summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjacob1 <jfu614@gmail.com>2013-07-21 19:59:51 (GMT)
committer jacob1 <jfu614@gmail.com>2013-07-21 19:59:51 (GMT)
commita63f5b875b9d31f8932ca62537ae7b863ef7f8b8 (patch)
tree09e917a515cf0ed03a09e14f6782ad964ae3c7ad
parenta9352008cf3765070a0634cb198820ebda9427f1 (diff)
downloadpowder-a63f5b875b9d31f8932ca62537ae7b863ef7f8b8.zip
powder-a63f5b875b9d31f8932ca62537ae7b863ef7f8b8.tar.gz
when scrolling up through comments, it starts at the bottom of the page instead of the top
-rw-r--r--src/gui/interface/ScrollPanel.cpp5
-rw-r--r--src/gui/interface/ScrollPanel.h1
-rw-r--r--src/gui/preview/PreviewView.cpp28
-rw-r--r--src/gui/preview/PreviewView.h1
4 files changed, 19 insertions, 16 deletions
diff --git a/src/gui/interface/ScrollPanel.cpp b/src/gui/interface/ScrollPanel.cpp
index 11a4f71..f1e8094 100644
--- a/src/gui/interface/ScrollPanel.cpp
+++ b/src/gui/interface/ScrollPanel.cpp
@@ -28,6 +28,11 @@ int ScrollPanel::GetScrollLimit()
return 0;
}
+void ScrollPanel::SetScrollPosition(int position)
+{
+ offsetY = position;
+}
+
void ScrollPanel::XOnMouseWheelInside(int localx, int localy, int d)
{
if(!d)
diff --git a/src/gui/interface/ScrollPanel.h b/src/gui/interface/ScrollPanel.h
index 08b5069..0d48658 100644
--- a/src/gui/interface/ScrollPanel.h
+++ b/src/gui/interface/ScrollPanel.h
@@ -21,6 +21,7 @@ namespace ui
ScrollPanel(Point position, Point size);
int GetScrollLimit();
+ void SetScrollPosition(int position);
virtual void Draw(const Point& screenPos);
virtual void XTick(float dt);
diff --git a/src/gui/preview/PreviewView.cpp b/src/gui/preview/PreviewView.cpp
index f55f6b5..590798e 100644
--- a/src/gui/preview/PreviewView.cpp
+++ b/src/gui/preview/PreviewView.cpp
@@ -69,7 +69,8 @@ PreviewView::PreviewView():
addCommentBox(NULL),
submitCommentButton(NULL),
commentBoxHeight(20),
- showAvatars(true)
+ showAvatars(true),
+ prevPage(false)
{
class FavAction: public ui::ButtonAction
{
@@ -374,7 +375,10 @@ void PreviewView::OnMouseWheel(int x, int y, int d)
if(commentsPanel->GetScrollLimit() == 1 && d < 0)
c->NextCommentPage();
if(commentsPanel->GetScrollLimit() == -1 && d > 0)
+ {
+ prevPage = true;
c->PrevCommentPage();
+ }
}
@@ -585,24 +589,16 @@ void PreviewView::NotifyCommentsChanged(PreviewModel * sender)
}
commentsPanel->InnerSize = ui::Point(commentsPanel->Size.X, currentY+4);
+ if (prevPage)
+ {
+ prevPage = false;
+ commentsPanel->SetScrollPosition(currentY);
+ //update positions of the comments so that it doesn't start at the top for a frame
+ commentsPanel->Tick(0);
+ }
}
}
-/*void PreviewView::NotifyPreviewChanged(PreviewModel * sender)
-{
- savePreview = sender->GetGameSave();
- if(savePreview && savePreview->Data && !(savePreview->Width == XRES/2 && savePreview->Height == YRES/2))
- {
- int newSizeX, newSizeY;
- float factorX = ((float)XRES/2)/((float)savePreview->Width);
- float factorY = ((float)YRES/2)/((float)savePreview->Height);
- float scaleFactor = factorY < factorX ? factorY : factorX;
- savePreview->Data = Graphics::resample_img(savePreview->Data, savePreview->Width, savePreview->Height, savePreview->Width*scaleFactor, savePreview->Height*scaleFactor);
- savePreview->Width *= scaleFactor;
- savePreview->Height *= scaleFactor;
- }
-}*/
-
PreviewView::~PreviewView()
{
if(addCommentBox)
diff --git a/src/gui/preview/PreviewView.h b/src/gui/preview/PreviewView.h
index 25c3772..9ddbb71 100644
--- a/src/gui/preview/PreviewView.h
+++ b/src/gui/preview/PreviewView.h
@@ -49,6 +49,7 @@ class PreviewView: public ui::Window {
int votesDown;
bool doOpen;
bool showAvatars;
+ bool prevPage;
int commentBoxHeight;
float commentBoxPositionX;