X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fcontainer.cpp;h=25079d972e9cb0fb3f6ba925a40a3282baa69af6;hb=d549bfdc8c872b966b9d787c00e5e8027366093c;hp=bd37b7738610a1e4c54586699b2932cf57cec417;hpb=ef811c836c00cc94ce1eaea5c2e77e5278298b18;p=architektonas diff --git a/src/container.cpp b/src/container.cpp index bd37b77..25079d9 100644 --- a/src/container.cpp +++ b/src/container.cpp @@ -169,6 +169,18 @@ printf("Container::Collided: Deleting object ($%X)\n", *i); return collision; } +/* +What we need to do is check for whether or not we're a top level container, +and override the passing of stuff into the objects held. So here, if we're *NOT* +a top level container, instead of passing PointerMoved to our contained objects, +we check to see if our bounds are met (for selection rectangle, e.g.). + +Also, for things like being able to split point's hot spots we need to be able +to check for that crap in the top level container. Which means that objects can +still know how to move themselves, but they can also defer to their container +as well. Which also means that things like HitTest() need to be in the Object +class so that we can leverage that stuff here as well. +*/ // The TLC is passing all mouse movement here, so we're doing the same here. // Need to adjust all other objects to handle things correctly. @@ -179,6 +191,26 @@ printf("Container::Collided: Deleting object ($%X)\n", *i); // every object for collision. /*virtual*/ void Container::PointerMoved(Vector point) { + if (!isTopLevelContainer) + { + // check for selection rectangle too + + + needUpdate = true; + + for(std::vector::iterator i=objects.begin(); i!=objects.end(); i++) + { + if ((*i)->HitTest(point)) + { + state = OSSelected; + return; + } + } + + state = OSInactive; + return; + } + // objectWasDragged = true; //printf("CONTAINER: PointerMoved()\n"); @@ -218,6 +250,13 @@ about keeping track of old states... /*virtual*/ bool Container::NeedsUpdate(void) { + // If this is *not* a top level container, then we treat it as an + // aggregate object. + if (!isTopLevelContainer) + { + return needUpdate; + } + // Search through objects for one that needs an update; if one is found, // return immediately. for(std::vector::iterator i=objects.begin(); i!=objects.end(); i++) @@ -237,6 +276,17 @@ printf("Container: Added object (=$%X). size = %li\n", object, objects.size()); } +/*virtual*/ QRectF Container::Extents(void) +{ + QRectF bounds; + + for(std::vector::iterator i=objects.begin(); i!=objects.end(); i++) + bounds = bounds.united((*i)->Extents()); + + return bounds; +} + + void Container::Delete(Object * objectToDelete) { std::vector::iterator i = objects.begin(); @@ -337,8 +387,12 @@ void Container::MoveContentsTo(Container * newContainer) return; // Shuffle the contents of this container to the new one - for(unsigned int i=0; iAdd(objects[i]); +// for(unsigned int i=0; i::iterator i=objects.begin(); i!=objects.end(); i++) + { + newContainer->Add(*i); + (*i)->Reparent(newContainer); + } // & clear our vector objects.clear(); @@ -361,6 +415,7 @@ void Container::MoveSelectedContentsTo(Container * newContainer) } newContainer->Add(*i); + (*i)->Reparent(newContainer); objects.erase(i); } }