Rectangles list is STL now.
This commit is contained in:
@ -99,8 +99,9 @@ void FltkViewBase::draw ()
|
||||
if ((d & FL_DAMAGE_USER1) && !(d & FL_DAMAGE_EXPOSE)) {
|
||||
lout::container::typed::Iterator <core::Rectangle> it;
|
||||
|
||||
for (it = drawRegion.rectangles (); it.hasNext (); ) {
|
||||
draw (it.getNext (), DRAW_BUFFERED);
|
||||
for( auto &rectangle: drawRegion )
|
||||
{
|
||||
draw( rectangle.get(), DRAW_BUFFERED );
|
||||
}
|
||||
|
||||
drawRegion.clear ();
|
||||
|
26
dw/types.cc
26
dw/types.cc
@ -220,16 +220,6 @@ bool Polygon::isPointWithin (int x, int y)
|
||||
}
|
||||
}
|
||||
|
||||
Region::Region()
|
||||
{
|
||||
rectangleList = new container::typed::List <Rectangle> (true);
|
||||
}
|
||||
|
||||
Region::~Region()
|
||||
{
|
||||
delete rectangleList;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Add a rectangle to the region and combine it with
|
||||
* existing rectangles if possible.
|
||||
@ -238,13 +228,11 @@ Region::~Region()
|
||||
*/
|
||||
void Region::addRectangle (Rectangle *rPointer)
|
||||
{
|
||||
container::typed::Iterator <Rectangle> it;
|
||||
Rectangle *r = new Rectangle (rPointer->x, rPointer->y,
|
||||
rPointer->width, rPointer->height);
|
||||
|
||||
for (it = rectangleList->iterator (); it.hasNext (); ) {
|
||||
Rectangle *ownRect = it.getNext ();
|
||||
auto r= std::make_unique< Rectangle >( rPointer->x, rPointer->y,
|
||||
rPointer->width, rPointer->height );
|
||||
|
||||
for( auto &ownRect: rectangleList )
|
||||
{
|
||||
int combinedHeight =
|
||||
misc::max(r->y + r->height, ownRect->y + ownRect->height) -
|
||||
misc::min(r->y, ownRect->y);
|
||||
@ -252,7 +240,7 @@ void Region::addRectangle (Rectangle *rPointer)
|
||||
misc::max(r->x + r->width, ownRect->x + ownRect->width) -
|
||||
misc::min(r->x, ownRect->x);
|
||||
|
||||
if (rectangleList->size() >= 16 ||
|
||||
if (rectangleList.size() >= 16 ||
|
||||
combinedWidth * combinedHeight <=
|
||||
ownRect->width * ownRect->height + r->width * r->height) {
|
||||
|
||||
@ -261,11 +249,11 @@ void Region::addRectangle (Rectangle *rPointer)
|
||||
r->width = combinedWidth;
|
||||
r->height = combinedHeight;
|
||||
|
||||
rectangleList->removeRef (ownRect);
|
||||
rectangleList.remove( ownRect );
|
||||
}
|
||||
}
|
||||
|
||||
rectangleList->append (r);
|
||||
rectangleList.push_back( std::move( r ) );
|
||||
}
|
||||
|
||||
Content::Type Content::maskForSelection (bool followReferences)
|
||||
|
21
dw/types.hh
21
dw/types.hh
@ -5,6 +5,9 @@
|
||||
# error Do not include this file directly, use "core.hh" instead.
|
||||
#endif
|
||||
|
||||
#include <memory>
|
||||
#include <list>
|
||||
|
||||
namespace dw {
|
||||
namespace core {
|
||||
|
||||
@ -140,20 +143,22 @@ public:
|
||||
class Region
|
||||
{
|
||||
private:
|
||||
lout::container::typed::List <Rectangle> *rectangleList;
|
||||
std::list< std::unique_ptr< Rectangle > > rectangleList;
|
||||
|
||||
public:
|
||||
Region ();
|
||||
~Region ();
|
||||
|
||||
void clear () { rectangleList->clear (); };
|
||||
void clear () { rectangleList.clear(); }
|
||||
|
||||
void addRectangle (Rectangle *r);
|
||||
|
||||
lout::container::typed::Iterator <Rectangle> rectangles ()
|
||||
auto begin()
|
||||
{
|
||||
return rectangleList->iterator ();
|
||||
};
|
||||
return rectangleList.begin();
|
||||
}
|
||||
|
||||
auto end()
|
||||
{
|
||||
return rectangleList.end();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user