Fix timeline re-painting issue when renaming a tag (#3242)

This commit is contained in:
David Capello 2022-04-25 13:32:16 -03:00
parent 1601f7f4b1
commit 96cb38c29d
5 changed files with 26 additions and 3 deletions

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2019-2022 Igara Studio S.A.
// Copyright (C) 2001-2015 David Capello
//
// This program is distributed under the terms of
@ -11,7 +11,11 @@
#include "app/cmd/set_tag_name.h"
#include "app/doc.h"
#include "app/doc_event.h"
#include "doc/sprite.h"
#include "doc/tag.h"
#include "doc/tags.h"
namespace app {
namespace cmd {
@ -35,5 +39,16 @@ void SetTagName::onUndo()
tag()->incrementVersion();
}
void SetTagName::onFireNotifications()
{
Tag* tag = this->tag();
Sprite* sprite = tag->owner()->sprite();
Doc* doc = static_cast<Doc*>(sprite->document());
DocEvent ev(doc);
ev.sprite(sprite);
ev.tag(tag);
doc->notify_observers<DocEvent&>(&DocObserver::onTagRename, ev);
}
} // namespace cmd
} // namespace app

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2019-2022 Igara Studio S.A.
// Copyright (C) 2001-2015 David Capello
//
// This program is distributed under the terms of
@ -26,6 +26,7 @@ namespace cmd {
protected:
void onExecute() override;
void onUndo() override;
void onFireNotifications() override;
size_t onMemSize() const override {
return sizeof(*this);
}

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018-2021 Igara Studio S.A.
// Copyright (C) 2018-2022 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -79,6 +79,7 @@ namespace app {
// Tags
virtual void onTagChange(DocEvent& ev) { }
virtual void onTagRename(DocEvent& ev) { }
// Slices
virtual void onSliceNameChange(DocEvent& ev) { }

View File

@ -1917,6 +1917,11 @@ void Timeline::onRemoveTag(DocEvent& ev)
onAddTag(ev);
}
void Timeline::onTagRename(DocEvent& ev)
{
invalidateHit(Hit(PART_TAGS));
}
void Timeline::onStateChanged(Editor* editor)
{
m_aniControls.updateUsingEditor(editor);

View File

@ -163,6 +163,7 @@ namespace app {
void onLayerNameChange(DocEvent& ev) override;
void onAddTag(DocEvent& ev) override;
void onRemoveTag(DocEvent& ev) override;
void onTagRename(DocEvent& ev) override;
// app::Context slots.
void onBeforeCommandExecution(CommandExecutionEvent& ev);