Back to index

gcompris  8.2.2
Classes | Public Member Functions | Public Attributes
anim.Gcompris_anim Class Reference

List of all members.

Classes

class  AnimItem
 Anim 2 specific. More...

Public Member Functions

def __init__
def start
def end
def pause
def repeat
def config
def key_press
def draw_tools
def tool_item_event
def draw_colors
def color_item_event
def draw_drawing_area
def draw_playing_area
def stop_event
def playing_stop
def speed_event
def draw_grid
def snap_to_grid
def move_item_event
def fillin_item_event
def fillout_item_event
def del_item
def del_item_event
def create_item_event
def snapshot_event
def run_flash
def playing_start
def playing_event
def draw_animtools
def object_move
def object_set_size_and_pos
def resize_item_event
def get_bounds
def item_type
def recursive_anchorize
def anchorize
def select_item
def rotate_relative
def item_flip
def new_z
def del_AnimItem
def z_raise
def z_lower
def get_animitem_properties
def z_reinit
def z_delete_on_shot
def get_modified_parameters
def Anim2Shot
def z_find_index
def apply_frame
def run_anim2
def Anim2Run
def unselect

Public Attributes

 gcomprisBoard
 itemlist
 format_string
 DEFAULT_ANCHOR_SIZE
 grid_step
 selector_section
 running
 draw_defaults_size
 empty
 file_type
 board_paused
 gamewon
 MAX_TEXT_CHAR
 ANCHOR_COLOR
 ANCHOR_NW
 ANCHOR_N
 ANCHOR_NE
 ANCHOR_E
 ANCHOR_W
 ANCHOR_SW
 ANCHOR_S
 ANCHOR_SE
 ANCHOR_T
 anchors
 types
 attributs
 fixedattributs
 events
 tools
 current_tool
 colors
 current_color
 current_step
 selected
 drawing_area
 playing_area
 in_select_ofx
 in_select_ofy
 item_frame_counter
 root_coloritem
 root_toolitem
 framelist
 animlist
 current_frame
 frames_total
 list_z_last_shot
 list_z_actual
 draw_created_object
 last_commit
 rootitem
 select_tool
 select_tool_number
 old_tool_item
 pos_x
 pos_y
 old_color_item
 root_drawingitem
 root_anim
 flash
 root_playingitem
 anim_speed
 speed_item
 timeout
 grid
 newitem
 newitemgroup
 playing
 playlist

Detailed Description

The cartoon activity

Definition at line 68 of file anim.py.


Constructor & Destructor Documentation

def anim.Gcompris_anim.__init__ (   self,
  gcomprisBoard 
)

Definition at line 71 of file anim.py.

00071 
00072   def __init__(self, gcomprisBoard):
00073 
00074     self.gcomprisBoard = gcomprisBoard
00075 
00076     # There is two board in the same code
00077     # here the diff in parameters
00078 
00079     # The main list of items
00080     # this parameter is used in svg save, to know where to get the list
00081     self.itemlist = { 'draw' : 'framelist',
00082                     'anim': 'animlist'
00083                       }
00084 
00085     if self.gcomprisBoard.mode == 'draw':
00086       self.format_string = { 'gcompris' : 'GCompris draw 2 cPikle file',
00087                              'svg' : 'GCompris draw 2 svg file'
00088                              }
00089     else:
00090       self.format_string = { 'gcompris' : 'GCompris anim 2 cPikle file',
00091                              'svg' : 'GCompris anim 2 svg file'
00092                              }
00093 
00094     if self.gcomprisBoard.mode == 'draw':
00095       # DRAW
00096       #
00097       # draw is adapted to little kids : big anchors
00098       self.DEFAULT_ANCHOR_SIZE     = 12
00099 
00100       # Step used in grid is wider
00101       self.grid_step = 10
00102 
00103       # draw specific UI
00104       self.selector_section = "draw2"
00105     else:
00106       # Anim
00107       #
00108       # Normal anchors
00109       self.DEFAULT_ANCHOR_SIZE     = 8
00110 
00111       # Step used in grid is wider
00112       self.grid_step = 5
00113 
00114       # anim specific UI
00115       self.selector_section = "anim2"
00116 
00117     # Initialisation. Should not change in draw.
00118     self.running = False
00119 
00120 
00121     # In draw objects are created without drag&drop
00122     # Default size for rect, circle, line
00123     self.draw_defaults_size = { 'RECT' : {'width' : 60 , 'height' : 40 },
00124                             'FILL_RECT' : {'width' : 60 , 'height' : 40 },
00125                             'CIRCLE' : {'width' : 60 , 'height' : 40 },
00126                                 'FILL_CIRCLE' : {'width' : 60 , 'height' : 40 },
00127                                 'LINE' : {'width' : 60 , 'height' : 40 }
00128                               }
00129 
00130     # Cool !!!
00131     self.empty="empty"
00132 
00133     # global parameter to access object structures from global fonctions
00134     global fles
00135     fles=self
00136 
00137     # File formats to save/restore
00138     #
00139     # svg has proprietary data to handle animation, base64 included images
00140     # gcompris is cPickle python saved data
00141     #
00142     # svg in draw mode is normal svg file with base64 included images
00143     global python_xml
00144     if self.gcomprisBoard.mode == 'draw':
00145       self.file_type = "image/gcompris+draw"
00146       if python_xml:
00147         self.file_type = self.file_type + " image/svg+xml"
00148     else:
00149       self.file_type = "image/gcompris+anim"
00150       #      if python_xml:
00151       #        self.file_type = self.file_type +"  image/svg+xml+javascript"
00152 
00153     # These are used to let us restart only after the bonux is displayed.
00154     # When the bonus is displayed, it call us first with pause(1) and then with pause(0)
00155     self.board_paused  = 0
00156     self.gamewon       = 0
00157 
00158     self.MAX_TEXT_CHAR = 50
00159 
00160     # kind of beautiful blue
00161     self.ANCHOR_COLOR = 0x36ede480
00162 
00163 
00164     # anchortype
00165     self.ANCHOR_NW = 1
00166     self.ANCHOR_N  = 2
00167     self.ANCHOR_NE = 3
00168     self.ANCHOR_E  = 4
00169     self.ANCHOR_W  = 5
00170     self.ANCHOR_SW = 6
00171     self.ANCHOR_S  = 7
00172     self.ANCHOR_SE = 8
00173     self.ANCHOR_T  = 9
00174 
00175     self.anchors = { 'LINE': [ self.ANCHOR_SW , self.ANCHOR_NE ],
00176                      'RECT': [ self.ANCHOR_N,
00177                                self.ANCHOR_NE,
00178                                self.ANCHOR_E,
00179                                self.ANCHOR_SE,
00180                                self.ANCHOR_S,
00181                                self.ANCHOR_SW,
00182                                self.ANCHOR_W,
00183                                self.ANCHOR_NW
00184                                ],
00185                      'TEXT': [ self.ANCHOR_T ]
00186                      }
00187     self.anchors ['FILL_RECT'] =  self.anchors ['RECT']
00188     self.anchors ['CIRCLE'] =  self.anchors ['RECT']
00189     self.anchors ['FILL_CIRCLE'] =  self.anchors ['RECT']
00190     self.anchors ['IMAGE'] =  self.anchors ['RECT']
00191 
00192     # gnomecanvas type corresponding
00193     self.types = { 'RECT' : gnomecanvas.CanvasRect,
00194                    'FILL_RECT' : gnomecanvas.CanvasRect,
00195                    'CIRCLE' : gnomecanvas.CanvasEllipse,
00196                    'FILL_CIRCLE' : gnomecanvas.CanvasEllipse,
00197                    'TEXT' : gnomecanvas.CanvasText,
00198                    'IMAGE' : gnomecanvas.CanvasPixbuf,
00199                    'LINE' : gnomecanvas.CanvasLine
00200                    }
00201 
00202     # mutable gnomecanvas attributs
00203     self.attributs = { 'LINE' : [ "points",
00204                                   "fill_color_rgba",
00205                                   ],
00206                        'RECT' : [ "x1",
00207                                   "y1",
00208                                   "x2",
00209                                   "y2",
00210                                   "outline_color_rgba",
00211                                   ],
00212                        'FILL_RECT' : [ "x1",
00213                                        "y1",
00214                                        "x2",
00215                                        "y2",
00216                                        "fill_color_rgba",
00217                                        ],
00218                        'CIRCLE' : [ "x1",
00219                                     "y1",
00220                                     "x2",
00221                                     "y2",
00222                                     "outline_color_rgba",
00223                                     ],
00224                        'FILL_CIRCLE' : [ "x1",
00225                                          "y1",
00226                                          "x2",
00227                                          "y2",
00228                                          "fill_color_rgba",
00229                                          ],
00230                        'TEXT' : [ "x",
00231                                   "y",
00232                                   "text",
00233                                   "fill_color_rgba",
00234                                   ],
00235                        'IMAGE' : [ "x",
00236                                    "y",
00237                                    "width",
00238                                    "height",
00239                                    ]
00240                        }
00241 
00242     # non mutable gnomecanvas attributs
00243     self.fixedattributs = { 'LINE' : { 'width-units': 8.0
00244                                        },
00245                             'RECT' : { 'width-units': 4.0
00246                                        },
00247                             'FILL_RECT' : { 'width-units': 1.0,
00248                                             'outline_color_rgba': 0x000000FFL
00249                                             },
00250                             'CIRCLE' : { 'width-units': 4.0 },
00251                             'FILL_CIRCLE' : { 'width-units': 1.0,
00252                                               'outline_color_rgba': 0x000000FFL
00253                                               },
00254                             'TEXT' : { 'font': gcompris.FONT_BOARD_BIG_BOLD,
00255                                        'anchor' : gtk.ANCHOR_CENTER
00256                                        },
00257                             'IMAGE' : { 'width_set': True,
00258                                         'height_set': True
00259                                         }
00260                        }
00261 
00262 
00263     # events handled by each type
00264     self.events = { 'LINE' : [ self.fillin_item_event,
00265                                self.move_item_event,
00266                                self.create_item_event,
00267                                self.del_item_event ] ,
00268                     'RECT' : [ self.fillout_item_event,
00269                                self.move_item_event,
00270                                self.create_item_event,
00271                                self.del_item_event ],
00272                     'TEXT' : [ self.fillin_item_event,
00273                                self.move_item_event,
00274                                self.create_item_event,
00275                                self.del_item_event ],
00276                     'IMAGE' : [ self.move_item_event,
00277                                 self.create_item_event,
00278                                 self.del_item_event ]
00279                     }
00280 
00281     self.events ['FILL_RECT']         = self.events ['LINE']
00282     self.events ['FILL_CIRCLE']       = self.events ['LINE']
00283     self.events ['CIRCLE']  = self.events ['RECT']
00284 
00285 
00286     # Part of UI : tools buttons
00287     # TOOL SELECTION
00288     self.tools = [
00289       ["SAVE",           "draw/tool-save.png",            "draw/tool-save.png",                  gcompris.CURSOR_SELECT],
00290       ["LOAD",           "draw/tool-load.png",            "draw/tool-load.png",                  gcompris.CURSOR_SELECT],
00291       ["MOVIE",          "draw/tool-movie.png",           "draw/tool-movie_on.png",              gcompris.CURSOR_SELECT],
00292       ["PICTURE",        "draw/tool-camera.png",          "draw/tool-camera_on.png",             gcompris.CURSOR_SELECT],
00293       ["RECT",           "draw/tool-rectangle.png",       "draw/tool-rectangle_on.png",          gcompris.CURSOR_RECT],
00294       ["FILL_RECT",      "draw/tool-filledrectangle.png", "draw/tool-filledrectangle_on.png",    gcompris.CURSOR_FILLRECT],
00295       ["CIRCLE",         "draw/tool-circle.png",          "draw/tool-circle_on.png",             gcompris.CURSOR_CIRCLE],
00296       ["FILL_CIRCLE",    "draw/tool-filledcircle.png",    "draw/tool-filledcircle_on.png",       gcompris.CURSOR_FILLCIRCLE],
00297       ["LINE",           "draw/tool-line.png",            "draw/tool-line_on.png",               gcompris.CURSOR_LINE],
00298       ["FILL",           "draw/tool-fill.png",            "draw/tool-fill_on.png",               gcompris.CURSOR_FILL],
00299       ["DEL",            "draw/tool-del.png",             "draw/tool-del_on.png",                gcompris.CURSOR_DEL],
00300       ["SELECT",         "draw/tool-select.png",          "draw/tool-select_on.png",             gcompris.CURSOR_SELECT],
00301       ["RAISE",          "draw/tool-up.png",              "draw/tool-up_on.png",                 gcompris.CURSOR_DEFAULT],
00302       ["LOWER",          "draw/tool-down.png",            "draw/tool-down_on.png",               gcompris.CURSOR_DEFAULT],
00303       ["CCW",            "draw/tool-rotation-ccw.png",    "draw/tool-rotation-ccw_on.png",       gcompris.CURSOR_DEFAULT],
00304       ["CW",             "draw/tool-rotation-cw.png",     "draw/tool-rotation-cw_on.png",        gcompris.CURSOR_DEFAULT],
00305       ["FLIP",           "draw/tool-flip.png",            "draw/tool-flip_on.png",               gcompris.CURSOR_DEFAULT],
00306       ["TEXT",           "draw/tool-text.png",            "draw/tool-text_on.png",               gcompris.CURSOR_LINE],
00307       ["IMAGE",          "draw/tool-image.png",           "draw/tool-image_on.png",              gcompris.CURSOR_DEFAULT],
00308       ]
00309 
00310     # keep the tool selected
00311     self.current_tool=0
00312 
00313     # Part of UI: colors buttons
00314     # COLOR SELECTION
00315     # RGBA unsigned long. A is always FF.
00316     # keep in mind if you change that to change the svg export: it does not pass A.
00317     self.colors = [   0x000000FFL, 0x202020FFL, 0x404040FFL, 0x505050FFL,
00318                       0x815a38FFL, 0xb57c51FFL, 0xe5a370FFL, 0xfcc69cFFL,
00319                       0xb20c0cFFL, 0xea2c2cFFL, 0xf26363FFL, 0xf7a3a3FFL,
00320                       0xff6600FFL, 0xff8a3dFFL, 0xfcaf7bFFL, 0xf4c8abFFL,
00321                       0x9b8904FFL, 0xd3bc10FFL, 0xf4dd2cFFL, 0xfcee85FFL,
00322                       0x255b0cFFL, 0x38930eFFL, 0x56d11dFFL, 0x8fe268FFL,
00323                       0x142f9bFFL, 0x2d52e5FFL, 0x667eddFFL, 0xa6b4eaFFL,
00324                       0x328989FFL, 0x37b2b2FFL, 0x3ae0e0FFL, 0x96e0e0FFL,
00325                       0x831891FFL, 0xc741d8FFL, 0xde81eaFFL, 0xeecdf2FFL,
00326                       0x666666FFL, 0x838384FFL, 0xc4c4c4FFL, 0xffffffFFL
00327                       ]
00328 
00329     # keep the current color here
00330     self.current_color = 0
00331 
00332     # step of the grid used for positioning objects
00333     # TODO : add a parameters to put step=5 in draw and step=1 in anim
00334     self.current_step = 0
00335 
00336     # selected object
00337     self.selected = None
00338 
00339     # Part of UI : drawing_area is the drawing zone
00340     # when anim is played, it's masked and playing_area is displayed
00341     #
00342     # Drawing area is editing image area
00343     # Palying area is playing map
00344     self.drawing_area = [124.0, 20.0, gcompris.BOARD_WIDTH - 15, gcompris.BOARD_HEIGHT - 78]
00345     self.playing_area = [124.0, 20.0, gcompris.BOARD_WIDTH - 15, gcompris.BOARD_HEIGHT - 78]
00346 
00347     # Global used for the select event
00348     #
00349     # used to keep the distance between pointer and corner in moving objects
00350     self.in_select_ofx = -1
00351     self.in_select_ofy = -1
00352 
00353     # The frame counter
00354     # TODO : check if used
00355     self.item_frame_counter = []
00356 
00357     # Not used for the moment in anim2
00358     # TODO : fix that
00359     #self.current_image = 0
00360 
00361     # Part of UI
00362     # The root items
00363     self.root_coloritem = []
00364     self.root_toolitem  = []
00365 
00366     # Anim2 variables
00367     # animlist is the full list of all items.
00368     # each item is keeped with it's frame information
00369     #    - frames where it's modified
00370     #    - all modifications for each frame
00371     #
00372     # list of items in current frame
00373     self.framelist = []
00374     # list of items in the full animation
00375     self.animlist = []
00376     # rank of the current frame being processed
00377     self.current_frame = 0
00378     self.frames_total =  self.current_frame
00379     # list of z values in last shot
00380     self.list_z_last_shot = []
00381     # list of actual z values
00382     self.list_z_actual = []
00383 
00384     # used to handle draw creation of object
00385     self.draw_created_object = False


