Exemplo n.º 1
0
void UndoTransaction::newFrameForLayer(Layer* layer, int frame)
{
  ASSERT(layer);
  ASSERT(frame >= 0);

  switch (layer->getType()) {

    case GFXOBJ_LAYER_IMAGE:
      // displace all cels in '>=frame' to the next frame
      for (int c=m_sprite->getTotalFrames()-1; c>=frame; --c) {
        Cel* cel = static_cast<LayerImage*>(layer)->getCel(c);
        if (cel)
          setCelFramePosition(cel, cel->getFrame()+1);
      }

      copyPreviousFrame(layer, frame);
      break;

    case GFXOBJ_LAYER_FOLDER: {
      LayerIterator it = static_cast<LayerFolder*>(layer)->get_layer_begin();
      LayerIterator end = static_cast<LayerFolder*>(layer)->get_layer_end();

      for (; it != end; ++it)
        newFrameForLayer(*it, frame);
      break;
    }

  }
}
Exemplo n.º 2
0
void DocumentApi::addFrameForLayer(Layer* layer, FrameNumber frame)
{
  ASSERT(layer);
  ASSERT(frame >= 0);

  Sprite* sprite = layer->getSprite();

  switch (layer->getType()) {

    case GFXOBJ_LAYER_IMAGE:
      // Displace all cels in '>=frame' to the next frame.
      for (FrameNumber c=sprite->getLastFrame(); c>=frame; --c) {
        Cel* cel = static_cast<LayerImage*>(layer)->getCel(c);
        if (cel)
          setCelFramePosition(sprite, cel, cel->getFrame().next());
      }

      copyPreviousFrame(layer, frame);
      break;

    case GFXOBJ_LAYER_FOLDER: {
      LayerIterator it = static_cast<LayerFolder*>(layer)->getLayerBegin();
      LayerIterator end = static_cast<LayerFolder*>(layer)->getLayerEnd();

      for (; it != end; ++it)
        addFrameForLayer(*it, frame);
      break;
    }

  }
}