mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-04 17:40:01 +00:00
Fix mini editor animation playback when we're drawing (inside a ToolLoop)
We've to show the document's extra cel only if we are in the current layer and frame.
This commit is contained in:
parent
8b4edc2f50
commit
ccf563c4dd
@ -95,6 +95,7 @@ namespace app {
|
||||
Document* document() { return m_location.document(); }
|
||||
Sprite* sprite() { return m_location.sprite(); }
|
||||
Layer* layer() { return m_location.layer(); }
|
||||
FrameNumber frame() { return m_location.frame(); }
|
||||
Image* destinationImage() const { return m_dst; }
|
||||
|
||||
// Updates the current editor to show the progress of the preview.
|
||||
|
@ -77,11 +77,12 @@ bool FilterPreview::onProcessMessage(Message* msg)
|
||||
case kOpenMessage:
|
||||
RenderEngine::setPreviewImage(
|
||||
m_filterMgr->layer(),
|
||||
m_filterMgr->frame(),
|
||||
m_filterMgr->destinationImage());
|
||||
break;
|
||||
|
||||
case kCloseMessage:
|
||||
RenderEngine::setPreviewImage(NULL, NULL);
|
||||
RenderEngine::setPreviewImage(NULL, FrameNumber(0), NULL);
|
||||
|
||||
// Stop the preview timer.
|
||||
m_timer.stop();
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "app/tools/trace_policy.h"
|
||||
#include "filters/tiled_mode.h"
|
||||
#include "gfx/point.h"
|
||||
#include "raster/frame_number.h"
|
||||
|
||||
namespace gfx {
|
||||
class Region;
|
||||
@ -82,6 +83,9 @@ namespace app {
|
||||
// Returns the layer that will be modified if the tool paints
|
||||
virtual Layer* getLayer() = 0;
|
||||
|
||||
// Returns the frame where we're paiting
|
||||
virtual FrameNumber getFrame() = 0;
|
||||
|
||||
// Should return an image where we can read pixels (readonly image)
|
||||
virtual Image* getSrcImage() = 0;
|
||||
|
||||
|
@ -74,13 +74,14 @@ void ToolLoopManager::prepareLoop(const Pointer& pointer)
|
||||
// in the tool-loop time, so we can see what we are drawing)
|
||||
RenderEngine::setPreviewImage(
|
||||
m_toolLoop->getLayer(),
|
||||
m_toolLoop->getFrame(),
|
||||
m_toolLoop->getDstImage());
|
||||
}
|
||||
|
||||
void ToolLoopManager::releaseLoop(const Pointer& pointer)
|
||||
{
|
||||
// No more preview image
|
||||
RenderEngine::setPreviewImage(NULL, NULL);
|
||||
RenderEngine::setPreviewImage(NULL, FrameNumber(0), NULL);
|
||||
}
|
||||
|
||||
void ToolLoopManager::pressKey(ui::KeyScancode key)
|
||||
|
@ -684,6 +684,8 @@ void Editor::flashCurrentLayer()
|
||||
int x, y;
|
||||
const Image* src_image = loc.image(&x, &y);
|
||||
if (src_image) {
|
||||
RenderEngine::setPreviewImage(NULL, FrameNumber(0), NULL);
|
||||
|
||||
m_document->prepareExtraCel(0, 0, m_sprite->width(), m_sprite->height(), 255);
|
||||
Image* flash_image = m_document->getExtraCelImage();
|
||||
|
||||
|
@ -216,6 +216,7 @@ public:
|
||||
Document* getDocument() override { return m_document; }
|
||||
Sprite* sprite() override { return m_sprite; }
|
||||
Layer* getLayer() override { return m_layer; }
|
||||
FrameNumber getFrame() override { return m_frame; }
|
||||
Image* getSrcImage() override { return m_expandCelCanvas.getSourceCanvas(); }
|
||||
Image* getDstImage() override { return m_expandCelCanvas.getDestCanvas(); }
|
||||
RgbMap* getRgbMap() override { return m_sprite->getRgbMap(m_frame); }
|
||||
|
@ -289,6 +289,7 @@ static app::Color checked_bg_color2;
|
||||
|
||||
static int global_opacity = 255;
|
||||
static const Layer* selected_layer = NULL;
|
||||
static FrameNumber selected_frame(0);
|
||||
static Image* preview_image = NULL;
|
||||
|
||||
// static
|
||||
@ -367,9 +368,10 @@ RenderEngine::RenderEngine(const Document* document,
|
||||
}
|
||||
|
||||
// static
|
||||
void RenderEngine::setPreviewImage(const Layer* layer, Image* image)
|
||||
void RenderEngine::setPreviewImage(const Layer* layer, FrameNumber frame, Image* image)
|
||||
{
|
||||
selected_layer = layer;
|
||||
selected_frame = frame;
|
||||
preview_image = image;
|
||||
}
|
||||
|
||||
@ -586,8 +588,8 @@ void RenderEngine::renderLayer(
|
||||
Image* src_image;
|
||||
|
||||
// Is the 'preview_image' set to be used with this layer?
|
||||
if ((frame == m_currentFrame) &&
|
||||
(selected_layer == layer) &&
|
||||
if ((selected_layer == layer) &&
|
||||
(selected_frame == frame) &&
|
||||
(preview_image != NULL)) {
|
||||
src_image = preview_image;
|
||||
}
|
||||
@ -635,8 +637,9 @@ void RenderEngine::renderLayer(
|
||||
}
|
||||
|
||||
// Draw extras
|
||||
if (layer == m_currentLayer &&
|
||||
m_document->getExtraCel() != NULL) {
|
||||
if (m_document->getExtraCel() &&
|
||||
layer == m_currentLayer &&
|
||||
frame == m_currentFrame) {
|
||||
Cel* extraCel = m_document->getExtraCel();
|
||||
if (extraCel->opacity() > 0) {
|
||||
Image* extraImage = m_document->getExtraCelImage();
|
||||
|
@ -63,7 +63,7 @@ namespace app {
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Preview image
|
||||
|
||||
static void setPreviewImage(const Layer* layer, Image* drawable);
|
||||
static void setPreviewImage(const Layer* layer, FrameNumber frame, Image* drawable);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Main function used by sprite-editors to render the sprite
|
||||
|
Loading…
Reference in New Issue
Block a user