mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-11 09:40:42 +00:00
Fix Preview button on filters dialog
Now unchecking the preview button will redraw the sprite editor and the color palette to show their original state.
This commit is contained in:
parent
5239db243a
commit
ade32b3247
@ -311,10 +311,8 @@ void FilterManagerImpl::flush()
|
||||
Editor* editor = current_editor;
|
||||
|
||||
// Redraw the color palette
|
||||
if (m_nextRowToFlush == 0 && paletteHasChanged()) {
|
||||
set_current_palette(getNewPalette(), false);
|
||||
ColorBar::instance()->invalidate();
|
||||
}
|
||||
if (m_nextRowToFlush == 0 && paletteHasChanged())
|
||||
redrawColorPalette();
|
||||
|
||||
// We expand the region one pixel at the top and bottom of the
|
||||
// region [m_row,m_nextRowToFlush) to be updated on the screen to
|
||||
@ -342,6 +340,17 @@ void FilterManagerImpl::flush()
|
||||
}
|
||||
}
|
||||
|
||||
void FilterManagerImpl::disablePreview()
|
||||
{
|
||||
current_editor->invalidate();
|
||||
|
||||
// Redraw the color bar in case the filter modified the palette.
|
||||
if (paletteHasChanged()) {
|
||||
restoreSpritePalette();
|
||||
redrawColorPalette();
|
||||
}
|
||||
}
|
||||
|
||||
const void* FilterManagerImpl::getSourceAddress()
|
||||
{
|
||||
return m_src->getPixelAddress(m_bounds.x, m_bounds.y+m_row);
|
||||
@ -453,6 +462,12 @@ void FilterManagerImpl::restoreSpritePalette()
|
||||
m_site.sprite()->setPalette(m_oldPalette.get(), false);
|
||||
}
|
||||
|
||||
void FilterManagerImpl::redrawColorPalette()
|
||||
{
|
||||
set_current_palette(getNewPalette(), false);
|
||||
ColorBar::instance()->invalidate();
|
||||
}
|
||||
|
||||
bool FilterManagerImpl::isMaskActive() const
|
||||
{
|
||||
return static_cast<const app::Document*>(m_site.document())
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -96,6 +96,8 @@ namespace app {
|
||||
// Updates the current editor to show the progress of the preview.
|
||||
void flush();
|
||||
|
||||
void disablePreview();
|
||||
|
||||
// FilterManager implementation
|
||||
const void* getSourceAddress() override;
|
||||
void* getDestinationAddress() override;
|
||||
@ -120,8 +122,12 @@ namespace app {
|
||||
void apply();
|
||||
void applyToCel(doc::Cel* cel);
|
||||
bool updateBounds(doc::Mask* mask);
|
||||
|
||||
// Returns true if the palette was changed (true when the filter
|
||||
// modifies the palette).
|
||||
bool paletteHasChanged();
|
||||
void restoreSpritePalette();
|
||||
void redrawColorPalette();
|
||||
|
||||
Context* m_context;
|
||||
doc::Site m_site;
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -40,6 +40,21 @@ FilterPreview::~FilterPreview()
|
||||
stop();
|
||||
}
|
||||
|
||||
void FilterPreview::setEnablePreview(bool state)
|
||||
{
|
||||
if (state) {
|
||||
current_editor->renderEngine().setPreviewImage(
|
||||
m_filterMgr->layer(),
|
||||
m_filterMgr->frame(),
|
||||
m_filterMgr->destinationImage(),
|
||||
m_filterMgr->position(),
|
||||
static_cast<doc::LayerImage*>(m_filterMgr->layer())->blendMode());
|
||||
}
|
||||
else {
|
||||
current_editor->renderEngine().removePreviewImage();
|
||||
}
|
||||
}
|
||||
|
||||
void FilterPreview::stop()
|
||||
{
|
||||
{
|
||||
@ -77,16 +92,11 @@ bool FilterPreview::onProcessMessage(Message* msg)
|
||||
switch (msg->type()) {
|
||||
|
||||
case kOpenMessage:
|
||||
current_editor->renderEngine().setPreviewImage(
|
||||
m_filterMgr->layer(),
|
||||
m_filterMgr->frame(),
|
||||
m_filterMgr->destinationImage(),
|
||||
m_filterMgr->position(),
|
||||
static_cast<doc::LayerImage*>(m_filterMgr->layer())->blendMode());
|
||||
setEnablePreview(true);
|
||||
break;
|
||||
|
||||
case kCloseMessage:
|
||||
current_editor->renderEngine().removePreviewImage();
|
||||
setEnablePreview(false);
|
||||
|
||||
// Stop the preview timer.
|
||||
m_timer.stop();
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -24,6 +24,8 @@ namespace app {
|
||||
FilterPreview(FilterManagerImpl* filterMgr);
|
||||
~FilterPreview();
|
||||
|
||||
void setEnablePreview(bool state);
|
||||
|
||||
void stop();
|
||||
void restartPreview();
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -10,11 +10,13 @@
|
||||
|
||||
#include "app/commands/filters/filter_window.h"
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "app/commands/filters/filter_manager_impl.h"
|
||||
#include "app/commands/filters/filter_worker.h"
|
||||
#include "app/ini_file.h"
|
||||
#include "app/modules/editors.h"
|
||||
#include "app/modules/gui.h"
|
||||
#include "app/ui/editor/editor.h"
|
||||
#include "base/bind.h"
|
||||
|
||||
namespace app {
|
||||
|
||||
@ -106,7 +108,7 @@ bool FilterWindow::doModal()
|
||||
|
||||
// Did the user press OK?
|
||||
if (closer() == &m_okButton) {
|
||||
m_preview.stop();
|
||||
stopPreview();
|
||||
|
||||
// Apply the filter in background
|
||||
start_filter_worker(m_filterMgr);
|
||||
@ -121,8 +123,13 @@ bool FilterWindow::doModal()
|
||||
|
||||
void FilterWindow::restartPreview()
|
||||
{
|
||||
if (m_showPreview.isSelected())
|
||||
bool state = m_showPreview.isSelected();
|
||||
m_preview.setEnablePreview(state);
|
||||
|
||||
if (state)
|
||||
m_preview.restartPreview();
|
||||
else
|
||||
stopPreview();
|
||||
}
|
||||
|
||||
void FilterWindow::setNewTarget(Target target)
|
||||
@ -146,6 +153,11 @@ void FilterWindow::onCancel(Event& ev)
|
||||
void FilterWindow::onShowPreview(Event& ev)
|
||||
{
|
||||
restartPreview();
|
||||
|
||||
// If the preview was disabled just redraw the current editor in its
|
||||
// original state.
|
||||
if (!m_showPreview.isSelected())
|
||||
m_filterMgr->disablePreview();
|
||||
}
|
||||
|
||||
// Called when the user changes the target-buttons.
|
||||
|
Loading…
x
Reference in New Issue
Block a user