Member Function Documentation

def anim.Gcompris_anim.anchorize (   self,
  group 
)

Definition at line 1826 of file anim.py.

01826 
01827   def anchorize(self, group):
01828     # group contains normal items.
01829 
01830     item = group.item_list[0]
01831 
01832     item_type = self.item_type(item)
01833 
01834     if item_type == "GROUP" or not item_type:
01835       return
01836 
01837     for event in self.events[item_type]:
01838       item.connect("event", event)
01839 
01840     anchorgroup=group.add(
01841       gnomecanvas.CanvasGroup,
01842       x=0,
01843       y=0
01844       )
01845     anchorgroup.set_data('anchors',True)
01846     anchorgroup.hide()
01847 
01848     for anchor_type in self.anchors[item_type]:
01849       anchor=anchorgroup.add(
01850         gnomecanvas.CanvasRect,
01851         fill_color_rgba=self.ANCHOR_COLOR,
01852         outline_color_rgba=0x000000FFL,
01853         width_pixels=1,
01854         )
01855       anchor.set_data('anchor_type', anchor_type)
01856       anchor.connect("event", self.resize_item_event,anchor_type)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2120 of file anim.py.

02120 
02121   def Anim2Run(self):
02122     gcompris.bar_hide(True)
02123     if self.frames_total==0:
02124       print "Mmm... Need to make shots before run anim !!"
02125       self.running=False
02126       return
02127     # Hide the current drawing
02128     self.root_anim.hide()
02129     self.playing = self.root_anim.add(
02130       gnomecanvas.CanvasGroup,
02131       x=0.0,
02132       y=0.0
02133       )
02134 
02135     self.playlist = []
02136     for aItem in self.animlist:
02137       playItem = self.AnimItem()
02138       playItem.frames_info = aItem.frames_info.copy()
02139       playItem.type = aItem.type
02140       self.playlist.append(playItem)
02141 
02142     # Show the first drawing
02143     self.apply_frame(0)
02144     self.current_frame = 0
02145 
02146     self.timeout=gobject.timeout_add(1000/self.anim_speed, self.run_anim2)
02147 

Here is the caller graph for this function:

Definition at line 2019 of file anim.py.

02019 
02020   def Anim2Shot(self):
02021     if self.gcomprisBoard.mode == 'draw':
02022       return
02023     self.flash.show()
02024     for anAnimItem in self.framelist[:]:
02025       if anAnimItem.z == None:
02026         # deleted
02027         self.z_delete_on_shot(anAnimItem)
02028         modified = { 'delete': True }
02029         self.framelist.remove(anAnimItem)
02030         if self.animlist.count(anAnimItem) == 0:
02031           # deleted without being in any shot
02032           continue
02033       else:
02034 #
02035         modified = self.get_modified_parameters(anAnimItem)
02036 
02037 
02038       if len(modified) != 0:
02039         anAnimItem.frames_info[self.current_frame] = modified
02040 #
02041     self.current_frame = self.current_frame + 1
02042     self.frames_total =  self.current_frame
02043     self.z_reinit()
02044     self.item_frame_counter.set(text=self.current_frame + 1)
02045     # print self.current_frame + 1
02046     gtk.timeout_add(500, self.run_flash)

Here is the call graph for this function:

Here is the caller graph for this function:

def anim.Gcompris_anim.apply_frame (   self,
  frame 
)

Definition at line 2056 of file anim.py.

02056 
02057   def apply_frame(self, frame):
02058     for item in self.playlist:
02059       if not item.frames_info.has_key(frame):
02060         continue
02061       modif = item.frames_info[frame].copy()
02062       if modif.has_key('delete'):
02063         item.canvas_item.destroy()
02064         continue
02065       if modif.has_key('create'):
02066         del modif['create']
02067         z = modif['z']
02068         del modif['z']
02069         matrice = modif['matrice']
02070         del modif['matrice']
02071         if item.type == 'IMAGE':
02072           image =  modif['image_name']
02073           del modif['image_name']
02074           pixmap = gcompris.utils.load_pixmap(image)
02075           modif['pixbuf']= pixmap
02076         item.canvas_item = self.playing.add(self.types[item.type], **modif)
02077         delta = len(self.playing.item_list) - z -1
02078         if delta != 0:
02079           item.canvas_item.lower(delta)
02080         item.canvas_item.affine_absolute(matrice)
02081         continue
02082       else:
02083         if modif.has_key('z'):
02084           z = modif['z']
02085           del modif['z']
02086           index = self.playing.item_list.index(item.canvas_item)
02087           if index > z:
02088             item.canvas_item.lower(index - z)
02089           else:
02090             item.canvas_item.raise_(z - index)
02091         if  modif.has_key('matrice'):
02092           matrice = modif['matrice']
02093           del modif['matrice']
02094           item.canvas_item.affine_absolute(matrice)
02095         if len(modif) != 0:
02096           item.canvas_item.set(**modif)

def anim.Gcompris_anim.color_item_event (   self,
  item,
  event,
  color 
)

Definition at line 692 of file anim.py.

00692 
00693   def color_item_event(self, item, event, color):
00694     if self.running:
00695       return
00696 
00697     if event.type == gtk.gdk.BUTTON_PRESS:
00698       if event.button == 1:
00699         # Deactivate old button
00700         self.old_color_item.set(width_units = 0.0,
00701                                 outline_color_rgba= 0x144B9DFFL)
00702 
00703         # Activate new button
00704         self.current_color = color
00705         self.old_color_item = item
00706         self.old_color_item.set(width_units = 4.0,
00707                                 outline_color_rgba= 0x16EC3DFFL)
00708 

Here is the caller graph for this function:

def anim.Gcompris_anim.config (   self)

Definition at line 439 of file anim.py.

00439 
00440   def config(self):
00441     print("Gcompris_anim config.")

def anim.Gcompris_anim.create_item_event (   self,
  item,
  event 
)

Definition at line 1054 of file anim.py.

