Add a method to subdivide the window into regular grid.
Will be used by wobbly windows effect. svn path=/trunk/KDE/kdebase/workspace/; revision=781469icc-effect-5.14.5
parent
23ff1daaaa
commit
3f581b4d0c
|
@ -614,6 +614,52 @@ WindowQuadList WindowQuadList::makeGrid( int maxquadsize ) const
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WindowQuadList WindowQuadList::makeRegularGrid( int xSubdivisions, int ySubdivisions ) const
|
||||||
|
{
|
||||||
|
if( empty())
|
||||||
|
return *this;
|
||||||
|
// find the bounding rectangle
|
||||||
|
double left = first().left();
|
||||||
|
double right = first().right();
|
||||||
|
double top = first().top();
|
||||||
|
double bottom = first().bottom();
|
||||||
|
foreach( WindowQuad quad, *this )
|
||||||
|
{
|
||||||
|
#ifndef NDEBUG
|
||||||
|
if( quad.isTransformed())
|
||||||
|
kFatal( 1212 ) << "Splitting quads is allowed only in pre-paint calls!" ;
|
||||||
|
#endif
|
||||||
|
left = qMin( left, quad.left());
|
||||||
|
right = qMax( right, quad.right());
|
||||||
|
top = qMin( top, quad.top());
|
||||||
|
bottom = qMax( bottom, quad.bottom());
|
||||||
|
}
|
||||||
|
|
||||||
|
double xincrement = (right - left) / xSubdivisions;
|
||||||
|
double yincrement = (bottom - top) / ySubdivisions;
|
||||||
|
WindowQuadList ret;
|
||||||
|
for( double y = top;
|
||||||
|
y < bottom;
|
||||||
|
y += yincrement )
|
||||||
|
{
|
||||||
|
for( double x = left;
|
||||||
|
x < right;
|
||||||
|
x += xincrement)
|
||||||
|
{
|
||||||
|
foreach( WindowQuad quad, *this )
|
||||||
|
{
|
||||||
|
if( QRectF( QPointF( quad.left(), quad.top()), QPointF( quad.right(), quad.bottom()))
|
||||||
|
.intersects( QRectF( x, y, xincrement, yincrement )))
|
||||||
|
{
|
||||||
|
ret.append( quad.makeSubQuad( qMax( x, quad.left()), qMax( y, quad.top()),
|
||||||
|
qMin( quad.right(), x + xincrement ), qMin( quad.bottom(), y + yincrement )));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
void WindowQuadList::makeArrays( float** vertices, float** texcoords ) const
|
void WindowQuadList::makeArrays( float** vertices, float** texcoords ) const
|
||||||
{
|
{
|
||||||
*vertices = new float[ count() * 4 * 2 ];
|
*vertices = new float[ count() * 4 * 2 ];
|
||||||
|
|
|
@ -759,6 +759,7 @@ class KWIN_EXPORT WindowQuadList
|
||||||
WindowQuadList splitAtX( double x ) const;
|
WindowQuadList splitAtX( double x ) const;
|
||||||
WindowQuadList splitAtY( double y ) const;
|
WindowQuadList splitAtY( double y ) const;
|
||||||
WindowQuadList makeGrid( int maxquadsize ) const;
|
WindowQuadList makeGrid( int maxquadsize ) const;
|
||||||
|
WindowQuadList makeRegularGrid( int xSubdivisions, int ySubdivisions ) const;
|
||||||
WindowQuadList select( WindowQuadType type ) const;
|
WindowQuadList select( WindowQuadType type ) const;
|
||||||
WindowQuadList filterOut( WindowQuadType type ) const;
|
WindowQuadList filterOut( WindowQuadType type ) const;
|
||||||
bool smoothNeeded() const;
|
bool smoothNeeded() const;
|
||||||
|
|
Loading…
Reference in New Issue