add operator& (intersection) for NormalizedRect

original patch by kde2eran@tromer.org, thanks!

CCMAIL: kde2eran@tromer.org

svn path=/trunk/KDE/kdegraphics/okular/; revision=809403
remotes/origin/KDE/4.1
Pino Toscano 18 years ago
parent 0b847d2926
commit d650603340
  1. 13
      core/area.cpp
  2. 8
      core/area.h

@ -122,6 +122,19 @@ NormalizedRect& NormalizedRect::operator|= (const NormalizedRect & r)
return *this;
}
NormalizedRect NormalizedRect::operator&( const NormalizedRect & r ) const
{
if ( isNull() || r.isNull() )
return NormalizedRect();
NormalizedRect ret;
ret.left = qMax( left, r.left );
ret.top = qMax( top, r.top );
ret.bottom = qMin( bottom, r.bottom );
ret.right = qMin( right, r.right );
return ret;
}
NormalizedRect & NormalizedRect::operator=( const NormalizedRect & r )
{
left = r.left;

@ -177,6 +177,14 @@ class OKULAR_EXPORT NormalizedRect
*/
NormalizedRect& operator|=( const NormalizedRect &other );
/**
* Returns the intersection of this normalized rectangle with the specified
* @p other. If the rects do not intersect then the result is null.
*
* @since 0.7 (KDE 4.1)
*/
NormalizedRect operator&( const NormalizedRect &other ) const;
/**
* Returns whether the normalized rectangle is equal to the @p other
* normalized rectangle.

Loading…
Cancel
Save