| 50 | } |
| 51 | |
| 52 | PixelsMovement::PixelsMovement( |
| 53 | Context* context, |
| 54 | Site site, |
| 55 | const Image* moveThis, |
| 56 | const Mask* mask, |
| 57 | const char* operationName) |
| 58 | : m_reader(context) |
| 59 | , m_site(site) |
| 60 | , m_document(static_cast<app::Document*>(site.document())) |
| 61 | , m_sprite(site.sprite()) |
| 62 | , m_layer(site.layer()) |
| 63 | , m_transaction(context, operationName) |
| 64 | , m_setMaskCmd(nullptr) |
| 65 | , m_isDragging(false) |
| 66 | , m_adjustPivot(false) |
| 67 | , m_handle(NoHandle) |
| 68 | , m_originalImage(Image::createCopy(moveThis)) |
| 69 | , m_opaque(false) |
| 70 | , m_maskColor(m_sprite->transparentColor()) |
| 71 | { |
| 72 | Transformation transform(mask->bounds()); |
| 73 | set_pivot_from_preferences(transform); |
| 74 | |
| 75 | m_initialData = transform; |
| 76 | m_currentData = transform; |
| 77 | |
| 78 | m_initialMask = new Mask(*mask); |
| 79 | m_currentMask = new Mask(*mask); |
| 80 | |
| 81 | m_pivotVisConn = |
| 82 | Preferences::instance().selection.pivotVisibility.AfterChange.connect( |
| 83 | base::Bind<void>(&PixelsMovement::onPivotChange, this)); |
| 84 | m_pivotPosConn = |
| 85 | Preferences::instance().selection.pivotPosition.AfterChange.connect( |
| 86 | base::Bind<void>(&PixelsMovement::onPivotChange, this)); |
| 87 | m_rotAlgoConn = |
| 88 | Preferences::instance().selection.rotationAlgorithm.AfterChange.connect( |
| 89 | base::Bind<void>(&PixelsMovement::onRotationAlgorithmChange, this)); |
| 90 | |
| 91 | // The extra cel must be null, because if it's not null, it means |
| 92 | // that someone else is using it (e.g. the editor brush preview), |
| 93 | // and its owner could destroy our new "extra cel". |
| 94 | ASSERT(!m_document->extraCel()); |
| 95 | redrawExtraImage(); |
| 96 | redrawCurrentMask(); |
| 97 | |
| 98 | // If the mask isn't in the document (e.g. it's from Paste command), |
| 99 | // we've to replace the document mask and generate its boundaries. |
| 100 | // |
| 101 | // This is really tricky. PixelsMovement is used in two situations: |
| 102 | // 1) When the current selection is transformed, and |
| 103 | // 2) when the user pastes the clipboard content. |
| 104 | // |
| 105 | // In the first case, the current document selection is used. And a |
| 106 | // cutMask() command could be called after PixelsMovement ctor. We |
| 107 | // need the following stack of Cmd instances in the Transaction: |
| 108 | // - cmd::ClearMask: clears the old mask) |
| 109 | // - cmd::SetMask (m_setMaskCmd): replaces the old mask with a new mask |
nothing calls this directly
no test coverage detected