01054 
01055   def create_item_event(self, item, event):
01056     if(event.type == gtk.gdk.BUTTON_PRESS and self.running==True):
01057       self.playing_stop()
01058       return False
01059 
01060     # Right button is a shortcup to Shot
01061     if (self.gcomprisBoard.mode != 'draw' and
01062         event.type == gtk.gdk.BUTTON_PRESS and
01063         event.button == 3):
01064       self.Anim2Shot()
01065       return False
01066 
01067     if (not (self.tools[self.current_tool][0] == "RECT" or
01068              self.tools[self.current_tool][0] == "CIRCLE" or
01069              self.tools[self.current_tool][0] == "FILL_RECT" or
01070              self.tools[self.current_tool][0] == "FILL_CIRCLE" or
01071              self.tools[self.current_tool][0] == "IMAGE" or
01072              self.tools[self.current_tool][0] == "TEXT" or
01073              self.tools[self.current_tool][0] == "LINE")):
01074       return False
01075 
01076     if event.type == gtk.gdk.BUTTON_PRESS:
01077 
01078       if event.button == 1:
01079         self.newitem = None
01080         print "----------------------------------------"
01081         print "Current image = " + str(self.current_frame)
01082         #self.dump_group(self.root_anim)
01083         self.newitemgroup = self.root_anim.add(
01084           gnomecanvas.CanvasGroup,
01085           x=0.0,
01086           y=0.0
01087           )
01088 
01089 
01090         if (self.tools[self.current_tool][0] == "DEL" or
01091             self.tools[self.current_tool][0] == "SELECT" or
01092             self.tools[self.current_tool][0] == "FILL"):
01093           # This event is treated in del_item_event to avoid
01094           # operating on background item and grid
01095           return False
01096 
01097         elif self.tools[self.current_tool][0] == "LINE":
01098 
01099           x,y = self.snap_to_grid(event.x,event.y)
01100           self.pos_x = x
01101           self.pos_y = y
01102 
01103           tuple_points = (x , y,  self.pos_x, self.pos_y)
01104 
01105           if self.gcomprisBoard.mode == 'draw':
01106             dist = {'x' : 'width', 'y' : 'height'}
01107 
01108             points = {}
01109             for c in ['x', 'y']:
01110               points[c + '1'] = eval(c) - self.draw_defaults_size['LINE'][dist[c]]/2
01111               points[c + '2'] = eval(c) + self.draw_defaults_size['LINE'][dist[c]]/2
01112             tuple_points = ( points['x1'], points['y1'], points['x2'], points['y2'])
01113 
01114 #     ItemGroup:
01115 #        AnchorsGroup
01116 #           ANCHOR_SE
01117 #           .....
01118 #        Item
01119 
01120           self.newitem = self.newitemgroup.add(
01121             gnomecanvas.CanvasLine,
01122             points=tuple_points,
01123             fill_color_rgba=self.colors[self.current_color],
01124             width_units=8.0
01125             )
01126 
01127         elif self.tools[self.current_tool][0] == "RECT":
01128 
01129           x,y = self.snap_to_grid(event.x,event.y)
01130           self.pos_x = x
01131           self.pos_y = y
01132 
01133           points = {}
01134           for c in ['x' , 'y']:
01135             points[c + '1'] = eval(c)
01136             points[c + '2'] = eval( 'self.pos_' + c )
01137 
01138 
01139           if self.gcomprisBoard.mode == 'draw':
01140             dist = {'x' : 'width', 'y' : 'height'}
01141 
01142             points = {}
01143             for c in ['x', 'y']:
01144               points[c + '1'] = eval(c) - self.draw_defaults_size['LINE'][dist[c]]/2
01145               points[c + '2'] = eval(c) + self.draw_defaults_size['LINE'][dist[c]]/2
01146 
01147           self.newitem = self.newitemgroup.add(
01148             gnomecanvas.CanvasRect,
01149             x1=points['x1'],
01150             y1=points['y1'],
01151             x2=points['x2'],
01152             y2=points['y2'],
01153             outline_color_rgba=self.colors[self.current_color],
01154             width_units=4.0
01155             )
01156           #          self.newitem.set_data('empty',True)
01157           gcompris.utils.canvas_set_property(self.newitem, "empty", "True")
01158 
01159         elif self.tools[self.current_tool][0] == "FILL_RECT":
01160 
01161           x,y = self.snap_to_grid(event.x,event.y)
01162           self.pos_x = x
01163           self.pos_y = y
01164 
01165           points = {}
01166           for c in ['x' , 'y']:
01167             points[c + '1'] = eval(c)
01168             points[c + '2'] = eval( 'self.pos_' + c )
01169 
01170           if self.gcomprisBoard.mode == 'draw':
01171             dist = {'x' : 'width', 'y' : 'height'}
01172 
01173             points = {}
01174             for c in ['x', 'y']:
01175               points[c + '1'] = eval(c) - self.draw_defaults_size['LINE'][dist[c]]/2
01176               points[c + '2'] = eval(c) + self.draw_defaults_size['LINE'][dist[c]]/2
01177 
01178           self.newitem = self.newitemgroup.add(
01179             gnomecanvas.CanvasRect,
01180             x1=points['x1'],
01181             y1=points['y1'],
01182             x2=points['x2'],
01183             y2=points['y2'],
01184             fill_color=self.colors[self.current_color],
01185             fill_color_rgba=self.colors[self.current_color],
01186             outline_color_rgba=0x000000FFL,
01187             width_units=1.0
01188             )
01189 
01190         elif self.tools[self.current_tool][0] == "CIRCLE":
01191 
01192           x,y = self.snap_to_grid(event.x,event.y)
01193           self.pos_x = x
01194           self.pos_y = y
01195 
01196 
01197           points = {}
01198           for c in ['x' , 'y']:
01199             points[c + '1'] = eval(c)
01200             points[c + '2'] = eval( 'self.pos_' + c )
01201 
01202 
01203           if self.gcomprisBoard.mode == 'draw':
01204             dist = {'x' : 'width', 'y' : 'height'}
01205 
01206             points = {}
01207             for c in ['x', 'y']:
01208               points[c + '1'] = eval(c) - self.draw_defaults_size['LINE'][dist[c]]/2
01209               points[c + '2'] = eval(c) + self.draw_defaults_size['LINE'][dist[c]]/2
01210 
01211           self.newitem = self.newitemgroup.add(
01212             gnomecanvas.CanvasEllipse,
01213             x1=points['x1'],
01214             y1=points['y1'],
01215             x2=points['x2'],
01216             y2=points['y2'],
01217              outline_color_rgba=self.colors[self.current_color],
01218             width_units=5.0
01219             )
01220           #          self.newitem.set_data('empty',True)
01221           gcompris.utils.canvas_set_property(self.newitem, "empty", "True")
01222 
01223         elif self.tools[self.current_tool][0] == "FILL_CIRCLE":
01224 
01225           x,y = self.snap_to_grid(event.x,event.y)
01226           self.pos_x = x
01227           self.pos_y = y
01228 
01229 
01230           points = {}
01231           for c in ['x' , 'y']:
01232             points[c + '1'] = eval(c)
01233             points[c + '2'] = eval( 'self.pos_' + c )
01234 
01235 
01236           if self.gcomprisBoard.mode == 'draw':
01237             dist = {'x' : 'width', 'y' : 'height'}
01238 
01239             points = {}
01240             for c in ['x', 'y']:
01241               points[c + '1'] = eval(c) - self.draw_defaults_size['LINE'][dist[c]]/2
01242               points[c + '2'] = eval(c) + self.draw_defaults_size['LINE'][dist[c]]/2
01243 
01244           self.newitem = self.newitemgroup.add(
01245             gnomecanvas.CanvasEllipse,
01246             x1=points['x1'],
01247             y1=points['y1'],
01248             x2=points['x2'],
01249             y2=points['y2'],
01250             fill_color_rgba=self.colors[self.current_color],
01251             outline_color_rgba=0x000000FFL,
01252             width_units=1.0
01253             )
01254 
01255         elif self.tools[self.current_tool][0] == "TEXT":
01256 
01257           x,y = self.snap_to_grid(event.x,event.y)
01258           self.pos_x = x
01259           self.pos_y = y
01260 
01261           self.newitem = self.newitemgroup.add(
01262             gnomecanvas.CanvasText,
01263             x=self.pos_x,
01264             y=self.pos_y,
01265             fill_color_rgba=self.colors[self.current_color],
01266             font=gcompris.FONT_BOARD_BIG_BOLD,
01267             text=u'?',
01268             anchor=gtk.ANCHOR_CENTER
01269             )
01270 
01271         if self.newitem != 0:
01272           self.anchorize(self.newitemgroup)
01273           anAnimItem = self.AnimItem()
01274           anAnimItem.z = self.new_z()
01275           anAnimItem.canvas_item = self.newitem
01276           anAnimItem.type = self.tools[self.current_tool][0]
01277           anAnimItem.canvas_item.set_data("AnimItem", anAnimItem)
01278           self.framelist.append(anAnimItem)
01279           self.list_z_actual.append(anAnimItem.z)
01280           self.draw_created_object = True
01281 
01282 
01283           if self.tools[self.current_tool][0] == "TEXT":
01284             (x1, x2, y1, y2) = self.get_bounds(self.newitem)
01285             self.object_set_size_and_pos(self.newitemgroup, x1, x2, y1, y2)
01286             self.select_item(self.newitemgroup)
01287             self.newitem = None
01288             self.newitemgroup = None
01289 
01290           elif self.gcomprisBoard.mode == 'draw':
01291             # needed because used to set the anchors.
01292             # The item has already the right size
01293             self.object_set_size_and_pos(self.newitemgroup,
01294                                           x1=points['x1'],
01295                                           y1=points['y1'],
01296                                           x2=points['x2'],
01297                                           y2=points['y2']
01298                                           )
01299 
01300             self.select_item(self.newitemgroup)
01301             # in draw creation is finished. Object is selected.
01302             self.newitem = None
01303             self.newitemgroup = None
01304 
01305       return True
01306 
01307     #
01308     # MOTION EVENT
01309     # ------------
01310     if event.type == gtk.gdk.MOTION_NOTIFY:
01311       # That's used only in itel creation.
01312       # In draw mode, item creation does not use drag&drop
01313       if self.gcomprisBoard.mode == 'draw':
01314         return False
01315 
01316       if ((self.tools[self.current_tool][0] == "IMAGE") or
01317           (self.tools[self.current_tool][0] == "TEXT")):
01318         return False
01319 
01320       if event.state & gtk.gdk.BUTTON1_MASK:
01321         if (self.tools[self.current_tool][0] == "RAISE" or
01322             self.tools[self.current_tool][0] == "LOWER"):
01323           return False
01324         x=event.x
01325         y=event.y
01326         x,y = self.snap_to_grid(event.x,event.y)
01327 
01328         # Check drawing boundaries
01329         if(event.x<self.drawing_area[0]):
01330           x=self.drawing_area[0]
01331         if(event.x>self.drawing_area[2]):
01332           x=self.drawing_area[2]
01333         if(event.y<self.drawing_area[1]):
01334           y=self.drawing_area[1]
01335         if(event.y>self.drawing_area[3]):
01336           y=self.drawing_area[3]
01337 
01338 #        if self.tools[self.current_tool][0] == "LINE":
01339 #          self.newitem.set( points=( self.pos_x, self.pos_y, x, y) )
01340 #        elif (self.tools[self.current_tool][0] == "RECT" or
01341 #              self.tools[self.current_tool][0] == "FILL_RECT" or
01342 #              self.tools[self.current_tool][0] == "CIRCLE" or
01343 #              self.tools[self.current_tool][0] == "FILL_CIRCLE"):
01344 #          self.newitem.set(
01345 #            x2=x,
01346 #            y2=y)
01347 
01348         if self.tools[self.current_tool][0] == "LINE":
01349           points= self.newitem.get_property("points")
01350           x1=points[0]
01351           y1=points[1]
01352         else:
01353           x1=self.newitem.get_property("x1")
01354           y1=self.newitem.get_property("y1")
01355         self.object_set_size_and_pos(self.newitemgroup,
01356                                      x1=x1,
01357                                      y1=y1,
01358                                      x2=x,
01359                                      y2=y
01360                                      )
01361     #
01362     # MOUSE DRAG STOP
01363     # ---------------
01364     if event.type == gtk.gdk.BUTTON_RELEASE:
01365       # That's used only in item creation.
01366       # In draw mode, item creation does not use drag&drop
01367       if self.draw_created_object:
01368         self.draw_created_object = False
01369         return True
01370 
01371       if ((self.tools[self.current_tool][0] == "IMAGE") or
01372           (self.tools[self.current_tool][0] == "TEXT")):
01373         return False
01374 
01375       if event.button == 1:
01376         if (self.tools[self.current_tool][0] == "RAISE" or
01377             self.tools[self.current_tool][0] == "LOWER"):
01378           return False
01379         # We have to remove empty created items (the kid did not drag enough)
01380         if self.tools[self.current_tool][0] == "LINE":
01381           # need to delete empty line. self.newitem est l'objet courant
01382           pass
01383         elif (self.tools[self.current_tool][0] == "RECT" or
01384               self.tools[self.current_tool][0] == "FILL_RECT" or
01385               self.tools[self.current_tool][0] == "CIRCLE" or
01386               self.tools[self.current_tool][0] == "FILL_CIRCLE"):
01387           # Oups, empty rect
01388           #self.del_item(self.newitem)
01389           pass
01390 
01391 #        print self.tools[self.current_tool][0]
01392 #        print self.newitem.get_bounds()
01393 #        print self.newitemgroup.get_bounds()
01394 
01395         return True
01396     return False

Here is the call graph for this function:

Here is the caller graph for this function:

def anim.Gcompris_anim.del_AnimItem (   self,
  AnimItem 
)

Definition at line 1935 of file anim.py.

01935 
01936   def del_AnimItem(self, AnimItem):
01937     # AnimItem is really deleted only on shot.
01938     self.list_z_actual.remove(AnimItem.z)
01939     AnimItem.z = None
01940     #AnimItem.frames_info[self.current_frame]['deleted']=True

Here is the caller graph for this function:

def anim.Gcompris_anim.del_item (   self,
  item 
)

Definition at line 1040 of file anim.py.

01040 
01041   def del_item(self, item):
01042     item.get_property("parent").destroy()
01043     self.del_AnimItem(item.get_data("AnimItem"))

Here is the call graph for this function:

Here is the caller graph for this function:

def anim.Gcompris_anim.del_item_event (   self,
  item,
  event 
)

Definition at line 1045 of file anim.py.

01045 
01046   def del_item_event(self, item, event):
01047     if event.type == gtk.gdk.BUTTON_PRESS:
01048       if event.button == 1:
01049         if self.tools[self.current_tool][0] == "DEL":
01050           self.del_item(item);
01051           return True
01052     return False

Here is the call graph for this function:

Definition at line 1421 of file anim.py.

01421 
01422   def draw_animtools(self):
01423     # Desactived for the moment
01424 
01425     x_left = 8
01426     y_top  = 472
01427     minibutton_width = 32
01428     minibutton_height = 20
01429 
01430     if self.gcomprisBoard.mode == 'draw':
01431       return
01432 
01433     # Draw the background area
01434     self.rootitem.add(
01435       gnomecanvas.CanvasPixbuf,
01436       pixbuf = gcompris.utils.load_pixmap(gcompris.skin.image_to_skin("draw/counter.png")),
01437       x=x_left - -11,
01438       y=y_top - 2,
01439       width=70.0,
01440       height=34.0,
01441       width_set=True,
01442       height_set=True
01443       )
01444 
01445     # First
01446     #item = self.rootitem.add(
01447     #  gnomecanvas.CanvasPixbuf,
01448     #  pixbuf = gcompris.utils.load_pixmap(gcompris.skin.image_to_skin("anim/minibutton.png")),
01449     #  x = x_left,
01450     #  y = y_top,
01451     #  )
01452     #item.connect("event", self.image_select_event, "first")
01453     #item = self.rootitem.add(
01454     #  gnomecanvas.CanvasText,
01455     #  text = "<<",
01456     #  x = x_left + 14,
01457     #  y = y_top + 7,
01458     #  )
01459     #item.connect("event", self.image_select_event, "first")
01460 
01461     # Image Number
01462     self.item_frame_counter = self.rootitem.add(
01463       gnomecanvas.CanvasText,
01464       text = self.current_frame + 1,
01465       x = x_left + minibutton_width + 14,
01466       y = y_top + 15,
01467       font = gcompris.skin.get_font("gcompris/board/medium"))
01468 
01469     # Last
01470     #item = self.rootitem.add(
01471     #  gnomecanvas.CanvasPixbuf,
01472     #  pixbuf = gcompris.utils.load_pixmap(gcompris.skin.image_to_skin("anim/minibutton.png")),
01473     #  x = x_left + 2*minibutton_width,
01474     #  y = y_top,
01475     #  )
01476     #item.connect("event", self.image_select_event, "last")
01477     #item = self.rootitem.add(
01478     #  gnomecanvas.CanvasText,
01479     #  text = ">>",
01480     #  x = x_left + 2*minibutton_width + 14,
01481     #  y = y_top + 7,
01482     #  )
01483     #item.connect("event", self.image_select_event, "last")
01484 
01485     # Next line
01486     #y_top += minibutton_height
01487 
01488     # Previous
01489     #item = self.rootitem.add(
01490     #  gnomecanvas.CanvasPixbuf,
01491     #  pixbuf = gcompris.utils.load_pixmap(gcompris.skin.image_to_skin("anim/minibutton.png")),
01492     #  x = x_left,
01493     #  y = y_top,
01494     #  )
01495     #item.connect("event", self.image_select_event, "previous")
01496     ##item = self.rootitem.add(
01497     #  gnomecanvas.CanvasText,
01498     #  text = "<",
01499     #  x = x_left + 14,
01500     #  y = y_top + 7,
01501     #  )
01502     #item.connect("event", self.image_select_event, "previous")
01503 
01504     # Next
01505     #item = self.rootitem.add(
01506     #  gnomecanvas.CanvasPixbuf,
01507     #  pixbuf = gcompris.utils.load_pixmap(gcompris.skin.image_to_skin("anim/minibutton.png")),
01508     #  x = x_left + 2*minibutton_width,
01509     #  y = y_top,
01510     #  )
01511     #item.connect("event", self.image_select_event, "next")
01512     #item = self.rootitem.add(
01513     #  gnomecanvas.CanvasText,
01514     #  text = ">",
01515     #  x = x_left + 2*minibutton_width + 14,
01516     #  y = y_top + 7,
01517     #  )
01518     #item.connect("event", self.image_select_event, "next")
01519 
01520     # Last button line
01521     #y_top += minibutton_height

Definition at line 643 of file anim.py.

00643 
00644   def draw_colors(self):
00645 
00646     pixmap = gcompris.utils.load_pixmap(gcompris.skin.image_to_skin("draw/color-selector.png"))
00647 
00648     x = (self.drawing_area[2] - self.drawing_area[0]
00649          - pixmap.get_width())/2 + self.drawing_area[0]
00650 
00651     color_pixmap_height = pixmap.get_height()
00652 
00653     y = gcompris.BOARD_HEIGHT - color_pixmap_height - 8
00654 
00655     c = 0
00656 
00657     self.root_coloritem = self.rootitem.add(
00658       gnomecanvas.CanvasGroup,
00659       x=0.0,
00660       y=0.0
00661       )
00662 
00663     self.root_coloritem.add(
00664       gnomecanvas.CanvasPixbuf,
00665       pixbuf = pixmap,
00666       x=x,
00667       y=y,
00668       )
00669 
00670     for i in range(0,10):
00671       x1=x+26+i*56
00672 
00673       for j in range(0,4):
00674         c = i*4 +j
00675         item = self.root_coloritem.add(
00676           gnomecanvas.CanvasRect,
00677           x1=x1 + 26*(j%2),
00678           y1=y+8 + (color_pixmap_height/2 -6)*(j/2),
00679           x2=x1 + 24  + 26*(j%2),
00680           y2=y + color_pixmap_height/2  + (color_pixmap_height/2 -6)*(j/2),
00681           fill_color_rgba=self.colors[c],
00682           outline_color_rgba=0x07A3E0FFL
00683           )
00684 
00685         item.connect("event", self.color_item_event, c)
00686         if (c==0):
00687           self.current_color = c
00688           self.old_color_item = item
00689           self.old_color_item.set(width_units = 4.0,
00690                                   outline_color_rgba= 0x16EC3DFFL)

Here is the call graph for this function:

def anim.Gcompris_anim.draw_drawing_area (   self,
  step 
)

Definition at line 710 of file anim.py.

00710 
00711   def draw_drawing_area(self,step):
00712 
00713     x1=self.drawing_area[0]
00714     y1=self.drawing_area[1]
00715     x2=self.drawing_area[2]
00716     y2=self.drawing_area[3]
00717 
00718     item = self.rootitem.add (
00719       gnomecanvas.CanvasRect,
00720       x1=x1,
00721       y1=y1,
00722       x2=x2,
00723       y2=y2,
00724       fill_color_rgba=0xFFFFFFFFL,
00725       width_units=2.0,
00726       outline_color_rgba=0x111199FFL
00727       )
00728     item.connect("event", self.create_item_event)
00729 
00730     # The CanvasGroup for the edit space.
00731     self.root_drawingitem = self.rootitem.add(
00732       gnomecanvas.CanvasGroup,
00733       x=0.0,
00734       y=0.0
00735       )
00736     self.draw_grid(x1,x2,y1,y2,step)
00737 
00738     # Create the root_anim group which contains all the drawings.
00739     # At root_anim root, there is a group for each drawings.
00740     self.root_anim = self.rootitem.add(
00741       gnomecanvas.CanvasGroup,
00742       x=0.0,
00743       y=0.0
00744       )
00745 
00746     gcompris.utils.item_absolute_move(self.root_anim,
00747                                       int(self.playing_area[0]-self.drawing_area[0]),
00748                                       int(self.playing_area[1]-self.drawing_area[1])
00749                                       )
00750 
00751     # Create a group for the first drawing
00752 
00753     self.flash = self.rootitem.add (
00754       gnomecanvas.CanvasPixbuf,
00755       pixbuf = gcompris.utils.load_pixmap(gcompris.skin.image_to_skin("draw/camera.png")),
00756       x=300,
00757       y=200,
00758       )
00759     self.flash.hide()
00760 

Here is the call graph for this function:

def anim.Gcompris_anim.draw_grid (   self,
  x1,
  x2,
  y1,
  y2,
  step 
)

Definition at line 854 of file anim.py.

00854 
00855   def draw_grid(self, x1, x2, y1, y2, step):
00856 
00857     self.current_step = step
00858 
00859     color = 0x1D0DFFFFL
00860 
00861     self.grid = self.rootitem.add (
00862       gnomecanvas.CanvasGroup,
00863       x=0.0,
00864       y=0.0
00865       )
00866     self.grid.hide()
00867 
00868     for i in range(int(x1), int(x2), step):
00869       item = self.grid.add (
00870         gnomecanvas.CanvasLine,
00871         points=(i , y1, i , y2),
00872         fill_color_rgba=color,
00873         width_units=1.0,
00874         )
00875       # Clicking on lines let you create object
00876       item.connect("event", self.create_item_event)
00877 
00878     for i in range(int(y1), int(y2), step):
00879       item = self.grid.add (
00880         gnomecanvas.CanvasLine,
00881         points=(x1, i, x2 , i),
00882         fill_color_rgba=color,
00883         width_units=1.0,
00884         )
00885       item.connect("event", self.create_item_event)

