gcompris r3465 - in branches/gcomprixogoo: boards/skins/babytoy/draw boards/skins/gartoon/draw src/anim-activity



Author: bcoudoin
Date: Sat Jul  5 00:05:56 2008
New Revision: 3465
URL: http://svn.gnome.org/viewvc/gcompris?rev=3465&view=rev

Log:
improvement in the animation activity.
now the rect and fill rect are implemented
the resizing works better, stick to anchors while resizing.


Removed:
   branches/gcomprixogoo/boards/skins/babytoy/draw/tool-camera.png
   branches/gcomprixogoo/boards/skins/babytoy/draw/tool-camera_on.png
   branches/gcomprixogoo/boards/skins/gartoon/draw/tool-camera.png
   branches/gcomprixogoo/boards/skins/gartoon/draw/tool-camera_on.png
Modified:
   branches/gcomprixogoo/src/anim-activity/AnimItem.py
   branches/gcomprixogoo/src/anim-activity/Color.py
   branches/gcomprixogoo/src/anim-activity/Timeline.py
   branches/gcomprixogoo/src/anim-activity/anim.py

Modified: branches/gcomprixogoo/src/anim-activity/AnimItem.py
==============================================================================
--- branches/gcomprixogoo/src/anim-activity/AnimItem.py	(original)
+++ branches/gcomprixogoo/src/anim-activity/AnimItem.py	Sat Jul  5 00:05:56 2008
@@ -472,68 +472,81 @@
             self.refpoint = None
             self.fixed_x = 0
             self.fixed_y = 0
+            self.offset_x = 0
+            self.offset_y = 0
             self.animitem.save_at_time(self.animitem.anim.timeline.get_time())
 
         elif (event.type == gtk.gdk.MOTION_NOTIFY
             and event.state & gtk.gdk.BUTTON1_MASK):
 
+            (x, y) = self.animitem.anim.gcomprisBoard.canvas.\
+                convert_from_item_space(item, event.x, event.y)
+            (x, y) = self.animitem.anim.gcomprisBoard.canvas.\
+                convert_to_item_space(self.animitem.item, x, y)
+
             if not self.refpoint:
+                mypoint = [] # Will reference the selected anchors coord
                 if anchor == self.ANCHOR_N:
                     self.refpoint = self.animitem.get_x2y2()
                     self.fixed_x = self.animitem.get_x1y1()[0]
+                    mypoint = self.animitem.get_x1y1()
                 elif anchor == self.ANCHOR_NE:
                     self.refpoint = self.animitem.get_x1y2()
+                    mypoint = self.animitem.get_x2y1()
                 elif anchor == self.ANCHOR_E:
                     self.refpoint = self.animitem.get_x1y1()
                     self.fixed_y = self.animitem.get_x2y2()[1]
+                    mypoint = self.animitem.get_x2y2()
                 elif anchor == self.ANCHOR_SE:
                     self.refpoint = self.animitem.get_x1y1()
+                    mypoint = self.animitem.get_x2y2()
                 elif anchor == self.ANCHOR_S:
                     self.refpoint = self.animitem.get_x1y1()
                     self.fixed_x = self.animitem.get_x2y2()[0]
+                    mypoint = self.animitem.get_x2y2()
                 elif anchor == self.ANCHOR_SW:
                     self.refpoint = self.animitem.get_x2y1()
+                    mypoint = self.animitem.get_x1y2()
                 elif anchor == self.ANCHOR_W:
                     self.refpoint = self.animitem.get_x2y2()
                     self.fixed_y = self.animitem.get_x1y1()[1]
+                    mypoint = self.animitem.get_x1y1()
                 elif anchor == self.ANCHOR_NW:
                     self.refpoint = self.animitem.get_x2y2()
+                    mypoint = self.animitem.get_x1y1()
 
-            (x, y) = self.animitem.anim.gcomprisBoard.canvas.\
-                convert_from_item_space(item, event.x, event.y)
-            (x, y) = self.animitem.anim.gcomprisBoard.canvas.\
-                convert_to_item_space(self.animitem.item, x, y)
+                self.offset_x = mypoint[0] - x
+                self.offset_y = mypoint[1] - y
 
             if self.fixed_x:
                 self.animitem.set_bounds(
                     self.refpoint,
                     (self.fixed_x,
-                     y) )
+                     y + self.offset_y) )
             elif self.fixed_y:
                 self.animitem.set_bounds(
                     self.refpoint,
-                    (x,
+                    (x + self.offset_x,
                      self.fixed_y) )
             else:
                 self.animitem.set_bounds(
                     self.refpoint,
-                    (x,
-                     y) )
+                    (x + self.offset_x,
+                     y + self.offset_y) )
 
             self.update()
 
 #
 # The Filled rectangle
 #
