mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-01 01:20:25 +00:00
Remove pimpl idiom from PixelsMovement class as it is used in just one file.
This commit is contained in:
parent
aedaf7e5b8
commit
d82507df9a
@ -18,32 +18,20 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "widgets/editor/pixels_movement.h"
|
||||
|
||||
#include "app.h"
|
||||
#include "document.h"
|
||||
#include "document_wrappers.h"
|
||||
#include "modules/gui.h"
|
||||
#include "raster/cel.h"
|
||||
#include "raster/image.h"
|
||||
#include "raster/mask.h"
|
||||
#include "raster/sprite.h"
|
||||
#include "undo_transaction.h"
|
||||
#include "util/expand_cel_canvas.h"
|
||||
#include "widgets/editor/pixels_movement.h"
|
||||
|
||||
using namespace gfx;
|
||||
|
||||
class PixelsMovementImpl
|
||||
{
|
||||
const DocumentReader m_documentReader;
|
||||
Sprite* m_sprite;
|
||||
UndoTransaction m_undoTransaction;
|
||||
int m_initial_x, m_initial_y;
|
||||
int m_catch_x, m_catch_y;
|
||||
bool m_firstDrop;
|
||||
bool m_isDragging;
|
||||
|
||||
public:
|
||||
PixelsMovementImpl(Document* document, Sprite* sprite, const Image* moveThis, int initial_x, int initial_y, int opacity)
|
||||
PixelsMovement::PixelsMovement(Document* document, Sprite* sprite, const Image* moveThis, int initial_x, int initial_y, int opacity)
|
||||
: m_documentReader(document)
|
||||
, m_sprite(sprite)
|
||||
, m_undoTransaction(document, "Pixels Movement")
|
||||
@ -51,30 +39,30 @@ public:
|
||||
, m_initial_y(initial_y)
|
||||
, m_firstDrop(true)
|
||||
, m_isDragging(false)
|
||||
{
|
||||
{
|
||||
DocumentWriter documentWriter(m_documentReader);
|
||||
documentWriter->prepareExtraCel(initial_x, initial_y, moveThis->w, moveThis->h, opacity);
|
||||
|
||||
Image* extraImage = documentWriter->getExtraCelImage();
|
||||
image_copy(extraImage, moveThis, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
~PixelsMovementImpl()
|
||||
{
|
||||
}
|
||||
PixelsMovement::~PixelsMovement()
|
||||
{
|
||||
}
|
||||
|
||||
void cutMask()
|
||||
{
|
||||
void PixelsMovement::cutMask()
|
||||
{
|
||||
{
|
||||
DocumentWriter documentWriter(m_documentReader);
|
||||
m_undoTransaction.clearMask(app_get_color_to_clear_layer(m_sprite->getCurrentLayer()));
|
||||
}
|
||||
|
||||
copyMask();
|
||||
}
|
||||
}
|
||||
|
||||
void copyMask()
|
||||
{
|
||||
void PixelsMovement::copyMask()
|
||||
{
|
||||
// Hide the mask (do not deselect it, it will be moved them using m_undoTransaction.setMaskPosition)
|
||||
Mask emptyMask;
|
||||
{
|
||||
@ -83,17 +71,17 @@ public:
|
||||
}
|
||||
|
||||
update_screen_for_document(m_documentReader);
|
||||
}
|
||||
}
|
||||
|
||||
void catchImage(int x, int y)
|
||||
{
|
||||
void PixelsMovement::catchImage(int x, int y)
|
||||
{
|
||||
m_catch_x = x;
|
||||
m_catch_y = y;
|
||||
m_isDragging = true;
|
||||
}
|
||||
}
|
||||
|
||||
void catchImageAgain(int x, int y)
|
||||
{
|
||||
void PixelsMovement::catchImageAgain(int x, int y)
|
||||
{
|
||||
// Create a new UndoTransaction to move the pixels to other position
|
||||
const Cel* cel = m_documentReader->getExtraCel();
|
||||
m_initial_x = cel->getX();
|
||||
@ -111,10 +99,10 @@ public:
|
||||
}
|
||||
|
||||
update_screen_for_document(m_documentReader);
|
||||
}
|
||||
}
|
||||
|
||||
Rect moveImage(int x, int y)
|
||||
{
|
||||
Rect PixelsMovement::moveImage(int x, int y)
|
||||
{
|
||||
DocumentWriter documentWriter(m_documentReader);
|
||||
Cel* cel = documentWriter->getExtraCel();
|
||||
Image* image = documentWriter->getExtraCelImage();
|
||||
@ -143,10 +131,10 @@ public:
|
||||
return Rect(MIN(x1, u1), MIN(y1, v1),
|
||||
MAX(x2, u2) - MIN(x1, u1) + 1,
|
||||
MAX(y2, v2) - MIN(y1, v1) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
void dropImageTemporarily()
|
||||
{
|
||||
void PixelsMovement::dropImageTemporarily()
|
||||
{
|
||||
m_isDragging = false;
|
||||
|
||||
const Cel* cel = m_documentReader->getExtraCel();
|
||||
@ -167,10 +155,10 @@ public:
|
||||
}
|
||||
|
||||
update_screen_for_document(m_documentReader);
|
||||
}
|
||||
}
|
||||
|
||||
void dropImage()
|
||||
{
|
||||
void PixelsMovement::dropImage()
|
||||
{
|
||||
m_isDragging = false;
|
||||
|
||||
const Cel* cel = m_documentReader->getExtraCel();
|
||||
@ -195,15 +183,15 @@ public:
|
||||
|
||||
documentWriter->destroyExtraCel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool isDragging()
|
||||
{
|
||||
bool PixelsMovement::isDragging()
|
||||
{
|
||||
return m_isDragging;
|
||||
}
|
||||
}
|
||||
|
||||
Rect getImageBounds()
|
||||
{
|
||||
Rect PixelsMovement::getImageBounds()
|
||||
{
|
||||
const Cel* cel = m_documentReader->getExtraCel();
|
||||
const Image* image = m_documentReader->getExtraCelImage();
|
||||
|
||||
@ -211,10 +199,10 @@ public:
|
||||
ASSERT(image != NULL);
|
||||
|
||||
return Rect(cel->getX(), cel->getY(), image->w, image->h);
|
||||
}
|
||||
}
|
||||
|
||||
void setMaskColor(uint32_t mask_color)
|
||||
{
|
||||
void PixelsMovement::setMaskColor(uint32_t mask_color)
|
||||
{
|
||||
{
|
||||
DocumentWriter documentWriter(m_documentReader);
|
||||
Image* image = documentWriter->getExtraCelImage();
|
||||
@ -225,69 +213,4 @@ public:
|
||||
}
|
||||
|
||||
update_screen_for_document(m_documentReader);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// PixelsMovement
|
||||
|
||||
PixelsMovement::PixelsMovement(Document* document, Sprite* sprite, const Image* moveThis, int x, int y, int opacity)
|
||||
{
|
||||
m_impl = new PixelsMovementImpl(document, sprite, moveThis, x, y, opacity);
|
||||
}
|
||||
|
||||
PixelsMovement::~PixelsMovement()
|
||||
{
|
||||
delete m_impl;
|
||||
}
|
||||
|
||||
void PixelsMovement::cutMask()
|
||||
{
|
||||
m_impl->cutMask();
|
||||
}
|
||||
|
||||
void PixelsMovement::copyMask()
|
||||
{
|
||||
m_impl->copyMask();
|
||||
}
|
||||
|
||||
void PixelsMovement::catchImage(int x, int y)
|
||||
{
|
||||
m_impl->catchImage(x, y);
|
||||
}
|
||||
|
||||
void PixelsMovement::catchImageAgain(int x, int y)
|
||||
{
|
||||
return m_impl->catchImageAgain(x, y);
|
||||
}
|
||||
|
||||
Rect PixelsMovement::moveImage(int x, int y)
|
||||
{
|
||||
return m_impl->moveImage(x, y);
|
||||
}
|
||||
|
||||
void PixelsMovement::dropImageTemporarily()
|
||||
{
|
||||
return m_impl->dropImageTemporarily();
|
||||
}
|
||||
|
||||
void PixelsMovement::dropImage()
|
||||
{
|
||||
m_impl->dropImage();
|
||||
}
|
||||
|
||||
bool PixelsMovement::isDragging()
|
||||
{
|
||||
return m_impl->isDragging();
|
||||
}
|
||||
|
||||
Rect PixelsMovement::getImageBounds()
|
||||
{
|
||||
return m_impl->getImageBounds();
|
||||
}
|
||||
|
||||
void PixelsMovement::setMaskColor(uint32_t mask_color)
|
||||
{
|
||||
m_impl->setMaskColor(mask_color);
|
||||
}
|
||||
|
@ -19,6 +19,9 @@
|
||||
#ifndef WIDGETS_EDITOR_PIXELS_MOVEMENT_H_INCLUDED
|
||||
#define WIDGETS_EDITOR_PIXELS_MOVEMENT_H_INCLUDED
|
||||
|
||||
#include "document_wrappers.h"
|
||||
#include "undo_transaction.h"
|
||||
|
||||
class Document;
|
||||
class Image;
|
||||
class Sprite;
|
||||
@ -34,7 +37,12 @@ public:
|
||||
void copyMask();
|
||||
void catchImage(int x, int y);
|
||||
void catchImageAgain(int x, int y);
|
||||
|
||||
// Moves the image to the new position (relative to the start
|
||||
// position given in the ctor). Returns the rectangle that should be
|
||||
// redrawn.
|
||||
gfx::Rect moveImage(int x, int y);
|
||||
|
||||
void dropImageTemporarily();
|
||||
void dropImage();
|
||||
bool isDragging();
|
||||
@ -44,7 +52,13 @@ public:
|
||||
void setMaskColor(uint32_t mask_color);
|
||||
|
||||
private:
|
||||
class PixelsMovementImpl* m_impl;
|
||||
const DocumentReader m_documentReader;
|
||||
Sprite* m_sprite;
|
||||
UndoTransaction m_undoTransaction;
|
||||
int m_initial_x, m_initial_y;
|
||||
int m_catch_x, m_catch_y;
|
||||
bool m_firstDrop;
|
||||
bool m_isDragging;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user