mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-06 03:39:51 +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_observer.h"
|
||||
#include "app/modules/gui.h"
|
||||
#include "app/modules/palettes.h"
|
||||
#include "base/bind.h"
|
||||
#include "doc/context_observer.h"
|
||||
#include "doc/documents_observer.h"
|
||||
@ -65,6 +66,8 @@ private:
|
||||
m_ctx->addObserver(this);
|
||||
m_ctx->documents().addObserver(this);
|
||||
if (m_ctx->activeDocument()) {
|
||||
m_frame = m_ctx->activeSite().frame();
|
||||
|
||||
attachDocument(
|
||||
static_cast<app::Document*>(m_ctx->activeDocument()));
|
||||
}
|
||||
@ -92,6 +95,11 @@ private:
|
||||
DocumentWriter writer(m_document, 100);
|
||||
m_document->undoHistory()->moveToState(item->state());
|
||||
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();
|
||||
}
|
||||
catch (const std::exception& ex) {
|
||||
@ -103,6 +111,8 @@ private:
|
||||
|
||||
// ContextObserver
|
||||
void onActiveSiteChange(const doc::Site& site) override {
|
||||
m_frame = site.frame();
|
||||
|
||||
if (m_document == site.document())
|
||||
return;
|
||||
|
||||
@ -205,6 +215,7 @@ private:
|
||||
|
||||
Context* m_ctx;
|
||||
app::Document* m_document;
|
||||
doc::frame_t m_frame;
|
||||
};
|
||||
|
||||
class UndoHistoryCommand : public Command {
|
||||
|
@ -349,11 +349,24 @@ void ColorBar::setPaletteEditorButtonState(bool state)
|
||||
void ColorBar::onActiveSiteChange(const doc::Site& site)
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
void ColorBar::onGeneralUpdate(doc::DocumentEvent& ev)
|
||||
{
|
||||
// TODO Observe palette changes only
|
||||
invalidate();
|
||||
}
|
||||
|
||||
void ColorBar::onAppPaletteChange()
|
||||
{
|
||||
fixColorIndex(m_fgColor);
|
||||
|
@ -18,6 +18,8 @@
|
||||
#include "base/signal.h"
|
||||
#include "base/unique_ptr.h"
|
||||
#include "doc/context_observer.h"
|
||||
#include "doc/document_observer.h"
|
||||
#include "doc/documents_observer.h"
|
||||
#include "doc/pixel_format.h"
|
||||
#include "doc/sort_palette.h"
|
||||
#include "ui/box.h"
|
||||
@ -39,6 +41,7 @@ namespace app {
|
||||
class ColorBar : public ui::Box
|
||||
, public PaletteViewDelegate
|
||||
, public doc::ContextObserver
|
||||
, public doc::DocumentObserver
|
||||
, public app::InputChainElement {
|
||||
static ColorBar* m_instance;
|
||||
public:
|
||||
@ -72,6 +75,9 @@ namespace app {
|
||||
// ContextObserver impl
|
||||
void onActiveSiteChange(const doc::Site& site) override;
|
||||
|
||||
// DocumentObserver impl
|
||||
void onGeneralUpdate(doc::DocumentEvent& ev) override;
|
||||
|
||||
// InputChainElement impl
|
||||
void onNewInputPriority(InputChainElement* element) override;
|
||||
bool onCanCut(Context* ctx) override;
|
||||
@ -150,7 +156,7 @@ namespace app {
|
||||
bool m_lock;
|
||||
bool m_syncingWithPref;
|
||||
base::UniquePtr<doc::Palette> m_oldPalette;
|
||||
const doc::Document* m_lastDocument;
|
||||
doc::Document* m_lastDocument;
|
||||
bool m_ascending;
|
||||
base::ScopedConnection m_beforeCmdConn;
|
||||
base::ScopedConnection m_afterCmdConn;
|
||||
|
Loading…
x
Reference in New Issue
Block a user