[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: koffice/lib/kofficeui
From: Thorsten Zachmann <t.zachmann () zagge ! de>
Date: 2005-11-02 6:01:47
Message-ID: 1130911307.036866.9756.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 476797 by zachmann:
o Added new method to get the next guide
o Fix in snapToGuide to return the value not negatet
M +84 -5 koGuides.cpp
M +11 -0 koGuides.h
--- trunk/koffice/lib/kofficeui/koGuides.cpp #476796:476797
@@ -369,7 +369,7 @@
if ( ( *it )->orientation == Qt::Horizontal )
{
- double tmp = rect.top() - (*it)->position;
+ double tmp = (*it)->position - rect.top();
if ( QABS( tmp ) < m_zoomHandler->unzoomItY( snap ) )
{
if(QABS( tmp ) < diff.y())
@@ -390,7 +390,7 @@
}
else
{
- double tmp = rect.left() - (*it)->position;
+ double tmp = (*it)->position - rect.left();
if ( QABS( tmp ) < m_zoomHandler->unzoomItX( snap ) )
{
if(QABS( tmp ) < diff.x())
@@ -418,7 +418,7 @@
if ( ( *it )->orientation == Qt::Horizontal )
{
- double tmp = rect.top() - (*it)->position;
+ double tmp = (*it)->position - rect.top();
if ( QABS( tmp ) < m_zoomHandler->unzoomItY( snap ) )
{
if(QABS( tmp ) < diff.y())
@@ -427,7 +427,7 @@
hClosest = *it;
}
}
- tmp = rect.bottom() - (*it)->position;
+ tmp = (*it)->position - rect.bottom();
if ( QABS( tmp ) < m_zoomHandler->unzoomItY( snap ) )
{
if(QABS( tmp ) < diff.y())
@@ -439,7 +439,7 @@
}
else
{
- double tmp = rect.left() - (*it)->position;
+ double tmp = (*it)->position - rect.left();
if ( QABS( tmp ) < m_zoomHandler->unzoomItX( snap ) )
{
if(QABS( tmp ) < diff.x())
@@ -551,6 +551,85 @@
}
+KoPoint KoGuides::diffNextGuide( KoRect &rect, bool right, bool bottom )
+{
+ KoPoint move( 0, 0 );
+ QValueList<double> horizHelplines;
+ QValueList<double> vertHelplines;
+ getGuideLines( horizHelplines, vertHelplines );
+
+ QValueList<double>::const_iterator it( vertHelplines.begin() );
+ bool xset = false;
+ bool yset = false;
+ for ( ; it != vertHelplines.end(); ++it )
+ {
+ double movexl = *it - rect.left();
+ double movexr = *it - rect.right();
+ if ( right )
+ {
+ if ( ( !xset || movexl < move.x() ) && movexl > 0 )
+ {
+ move.setX( movexl );
+ xset = true;
+ }
+ if ( ( !xset || movexr < move.x() ) && movexr > 0 )
+ {
+ move.setX( movexr );
+ xset = true;
+ }
+ }
+ else
+ {
+ if ( ( !xset || movexl > move.x() ) && movexl < 0 )
+ {
+ move.setX( movexl );
+ xset = true;
+ }
+ if ( ( !xset || movexr > move.x() ) && movexr < 0 )
+ {
+ move.setX( movexr );
+ xset = true;
+ }
+ }
+ }
+
+ it = horizHelplines.begin();
+ for ( ; it != horizHelplines.end(); ++it )
+ {
+ double moveyl = *it - rect.top();
+ double moveyr = *it - rect.bottom();
+ if ( bottom )
+ {
+ if ( ( !yset || moveyl < move.y() ) && moveyl > 0 )
+ {
+ move.setY( moveyl );
+ yset = true;
+ }
+ if ( ( !yset || moveyr < move.y() ) && moveyr > 0 )
+ {
+ move.setY( moveyr );
+ yset = true;
+ }
+ }
+ else
+ {
+ if ( ( !yset || moveyl > move.y() ) && moveyl < 0 )
+ {
+ move.setY( moveyl );
+ yset = true;
+ }
+ if ( ( !yset || moveyr > move.y() ) && moveyr < 0 )
+ {
+ move.setY( moveyr );
+ yset = true;
+ }
+ }
+ }
+
+ return move;
+}
+
+
void KoGuides::moveGuide( const QPoint &pos, bool horizontal, int rulerWidth )
{
int x = pos.x() - rulerWidth;
--- trunk/koffice/lib/kofficeui/koGuides.h #476796:476797
@@ -152,6 +152,17 @@
*/
KoPoint diffGuide( KoRect &rect, double diffx, double diffy );
+ /**
+ * @brief Get the disance to the next guide in the indicated directions
+ *
+ * @param rect The rect which should be snapped
+ * @param right If true, search to the right otherwise to the left.
+ * @param bottom If true, search to the bottom otherwise to the top.
+ *
+ * @return the distance to the guide or ( 0, 0 ) if there is no guide to snap to.
+ */
+ KoPoint diffNextGuide( KoRect &rect, bool right, bool bottom );
+
public slots:
/**
* @brief Move Guide
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic