mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-09 18:44:46 +00:00
Minor refactor adding ToolLoop::onSliceRect()
This commit is contained in:
parent
951fb7c357
commit
40957c196f
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2018 Igara Studio S.A.
|
// Copyright (C) 2018-2019 Igara Studio S.A.
|
||||||
// Copyright (C) 2001-2018 David Capello
|
// Copyright (C) 2001-2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
@ -14,7 +14,6 @@
|
|||||||
#include "app/doc_undo.h"
|
#include "app/doc_undo.h"
|
||||||
#include "app/tools/pick_ink.h"
|
#include "app/tools/pick_ink.h"
|
||||||
#include "doc/mask.h"
|
#include "doc/mask.h"
|
||||||
#include "doc/slice.h"
|
|
||||||
#include "gfx/region.h"
|
#include "gfx/region.h"
|
||||||
|
|
||||||
namespace app {
|
namespace app {
|
||||||
@ -243,11 +242,8 @@ public:
|
|||||||
if (state) {
|
if (state) {
|
||||||
m_maxBounds = gfx::Rect(0, 0, 0, 0);
|
m_maxBounds = gfx::Rect(0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
else if (loop->getMouseButton() == ToolLoop::Left) {
|
else {
|
||||||
Slice* slice = new Slice;
|
loop->onSliceRect(m_maxBounds);
|
||||||
SliceKey key(m_maxBounds);
|
|
||||||
slice->insert(loop->getFrame(), key);
|
|
||||||
loop->addSlice(slice);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -127,9 +127,6 @@ namespace app {
|
|||||||
virtual Mask* getMask() = 0;
|
virtual Mask* getMask() = 0;
|
||||||
virtual void setMask(Mask* newMask) = 0;
|
virtual void setMask(Mask* newMask) = 0;
|
||||||
|
|
||||||
// Adds a new slice (only for slice ink)
|
|
||||||
virtual void addSlice(doc::Slice* newSlice) = 0;
|
|
||||||
|
|
||||||
// Gets mask X,Y origin coordinates
|
// Gets mask X,Y origin coordinates
|
||||||
virtual gfx::Point getMaskOrigin() = 0;
|
virtual gfx::Point getMaskOrigin() = 0;
|
||||||
|
|
||||||
@ -236,6 +233,9 @@ namespace app {
|
|||||||
virtual render::DitheringMatrix getDitheringMatrix() = 0;
|
virtual render::DitheringMatrix getDitheringMatrix() = 0;
|
||||||
virtual render::DitheringAlgorithmBase* getDitheringAlgorithm() = 0;
|
virtual render::DitheringAlgorithmBase* getDitheringAlgorithm() = 0;
|
||||||
virtual render::GradientType getGradientType() = 0;
|
virtual render::GradientType getGradientType() = 0;
|
||||||
|
|
||||||
|
// Called when the user release the mouse on SliceInk
|
||||||
|
virtual void onSliceRect(const gfx::Rect& bounds) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace tools
|
} // namespace tools
|
||||||
|
@ -343,6 +343,9 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void onSliceRect(const gfx::Rect& bounds) override { }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
@ -568,16 +571,6 @@ public:
|
|||||||
void setMask(Mask* newMask) override {
|
void setMask(Mask* newMask) override {
|
||||||
m_transaction.execute(new cmd::SetMask(m_document, newMask));
|
m_transaction.execute(new cmd::SetMask(m_document, newMask));
|
||||||
}
|
}
|
||||||
void addSlice(Slice* newSlice) override {
|
|
||||||
auto color = Preferences::instance().slices.defaultColor();
|
|
||||||
newSlice->userData().setColor(
|
|
||||||
doc::rgba(color.getRed(),
|
|
||||||
color.getGreen(),
|
|
||||||
color.getBlue(),
|
|
||||||
color.getAlpha()));
|
|
||||||
|
|
||||||
m_transaction.execute(new cmd::AddSlice(m_sprite, newSlice));
|
|
||||||
}
|
|
||||||
gfx::Point getMaskOrigin() override { return m_maskOrigin; }
|
gfx::Point getMaskOrigin() override { return m_maskOrigin; }
|
||||||
bool getFilled() override { return m_filled; }
|
bool getFilled() override { return m_filled; }
|
||||||
bool getPreviewFilled() override { return m_previewFilled; }
|
bool getPreviewFilled() override { return m_previewFilled; }
|
||||||
@ -587,6 +580,23 @@ public:
|
|||||||
void cancel() override { m_canceled = true; }
|
void cancel() override { m_canceled = true; }
|
||||||
bool isCanceled() override { return m_canceled; }
|
bool isCanceled() override { return m_canceled; }
|
||||||
|
|
||||||
|
void onSliceRect(const gfx::Rect& bounds) override {
|
||||||
|
if (getMouseButton() == ToolLoop::Left) {
|
||||||
|
Slice* slice = new Slice;
|
||||||
|
SliceKey key(bounds);
|
||||||
|
slice->insert(getFrame(), key);
|
||||||
|
|
||||||
|
auto color = Preferences::instance().slices.defaultColor();
|
||||||
|
slice->userData().setColor(
|
||||||
|
doc::rgba(color.getRed(),
|
||||||
|
color.getGreen(),
|
||||||
|
color.getBlue(),
|
||||||
|
color.getAlpha()));
|
||||||
|
|
||||||
|
m_transaction.execute(new cmd::AddSlice(m_sprite, slice));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef ENABLE_UI
|
#ifdef ENABLE_UI
|
||||||
@ -776,7 +786,6 @@ public:
|
|||||||
bool useMask() override { return false; }
|
bool useMask() override { return false; }
|
||||||
Mask* getMask() override { return nullptr; }
|
Mask* getMask() override { return nullptr; }
|
||||||
void setMask(Mask* newMask) override { }
|
void setMask(Mask* newMask) override { }
|
||||||
void addSlice(Slice* newSlice) override { }
|
|
||||||
gfx::Point getMaskOrigin() override { return gfx::Point(0, 0); }
|
gfx::Point getMaskOrigin() override { return gfx::Point(0, 0); }
|
||||||
bool getFilled() override { return false; }
|
bool getFilled() override { return false; }
|
||||||
bool getPreviewFilled() override { return false; }
|
bool getPreviewFilled() override { return false; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user