Preview the modified image for brush slots that don't save image colors

This is to show the brush image with the new fg color in the brush
popup instead of the original image when image colors shouldn't be
preserved for that specific slot.
master
David Capello 2022-07-15 12:49:48 -03:00
parent c6e3ca0d8b
commit 7e19592470
2 changed files with 12 additions and 5 deletions

View File

@ -79,7 +79,9 @@ public:
, m_slot(slot) {
if (m_brush.hasBrush()) {
SkinPartPtr icon(new SkinPart);
icon->setBitmap(0, BrushPopup::createSurfaceForBrush(m_brush.brush()));
icon->setBitmap(0, BrushPopup::createSurfaceForBrush(
m_brush.brush(),
m_brush.hasFlag(BrushSlot::Flags::ImageColor)));
setIcon(icon);
}
}
@ -445,7 +447,8 @@ void BrushPopup::onBrushChanges()
}
// static
os::SurfaceRef BrushPopup::createSurfaceForBrush(const BrushRef& origBrush)
os::SurfaceRef BrushPopup::createSurfaceForBrush(const BrushRef& origBrush,
const bool useOriginalImage)
{
Image* image = nullptr;
BrushRef brush = origBrush;
@ -456,7 +459,10 @@ os::SurfaceRef BrushPopup::createSurfaceForBrush(const BrushRef& origBrush)
}
// Show the original image in the popup (without the image colors
// modified if there were some modification).
image = brush->originalImage();
if (useOriginalImage)
image = brush->originalImage();
else
image = brush->image();
}
os::SurfaceRef surface = os::instance()->makeRgbaSurface(

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018-2020 Igara Studio S.A.
// Copyright (C) 2018-2022 Igara Studio S.A.
// Copyright (C) 2001-2015 David Capello
//
// This program is distributed under the terms of
@ -23,7 +23,8 @@ namespace app {
void setBrush(doc::Brush* brush);
void regenerate(const gfx::Rect& box);
static os::SurfaceRef createSurfaceForBrush(const doc::BrushRef& brush);
static os::SurfaceRef createSurfaceForBrush(const doc::BrushRef& brush,
const bool useOriginalImage = false);
private:
void onStandardBrush();