예제 #1
0
MovingPixelsState::MovingPixelsState(Editor* editor, Message* msg, Image* imge, int x, int y, int opacity)
{
  // Copy the mask to the extra cel image
  Document* document = editor->getDocument();
  Sprite* sprite = editor->getSprite();
  Image* tmpImage = NewImageFromMask(document);
  x = document->getMask()->x;
  y = document->getMask()->y;
  m_pixelsMovement = new PixelsMovement(document, sprite, tmpImage, x, y, opacity);
  delete tmpImage;

  // If the CTRL key is pressed start dragging a copy of the selection
  if (key[KEY_LCONTROL] || key[KEY_RCONTROL]) // TODO configurable
    m_pixelsMovement->copyMask();
  else
    m_pixelsMovement->cutMask();

  editor->screenToEditor(msg->mouse.x, msg->mouse.y, &x, &y);
  m_pixelsMovement->catchImage(x, y);

  // Setup mask color
  setTransparentColor(app_get_statusbar()->getTransparentColor());

  app_get_statusbar()->addListener(this);
  app_get_statusbar()->showMovePixelsOptions();

  editor->captureMouse();
}
예제 #2
0
void StandbyState::transformSelection(Editor* editor, MouseMessage* msg, HandleType handle)
{
  try {
    EditorCustomizationDelegate* customization = editor->getCustomizationDelegate();
    Document* document = editor->document();
    base::UniquePtr<Image> tmpImage(NewImageFromMask(editor->getDocumentLocation()));
    int x = document->mask()->bounds().x;
    int y = document->mask()->bounds().y;
    int opacity = 255;
    Sprite* sprite = editor->sprite();
    Layer* layer = editor->layer();
    PixelsMovementPtr pixelsMovement(
      new PixelsMovement(UIContext::instance(),
        document, sprite, layer,
        tmpImage, x, y, opacity,
        "Transformation"));

    // If the Ctrl key is pressed start dragging a copy of the selection
    if (customization && customization->isCopySelectionKeyPressed())
      pixelsMovement->copyMask();
    else
      pixelsMovement->cutMask();

    editor->setState(EditorStatePtr(new MovingPixelsState(editor, msg, pixelsMovement, handle)));
  }
  catch (const LockedDocumentException&) {
    // Other editor is locking the document.

    // TODO steal the PixelsMovement of the other editor and use it for this one.
  }
}