]> Shamusworld >> Repos - architektonas/blobdiff - src/container.cpp
First stabs at sizing dimension lines properly.
[architektonas] / src / container.cpp
index 4fceefdac106829e6d0a939f5e89fc27b66f437e..e125672eac63c6690d4d1cbc4da044e08a9e6ee7 100644 (file)
@@ -4,11 +4,13 @@
 // (C) 2011 Underground Software
 // See the README and GPLv3 files for licensing and warranty information
 //
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
 //
 // WHO  WHEN        WHAT
 // ---  ----------  ------------------------------------------------------------
 // JLH  03/30/2011  Created this file
+// JLH  06/02/2011  Added code to delete objects in this container when they go
+//                  out of scope
 //
 
 #include "container.h"
@@ -23,9 +25,15 @@ Container::Container(Vector p1, Object * p/*= NULL*/): Object(p1, p),
 
 Container::~Container()
 {
+       // No memory leaks!
+       while (objects.size() > 0)
+       {
+               delete objects[0];
+               objects.erase(objects.begin());
+       }
 }
 
-/*virtual*/ void Container::Draw(QPainter * painter)
+/*virtual*/ void Container::Draw(Painter * painter)
 {
        for(int i=0; i<(int)objects.size(); i++)
                objects[i]->Draw(painter);
@@ -130,47 +138,23 @@ Like so:
        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;
+//     objectWasDragged = true;
+//printf("CONTAINER: PointerMoved()\n");
 
-//             position += delta;
-//             endpoint += delta;
-               radius = Vector(point - position).Magnitude();
-
-               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;
 }
@@ -208,7 +192,7 @@ about keeping track of old states...
        return needUpdate;
 }
 
-void Container::Add(Object * object)
+/*virtual*/ void Container::Add(Object * object)
 {
        objects.push_back(object);
 }