Here is the caller graph for this function:

Definition at line 762 of file anim.py.

00762 
00763   def draw_playing_area(self):
00764 
00765     x1=self.playing_area[0]
00766     y1=self.playing_area[1]
00767     x2=self.playing_area[2]
00768     y2=self.playing_area[3]
00769 
00770 
00771     # The CanvasGroup for the playing area.
00772     self.root_playingitem = self.rootitem.add(
00773       gnomecanvas.CanvasGroup,
00774       x=0.0,
00775       y=0.0
00776       )
00777     self.root_playingitem.hide()
00778 
00779     # intervall = 1000 / anim_speed
00780     self.anim_speed=5
00781 
00782     run = self.root_playingitem.add(
00783       gnomecanvas.CanvasPixbuf,
00784       pixbuf = gcompris.utils.load_pixmap(gcompris.skin.image_to_skin("draw/down.png")),
00785       x = 15,
00786       y = 410,
00787       width = 20,
00788       height = 20,
00789       width_set = 1,
00790       height_set = 1
00791       )
00792     run.connect("event", self.speed_event,False)
00793 
00794     self.speed_item = self.root_playingitem.add(
00795       gnomecanvas.CanvasText,
00796       text=self.anim_speed,
00797       font = gcompris.skin.get_font("gcompris/board/medium"),
00798       x=52,
00799       y=420,
00800       anchor=gtk.ANCHOR_CENTER,
00801       )
00802 
00803 
00804     run = self.root_playingitem.add(
00805       gnomecanvas.CanvasPixbuf,
00806       pixbuf = gcompris.utils.load_pixmap(gcompris.skin.image_to_skin("draw/up.png")),
00807       x = 70,
00808       y = 410,
00809       width = 20,
00810       height = 20,
00811       width_set = 1,
00812       height_set = 1
00813       )
00814     run.connect("event", self.speed_event,True)
00815 
00816     # And finaly a STOP icon
00817     run = self.root_playingitem.add(
00818       gnomecanvas.CanvasPixbuf,
00819       pixbuf = gcompris.utils.load_pixmap("boardicons/draw.png"),
00820       x = 16,
00821       y = 110,
00822       )
00823     run.connect("event", self.stop_event,True)
00824 

Definition at line 527 of file anim.py.

00527 
00528   def draw_tools(self):
00529 
00530     self.root_toolitem = self.rootitem.add(
00531       gnomecanvas.CanvasGroup,
00532       x=0.0,
00533       y=0.0
00534       )
00535 
00536     self.root_toolitem.add(
00537       gnomecanvas.CanvasPixbuf,
00538       pixbuf = gcompris.utils.load_pixmap(gcompris.skin.image_to_skin("draw/tool-selector.png")),
00539       x=5,
00540       y=5.0,
00541       width=107.0,
00542       height=517.0,
00543       width_set=True,
00544       height_set=True
00545       )
00546 
00547     x1=11.0
00548     x2=56.0
00549     y=11.0
00550     stepy=45
00551 
00552     # Display the tools
00553     for i in range(0,len(self.tools)):
00554 
00555       # Exclude the anim specific buttons
00556       if self.gcomprisBoard.mode == 'draw':
00557         if self.tools[i][0]=="MOVIE" or self.tools[i][0]=="PICTURE":
00558           continue
00559 
00560       if(i%2):
00561         theX = x2
00562       else:
00563         theX = x1
00564 
00565       item = self.root_toolitem.add(
00566         gnomecanvas.CanvasPixbuf,
00567         pixbuf = gcompris.utils.load_pixmap(gcompris.skin.image_to_skin(self.tools[i][1])),
00568         x=theX,
00569         y=y
00570         )
00571       item.connect("event", self.tool_item_event, i)
00572       if i%2:
00573         y += stepy
00574 
00575       if(self.tools[i][0]=="SELECT"):
00576         self.select_tool = item
00577         self.select_tool_number = i
00578         # Always select the SELECT item by default
00579         self.current_tool = i
00580         self.old_tool_item = item
00581         self.old_tool_item.set(pixbuf = gcompris.utils.load_pixmap(gcompris.skin.image_to_skin(self.tools[i][2])))
00582         gcompris.set_cursor(self.tools[i][3]);
00583 

Here is the call graph for this function:

def anim.Gcompris_anim.end (   self)

Definition at line 422 of file anim.py.

00422 
00423   def end(self):
00424     # stop the animation
00425     if self.running:
00426       self.playing_stop()
00427 
00428     # Remove the root item removes all the others inside it
00429     gcompris.set_cursor(gcompris.CURSOR_DEFAULT);
00430     self.rootitem.destroy()

Here is the call graph for this function:

def anim.Gcompris_anim.fillin_item_event (   self,
  item,
  event 
)

Definition at line 1022 of file anim.py.

01022 
01023   def fillin_item_event(self, item, event):
01024     if event.type == gtk.gdk.BUTTON_PRESS:
01025       if event.button == 1:
01026         if self.tools[self.current_tool][0] == "FILL":
01027           item.set(fill_color_rgba=self.colors[self.current_color])
01028           return True
01029     return False

def anim.Gcompris_anim.fillout_item_event (   self,
  item,
  event 
)

Definition at line 1031 of file anim.py.

01031 
01032   def fillout_item_event(self, item, event):
01033     if event.type == gtk.gdk.BUTTON_PRESS:
01034       if event.button == 1:
01035         if self.tools[self.current_tool][0] == "FILL":
01036           item.set(outline_color_rgba=self.colors[self.current_color])
01037           return True
01038     return False

def anim.Gcompris_anim.get_animitem_properties (   self,
  anAnimItem 
)

Definition at line 1967 of file anim.py.

01967 
01968   def get_animitem_properties(self, anAnimItem):
01969     properties = {'matrice' : anAnimItem.canvas_item.i2c_affine((0,0,0,0,0,0)) }
01970     for property_name in self.attributs[anAnimItem.type]:
01971       properties [property_name] = anAnimItem.canvas_item.get_property(property_name)
01972       if property_name == 'text':
01973         properties [property_name] = properties [property_name].decode('UTF-8')
01974     return properties

Here is the caller graph for this function:

def anim.Gcompris_anim.get_bounds (   self,
  item 
)

Definition at line 1730 of file anim.py.

01730 
01731   def get_bounds(self, item):
01732 
01733     if gobject.type_name(item)=="GnomeCanvasLine":
01734       (x1,y1,x2,y2)=item.get_property("points")
01735     elif gobject.type_name(item)=="GnomeCanvasPixbuf":
01736       x1=item.get_property("x")
01737       y1=item.get_property("y")
01738       x2=item.get_property("x")+item.get_property("width")
01739       y2=item.get_property("y")+item.get_property("height")
01740     elif gobject.type_name(item)=="GnomeCanvasText":
01741       x=item.get_property("x")
01742       y=item.get_property("y")
01743       width=item.get_property("text_width")
01744       height=item.get_property("text_height")
01745       x1=x-width/2
01746       y1=y-height/2
01747       x2=x1+width
01748       y2=y1+height
01749     else:
01750       x1=item.get_property("x1")
01751       y1=item.get_property("y1")
01752       x2=item.get_property("x2")
01753       y2=item.get_property("y2")
01754 
01755     return (min(x1,x2),min(y1,y2),max(x1,x2),max(y1,y2))
01756 

Here is the caller graph for this function:

def anim.Gcompris_anim.get_modified_parameters (   self,
  animItem 
)

Definition at line 1987 of file anim.py.

01987 
01988   def get_modified_parameters(self, animItem):
01989 
01990         modified= {}
01991         dict_properties = self.get_animitem_properties(animItem)
01992         frames = animItem.frames_info.keys()
01993         if frames != []:
01994           frames.sort()
01995           frames.reverse()
01996 
01997           for property in dict_properties.keys():
01998             for frame in frames:
01999 #              print animItem.type, property, frame, animItem.frames_info[frame]
02000               if animItem.frames_info[frame].has_key(property):
02001                 if not animItem.frames_info[frame][property]==dict_properties[property]:
02002                   modified[property]=dict_properties[property]
02003                 break
02004         else:
02005           modified = dict_properties
02006           modified.update(self.fixedattributs[animItem.type])
02007           if animItem.type == 'IMAGE':
02008             modified['image_name']= animItem.image_name
02009           modified['create']=True
02010           self.animlist.append(animItem)
02011 
02012         if animItem.z != animItem.z_previous:
02013           if animItem.z_previous != None:
02014             self.list_z_last_shot.remove(animItem.z_previous)
02015           modified['z'] = self.z_find_index(animItem)
02016           self.list_z_last_shot.insert( modified['z'], animItem.z)
02017 
02018         return modified

Here is the call graph for this function:

Here is the caller graph for this function:

def anim.Gcompris_anim.item_flip (   self,
  item 
)

Definition at line 1909 of file anim.py.

01909 
01910   def item_flip(self, item):
01911     bounds = self.get_bounds(item)
01912     (cx, cy) = ( (bounds[2]+bounds[0])/2 , (bounds[3]+bounds[1])/2)
01913 
01914     mat = ( -1, 0, 0, 1, 2*cx, 0)
01915 
01916     item.get_property("parent").affine_relative(mat)
01917 

Here is the call graph for this function:

Here is the caller graph for this function:

def anim.Gcompris_anim.item_type (   self,
  item 
)

Definition at line 1757 of file anim.py.

01757 
01758   def item_type(self, item):
01759 
01760     item_type = ''
01761 
01762     if gobject.type_name(item)=="GnomeCanvasGroup":
01763       item_type='GROUP'
01764     elif gobject.type_name(item)=="GnomeCanvasLine":
01765       item_type='LINE'
01766     elif gobject.type_name(item)=="GnomeCanvasPixbuf":
01767       item_type='IMAGE'
01768     elif gobject.type_name(item)=="GnomeCanvasRect":
01769       try:
01770         # Can't do it here because it needs to be C compatible for the svgexport
01771         empty = gcompris.utils.canvas_get_property(item, "empty")
01772         #empty = item.get_data('empty')
01773         if empty == None:
01774           empty = Fale
01775         else:
01776           empty = True
01777         # empty is passed from C, not python object
01778         # if we get it that means is True
01779       except:
01780         empty = False
01781 
01782       if empty:
01783         item_type='RECT'
01784       else:
01785         item_type='FILL_RECT'
01786 
01787     elif gobject.type_name(item)=="GnomeCanvasEllipse":
01788       try:
01789         #empty = item.get_data('empty')
01790         # Can't do it here because it needs to be C compatible for the svgexport
01791         empty = gcompris.utils.canvas_get_property(item, "empty")
01792 
01793         if empty == None:
01794           empty = Fale
01795         else:
01796           empty = True
01797         # empty is passed from C, not python object
01798         # if we get it that means is True
01799       except:
01800         empty = False
01801 
01802       if empty:
01803         item_type='CIRCLE'
01804       else:
01805         item_type='FILL_CIRCLE'
01806 
01807     elif gobject.type_name(item)=="GnomeCanvasText":
01808       item_type='TEXT'
01809 
01810 
01811     return item_type
01812 