-class AnimItemFillRect(AnimItem):
+class AnimItemRect(AnimItem):
 
     x = 0
     y = 0
     width = 0
     height = 0
-    line_width = 1
 
-    def __init__(self, anim, x, y):
+    def __init__(self, anim, x, y, color_fill, color_stroke, line_width):
         AnimItem.__init__(self, anim)
         x,y = self.snap_to_grid(x, y)
         self.x = x
@@ -546,9 +559,11 @@
                 y = self.y,
                 width = self.width,
                 height = self.height,
-                fill_color_rgba = self.anim.color.fill,
-                stroke_color_rgba = self.anim.color.stroke,
-                line_width = self.line_width)
+                stroke_color_rgba = color_stroke,
+                line_width = line_width)
+
+        if color_fill:
+            self.item.set_properties(fill_color_rgba = color_fill)
 
         self.item.set_data("AnimItem", self)
         self.item.connect("button_press_event", anim.item_event)

Modified: branches/gcomprixogoo/src/anim-activity/Color.py
==============================================================================
--- branches/gcomprixogoo/src/anim-activity/Color.py	(original)
+++ branches/gcomprixogoo/src/anim-activity/Color.py	Sat Jul  5 00:05:56 2008
@@ -25,6 +25,8 @@
 import gtk
 import gtk.gdk
 
+# This is the color selector of the animation activity.
+
 class Color:
 
     # We keep the current color here

Modified: branches/gcomprixogoo/src/anim-activity/Timeline.py
==============================================================================
--- branches/gcomprixogoo/src/anim-activity/Timeline.py	(original)
+++ branches/gcomprixogoo/src/anim-activity/Timeline.py	Sat Jul  5 00:05:56 2008
@@ -25,6 +25,8 @@
 import gtk
 import gtk.gdk
 
+# This is the timeline of the animation activity.
+
 class Timeline:
 
     def __init__(self, anim):
@@ -56,10 +58,13 @@
         y  = self.drawing_area[3] + 5
 
         # Our timeline repesentation respects the drawing area ratio
-        self.zoom = (( self.drawing_area[2] - self.drawing_area[0] ) /
-                     ( self.drawing_area[3] - self.drawing_area[1] ))
+        # If we could display a thumbnail of the current frame in each
+        # time zone, and we could scroll the time zone.
+        #self.zoom = (( self.drawing_area[2] - self.drawing_area[0] ) /
+        #             ( self.drawing_area[3] - self.drawing_area[1] ))
+        # w = h * self.zoom
+        w = 14
         h = 27
-        w = h * self.zoom
 
 
         i = x1

Modified: branches/gcomprixogoo/src/anim-activity/anim.py
==============================================================================
--- branches/gcomprixogoo/src/anim-activity/anim.py	(original)
+++ branches/gcomprixogoo/src/anim-activity/anim.py	Sat Jul  5 00:05:56 2008
@@ -661,7 +661,11 @@
         gcompris.sound.play_ogg("sounds/bleep.wav")
 
         animItem = item.get_data("AnimItem")
-        if animItem:
+        if not animItem:
+          if self.selected:
+              self.selected.deselect()
+              self.selected = None
+        else:
           if self.tools[self.current_tool][0] == "FILL":
             animItem.fill(self.color.fill,
                           self.color.stroke)
@@ -689,8 +693,16 @@
             animItem.flip()
 
         if self.tools[self.current_tool][0] == "FILL_RECT":
-          self.created_object = AnimItemFillRect(self,
-                                                 event.x, event.y)
+          self.created_object = AnimItemRect(self,
+                                             event.x, event.y,
+                                             self.color.fill, self.color.stroke, 2)
+          self.created_object.create_item_event(item,
+                                                target,
+                                                event)
+        elif self.tools[self.current_tool][0] == "RECT":
+          self.created_object = AnimItemRect(self,
+                                             event.x, event.y,
+                                             None, self.color.stroke, 5)
           self.created_object.create_item_event(item,
                                                 target,
                                                 event)
@@ -710,7 +722,8 @@
 
     elif (event.type == gtk.gdk.MOTION_NOTIFY
           and event.state & gtk.gdk.BUTTON1_MASK
-          and self.tools[self.current_tool][0] == "SELECT"):
+          and self.tools[self.current_tool][0] == "SELECT"
+          and self.selected):
         self.selected.move_item_event(item,
                                       target,
                                       event)



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