[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdegraphics/kviewshell/shell
From:       Wilfried Huss <Wilfried.Huss () gmx ! at>
Date:       2006-10-08 11:40:59
Message-ID: 1160307659.807487.5484.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 593581 by whuss:

Port of commit 593070:

subclasses of SmoothScrollview can now decide which movements
should be performed smoothly, and a few small fixes in the thumbnail list.

 M  +18 -0     marklist.cpp  
 M  +2 -0      marklist.h  
 M  +11 -3     smoothScrollView.cpp  
 M  +12 -0     smoothScrollView.h  


--- trunk/KDE/kdegraphics/kviewshell/shell/marklist.cpp #593580:593581
@@ -424,6 +424,15 @@
 }
 
 
+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
@@ -491,6 +500,8 @@
 
   resizeContents(visibleWidth(), y);
   viewport()->update();
+
+  setCurrentPage();
 }
 
 
@@ -695,6 +706,10 @@
     if (dataModel->numberOfPages() == 0)
       return;
 
+    // Temporarely disable smooth scrolling
+    bool smooth = dataModel->preferences()->smoothScrolling();
+    dataModel->preferences()->setSmoothScrolling(false);
+
     // Save page selections.
     QList<bool> selections;
     for (int i = 0; i < widgetList.size(); i++)
@@ -710,6 +725,9 @@
     // Restore page selections
     for (int i = 0; i < widgetList.size(); i++)
       widgetList[i]->setChecked(selections[i]);
+
+    // Set smooth scrolling to its old state
+    dataModel->preferences()->setSmoothScrolling(smooth);
   }
 }
 
--- trunk/KDE/kdegraphics/kviewshell/shell/marklist.h #593580:593581
@@ -181,6 +181,8 @@
 
   virtual void mousePressEvent(QMouseEvent*);
 
+  virtual bool isSmoothScrollDistance(double scrollDistance);
+
 private slots:
   void setCurrentPage();
   void setNumberOfPages();
--- trunk/KDE/kdegraphics/kviewshell/shell/smoothScrollView.cpp #593580:593581
@@ -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.
--- trunk/KDE/kdegraphics/kviewshell/shell/smoothScrollView.h #593580:593581
@@ -47,6 +47,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