mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-29 10:20:48 +00:00
Fix useTool() with images: brushes must be created like when we use the UI, with a mask
This commit is contained in:
parent
640800259d
commit
f97d76344d
@ -12,6 +12,7 @@
|
||||
#include "app/script/luacpp.h"
|
||||
#include "doc/brush.h"
|
||||
#include "doc/image.h"
|
||||
#include "doc/mask.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@ -70,8 +71,12 @@ BrushRef Brush_new(lua_State* L, int index)
|
||||
lua_pop(L, 1);
|
||||
|
||||
brush.reset(new Brush(type, size, angle));
|
||||
if (image)
|
||||
brush->setImage(image, nullptr);
|
||||
if (image) {
|
||||
// TODO add a way to add a bitmap mask
|
||||
doc::Mask mask;
|
||||
mask.replace(image->bounds());
|
||||
brush->setImage(image, mask.bitmap());
|
||||
}
|
||||
|
||||
if (lua_getfield(L, index, "center") != LUA_TNIL) {
|
||||
gfx::Point center = convert_args_into_point(L, -1);
|
||||
|
@ -23,10 +23,14 @@
|
||||
#include "doc/image.h"
|
||||
#include "doc/primitives.h"
|
||||
#include "doc/sprite.h"
|
||||
#include "gfx/point_io.h"
|
||||
#include "gfx/rect_io.h"
|
||||
#include "gfx/region.h"
|
||||
|
||||
#include <climits>
|
||||
|
||||
#define TOOL_TRACE(...) // TRACEARGS
|
||||
|
||||
namespace app {
|
||||
namespace tools {
|
||||
|
||||
@ -71,6 +75,8 @@ void ToolLoopManager::notifyToolLoopModifiersChange()
|
||||
|
||||
void ToolLoopManager::pressButton(const Pointer& pointer)
|
||||
{
|
||||
TOOL_TRACE("ToolLoopManager::pressButton", pointer.point());
|
||||
|
||||
m_lastPointer = pointer;
|
||||
|
||||
if (isCanceled())
|
||||
@ -101,6 +107,8 @@ void ToolLoopManager::pressButton(const Pointer& pointer)
|
||||
|
||||
bool ToolLoopManager::releaseButton(const Pointer& pointer)
|
||||
{
|
||||
TOOL_TRACE("ToolLoopManager::releaseButton", pointer.point());
|
||||
|
||||
m_lastPointer = pointer;
|
||||
|
||||
if (isCanceled())
|
||||
@ -125,6 +133,8 @@ bool ToolLoopManager::releaseButton(const Pointer& pointer)
|
||||
|
||||
void ToolLoopManager::movement(const Pointer& pointer)
|
||||
{
|
||||
TOOL_TRACE("ToolLoopManager::movement", pointer.point());
|
||||
|
||||
m_lastPointer = pointer;
|
||||
|
||||
if (isCanceled())
|
||||
@ -215,6 +225,8 @@ void ToolLoopManager::doLoopStep(bool lastStep)
|
||||
|
||||
if (!m_dirtyArea.isEmpty())
|
||||
m_toolLoop->updateDirtyArea(m_dirtyArea);
|
||||
|
||||
TOOL_TRACE("ToolLoopManager::doLoopStep dirtyArea", m_dirtyArea.bounds());
|
||||
}
|
||||
|
||||
// Applies the grid settings to the specified sprite point.
|
||||
|
@ -26,6 +26,9 @@
|
||||
#include "doc/layer.h"
|
||||
#include "doc/primitives.h"
|
||||
#include "doc/sprite.h"
|
||||
#include "gfx/rect_io.h"
|
||||
|
||||
#define EXP_TRACE(...) // TRACEARGS
|
||||
|
||||
namespace {
|
||||
|
||||
@ -141,6 +144,10 @@ ExpandCelCanvas::~ExpandCelCanvas()
|
||||
|
||||
void ExpandCelCanvas::commit()
|
||||
{
|
||||
EXP_TRACE("ExpandCelCanvas::commit",
|
||||
"validSrcRegion", m_validSrcRegion.bounds(),
|
||||
"validDstRegion", m_validDstRegion.bounds());
|
||||
|
||||
ASSERT(!m_closed);
|
||||
ASSERT(!m_committed);
|
||||
|
||||
@ -204,6 +211,8 @@ void ExpandCelCanvas::commit()
|
||||
regionToPatch = &reduced;
|
||||
}
|
||||
|
||||
EXP_TRACE(" - regionToPatch", regionToPatch->bounds());
|
||||
|
||||
// Check that the region to copy or patch is not empty before we
|
||||
// create the new cmd
|
||||
if (!regionToPatch->isEmpty()) {
|
||||
@ -277,6 +286,8 @@ Image* ExpandCelCanvas::getDestCanvas()
|
||||
|
||||
void ExpandCelCanvas::validateSourceCanvas(const gfx::Region& rgn)
|
||||
{
|
||||
EXP_TRACE("ExpandCelCanvas::validateSourceCanvas", rgn.bounds());
|
||||
|
||||
getSourceCanvas();
|
||||
|
||||
gfx::Region rgnToValidate(rgn);
|
||||
@ -309,6 +320,8 @@ void ExpandCelCanvas::validateSourceCanvas(const gfx::Region& rgn)
|
||||
|
||||
void ExpandCelCanvas::validateDestCanvas(const gfx::Region& rgn)
|
||||
{
|
||||
EXP_TRACE("ExpandCelCanvas::validateDestCanvas", rgn.bounds());
|
||||
|
||||
Image* src;
|
||||
int src_x, src_y;
|
||||
if ((m_flags & NeedsSource) == NeedsSource) {
|
||||
@ -355,11 +368,14 @@ void ExpandCelCanvas::validateDestCanvas(const gfx::Region& rgn)
|
||||
|
||||
void ExpandCelCanvas::invalidateDestCanvas()
|
||||
{
|
||||
EXP_TRACE("ExpandCelCanvas::invalidateDestCanvas");
|
||||
m_validDstRegion.clear();
|
||||
}
|
||||
|
||||
void ExpandCelCanvas::invalidateDestCanvas(const gfx::Region& rgn)
|
||||
{
|
||||
EXP_TRACE("ExpandCelCanvas::invalidateDestCanvas", rgn.bounds());
|
||||
|
||||
gfx::Region rgnToInvalidate(rgn);
|
||||
rgnToInvalidate.offset(-m_bounds.origin());
|
||||
m_validDstRegion.createSubtraction(m_validDstRegion, rgnToInvalidate);
|
||||
@ -367,6 +383,8 @@ void ExpandCelCanvas::invalidateDestCanvas(const gfx::Region& rgn)
|
||||
|
||||
void ExpandCelCanvas::copyValidDestToSourceCanvas(const gfx::Region& rgn)
|
||||
{
|
||||
EXP_TRACE("ExpandCelCanvas::copyValidDestToSourceCanvas", rgn.bounds());
|
||||
|
||||
gfx::Region rgn2(rgn);
|
||||
rgn2.offset(-m_bounds.origin());
|
||||
rgn2.createIntersection(rgn2, m_validSrcRegion);
|
||||
|
Loading…
x
Reference in New Issue
Block a user