mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-16 14:42:44 +00:00
Redraw ColorBar when we change the active state in the Undo History window
This commit is contained in:
parent
be214b715b
commit
8996d82d21
@ -18,6 +18,7 @@
|
|||||||
#include "app/document_undo.h"
|
#include "app/document_undo.h"
|
||||||
#include "app/document_undo_observer.h"
|
#include "app/document_undo_observer.h"
|
||||||
#include "app/modules/gui.h"
|
#include "app/modules/gui.h"
|
||||||
|
#include "app/modules/palettes.h"
|
||||||
#include "base/bind.h"
|
#include "base/bind.h"
|
||||||
#include "doc/context_observer.h"
|
#include "doc/context_observer.h"
|
||||||
#include "doc/documents_observer.h"
|
#include "doc/documents_observer.h"
|
||||||
@ -65,6 +66,8 @@ private:
|
|||||||
m_ctx->addObserver(this);
|
m_ctx->addObserver(this);
|
||||||
m_ctx->documents().addObserver(this);
|
m_ctx->documents().addObserver(this);
|
||||||
if (m_ctx->activeDocument()) {
|
if (m_ctx->activeDocument()) {
|
||||||
|
m_frame = m_ctx->activeSite().frame();
|
||||||
|
|
||||||
attachDocument(
|
attachDocument(
|
||||||
static_cast<app::Document*>(m_ctx->activeDocument()));
|
static_cast<app::Document*>(m_ctx->activeDocument()));
|
||||||
}
|
}
|
||||||
@ -92,6 +95,11 @@ private:
|
|||||||
DocumentWriter writer(m_document, 100);
|
DocumentWriter writer(m_document, 100);
|
||||||
m_document->undoHistory()->moveToState(item->state());
|
m_document->undoHistory()->moveToState(item->state());
|
||||||
m_document->generateMaskBoundaries();
|
m_document->generateMaskBoundaries();
|
||||||
|
|
||||||
|
// TODO this should be an observer of the current document palette
|
||||||
|
set_current_palette(m_document->sprite()->palette(m_frame),
|
||||||
|
false);
|
||||||
|
|
||||||
m_document->notifyGeneralUpdate();
|
m_document->notifyGeneralUpdate();
|
||||||
}
|
}
|
||||||
catch (const std::exception& ex) {
|
catch (const std::exception& ex) {
|
||||||
@ -103,6 +111,8 @@ private:
|
|||||||
|
|
||||||
// ContextObserver
|
// ContextObserver
|
||||||
void onActiveSiteChange(const doc::Site& site) override {
|
void onActiveSiteChange(const doc::Site& site) override {
|
||||||
|
m_frame = site.frame();
|
||||||
|
|
||||||
if (m_document == site.document())
|
if (m_document == site.document())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -205,6 +215,7 @@ private:
|
|||||||
|
|
||||||
Context* m_ctx;
|
Context* m_ctx;
|
||||||
app::Document* m_document;
|
app::Document* m_document;
|
||||||
|
doc::frame_t m_frame;
|
||||||
};
|
};
|
||||||
|
|
||||||
class UndoHistoryCommand : public Command {
|
class UndoHistoryCommand : public Command {
|
||||||
|
@ -349,11 +349,24 @@ void ColorBar::setPaletteEditorButtonState(bool state)
|
|||||||
void ColorBar::onActiveSiteChange(const doc::Site& site)
|
void ColorBar::onActiveSiteChange(const doc::Site& site)
|
||||||
{
|
{
|
||||||
if (m_lastDocument != site.document()) {
|
if (m_lastDocument != site.document()) {
|
||||||
m_lastDocument = site.document();
|
if (m_lastDocument)
|
||||||
|
m_lastDocument->removeObserver(this);
|
||||||
|
|
||||||
|
m_lastDocument = const_cast<doc::Document*>(site.document());
|
||||||
|
|
||||||
|
if (m_lastDocument)
|
||||||
|
m_lastDocument->addObserver(this);
|
||||||
|
|
||||||
hideRemap();
|
hideRemap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ColorBar::onGeneralUpdate(doc::DocumentEvent& ev)
|
||||||
|
{
|
||||||
|
// TODO Observe palette changes only
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
void ColorBar::onAppPaletteChange()
|
void ColorBar::onAppPaletteChange()
|
||||||
{
|
{
|
||||||
fixColorIndex(m_fgColor);
|
fixColorIndex(m_fgColor);
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
#include "base/signal.h"
|
#include "base/signal.h"
|
||||||
#include "base/unique_ptr.h"
|
#include "base/unique_ptr.h"
|
||||||
#include "doc/context_observer.h"
|
#include "doc/context_observer.h"
|
||||||
|
#include "doc/document_observer.h"
|
||||||
|
#include "doc/documents_observer.h"
|
||||||
#include "doc/pixel_format.h"
|
#include "doc/pixel_format.h"
|
||||||
#include "doc/sort_palette.h"
|
#include "doc/sort_palette.h"
|
||||||
#include "ui/box.h"
|
#include "ui/box.h"
|
||||||
@ -39,6 +41,7 @@ namespace app {
|
|||||||
class ColorBar : public ui::Box
|
class ColorBar : public ui::Box
|
||||||
, public PaletteViewDelegate
|
, public PaletteViewDelegate
|
||||||
, public doc::ContextObserver
|
, public doc::ContextObserver
|
||||||
|
, public doc::DocumentObserver
|
||||||
, public app::InputChainElement {
|
, public app::InputChainElement {
|
||||||
static ColorBar* m_instance;
|
static ColorBar* m_instance;
|
||||||
public:
|
public:
|
||||||
@ -72,6 +75,9 @@ namespace app {
|
|||||||
// ContextObserver impl
|
// ContextObserver impl
|
||||||
void onActiveSiteChange(const doc::Site& site) override;
|
void onActiveSiteChange(const doc::Site& site) override;
|
||||||
|
|
||||||
|
// DocumentObserver impl
|
||||||
|
void onGeneralUpdate(doc::DocumentEvent& ev) override;
|
||||||
|
|
||||||
// InputChainElement impl
|
// InputChainElement impl
|
||||||
void onNewInputPriority(InputChainElement* element) override;
|
void onNewInputPriority(InputChainElement* element) override;
|
||||||
bool onCanCut(Context* ctx) override;
|
bool onCanCut(Context* ctx) override;
|
||||||
@ -150,7 +156,7 @@ namespace app {
|
|||||||
bool m_lock;
|
bool m_lock;
|
||||||
bool m_syncingWithPref;
|
bool m_syncingWithPref;
|
||||||
base::UniquePtr<doc::Palette> m_oldPalette;
|
base::UniquePtr<doc::Palette> m_oldPalette;
|
||||||
const doc::Document* m_lastDocument;
|
doc::Document* m_lastDocument;
|
||||||
bool m_ascending;
|
bool m_ascending;
|
||||||
base::ScopedConnection m_beforeCmdConn;
|
base::ScopedConnection m_beforeCmdConn;
|
||||||
base::ScopedConnection m_afterCmdConn;
|
base::ScopedConnection m_afterCmdConn;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user