[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/work/kviewshell-0.7/kviewshell/shell
From: Wilfried Huss <Wilfried.Huss () gmx ! at>
Date: 2006-10-06 18:09:47
Message-ID: 1160158187.763625.32414.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 593070 by whuss:
subclasses of SmoothScrollview can now decide which movements
should be performed smoothly, and a few small fixes in the thumbnail list.
M +19 -1 marklist.cpp
M +2 -0 marklist.h
M +11 -3 smoothScrollView.cpp
M +12 -0 smoothScrollView.h
--- branches/work/kviewshell-0.7/kviewshell/shell/marklist.cpp #593069:593070
@@ -414,12 +414,21 @@
}
+bool MarkList::isSmoothScrollDistance(double scrollDistance)
+{
+ double viewportDiagonal = sqrt((double)(visibleHeight()) * \
(double)(visibleHeight()) + + \
(double)(visibleWidth()) * (double)(visibleWidth())); +
+ return scrollDistance < 1.5 * viewportDiagonal;
+}
+
+
void MarkList::viewportPaintEvent(QPaintEvent* e)
{
// Region from which rectangles occupied by child widgets will be
// subtracted.
QRegion backgroundArea(e->rect());
-
+
// Paint the background.
QPainter p(viewport());
@@ -470,6 +479,8 @@
resizeContents(visibleWidth(), y);
viewport()->update();
+
+ setCurrentPage();
}
@@ -681,6 +692,10 @@
if (dataModel->numberOfPages() == 0)
return;
+ // Temporarely disable smooth scrolling
+ bool smooth = dataModel->preferences()->smoothScrolling();
+ dataModel->preferences()->setSmoothScrolling(false);
+
// Save page selections.
QValueVector<bool> selections;
selections.resize(widgetList.count());
@@ -697,6 +712,9 @@
// Restore page selections
for (unsigned int i = 0; i < widgetList.count(); i++)
widgetList[i]->setChecked(selections[i]);
+
+ // Set smooth scrolling to its old state
+ dataModel->preferences()->setSmoothScrolling(smooth);
}
}
--- branches/work/kviewshell-0.7/kviewshell/shell/marklist.h #593069:593070
@@ -181,6 +181,8 @@
virtual void mousePressEvent(QMouseEvent*);
+ virtual bool isSmoothScrollDistance(double scrollDistance);
+
private slots:
void setCurrentPage();
void setNumberOfPages();
--- branches/work/kviewshell-0.7/kviewshell/shell/smoothScrollView.cpp #593069:593070
@@ -46,17 +46,25 @@
}
+bool SmoothScrollView::isSmoothScrollDistance(double scrollDistance)
+{
+ double viewportDiagonal = sqrt((double)(visibleHeight()) * \
(double)(visibleHeight()) + + \
(double)(visibleWidth()) * (double)(visibleWidth())); + return (scrollDistance < 3 * \
viewportDiagonal); +}
+
+
void SmoothScrollView::setContentsPosSmooth(int x, int y)
{
// Measure the time between the last call of this function.
int timeBetweenFunctionCalls = viewportMoveTime.elapsed();
viewportMoveTime.start();
- double scrollDistance = sqrt((contentsY() - y) * (contentsY() - y) + (contentsX() \
- x) * (contentsX() - x));
- double viewportDiagonal = sqrt(visibleHeight() * visibleHeight() + visibleWidth() \
* visibleWidth()); + double scrollDistance = sqrt((double)(contentsY() - y) * \
(double)(contentsY() - y) + + (double)(contentsX() - x) \
* (double)(contentsX() - x));
// Only use smooth scrolling if we move the viewport a moderate distance.
- if (dataModel->preferences()->smoothScrolling() && scrollDistance < 3 * \
viewportDiagonal) + if (dataModel->preferences()->smoothScrolling() && \
isSmoothScrollDistance(scrollDistance)) {
// If a smooth scrolling operation is active, or the time between two \
invocations of this
// function is small, we cancel the smooth scroll and jump to the requested \
position.
--- branches/work/kviewshell-0.7/kviewshell/shell/smoothScrollView.h #593069:593070
@@ -45,6 +45,18 @@
protected:
bool moveInProgress() { return viewportMoveActive; }
+ /**
+ @brief decides if the scrolling should be smooth or instentanious.
+
+ @param scrollDistance the distance of the move in pixels
+
+ @returns true if the scroll should be smooth.
+
+ @note reimplement in a subclass if the default implementation does
+ not give the optimal result.
+ */
+ virtual bool isSmoothScrollDistance(double scrollDistance);
+
private slots:
void slotMoveViewport();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic