X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fcontainer.cpp;h=8a9c07bcc297a64193d7b8c98ee0b27e2de874c3;hb=746443089f76c115245d1500b780d7d189b9b2af;hp=727c14360450cc498cf809b119bb08f3967021fb;hpb=9f6ad3fe0b9cb30115a5d38e8af3aebed0d70c08;p=architektonas diff --git a/src/container.cpp b/src/container.cpp index 727c143..8a9c07b 100644 --- a/src/container.cpp +++ b/src/container.cpp @@ -101,60 +101,52 @@ Like so: #else bool collision = false; - for(int i=0; i<(int)objects.size(); i++) + // NOTE that this deletes the object on mouse down instead of mouse up. Have to + // check to see how it feels to do it that way... + if (deleteActive) { - if (objects[i]->Collided(point)) - collision = true; + for(int i=0; i<(int)objects.size(); i++) + { + if (objects[i]->Collided(point)) + { + objects.erase(objects.begin() + i); // Calls the destructor, (deletes the object, I presume... O_o) + break; + } + } + } + else + { + for(int i=0; i<(int)objects.size(); i++) + { + if (objects[i]->Collided(point)) + collision = true; + } } #endif - // Do we decouple the state of the generic container from the objects inside??? + // Do we decouple the state of the generic container from the objects inside??? Mebbe. state = OSInactive; // return false; return collision; } +// 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. +// One optimization that will need to be done eventually is to subdivide the screen +// into parts and keep subdividing until an acceptable number of objects lie within +// the slice. This way, the GUI will still be responsive and *not* have to test +// every object for collision. /*virtual*/ void Container::PointerMoved(Vector point) { - objectWasDragged = true; -#if 0 - if (dragging) - { - // Here we need to check whether or not we're dragging a handle or the object itself... -// Vector delta = point - oldPoint; - -// position += delta; -// endpoint += delta; - radius = Vector(point - position).Magnitude(); +// objectWasDragged = true; +//printf("CONTAINER: PointerMoved()\n"); - oldPoint = point; - needUpdate = true; - } - else if (draggingHandle1) - { - Vector delta = point - oldPoint; - position += delta; - oldPoint = point; - needUpdate = true; - } -/* else if (draggingHandle2) - { - Vector delta = point - oldPoint; - - endpoint += delta; - - oldPoint = point; - needUpdate = true; - }*/ - else - needUpdate = false; -#else for(int i=0; i<(int)objects.size(); i++) { - if (objects[i]->GetState() == OSSelected) +// if (objects[i]->GetState() == OSSelected) objects[i]->PointerMoved(point); } -#endif + // Generic container doesn't need this??? // needUpdate = false; } @@ -192,7 +184,7 @@ about keeping track of old states... return needUpdate; } -void Container::Add(Object * object) +/*virtual*/ void Container::Add(Object * object) { objects.push_back(object); }