Here is the caller graph for this function:

def anim.Gcompris_anim.key_press (   self,
  keyval,
  commit_str,
  preedit_str 
)

Definition at line 442 of file anim.py.

00442 
00443   def key_press(self, keyval, commit_str, preedit_str):
00444     #
00445     # I suppose codec is the stdin one.
00446     #
00447     codec = sys.stdin.encoding
00448 
00449     # keyboard shortcuts
00450     if (keyval == gtk.keysyms.F1):
00451       gcompris.file_selector_save( self.gcomprisBoard, self.selector_section, self.file_type, general_save)
00452     elif (keyval == gtk.keysyms.F2):
00453       gcompris.file_selector_load( self.gcomprisBoard, self.selector_section, self.file_type, general_restore)
00454 
00455     # Printing
00456     # Bruno we need a print button !
00457     #
00458     # was in anim1, but not print an animation is not interesting.
00459     elif (keyval == gtk.keysyms.F3):
00460       pass
00461       #if self.gcomprisBoard.mode == 'draw':
00462         # We can keep in draw2, svg export will be pure svg.
00463         #self.ps_print(self.get_drawing(self.current_image))
00464       #else:
00465         #print "Sorry i can't print an animation"
00466 
00467     # AFAIR The keyboard part was written by bruno
00468     elif ((keyval == gtk.keysyms.Shift_L) or
00469           (keyval == gtk.keysyms.Shift_R) or
00470           (keyval == gtk.keysyms.Control_L) or
00471           (keyval == gtk.keysyms.Control_R) or
00472           (keyval == gtk.keysyms.Caps_Lock) or
00473           (keyval == gtk.keysyms.Shift_Lock) or
00474           (keyval == gtk.keysyms.Meta_L) or
00475           (keyval == gtk.keysyms.Meta_R) or
00476           (keyval == gtk.keysyms.Alt_L) or
00477           (keyval == gtk.keysyms.Alt_R) or
00478           (keyval == gtk.keysyms.Super_L) or
00479           (keyval == gtk.keysyms.Super_R) or
00480           (keyval == gtk.keysyms.Hyper_L) or
00481           (keyval == gtk.keysyms.Hyper_R) or
00482           (keyval == gtk.keysyms.Mode_switch) or
00483           (keyval == gtk.keysyms.dead_circumflex) or
00484           (keyval == gtk.keysyms.Num_Lock)):
00485       return False
00486 
00487     if (self.selected == None):
00488       return True
00489     elif (gobject.type_name(self.selected.item_list[0])!="GnomeCanvasText"):
00490       #print "Not Text object when got key !!!"
00491       return True
00492 
00493     textItem = self.selected.item_list[0]
00494     if (self.last_commit == None):
00495       oldtext = textItem.get_property('text').decode('UTF-8')
00496     else:
00497       oldtext = self.last_commit
00498 
00499     if ((keyval == gtk.keysyms.BackSpace) or
00500         (keyval == gtk.keysyms.Delete)):
00501       if (len(oldtext) != 1):
00502         newtext = oldtext[:-1]
00503       else:
00504         newtext = u'?'
00505       self.last_commit = newtext
00506     else:
00507       if ((oldtext[:1] == u'?') and (len(oldtext)==1)):
00508         oldtext = u' '
00509         oldtext = oldtext.strip()
00510 
00511       if (commit_str != None):
00512         str = commit_str
00513         self.last_commit = oldtext + str
00514       if (preedit_str != None):
00515         str = '<span foreground="red">'+ preedit_str +'</span>'
00516         self.last_commit = oldtext
00517 
00518       if (len(oldtext) < self.MAX_TEXT_CHAR):
00519         newtext = oldtext + str
00520       else:
00521         newtext = oldtext
00522 
00523     textItem.set(markup=newtext.encode('UTF-8'))
00524 
00525     return True

def anim.Gcompris_anim.move_item_event (   self,
  item,
  event 
)

Definition at line 900 of file anim.py.

00900 
00901   def move_item_event(self, item, event):
00902     if self.tools[self.current_tool][0] == "CCW":
00903       if ((event.type == gtk.gdk.BUTTON_PRESS) and
00904           (event.button == 1) and
00905           (gobject.type_name(item)!="GnomeCanvasText")):
00906         # this one seems broken
00907         #gcompris.utils.item_rotate_relative(item.get_property("parent"),-10)
00908         self.rotate_relative(item,-10)
00909         return True
00910       else:
00911         return False
00912 
00913     if self.tools[self.current_tool][0] == "CW":
00914       if ((event.type == gtk.gdk.BUTTON_PRESS) and
00915           (event.button == 1) and
00916           (gobject.type_name(item)!="GnomeCanvasText")):
00917         self.rotate_relative(item,10)
00918         return True
00919       else:
00920         return False
00921 
00922     if self.tools[self.current_tool][0] == "FLIP":
00923       if ((event.type == gtk.gdk.BUTTON_PRESS) and
00924           (event.button == 1) and
00925           (gobject.type_name(item)!="GnomeCanvasText")):
00926         self.item_flip(item);
00927         return True
00928       else:
00929         return False
00930 
00931     if self.tools[self.current_tool][0] == "RAISE":
00932       if event.type == gtk.gdk.BUTTON_PRESS and event.button == 1:
00933         item.get_property("parent").raise_(1)
00934         self.z_raise(item.get_data("AnimItem"))
00935         return True
00936       else:
00937         return False
00938 
00939     if self.tools[self.current_tool][0] == "LOWER":
00940       if event.type == gtk.gdk.BUTTON_PRESS and event.button == 1:
00941         item.get_property("parent").lower(1)
00942         self.z_lower(item.get_data("AnimItem"))
00943         return True
00944       else:
00945         return False
00946 
00947     if self.tools[self.current_tool][0] != "SELECT":
00948       return False
00949 
00950     if event.type == gtk.gdk.BUTTON_PRESS and event.button == 1:
00951       if event.button == 1:
00952         self.unselect()
00953 
00954     #
00955     # MOUSE DRAG STOP
00956     # ---------------
00957     if event.type == gtk.gdk.BUTTON_RELEASE:
00958       if event.button == 1:
00959         if self.draw_created_object:
00960           self.draw_created_object = False
00961           return True
00962         # activate the anchors
00963         self.selected=item.get_property("parent")
00964         self.selected.item_list[1].show()
00965 
00966         # Reset the in_select_ofx ofset
00967         self.in_select_ofx = -1
00968         self.in_select_ofy = -1
00969 
00970         return True
00971 
00972     if event.state & gtk.gdk.BUTTON1_MASK:
00973       wx=event.x
00974       wy=event.y
00975       #pass in item relative coordinate
00976       (x, y)= item.w2i( wx, wy)
00977 
00978       bounds = item.get_bounds()
00979       #bounds = self.get_bounds(item)
00980 
00981       # Save the ofset between the mouse pointer and the upper left corner of the object
00982       if(self.in_select_ofx == -1):
00983         self.in_select_ofx = x-bounds[0]
00984         self.in_select_ofy = y-bounds[1]
00985 
00986       x -= self.in_select_ofx
00987       y -= self.in_select_ofy
00988 
00989       x,y = self.snap_to_grid(x,y)
00990 
00991       # Check drawing boundaries
00992       #needs to be corrected with item relative coordinate
00993       # FIXME
00994 #      if(x<self.drawing_area[0]):
00995 #        x=self.drawing_area[0]
00996 #      if(x>(self.drawing_area[2]-(bounds[2]-bounds[0]))):
00997 #        x=self.drawing_area[2]-(bounds[2]-bounds[0])
00998         # We need to realign x cause the bounds values are not precise enough
00999 #        x,n = self.snap_to_grid(x,y)
01000 #      if(y<self.drawing_area[1]):
01001 #        y=self.drawing_area[1]
01002 #      if(y>(self.drawing_area[3]-(bounds[3]-bounds[1]))):
01003 #        y=self.drawing_area[3]-(bounds[3]-bounds[1])
01004         # We need to realign y cause the bounds values are not precise enough
01005 #        n,y = self.snap_to_grid(x,y)
01006 
01007       # Now perform the object move
01008       #gcompris.utils.item_absolute_move(item.get_property("parent"), x, y)
01009       # pass it in item coordinate:
01010       #(idx, idy) =  item.w2i( x-bounds[0], y-bounds[1] )
01011       (idx, idy) =  ( x-bounds[0], y-bounds[1] )
01012       self.object_move(
01013         item.get_property("parent"),
01014         idx,
01015         idy
01016         )
01017 
01018       return True
01019 
01020     return False

Here is the call graph for this function:

def anim.Gcompris_anim.new_z (   self)

Definition at line 1929 of file anim.py.

01929 
01930   def new_z(self):
01931     if self.list_z_actual != []:
01932       return int(self.list_z_actual[-1] + 1 )
01933     else:
01934       return 1

def anim.Gcompris_anim.object_move (   self,
  object,
  dx,
  dy 
)

Definition at line 1522 of file anim.py.

01522 
01523   def object_move(self,object,dx,dy):
01524     # Unfortunately object.move is broken for 'TEXT' group.
01525 
01526     if gobject.type_name(object.item_list[0])=="GnomeCanvasText":
01527       (x1,y1,x2,y2) = object.get_bounds()
01528       (idx, idy) =  object.w2i( dx, dy )
01529       self.object_set_size_and_pos(object, x1+idx, y1+idy, x2+idx, y2+idy)
01530     else:
01531       object.move(dx, dy)

Here is the call graph for this function:

Here is the caller graph for this function:

def anim.Gcompris_anim.object_set_size_and_pos (   self,
  object,
  x1,
  y1,
  x2,
  y2 
)

Definition at line 1532 of file anim.py.

