Example #1
0
    def save_snapshot(self):
        """Creates and returns a snapshot of the surface

        Snapshotting marks all the tiles of the surface as read-only,
        then just shallow-copes the tiledict. It's quick. See
        tile_request() for how new read/write tiles can be unlocked.

        """
        sshot = _SurfaceSnapshot()
        for t in itervalues(self.tiledict):
            t.readonly = True
        sshot.tiledict = self.tiledict.copy()
        return sshot
 def _delete_brush(self, b, replacement=None):
     bm = self.app.brushmanager
     for brushes in itervalues(bm.groups):
         if b in brushes:
             idx = brushes.index(b)
             if replacement:
                 brushes[idx] = replacement
             else:
                 del brushes[idx]
             bm.brushes_changed(brushes)
             assert b not in brushes, \
                 'Brush exists multiple times in the same group!'
     if not b.delete_from_disk():
         # stock brush can't be deleted
         deleted_group = brushmanager.DELETED_BRUSH_GROUP
         deleted_brushes = bm.get_group_brushes(deleted_group)
         deleted_brushes.insert(0, b)
         bm.brushes_changed(deleted_brushes)