mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-30 06:32:42 +00:00
Delete all links after deleting the whole cel content (related to #1214)
This commit is contained in:
parent
638206becd
commit
3ee397a0ec
@ -14,6 +14,8 @@
|
||||
#include "app/cmd/remove_cel.h"
|
||||
#include "doc/algorithm/shrink_bounds.h"
|
||||
#include "doc/cel.h"
|
||||
#include "doc/layer.h"
|
||||
#include "doc/sprite.h"
|
||||
|
||||
namespace app {
|
||||
namespace cmd {
|
||||
@ -26,32 +28,21 @@ TrimCel::TrimCel(Cel* cel)
|
||||
if (algorithm::shrink_bounds(cel->image(), newBounds,
|
||||
cel->image()->maskColor())) {
|
||||
newBounds.offset(cel->position());
|
||||
m_subCmd = new cmd::CropCel(cel, newBounds);
|
||||
add(new cmd::CropCel(cel, newBounds));
|
||||
}
|
||||
else {
|
||||
m_subCmd = new cmd::RemoveCel(cel);
|
||||
// Delete the given "cel" and all its links.
|
||||
Sprite* sprite = cel->sprite();
|
||||
Layer* layer = cel->layer();
|
||||
CelData* celData = cel->dataRef().get();
|
||||
|
||||
for (frame_t fr=sprite->totalFrames()-1; fr>=0; --fr) {
|
||||
Cel* c = layer->cel(fr);
|
||||
if (c && c->dataRef().get() == celData)
|
||||
add(new cmd::RemoveCel(c));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TrimCel::~TrimCel()
|
||||
{
|
||||
delete m_subCmd;
|
||||
}
|
||||
|
||||
void TrimCel::onExecute()
|
||||
{
|
||||
m_subCmd->execute(context());
|
||||
}
|
||||
|
||||
void TrimCel::onUndo()
|
||||
{
|
||||
m_subCmd->undo();
|
||||
}
|
||||
|
||||
void TrimCel::onRedo()
|
||||
{
|
||||
m_subCmd->redo();
|
||||
}
|
||||
|
||||
} // namespace cmd
|
||||
} // namespace app
|
||||
|
@ -8,7 +8,7 @@
|
||||
#define APP_CMD_TRIM_CEL_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
#include "app/cmd.h"
|
||||
#include "app/cmd_sequence.h"
|
||||
|
||||
namespace doc {
|
||||
class Cel;
|
||||
@ -17,21 +17,9 @@ namespace doc {
|
||||
namespace app {
|
||||
namespace cmd {
|
||||
|
||||
class TrimCel : public Cmd {
|
||||
class TrimCel : public CmdSequence {
|
||||
public:
|
||||
TrimCel(doc::Cel* cel);
|
||||
~TrimCel();
|
||||
|
||||
protected:
|
||||
void onExecute() override;
|
||||
void onUndo() override;
|
||||
void onRedo() override;
|
||||
size_t onMemSize() const override {
|
||||
return sizeof(*this) + m_subCmd->memSize();
|
||||
}
|
||||
|
||||
private:
|
||||
Cmd* m_subCmd;
|
||||
};
|
||||
|
||||
} // namespace cmd
|
||||
|
Loading…
x
Reference in New Issue
Block a user