01532 
01533   def object_set_size_and_pos(self, object, x1, y1, x2, y2):
01534     if gobject.type_name(object.item_list[0])=="GnomeCanvasLine":
01535       object.item_list[0].set(
01536         points=(x1,y1,x2,y2)
01537         )
01538     elif gobject.type_name(object.item_list[0])=="GnomeCanvasPixbuf":
01539       object.item_list[0].set(
01540         x=x1,
01541         y=y1,
01542         width=x2-x1,
01543         height=y2-y1
01544         )
01545     elif gobject.type_name(object.item_list[0])=="GnomeCanvasText":
01546       object.item_list[0].set(
01547         x=(x1+x2)/2,
01548         y=(y1+y2)/2
01549         )
01550     else:
01551       object.item_list[0].set(
01552         x1=x1,
01553         x2=x2,
01554         y1=y1,
01555         y2=y2
01556         )
01557 
01558     for anchor in object.item_list[1].item_list:
01559       anchor_type = anchor.get_data('anchor_type')
01560 
01561       if anchor_type == self.ANCHOR_N:
01562         anchor.set(
01563           x1= (x1 + x2 - self.DEFAULT_ANCHOR_SIZE)/2,
01564           x2= (x1 + x2 + self.DEFAULT_ANCHOR_SIZE)/2,
01565           y1= y2,
01566           y2= y2 + self.DEFAULT_ANCHOR_SIZE
01567           )
01568       elif anchor_type == self.ANCHOR_T:
01569         anchor.set(
01570           x1= (x1 + x2 - self.DEFAULT_ANCHOR_SIZE*3)/2,
01571           x2= (x1 + x2 + self.DEFAULT_ANCHOR_SIZE*3)/2,
01572           y1= y2,
01573           y2= y2 + self.DEFAULT_ANCHOR_SIZE
01574           )
01575       elif anchor_type == self.ANCHOR_NE:
01576         anchor.set(
01577           x1= x2,
01578           x2= x2 + self.DEFAULT_ANCHOR_SIZE,
01579           y1= y2,
01580           y2= y2 + self.DEFAULT_ANCHOR_SIZE
01581           )
01582       elif anchor_type == self.ANCHOR_E:
01583         anchor.set(
01584           x1= x2,
01585           x2= x2 + self.DEFAULT_ANCHOR_SIZE,
01586           y1= (y1 + y2 - self.DEFAULT_ANCHOR_SIZE)/2,
01587           y2= (y1 + y2 + self.DEFAULT_ANCHOR_SIZE)/2
01588           )
01589       elif anchor_type == self.ANCHOR_SE:
01590         anchor.set(
01591           x1= x2,
01592           x2= x2 + self.DEFAULT_ANCHOR_SIZE,
01593           y1= y1,
01594           y2= y1 - self.DEFAULT_ANCHOR_SIZE
01595           )
01596       elif anchor_type == self.ANCHOR_S:
01597         anchor.set(
01598           x1= (x1 + x2 - self.DEFAULT_ANCHOR_SIZE)/2,
01599           x2= (x1 + x2 + self.DEFAULT_ANCHOR_SIZE)/2,
01600           y1= y1,
01601           y2= y1 - self.DEFAULT_ANCHOR_SIZE
01602           )
01603       elif anchor_type == self.ANCHOR_SW:
01604         anchor.set(
01605           x1= x1,
01606           x2= x1 - self.DEFAULT_ANCHOR_SIZE,
01607           y1= y1,
01608           y2= y1 - self.DEFAULT_ANCHOR_SIZE
01609           )
01610       elif anchor_type == self.ANCHOR_W:
01611         anchor.set(
01612           x1= x1,
01613           x2= x1 - self.DEFAULT_ANCHOR_SIZE,
01614           y1= (y1 + y2 - self.DEFAULT_ANCHOR_SIZE)/2,
01615           y2=  (y1 + y2 + self.DEFAULT_ANCHOR_SIZE)/2,
01616           )
01617       elif anchor_type == self.ANCHOR_NW:
01618         anchor.set(
01619           x1= x1,
01620           x2= x1 - self.DEFAULT_ANCHOR_SIZE,
01621           y1= y2,
01622           y2= y2 + self.DEFAULT_ANCHOR_SIZE
01623           )
01624 

Here is the caller graph for this function:

def anim.Gcompris_anim.pause (   self,
  pause 
)

Definition at line 431 of file anim.py.

00431 
00432   def pause(self, pause):
00433     #used to stop the event reception at the end?
00434     self.board_paused = pause
00435     return

def anim.Gcompris_anim.playing_event (   self,
  item,
  event,
  state 
)

Definition at line 1413 of file anim.py.

01413 
01414   def playing_event(self, item, event, state):
01415     if event.type == gtk.gdk.BUTTON_PRESS:
01416       if state:
01417         self.playing_start()
01418       else:
01419         self.playing_stop()

Here is the call graph for this function:

Definition at line 1405 of file anim.py.

01405 
01406   def playing_start(self):
01407     if not self.running:
01408       self.running=True
01409       self.root_coloritem.hide()
01410       self.root_toolitem.hide()
01411       self.root_playingitem.show()
01412       self.Anim2Run()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 829 of file anim.py.

00829 
00830   def playing_stop(self):
00831     self.running=False
00832     gobject.source_remove(self.timeout)
00833     self.run_anim2()

Here is the call graph for this function:

Here is the caller graph for this function:

def anim.Gcompris_anim.recursive_anchorize (   self,
  root_item 
)

Definition at line 1816 of file anim.py.

01816 
01817   def recursive_anchorize(self, root_item):
01818     for item in root_item.item_list:
01819       if gobject.type_name(item)=="GnomeCanvasGroup":
01820         self.recursive_anchorize(item)
01821       else:
01822         self.anchorize(item.get_property("parent"))

Here is the call graph for this function:

Here is the caller graph for this function:

def anim.Gcompris_anim.repeat (   self)

Definition at line 436 of file anim.py.

00436 
00437   def repeat(self):
00438     print("Gcompris_anim repeat.")

Here is the caller graph for this function:

def anim.Gcompris_anim.resize_item_event (   self,
  item,
  event,
  anchor_type 
)

Definition at line 1625 of file anim.py.

01625 
01626   def resize_item_event(self, item, event, anchor_type):
01627     if self.running:
01628       return
01629 
01630     # Right button is a shortcup to Shot
01631     if event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
01632       self.Anim2Shot()
01633       return False
01634 
01635     if event.state & gtk.gdk.BUTTON1_MASK:
01636       # warning: anchor is in a group of anchors, which is in the object group
01637       parent=item.get_property("parent").get_property("parent")
01638       real_item=parent.item_list[0]
01639 
01640       wx=event.x
01641       wy=event.y
01642       #passing x, y to item relative coordinate
01643       (x,y)= item.w2i(wx,wy)
01644 
01645       if gobject.type_name(real_item)=="GnomeCanvasLine":
01646         points= real_item.get_property("points")
01647         x1=points[0]
01648         y1=points[1]
01649         x2=points[2]
01650         y2=points[3]
01651       elif gobject.type_name(real_item)=="GnomeCanvasPixbuf":
01652         x1=real_item.get_property("x")
01653         y1=real_item.get_property("y")
01654         x2=x1+real_item.get_property("width")
01655         y2=y1+real_item.get_property("height")
01656       elif gobject.type_name(real_item)=="GnomeCanvasText":
01657         y1=y
01658         y2=y+real_item.get_property("text_height")
01659         pass
01660       else:
01661         x1=real_item.get_property("x1")
01662         y1=real_item.get_property("y1")
01663         x2=real_item.get_property("x2")
01664         y2=real_item.get_property("y2")
01665 
01666       if (anchor_type == self.ANCHOR_N):
01667         self.object_set_size_and_pos(parent,
01668                                      x1=x1,
01669                                      y1=y1,
01670                                      x2=x2,
01671                                      y2=y
01672                                      )
01673       elif (anchor_type == self.ANCHOR_T):
01674         self.object_set_size_and_pos(parent,
01675                                      x1=x,
01676                                      y1=y1,
01677                                      x2=x,
01678                                      y2=y2
01679                                      )
01680       elif (anchor_type == self.ANCHOR_NE):
01681         self.object_set_size_and_pos(parent,
01682                                      x1=x1,
01683                                      y1=y1,
01684                                      x2=x,
01685                                      y2=y
01686                                      )
01687       elif (anchor_type == self.ANCHOR_E):
01688         self.object_set_size_and_pos(parent,
01689                                      x1=x1,
01690                                      y1=y1,
01691                                      x2=x,
01692                                      y2=y2
01693                                      )
01694       elif (anchor_type == self.ANCHOR_SE):
01695         self.object_set_size_and_pos(parent,
01696                                      x1=x1,
01697                                      y1=y,
01698                                      x2=x,
01699                                      y2=y2
01700                                      )
01701       elif (anchor_type == self.ANCHOR_S):
01702         self.object_set_size_and_pos(parent,
01703                                      x1=x1,
01704                                      y1=y,
01705                                      x2=x2,
01706                                      y2=y2
01707                                      )
01708       elif (anchor_type == self.ANCHOR_SW):
01709         self.object_set_size_and_pos(parent,
01710                                      x1=x,
01711                                      y1=y,
01712                                      x2=x2,
01713                                      y2=y2
01714                                      )
01715       elif (anchor_type == self.ANCHOR_W):
01716         self.object_set_size_and_pos(parent,
01717                                      x1=x,
01718                                      y1=y1,
01719                                      x2=x2,
01720                                      y2=y2
01721                                      )
01722       elif (anchor_type == self.ANCHOR_NW):
01723         self.object_set_size_and_pos(parent,
01724                                      x1=x,
01725                                      y1=y1,
01726                                      x2=x2,
01727                                      y2=y
01728                                      )
01729 

Here is the call graph for this function:

Here is the caller graph for this function:

def anim.Gcompris_anim.rotate_relative (   self,
  item,
  angle 
)

Definition at line 1873 of file anim.py.

01873 
01874   def rotate_relative(self, item, angle):
01875     bounds = item.get_bounds()
01876     #    print "Item bounds : ", bounds
01877 
01878     #bds = item.get_property("parent").get_bounds()
01879     #    print "Item parent bounds : ", bounds
01880 
01881     (cx, cy) = ( (bounds[2]+bounds[0])/2 , (bounds[3]+bounds[1])/2)
01882 
01883 
01884     t = math.radians(angle)
01885 
01886     # This matrix rotate around ( cx, cy )
01887 
01888     #     This is the result of the product:
01889 
01890 
01891     #            T_{-c}             Rot (t)                 T_c
01892 
01893     #       1    0   cx       cos(t) -sin(t)    0        1    0  -cx
01894     #       0    1   cy  by   sin(t)  cos(t)    0   by   0    1  -cy
01895     #       0    0    1         0       0       1        0    0   1
01896 
01897 
01898     mat = ( math.cos(t),
01899             math.sin(t),
01900             -math.sin(t),
01901             math.cos(t),
01902             (1-math.cos(t))*cx + math.sin(t)*cy,
01903             -math.sin(t)*cx + (1 - math.cos(t))*cy)
01904 
01905     item.get_property("parent").affine_relative(mat)
01906 
01907 
01908     return

Here is the caller graph for this function:

Definition at line 2097 of file anim.py.

02097 
02098   def run_anim2(self):
02099     if self.running:
02100       if self.current_frame==0:
02101         self.playing.destroy()
02102         self.playing = self.rootitem.add(
02103           gnomecanvas.CanvasGroup,
02104           x=0.0,
02105           y=0.0
02106           )
02107       self.apply_frame((self.current_frame)%(self.frames_total))
02108       self.current_frame=(self.current_frame+1)%(self.frames_total)
02109       self.item_frame_counter.set(text=self.current_frame + 1)
02110     else:
02111       self.playing.destroy()
02112       self.current_frame = self.frames_total
02113       self.item_frame_counter.set(text=self.current_frame + 1)
02114       self.root_anim.show()
02115       self.root_coloritem.show()
02116       self.root_toolitem.show()
02117       self.root_playingitem.hide()
02118       gcompris.bar_hide(False)
02119     return self.running

Here is the caller graph for this function:

Definition at line 1401 of file anim.py.

01401 
01402   def run_flash(self):
01403     self.flash.hide()
01404     return False

Here is the caller graph for this function:

def anim.Gcompris_anim.select_item (   self,
  group 
)

Definition at line 1857 of file anim.py.

01857 
01858   def select_item(self, group):
01859     if (self.selected != None):
01860       self.unselect()
01861 
01862     # Deactivate old button
01863     self.old_tool_item.set(pixbuf = gcompris.utils.load_pixmap(gcompris.skin.image_to_skin(self.tools[self.current_tool][1])))
01864 
01865     # Activate new button
01866     self.current_tool = self.select_tool_number
01867     self.old_tool_item = self.select_tool
01868     self.old_tool_item.set(pixbuf = gcompris.utils.load_pixmap(gcompris.skin.image_to_skin(self.tools[self.current_tool][2])))
01869     gcompris.set_cursor(self.tools[self.current_tool][3]);
01870 
01871     self.selected = group
01872     self.selected.item_list[1].show()

Here is the call graph for this function:

def anim.Gcompris_anim.snap_to_grid (   self,
  x,
  y 
)

Definition at line 887 of file anim.py.

