MCPcopy Create free account
hub / github.com/LibreSprite/LibreSprite / PixelsMovement

Method PixelsMovement

src/app/ui/editor/pixels_movement.cpp:52–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50}
51
52PixelsMovement::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

Callers

nothing calls this directly

Calls 10

instanceFunction · 0.85
transparentColorMethod · 0.80
extraCelMethod · 0.80
maskMethod · 0.80
documentMethod · 0.45
spriteMethod · 0.45
layerMethod · 0.45
boundsMethod · 0.45

Tested by

no test coverage detected