Better handling of Cel Properties for multiple cels

This commit is contained in:
David Capello 2021-06-11 11:04:52 -03:00
parent a4e7ac13c1
commit 9f300bf55d
3 changed files with 13 additions and 11 deletions

View File

@ -84,14 +84,16 @@ public:
if (m_document) if (m_document)
m_document->add_observer(this); m_document->add_observer(this);
if (countCels() > 0 && m_cel) { if (countCels() > 0) {
ui::Grid* mainGrid = g_window->propertiesGrid(); ui::Grid* mainGrid = g_window->propertiesGrid();
m_userDataView.configureAndSet(m_cel->data()->userData(), mainGrid); m_userDataView.configureAndSet(
(m_cel ? m_cel->data()->userData(): UserData()), mainGrid);
} }
else if (!m_cel) else if (!m_cel)
m_userDataView.setVisible(false, false); m_userDataView.setVisible(false, false);
g_window->remapWindow();
manager()->invalidate(); g_window->expandWindow(gfx::Size(g_window->bounds().w,
g_window->sizeHint().h));
updateFromCel(); updateFromCel();
} }
@ -220,10 +222,10 @@ private:
} }
void onToggleUserData() { void onToggleUserData() {
if (m_cel) { if (countCels() > 0) {
m_userDataView.toggleVisibility(); m_userDataView.toggleVisibility();
g_window->remapWindow(); g_window->expandWindow(gfx::Size(g_window->bounds().w,
manager()->invalidate(); g_window->sizeHint().h));
} }
} }

View File

@ -1,5 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2020 Igara Studio S.A. // Copyright (C) 2020-2021 Igara Studio S.A.
// //
// This program is distributed under the terms of // This program is distributed under the terms of
// the End-User License Agreement for Aseprite. // the End-User License Agreement for Aseprite.
@ -29,7 +29,7 @@ UserDataView::UserDataView(gen::UserData* userDataWidgetsContainer, Option<bool>
{ {
} }
void UserDataView::configureAndSet(doc::UserData& userData, ui::Grid* parent) void UserDataView::configureAndSet(const doc::UserData& userData, ui::Grid* parent)
{ {
if (!isConfigured()) { if (!isConfigured()) {
// Find the correct hspan to add to an arbitrary grid column count: // Find the correct hspan to add to an arbitrary grid column count:

View File

@ -1,5 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2020 Igara Studio S.A. // Copyright (C) 2020-2021 Igara Studio S.A.
// //
// This program is distributed under the terms of // This program is distributed under the terms of
// the End-User License Agreement for Aseprite. // the End-User License Agreement for Aseprite.
@ -24,7 +24,7 @@ namespace app {
public: public:
UserDataView(gen::UserData* userDataWidgetsContainer, Option<bool>* visibility); UserDataView(gen::UserData* userDataWidgetsContainer, Option<bool>* visibility);
void configureAndSet(doc::UserData& userData, ui::Grid* parent); void configureAndSet(const doc::UserData& userData, ui::Grid* parent);
void toggleVisibility(); void toggleVisibility();
void setVisible(bool state, bool saveAsDefault = true); void setVisible(bool state, bool saveAsDefault = true);
void freeUserDataWidgets(ui::Grid* parent); void freeUserDataWidgets(ui::Grid* parent);