Fix timeline re-painting issue when changing tag color (#3242)

This is the worst possible hack, but we're already doing this for cel
and layer color. Something to think about with #3266
This commit is contained in:
David Capello 2022-04-25 15:14:02 -03:00
parent b31affd2e8
commit c15f374690

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2019-2020 Igara Studio S.A.
// Copyright (C) 2019-2022 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -21,11 +21,12 @@
#include "app/loop_tag.h"
#include "app/tx.h"
#include "app/ui/tag_window.h"
#include "app/ui/timeline/timeline.h"
#include "base/convert_to.h"
#include "doc/anidir.h"
#include "doc/sprite.h"
#include "doc/user_data.h"
#include "doc/tag.h"
#include "doc/user_data.h"
namespace app {
@ -109,8 +110,20 @@ void FrameTagPropertiesCommand::onExecute(Context* context)
// Change user data
doc::UserData userData = window.userDataValue();
if (tag->userData() != userData)
if (tag->userData() != userData) {
// TODO Don't invalidate the whole timeline when the tag color
// change, and make this from the Timeline side listening
// DocObserver::onUserDataChange event. Anyway this is done
// in Cel properties and Layer properties dialog, so there is
// some general refactoring needed.
auto app = App::instance();
if (app && app->timeline() &&
tag->userData().color() != userData.color()) {
App::instance()->timeline()->invalidate();
}
tx(new cmd::SetUserData(tag, userData, static_cast<Doc*>(sprite->document())));
}
tx.commit();
}