00887 
00888   def snap_to_grid(self, x, y):
00889     result = []
00890     tmp = round(((x+(self.current_step)) -
00891                self.drawing_area[0])/self.current_step) - 1
00892     result.append(float(self.drawing_area[0] + tmp*self.current_step))
00893 
00894     tmp = round(((y+(self.current_step)) -
00895                self.drawing_area[1])/self.current_step) - 1
00896     result.append(float(self.drawing_area[1] + tmp*self.current_step))
00897     return result
00898 

Here is the caller graph for this function:

def anim.Gcompris_anim.snapshot_event (   self,
  item,
  event 
)

Definition at line 1397 of file anim.py.

01397 
01398   def snapshot_event(self, item, event):
01399     if event.type == gtk.gdk.BUTTON_PRESS:
01400       self.Anim2Shot()

Here is the call graph for this function:

def anim.Gcompris_anim.speed_event (   self,
  item,
  event,
  up 
)

Definition at line 834 of file anim.py.

00834 
00835   def speed_event(self, item, event, up):
00836 
00837     if event.type == gtk.gdk.BUTTON_PRESS:
00838       if up:
00839         if self.anim_speed==25:
00840           return
00841         else:
00842           self.anim_speed=self.anim_speed+1
00843       else:
00844         if self.anim_speed==1:
00845           return
00846         else:
00847           self.anim_speed=self.anim_speed-1
00848 
00849       gobject.source_remove(self.timeout)
00850       self.timeout=gobject.timeout_add(1000/self.anim_speed, self.run_anim2)
00851       self.speed_item.set(text=self.anim_speed)

def anim.Gcompris_anim.start (   self)

Definition at line 386 of file anim.py.

00386 
00387   def start(self):
00388 
00389     self.last_commit = None
00390 
00391     # GCompris initialisation
00392     self.gcomprisBoard.level=1
00393     self.gcomprisBoard.maxlevel=1
00394     self.gcomprisBoard.sublevel=0
00395     self.gcomprisBoard.number_of_sublevel=0
00396 
00397     gcompris.bar_set(0)
00398     gcompris.set_background(self.gcomprisBoard.canvas.root(),
00399                             gcompris.skin.image_to_skin("gcompris-bg.jpg"))
00400 
00401     # Create our rootitem. We put each canvas item in it so at the end we
00402     # only have to kill it. The canvas deletes all the items it contains automaticaly.
00403     self.rootitem = self.gcomprisBoard.canvas.root().add(
00404       gnomecanvas.CanvasGroup,
00405       x=0.0,
00406       y=0.0
00407       )
00408 
00409     # initialisation
00410     self.draw_tools()
00411     self.draw_animtools()
00412     self.draw_colors()
00413     self.draw_drawing_area(self.grid_step)
00414     self.draw_playing_area()
00415     self.pause(0)
00416 
00417     global python_xml
00418     if not python_xml:
00419       #gcompris.utils.dialog(_('Python xml module not found. SVG is disabled. Install the python xml module to enable SVG Save/restore.'), None)
00420       #print _('Python xml module not found. SVG is disabled. Install the python xml module to enable SVG Save/restore.')
00421       pass

def anim.Gcompris_anim.stop_event (   self,
  item,
  event,
  up 
)

Definition at line 825 of file anim.py.

00825 
00826   def stop_event(self, item, event, up):
00827     if event.type == gtk.gdk.BUTTON_PRESS:
00828       self.playing_stop()

Here is the call graph for this function:

def anim.Gcompris_anim.tool_item_event (   self,
  item,
  event,
  tool 
)

Definition at line 586 of file anim.py.

00586 
00587   def tool_item_event(self, item, event, tool):
00588 
00589     if event.type == gtk.gdk.BUTTON_PRESS:
00590       if event.button == 1:
00591         # Some button have instant effects
00592         if (self.tools[tool][0] == "SAVE"):
00593 #          self.Anim2Shot()
00594           gcompris.file_selector_save( self.gcomprisBoard, self.selector_section, self.file_type, general_save)
00595           return True
00596 
00597         elif (self.tools[tool][0] == "LOAD"):
00598           gcompris.file_selector_load( self.gcomprisBoard, self.selector_section, self.file_type, general_restore)
00599           return True
00600 
00601         elif (self.tools[tool][0] == "IMAGE"):
00602           self.pos_x = gcompris.BOARD_WIDTH/2
00603           self.pos_y = gcompris.BOARD_HEIGHT/2
00604 
00605           gcompris.images_selector_start(self.gcomprisBoard,
00606                                          "dataset",
00607                                          image_selected);
00608           return True
00609 
00610         elif (self.tools[tool][0] == "PICTURE"):
00611           self.Anim2Shot()
00612           return True
00613 
00614         elif (self.tools[tool][0] == "MOVIE"):
00615           if self.frames_total == 0:
00616             print 'Mmm... Need to make shots before run anim !!'
00617             return True
00618 
00619           if not self.running:
00620             # unselect object if necessary
00621             self.unselect()
00622 
00623             self.playing_start()
00624             return True
00625 
00626         elif (self.tools[tool][0] != "SELECT") and (self.selected != None):
00627           self.unselect()
00628 
00629         #
00630         # Normal case, tool button switch
00631         # -------------------------------
00632 
00633         # Deactivate old button
00634         self.old_tool_item.set(pixbuf = gcompris.utils.load_pixmap(gcompris.skin.image_to_skin(self.tools[self.current_tool][1])))
00635 
00636         # Activate new button
00637         self.current_tool = tool
00638         self.old_tool_item = item
00639         self.old_tool_item.set(pixbuf = gcompris.utils.load_pixmap(gcompris.skin.image_to_skin(self.tools[self.current_tool][2])))
00640         gcompris.set_cursor(self.tools[self.current_tool][3]);
00641 

Here is the caller graph for this function:

Definition at line 2148 of file anim.py.

02148 
02149   def unselect(self):
02150     if not self.selected:
02151       return
02152     if ((gobject.type_name(self.selected.item_list[0])=="GnomeCanvasText")
02153         and
02154         (self.last_commit != None)):
02155       #suppress preedit
02156       self.selected.item_list[0].set(markup=self.last_commit)
02157       self.last_commit = None
02158       gcompris.im_reset()
02159     self.selected.item_list[1].hide()
02160     self.selected = None
02161 
02162 
02163 
02164 

Here is the caller graph for this function:

def anim.Gcompris_anim.z_delete_on_shot (   self,
  anAnimItem 
)

Definition at line 1983 of file anim.py.

01983 
01984   def z_delete_on_shot(self, anAnimItem):
01985     if anAnimItem.z_previous != None:
01986         self.list_z_last_shot.remove(anAnimItem.z_previous)

Here is the caller graph for this function:

def anim.Gcompris_anim.z_find_index (   self,
  anAnimItem 
)

Definition at line 2047 of file anim.py.

02047 
02048   def z_find_index(self, anAnimItem):
02049     def f(x): return x < anAnimItem.z
02050 
02051     return len(filter(f, self.list_z_last_shot))
02052 
02053 #    self.z_reinit()
02054 
02055 #  def anim2Run(self):

Here is the caller graph for this function:

def anim.Gcompris_anim.z_lower (   self,
  anAnimItem 
)

Definition at line 1951 of file anim.py.

01951 
01952   def z_lower(self, anAnimItem):
01953     index = self.list_z_actual.index(anAnimItem.z)
01954     if index > 0:
01955       if index > 1:
01956          anAnimItem.z = (self.list_z_actual[index - 1] + self.list_z_actual[index - 2])/2.0
01957       else:
01958         anAnimItem.z = self.list_z_actual[0] /2.0
01959       self.list_z_actual.pop(index)
01960       self.list_z_actual.insert(index-1, anAnimItem.z)

Here is the caller graph for this function:

def anim.Gcompris_anim.z_raise (   self,
  anAnimItem 
)

Definition at line 1941 of file anim.py.

01941 
01942   def z_raise(self, anAnimItem):
01943     index = self.list_z_actual.index(anAnimItem.z)
01944     if index < len(self.list_z_actual) -1 :
01945       if index < len(self.list_z_actual) - 2 :
01946         anAnimItem.z = (self.list_z_actual[index + 1] + self.list_z_actual[index + 2])/2.0
01947       else:
01948         anAnimItem.z = self.list_z_actual[-1] + 1
01949       self.list_z_actual.pop(index)
01950       self.list_z_actual.insert(index+1, anAnimItem.z)

Here is the caller graph for this function:

Definition at line 1975 of file anim.py.

01975 
01976   def z_reinit(self):
01977     for anAnimItem in self.framelist:
01978       anAnimItem.z = self.list_z_actual.index(anAnimItem.z)+1
01979       anAnimItem.z_previous =  anAnimItem.z
01980 
01981     self.list_z_last_shot= range(1, len(self.list_z_actual) + 1)
01982     self.list_z_actual=self.list_z_last_shot[:]

Here is the caller graph for this function:


Member Data Documentation

Definition at line 160 of file anim.py.

Definition at line 167 of file anim.py.

Definition at line 165 of file anim.py.

Definition at line 166 of file anim.py.

Definition at line 164 of file anim.py.

Definition at line 170 of file anim.py.

Definition at line 171 of file anim.py.

Definition at line 169 of file anim.py.

Definition at line 172 of file anim.py.

Definition at line 168 of file anim.py.

Definition at line 174 of file anim.py.

Definition at line 779 of file anim.py.

Definition at line 374 of file anim.py.

Definition at line 202 of file anim.py.

Definition at line 154 of file anim.py.

Definition at line 316 of file anim.py.

Definition at line 329 of file anim.py.

Definition at line 376 of file anim.py.

Definition at line 333 of file anim.py.

Definition at line 310 of file anim.py.

Definition at line 97 of file anim.py.

Definition at line 384 of file anim.py.

Definition at line 122 of file anim.py.

Definition at line 343 of file anim.py.

Definition at line 130 of file anim.py.

Definition at line 263 of file anim.py.

Definition at line 144 of file anim.py.

Definition at line 242 of file anim.py.

Definition at line 752 of file anim.py.

Definition at line 85 of file anim.py.

Definition at line 372 of file anim.py.

Definition at line 377 of file anim.py.

Definition at line 155 of file anim.py.

Definition at line 73 of file anim.py.

Definition at line 860 of file anim.py.

Definition at line 100 of file anim.py.

Definition at line 349 of file anim.py.

Definition at line 350 of file anim.py.

Definition at line 354 of file anim.py.

Definition at line 80 of file anim.py.

Definition at line 388 of file anim.py.

Definition at line 381 of file anim.py.

Definition at line 379 of file anim.py.

Definition at line 157 of file anim.py.

Definition at line 1078 of file anim.py.

Definition at line 1082 of file anim.py.

Definition at line 687 of file anim.py.

Definition at line 579 of file anim.py.

Definition at line 2101 of file anim.py.

Definition at line 344 of file anim.py.

Definition at line 2134 of file anim.py.

Definition at line 601 of file anim.py.

Definition at line 602 of file anim.py.

Definition at line 739 of file anim.py.

Definition at line 362 of file anim.py.

Definition at line 730 of file anim.py.

Definition at line 771 of file anim.py.

Definition at line 363 of file anim.py.

Definition at line 402 of file anim.py.

Definition at line 117 of file anim.py.

Definition at line 575 of file anim.py.

Definition at line 576 of file anim.py.

Definition at line 336 of file anim.py.

Definition at line 103 of file anim.py.

Definition at line 793 of file anim.py.

Definition at line 849 of file anim.py.

Definition at line 287 of file anim.py.

Definition at line 192 of file anim.py.


The documentation for this class was generated from the following file: