This is an automated email from the git hooks/post-receive script. thansen pushed a commit to branch master in repository aseprite.
commit 08bef859e3a500b051c7f9aa615deea3376db1a9 Author: David Capello <[email protected]> Date: Thu Dec 10 18:34:25 2015 -0300 Add user data field on layers and cels --- data/skins/default/sheet.png | Bin 14034 -> 14067 bytes data/skins/default/skin.xml | 1 + data/widgets/cel_properties.xml | 5 ++++ data/widgets/layer_properties.xml | 5 ++++ src/app/CMakeLists.txt | 2 ++ src/app/cmd/set_user_data.cpp | 37 ++++++++++++++++++++++++ src/app/cmd/set_user_data.h | 45 ++++++++++++++++++++++++++++++ src/app/commands/cmd_cel_properties.cpp | 30 ++++++++++++++++++-- src/app/commands/cmd_layer_properties.cpp | 21 +++++++++++++- src/app/ui/user_data_popup.cpp | 40 ++++++++++++++++++++++++++ src/app/ui/user_data_popup.h | 25 +++++++++++++++++ src/doc/cel_data.cpp | 4 +-- src/doc/cel_data.h | 3 +- src/doc/layer.cpp | 2 +- src/doc/layer.h | 3 +- src/doc/user_data.h | 37 ++++++++++++++++++++++++ src/doc/with_user_data.h | 35 +++++++++++++++++++++++ 17 files changed, 286 insertions(+), 9 deletions(-) diff --git a/data/skins/default/sheet.png b/data/skins/default/sheet.png index 57962f2..7b796bc 100644 Binary files a/data/skins/default/sheet.png and b/data/skins/default/sheet.png differ diff --git a/data/skins/default/skin.xml b/data/skins/default/skin.xml index 203fe57..5cbca26 100644 --- a/data/skins/default/skin.xml +++ b/data/skins/default/skin.xml @@ -411,6 +411,7 @@ <part id="icon_arrow_down" x="144" y="256" w="7" h="4" /> <part id="icon_close" x="152" y="256" w="7" h="7" /> <part id="icon_search" x="160" y="256" w="8" h="8" /> + <part id="icon_user_data" x="168" y="256" w="8" h="8" /> </parts> <stylesheet> diff --git a/data/widgets/cel_properties.xml b/data/widgets/cel_properties.xml index 778caed..a8b6ed2 100644 --- a/data/widgets/cel_properties.xml +++ b/data/widgets/cel_properties.xml @@ -5,6 +5,11 @@ <grid columns="2"> <label text="Opacity:" /> <slider min="0" max="255" id="opacity" cell_align="horizontal" width="128" /> + + <label text="Extras:" /> + <hbox> + <button id="user_data" icon="icon_user_data" tooltip="User Data" /> + </hbox> </grid> </window> </gui> diff --git a/data/widgets/layer_properties.xml b/data/widgets/layer_properties.xml index f3371f0..89b8894 100644 --- a/data/widgets/layer_properties.xml +++ b/data/widgets/layer_properties.xml @@ -12,6 +12,11 @@ <label text="Opacity:" /> <slider id="opacity" min="0" max="255" width="128" /> + + <label text="Extras:" /> + <hbox> + <button id="user_data" icon="icon_user_data" tooltip="User Data" /> + </hbox> </grid> </vbox> </window> diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index f1392ba..490c21c 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -146,6 +146,7 @@ add_library(app-lib cmd/set_sprite_size.cpp cmd/set_total_frames.cpp cmd/set_transparent_color.cpp + cmd/set_user_data.cpp cmd/shift_masked_cel.cpp cmd/unlink_cel.cpp cmd/with_cel.cpp @@ -398,6 +399,7 @@ add_library(app-lib ui/tabs.cpp ui/timeline.cpp ui/toolbar.cpp + ui/user_data_popup.cpp ui/workspace.cpp ui/workspace_panel.cpp ui/workspace_tabs.cpp diff --git a/src/app/cmd/set_user_data.cpp b/src/app/cmd/set_user_data.cpp new file mode 100644 index 0000000..0ca16df --- /dev/null +++ b/src/app/cmd/set_user_data.cpp @@ -0,0 +1,37 @@ +// Aseprite +// Copyright (C) 2001-2015 David Capello +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation. + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "app/cmd/set_user_data.h" + +#include "doc/with_user_data.h" + +namespace app { +namespace cmd { + +SetUserData::SetUserData(doc::WithUserData* obj, const doc::UserData& userData) + : m_objId(obj->id()) + , m_oldUserData(obj->userData()) + , m_newUserData(userData) +{ +} + +void SetUserData::onExecute() +{ + doc::get<doc::WithUserData>(m_objId)->setUserData(m_newUserData); +} + +void SetUserData::onUndo() +{ + doc::get<doc::WithUserData>(m_objId)->setUserData(m_oldUserData); +} + +} // namespace cmd +} // namespace app diff --git a/src/app/cmd/set_user_data.h b/src/app/cmd/set_user_data.h new file mode 100644 index 0000000..0c0f246 --- /dev/null +++ b/src/app/cmd/set_user_data.h @@ -0,0 +1,45 @@ +// Aseprite +// Copyright (C) 2001-2015 David Capello +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation. + +#ifndef APP_CMD_SET_USER_DATA_H_INCLUDED +#define APP_CMD_SET_USER_DATA_H_INCLUDED +#pragma once + +#include "app/cmd.h" +#include "doc/object_id.h" +#include "doc/user_data.h" + +namespace doc { + class WithUserData; +} + +namespace app { +namespace cmd { + + class SetUserData : public Cmd { + public: + SetUserData(doc::WithUserData* obj, const doc::UserData& userData); + + protected: + void onExecute() override; + void onUndo() override; + size_t onMemSize() const override { + return sizeof(*this) + + m_oldUserData.size() + + m_newUserData.size(); + } + + private: + doc::ObjectId m_objId; + doc::UserData m_oldUserData; + doc::UserData m_newUserData; + }; + +} // namespace cmd +} // namespace app + +#endif diff --git a/src/app/commands/cmd_cel_properties.cpp b/src/app/commands/cmd_cel_properties.cpp index 742b9f2..cffa867 100644 --- a/src/app/commands/cmd_cel_properties.cpp +++ b/src/app/commands/cmd_cel_properties.cpp @@ -11,6 +11,7 @@ #include "app/app.h" #include "app/cmd/set_cel_opacity.h" +#include "app/cmd/set_user_data.h" #include "app/commands/command.h" #include "app/console.h" #include "app/context_access.h" @@ -20,6 +21,7 @@ #include "app/transaction.h" #include "app/ui/main_window.h" #include "app/ui/timeline.h" +#include "app/ui/user_data_popup.h" #include "app/ui_context.h" #include "base/bind.h" #include "base/mem_utils.h" @@ -51,6 +53,7 @@ public: , m_cel(nullptr) , m_selfUpdate(false) { opacity()->Change.connect(base::Bind<void>(&CelPropertiesWindow::onStartTimer, this)); + userData()->Click.connect(base::Bind<void>(&CelPropertiesWindow::onPopupUserData, this)); m_timer.Tick.connect(base::Bind<void>(&CelPropertiesWindow::onCommitChange, this)); remapWindow(); @@ -154,14 +157,18 @@ private: int count = countCels(); if ((count > 1) || - (count == 1 && newOpacity != m_cel->opacity())) { + (count == 1 && (newOpacity != m_cel->opacity() || + m_userData != m_cel->data()->userData()))) { try { ContextWriter writer(UIContext::instance()); - Transaction transaction(writer.context(), "Cel Opacity Change"); + Transaction transaction(writer.context(), "Set Cel Properties"); if (count == 1) { if (newOpacity != m_cel->opacity()) transaction.execute(new cmd::SetCelOpacity(writer.cel(), newOpacity)); + + if (m_userData != m_cel->data()->userData()) + transaction.execute(new cmd::SetUserData(writer.cel()->data(), m_userData)); } else { for (Cel* cel : m_document->sprite()->uniqueCels()) { @@ -170,6 +177,9 @@ private: cel->frame())) { transaction.execute(new cmd::SetCelOpacity(cel, newOpacity)); } + + if (m_userData != cel->data()->userData()) + transaction.execute(new cmd::SetUserData(cel->data(), m_userData)); } } @@ -183,6 +193,14 @@ private: } } + void onPopupUserData() { + if (m_cel) { + if (show_user_data_popup(userData()->bounds(), m_userData)) { + onStartTimer(); + } + } + } + // ContextObserver impl void onActiveSiteChange(const Site& site) override { if (isVisible()) @@ -208,15 +226,20 @@ private: int count = countCels(); + m_userData = UserData(); + if (count > 0) { if (m_cel) { opacity()->setValue(m_cel->opacity()); opacity()->setEnabled( (count > 1) || (count == 1 && !m_cel->layer()->isBackground())); + + m_userData = m_cel->data()->userData(); } - else // Enable slider to change the whole range + else { // Enable slider to change the whole range opacity()->setEnabled(true); + } } else { opacity()->setEnabled(false); @@ -228,6 +251,7 @@ private: Cel* m_cel; DocumentRange m_range; bool m_selfUpdate; + UserData m_userData; }; class CelPropertiesCommand : public Command { diff --git a/src/app/commands/cmd_layer_properties.cpp b/src/app/commands/cmd_layer_properties.cpp index a4a4b1e..18bfb99 100644 --- a/src/app/commands/cmd_layer_properties.cpp +++ b/src/app/commands/cmd_layer_properties.cpp @@ -13,11 +13,13 @@ #include "app/cmd/set_layer_blend_mode.h" #include "app/cmd/set_layer_name.h" #include "app/cmd/set_layer_opacity.h" +#include "app/cmd/set_user_data.h" #include "app/commands/command.h" #include "app/console.h" #include "app/context_access.h" #include "app/modules/gui.h" #include "app/transaction.h" +#include "app/ui/user_data_popup.h" #include "app/ui_context.h" #include "base/bind.h" #include "base/scoped_value.h" @@ -26,6 +28,7 @@ #include "doc/image.h" #include "doc/layer.h" #include "doc/sprite.h" +#include "doc/user_data.h" #include "ui/ui.h" #include "layer_properties.xml.h" @@ -79,6 +82,7 @@ public: mode()->Change.connect(base::Bind<void>(&LayerPropertiesWindow::onStartTimer, this)); opacity()->Change.connect(base::Bind<void>(&LayerPropertiesWindow::onStartTimer, this)); m_timer.Tick.connect(base::Bind<void>(&LayerPropertiesWindow::onCommitChange, this)); + userData()->Click.connect(base::Bind<void>(&LayerPropertiesWindow::onPopupUserData, this)); remapWindow(); centerWindow(); @@ -175,7 +179,8 @@ private: if (newName != m_layer->name() || newOpacity != m_layer->opacity() || - newBlendMode != m_layer->blendMode()) { + newBlendMode != m_layer->blendMode() || + m_userData != m_layer->userData()) { try { ContextWriter writer(UIContext::instance()); Transaction transaction(writer.context(), "Set Layer Properties"); @@ -189,6 +194,9 @@ private: if (newBlendMode != m_layer->blendMode()) transaction.execute(new cmd::SetLayerBlendMode(static_cast<LayerImage*>(writer.layer()), newBlendMode)); + if (m_userData != m_layer->userData()) + transaction.execute(new cmd::SetUserData(writer.layer(), m_userData)); + transaction.commit(); } catch (const std::exception& e) { @@ -223,6 +231,14 @@ private: updateFromLayer(); } + void onPopupUserData() { + if (m_layer) { + if (show_user_data_popup(userData()->bounds(), m_userData)) { + onStartTimer(); + } + } + } + void updateFromLayer() { if (m_selfUpdate) return; @@ -238,18 +254,21 @@ private: mode()->setEnabled(!m_layer->isBackground()); opacity()->setValue(m_layer->opacity()); opacity()->setEnabled(!m_layer->isBackground()); + m_userData = m_layer->userData(); } else { name()->setText("No Layer"); name()->setEnabled(false); mode()->setEnabled(false); opacity()->setEnabled(false); + m_userData = UserData(); } } Timer m_timer; LayerImage* m_layer; bool m_selfUpdate; + UserData m_userData; }; LayerPropertiesCommand::LayerPropertiesCommand() diff --git a/src/app/ui/user_data_popup.cpp b/src/app/ui/user_data_popup.cpp new file mode 100644 index 0000000..bdea74c --- /dev/null +++ b/src/app/ui/user_data_popup.cpp @@ -0,0 +1,40 @@ +// Aseprite +// Copyright (C) 2001-2015 David Capello +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation. + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "app/ui/user_data_popup.h" + +#include "doc/user_data.h" + +#include "user_data.xml.h" + +namespace app { + +using namespace ui; + +bool show_user_data_popup(const gfx::Rect& bounds, + doc::UserData& userData) +{ + app::gen::UserData window; + window.text()->setText(userData.text()); + window.setCloseOnKeyDown(false); + window.pointAt(TOP, bounds); + window.openWindowInForeground(); + + if (userData.text() != window.text()->text()) { + userData.setText(window.text()->text()); + return true; + } + else { + return false; + } +} + +} // namespace app diff --git a/src/app/ui/user_data_popup.h b/src/app/ui/user_data_popup.h new file mode 100644 index 0000000..f36bca3 --- /dev/null +++ b/src/app/ui/user_data_popup.h @@ -0,0 +1,25 @@ +// Aseprite +// Copyright (C) 2001-2015 David Capello +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation. + +#ifndef APP_UI_USER_DATA_POPUP_H_INCLUDED +#define APP_UI_USER_DATA_POPUP_H_INCLUDED +#pragma once + +#include "gfx/rect.h" + +namespace doc { + class UserData; +} + +namespace app { + + bool show_user_data_popup(const gfx::Rect& bounds, + doc::UserData& userData); + +} // namespace app + +#endif diff --git a/src/doc/cel_data.cpp b/src/doc/cel_data.cpp index 0d89773..6ebff93 100644 --- a/src/doc/cel_data.cpp +++ b/src/doc/cel_data.cpp @@ -18,7 +18,7 @@ namespace doc { CelData::CelData(const ImageRef& image) - : Object(ObjectType::CelData) + : WithUserData(ObjectType::CelData) , m_image(image) , m_position(0, 0) , m_opacity(255) @@ -26,7 +26,7 @@ CelData::CelData(const ImageRef& image) } CelData::CelData(const CelData& celData) - : Object(ObjectType::CelData) + : WithUserData(ObjectType::CelData) , m_image(celData.m_image) , m_position(celData.m_position) , m_opacity(celData.m_opacity) diff --git a/src/doc/cel_data.h b/src/doc/cel_data.h index b04693b..2b777aa 100644 --- a/src/doc/cel_data.h +++ b/src/doc/cel_data.h @@ -11,10 +11,11 @@ #include "base/shared_ptr.h" #include "doc/image_ref.h" #include "doc/object.h" +#include "doc/with_user_data.h" namespace doc { - class CelData : public Object { + class CelData : public WithUserData { public: CelData(const ImageRef& image); CelData(const CelData& celData); diff --git a/src/doc/layer.cpp b/src/doc/layer.cpp index c4865b5..5c98bd1 100644 --- a/src/doc/layer.cpp +++ b/src/doc/layer.cpp @@ -21,7 +21,7 @@ namespace doc { Layer::Layer(ObjectType type, Sprite* sprite) - : Object(type) + : WithUserData(type) , m_sprite(sprite) , m_parent(NULL) , m_flags(LayerFlags( diff --git a/src/doc/layer.h b/src/doc/layer.h index e7882b8..95cf3d0 100644 --- a/src/doc/layer.h +++ b/src/doc/layer.h @@ -13,6 +13,7 @@ #include "doc/frame.h" #include "doc/layer_list.h" #include "doc/object.h" +#include "doc/with_user_data.h" #include <string> @@ -38,7 +39,7 @@ namespace doc { BackgroundLayerFlags = LockMove | Background, }; - class Layer : public Object { + class Layer : public WithUserData { protected: Layer(ObjectType type, Sprite* sprite); diff --git a/src/doc/user_data.h b/src/doc/user_data.h new file mode 100644 index 0000000..b214709 --- /dev/null +++ b/src/doc/user_data.h @@ -0,0 +1,37 @@ +// Aseprite Document Library +// Copyright (c) 2001-2015 David Capello +// +// This file is released under the terms of the MIT license. +// Read LICENSE.txt for more information. + +#ifndef DOC_USER_DATA_H_INCLUDED +#define DOC_USER_DATA_H_INCLUDED +#pragma once + +#include <string> + +namespace doc { + + class UserData { + public: + size_t size() const { return m_text.size(); } + bool isEmpty() const { return m_text.empty(); } + + const std::string& text() const { return m_text; } + void setText(const std::string& text) { m_text = text; } + + bool operator==(const UserData& other) const { + return (m_text == other.m_text); + } + + bool operator!=(const UserData& other) const { + return !operator==(other); + } + + private: + std::string m_text; + }; + +} // namespace doc + +#endif diff --git a/src/doc/with_user_data.h b/src/doc/with_user_data.h new file mode 100644 index 0000000..5aeff0a --- /dev/null +++ b/src/doc/with_user_data.h @@ -0,0 +1,35 @@ +// Aseprite Document Library +// Copyright (c) 2001-2015 David Capello +// +// This file is released under the terms of the MIT license. +// Read LICENSE.txt for more information. + +#ifndef DOC_WITH_USER_DATA_H_INCLUDED +#define DOC_WITH_USER_DATA_H_INCLUDED +#pragma once + +#include "doc/object.h" +#include "doc/user_data.h" + +namespace doc { + + class WithUserData : public Object { + public: + WithUserData(ObjectType type) : Object(type) { + } + + const UserData& userData() const { + return m_userData; + } + + void setUserData(const UserData& userData) { + m_userData = userData; + } + + private: + UserData m_userData; + }; + +} // namespace doc + +#endif -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/aseprite.git _______________________________________________ Pkg-games-commits mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-games-commits

