pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] CVS: Games/Pingus/src/editor selection.cxx,1.15,1.16 select


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src/editor selection.cxx,1.15,1.16 selection.hxx,1.12,1.13
Date: 9 Oct 2002 14:49:48 -0000

Update of /usr/local/cvsroot/Games/Pingus/src/editor
In directory dark:/tmp/cvs-serv6637

Modified Files:
        selection.cxx selection.hxx 
Log Message:
fixed 691 Shift + Rectangle selection causes objects to end up two times in the 
selection

Index: selection.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/selection.cxx,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- selection.cxx       28 Sep 2002 11:52:23 -0000      1.15
+++ selection.cxx       9 Oct 2002 14:49:45 -0000       1.16
@@ -59,13 +59,26 @@
 void
 Selection::add(EditorObj* obj)
 {
-  obj_list.push_back(obj);
+  if (!has_object(obj))
+    obj_list.push_back(obj);
 }
 
 void
 Selection::add(vector<EditorObj*> objs)
 {
-  obj_list.insert(obj_list.end(), objs.begin(), objs.end());
+  for (vector<EditorObj*>::iterator it = objs.begin(); it != objs.end(); ++it)
+    add(*it);
+}
+
+bool
+Selection::has_object(EditorObj* obj)
+{
+  for (vector<EditorObj*>::iterator it = obj_list.begin(); it != 
obj_list.end(); ++it)
+    {
+      if (*it == obj)
+        return true;
+    }
+  return false;
 }
 
 void
@@ -104,8 +117,7 @@
   y1 = static_cast<int> (Math::min(y1_, y2_));
   y2 = static_cast<int> (Math::max(y1_, y2_));
 
-  vector<EditorObj*> erg = object_manager->rect_get_objs(x1, y1, x2, y2);
-  obj_list.insert(obj_list.end(), erg.begin(), erg.end());
+  add(object_manager->rect_get_objs(x1, y1, x2, y2));
 }
 
 bool

Index: selection.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/selection.hxx,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- selection.hxx       28 Sep 2002 11:52:23 -0000      1.12
+++ selection.hxx       9 Oct 2002 14:49:46 -0000       1.13
@@ -46,6 +46,9 @@
   void move(const Vector& pos);
   void drag();
   void drop();
+
+  /** @return true if the obj is already in the selection, false otherwise */
+  bool has_object(EditorObj* obj);
     
   /** Add the given object to the selection */
   void add(EditorObj* obj);





reply via email to

[Prev in Thread] Current Thread [Next in Thread]