コード例 #1
0
ファイル: container.py プロジェクト: yantrabuddhi/blocos
 def copy_group(self, group):
     
     #cpdict = {}
     buffer = []
     
     for block in group:
         if type(block) == commands.start_block or type(block) == commands.newprocedure_block:
             newblock = commands.newprocedure_block()
             newblock.set_position( block.get_position() )
             newblock.layer = block.layer
         else:
             newblock = block.copy()
             
         buffer.append( newblock )
     #    cpdict[block] = newblock
     
     #for block in group:
     #    cpblock = cpdict[block]
     #    for i in range( len( block.get_docks() ) ):
     #        dock_orig    = block.get_docks()[i]
     #        dock_orig_cp = cpblock.get_docks()[i]
     #        dest_dock    = dock_orig.get_destiny_conn()
     #        if dest_dock is not None:
     #            dest_block = dock_orig.get_destiny_block()
     #            j = dest_block.get_docks().index(dest_dock)
     #            dest_dock_cp = cpdict[dest_block].get_docks()[j]
     #            dock_orig_cp.connect( dest_dock_cp )
     
     return buffer
コード例 #2
0
ファイル: canvas.py プロジェクト: yantrabuddhi/blocos
    def on_button_release(self, widget, event):
        
        if self.clicked:
            self.arrow_mark_dirty()
            self.clicked.brelease( Vector(event.x, event.y) )
            self.arrow_mark_dirty()

        if self.selectrect_on == True:
            
            if self.selectrect.w > 0 and self.selectrect.h > 0:
                self.selectrect_mark_dirty()
                
                collide_pix = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, self.selectrect.w, self.selectrect.h )
                collide_pix.fill( 0x00000000 )
                collide_pix = collide_pix.add_alpha(False, chr(255), chr(255), chr(255) )
                
                group = set()
                for block in self.get_children():
                    if self.selectrect.pos_inside( block.get_position() ) or collide_pixbuf(block.get_x(), block.get_y(), block.get_image()[0], self.selectrect.x, self.selectrect.y, collide_pix):
                        group.add( block )
                
                self.unselect( self.get_children() )
                self.select( group )
                self.set_group( self.clicked )
                
            self.selectrect_on = False
            
        self.get_toplevel().window.set_cursor(None)
        self.set_adjustment()
コード例 #3
0
ファイル: container.py プロジェクト: yantrabuddhi/blocos
 def paste(self):
     block = None
     cpblocks = []
     
     cpblocks = self.copy_group( self.buffer )
     
     for block in cpblocks:
         block.set_position( block.get_position() + Vector(20, 20) )
         block.put_aux( self, block.get_x(), block.get_y() )
         
     self.buffer = cpblocks
     self.unselect( self.get_children() )
     self.select( self.buffer )
     self.set_group( block )
     self.sort_blocks()