2015-02-12 23:16:25 +08:00
|
|
|
// Aseprite
|
2025-08-26 03:20:37 +08:00
|
|
|
// Copyright (C) 2020-2025 Igara Studio S.A.
|
2018-07-07 13:47:42 +08:00
|
|
|
// Copyright (C) 2001-2018 David Capello
|
2015-02-12 23:16:25 +08:00
|
|
|
//
|
2016-08-27 04:02:58 +08:00
|
|
|
// This program is distributed under the terms of
|
|
|
|
// the End-User License Agreement for Aseprite.
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2012-01-06 06:45:03 +08:00
|
|
|
#include "config.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#endif
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/app.h"
|
2015-08-21 19:35:29 +08:00
|
|
|
#include "app/cmd/set_cel_opacity.h"
|
2023-04-11 04:44:22 +08:00
|
|
|
#include "app/cmd/set_cel_zindex.h"
|
2015-12-11 05:34:25 +08:00
|
|
|
#include "app/cmd/set_user_data.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/commands/command.h"
|
2015-08-21 19:35:29 +08:00
|
|
|
#include "app/console.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/context_access.h"
|
2018-07-07 13:47:42 +08:00
|
|
|
#include "app/doc_event.h"
|
2018-07-07 21:07:21 +08:00
|
|
|
#include "app/doc_range.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/modules/gui.h"
|
2018-08-21 03:00:59 +08:00
|
|
|
#include "app/tx.h"
|
2017-03-27 00:33:12 +08:00
|
|
|
#include "app/ui/timeline/timeline.h"
|
2020-09-11 02:49:08 +08:00
|
|
|
#include "app/ui/user_data_view.h"
|
2015-08-21 19:35:29 +08:00
|
|
|
#include "app/ui_context.h"
|
|
|
|
#include "base/scoped_value.h"
|
2014-10-21 09:21:31 +08:00
|
|
|
#include "doc/cel.h"
|
2015-08-21 22:01:49 +08:00
|
|
|
#include "doc/cels_range.h"
|
2014-10-21 09:21:31 +08:00
|
|
|
#include "doc/image.h"
|
|
|
|
#include "doc/layer.h"
|
|
|
|
#include "doc/sprite.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "ui/ui.h"
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2015-09-23 03:33:49 +08:00
|
|
|
#include "cel_properties.xml.h"
|
2015-08-21 10:42:05 +08:00
|
|
|
|
2023-04-11 04:44:22 +08:00
|
|
|
#include <algorithm>
|
|
|
|
#include <limits>
|
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
namespace app {
|
|
|
|
|
2012-06-18 09:02:54 +08:00
|
|
|
using namespace ui;
|
|
|
|
|
2015-08-21 19:35:29 +08:00
|
|
|
class CelPropertiesWindow;
|
|
|
|
static CelPropertiesWindow* g_window = nullptr;
|
|
|
|
|
2023-05-23 05:29:02 +08:00
|
|
|
struct CelPropsLastValues {
|
|
|
|
int opacity = 0;
|
|
|
|
int zIndex = 0;
|
|
|
|
color_t color = 0;
|
|
|
|
std::string text = "";
|
|
|
|
};
|
|
|
|
|
2018-07-07 13:47:42 +08:00
|
|
|
class CelPropertiesWindow : public app::gen::CelProperties,
|
|
|
|
public ContextObserver,
|
|
|
|
public DocObserver {
|
2015-08-21 10:42:05 +08:00
|
|
|
public:
|
2015-08-21 19:35:29 +08:00
|
|
|
CelPropertiesWindow()
|
|
|
|
: m_timer(250, this)
|
2022-05-20 05:56:21 +08:00
|
|
|
, m_userDataView(Preferences::instance().cels.userDataVisibility)
|
2020-09-11 02:49:08 +08:00
|
|
|
{
|
2020-07-04 08:51:46 +08:00
|
|
|
opacity()->Change.connect([this] { onStartTimer(); });
|
2023-04-11 04:44:22 +08:00
|
|
|
zindex()->Change.connect([this] { onStartTimer(); });
|
2020-09-11 02:49:08 +08:00
|
|
|
userData()->Click.connect([this] { onToggleUserData(); });
|
2020-07-04 08:51:46 +08:00
|
|
|
m_timer.Tick.connect([this] { onCommitChange(); });
|
2015-08-21 19:35:29 +08:00
|
|
|
|
2022-05-20 06:15:32 +08:00
|
|
|
m_userDataView.UserDataChange.connect([this] { onStartTimer(); });
|
2020-09-11 02:49:08 +08:00
|
|
|
|
2023-04-11 04:44:22 +08:00
|
|
|
// TODO add to Expr widget spin flag to include these widgets in
|
|
|
|
// the same Expr
|
|
|
|
zindexSpin()->ItemChange.connect([this] {
|
|
|
|
int dz = (zindexSpin()->selectedItem() == 0 ? +1 : -1);
|
|
|
|
zindex()->setTextf("%d", zindex()->textInt() + dz);
|
|
|
|
onStartTimer();
|
|
|
|
});
|
|
|
|
|
2015-08-21 19:35:29 +08:00
|
|
|
remapWindow();
|
|
|
|
centerWindow();
|
|
|
|
load_window_pos(this, "CelProperties");
|
|
|
|
|
2016-09-14 02:02:00 +08:00
|
|
|
UIContext::instance()->add_observer(this);
|
2015-08-21 19:35:29 +08:00
|
|
|
}
|
|
|
|
|
2016-09-14 02:02:00 +08:00
|
|
|
~CelPropertiesWindow() { UIContext::instance()->remove_observer(this); }
|
2015-08-21 19:35:29 +08:00
|
|
|
|
2018-07-07 22:54:44 +08:00
|
|
|
void setCel(Doc* doc, Cel* cel)
|
|
|
|
{
|
2015-08-21 22:01:49 +08:00
|
|
|
if (m_document) {
|
2016-09-14 02:02:00 +08:00
|
|
|
m_document->remove_observer(this);
|
2015-08-21 22:01:49 +08:00
|
|
|
m_document = nullptr;
|
2015-08-21 19:35:29 +08:00
|
|
|
m_cel = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_timer.stop();
|
2015-08-21 22:01:49 +08:00
|
|
|
m_document = doc;
|
|
|
|
m_cel = cel;
|
2023-06-09 06:00:49 +08:00
|
|
|
m_range = UIContext::instance()->range();
|
2015-08-21 19:35:29 +08:00
|
|
|
|
2015-08-21 22:01:49 +08:00
|
|
|
if (m_document)
|
2016-09-14 02:02:00 +08:00
|
|
|
m_document->add_observer(this);
|
2015-08-21 19:35:29 +08:00
|
|
|
|
2021-06-11 22:04:52 +08:00
|
|
|
if (countCels() > 0) {
|
2022-10-13 20:40:54 +08:00
|
|
|
m_userDataView.configureAndSet((m_cel ? m_cel->data()->userData() : UserData()),
|
2025-08-26 03:20:37 +08:00
|
|
|
propertiesGrid());
|
2020-09-11 02:49:08 +08:00
|
|
|
}
|
|
|
|
else if (!m_cel)
|
|
|
|
m_userDataView.setVisible(false, false);
|
2021-06-11 22:04:52 +08:00
|
|
|
|
2025-08-26 03:20:37 +08:00
|
|
|
expandWindow(gfx::Size(bounds().w, sizeHint().h));
|
2015-08-21 22:01:49 +08:00
|
|
|
updateFromCel();
|
2015-08-21 10:42:05 +08:00
|
|
|
}
|
2015-08-21 19:35:29 +08:00
|
|
|
|
|
|
|
private:
|
2017-04-06 03:01:18 +08:00
|
|
|
int opacityValue() const { return opacity()->getValue(); }
|
2015-08-21 19:35:29 +08:00
|
|
|
|
2023-04-11 04:44:22 +08:00
|
|
|
int zindexValue() const { return zindex()->textInt(); }
|
|
|
|
|
2016-02-01 21:52:05 +08:00
|
|
|
int countCels(int* backgroundCount = nullptr) const
|
|
|
|
{
|
|
|
|
if (backgroundCount)
|
|
|
|
*backgroundCount = 0;
|
|
|
|
|
2015-08-21 22:01:49 +08:00
|
|
|
if (!m_document)
|
|
|
|
return 0;
|
|
|
|
else if (m_cel && (!m_range.enabled() || (m_range.frames() == 1 && m_range.layers() == 1))) {
|
2016-02-01 21:52:05 +08:00
|
|
|
if (backgroundCount && m_cel->layer()->isBackground())
|
|
|
|
*backgroundCount = 1;
|
2015-08-21 22:01:49 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else if (m_range.enabled()) {
|
2016-02-02 05:05:40 +08:00
|
|
|
Sprite* sprite = m_document->sprite();
|
2015-08-21 22:01:49 +08:00
|
|
|
int count = 0;
|
2016-08-25 23:31:00 +08:00
|
|
|
for (Cel* cel : sprite->uniqueCels(m_range.selectedFrames())) {
|
|
|
|
if (m_range.contains(cel->layer())) {
|
2016-02-01 21:52:05 +08:00
|
|
|
if (backgroundCount && cel->layer()->isBackground())
|
|
|
|
++(*backgroundCount);
|
2015-08-21 22:01:49 +08:00
|
|
|
++count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-08-21 19:35:29 +08:00
|
|
|
bool onProcessMessage(ui::Message* msg) override
|
|
|
|
{
|
|
|
|
switch (msg->type()) {
|
2015-08-22 01:53:31 +08:00
|
|
|
case kKeyDownMessage:
|
2023-04-11 04:44:22 +08:00
|
|
|
if (opacity()->hasFocus() || zindex()->hasFocus()) {
|
2016-10-24 05:46:21 +08:00
|
|
|
KeyScancode scancode = static_cast<KeyMessage*>(msg)->scancode();
|
|
|
|
if (scancode == kKeyEnter || scancode == kKeyEsc) {
|
2015-08-22 01:53:31 +08:00
|
|
|
onCommitChange();
|
|
|
|
closeWindow(this);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2015-08-21 19:35:29 +08:00
|
|
|
case kCloseMessage:
|
|
|
|
// Save changes before we close the window
|
2020-09-11 02:49:08 +08:00
|
|
|
if (m_cel)
|
|
|
|
save_window_pos(this, "CelProperties");
|
2015-08-21 22:01:49 +08:00
|
|
|
setCel(nullptr, nullptr);
|
2015-08-21 19:35:29 +08:00
|
|
|
deferDelete();
|
|
|
|
g_window = nullptr;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return Window::onProcessMessage(msg);
|
|
|
|
}
|
|
|
|
|
2015-08-21 22:01:49 +08:00
|
|
|
void onStartTimer()
|
|
|
|
{
|
2015-08-21 19:35:29 +08:00
|
|
|
if (m_selfUpdate)
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_timer.start();
|
2022-05-20 06:15:32 +08:00
|
|
|
m_pendingChanges = true;
|
2015-08-21 19:35:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void onCommitChange()
|
|
|
|
{
|
2022-05-20 06:15:32 +08:00
|
|
|
// Nothing to change
|
|
|
|
if (!m_pendingChanges)
|
|
|
|
return;
|
|
|
|
|
2023-04-15 00:43:36 +08:00
|
|
|
base::ScopedValue switchSelf(m_selfUpdate, true);
|
2015-08-21 19:35:29 +08:00
|
|
|
|
|
|
|
m_timer.stop();
|
|
|
|
|
2017-04-06 03:01:18 +08:00
|
|
|
const int newOpacity = opacityValue();
|
2023-04-11 04:44:22 +08:00
|
|
|
// Clamp z-index to the limits of the .aseprite specs
|
|
|
|
const int newZIndex = std::clamp<int>(zindexValue(),
|
|
|
|
std::numeric_limits<int16_t>::min(),
|
|
|
|
std::numeric_limits<int16_t>::max());
|
2023-05-23 05:29:02 +08:00
|
|
|
UserData newUserData = m_userDataView.userData();
|
|
|
|
|
|
|
|
const bool opacityChanged = newOpacity != m_lastValues.opacity;
|
|
|
|
const bool colorChanged = newUserData.color() != m_lastValues.color;
|
|
|
|
const bool textChanged = newUserData.text() != m_lastValues.text;
|
|
|
|
|
2017-04-06 03:01:18 +08:00
|
|
|
const int count = countCels();
|
2015-08-21 19:35:29 +08:00
|
|
|
|
2023-05-23 05:29:02 +08:00
|
|
|
if ((count > 0) || (count == 1 && m_cel &&
|
2016-02-01 21:52:05 +08:00
|
|
|
(newOpacity != m_cel->opacity() || newZIndex != m_cel->zIndex() ||
|
2020-09-11 02:49:08 +08:00
|
|
|
newUserData != m_cel->data()->userData()))) {
|
2015-08-21 19:35:29 +08:00
|
|
|
try {
|
|
|
|
ContextWriter writer(UIContext::instance());
|
2023-12-13 08:34:30 +08:00
|
|
|
Tx tx(writer, "Set Cel Properties");
|
2015-08-21 19:35:29 +08:00
|
|
|
|
2018-07-07 21:07:21 +08:00
|
|
|
DocRange range;
|
2023-05-16 02:20:16 +08:00
|
|
|
if (m_range.enabled()) {
|
2016-08-26 07:19:29 +08:00
|
|
|
range = m_range;
|
2023-05-16 02:20:16 +08:00
|
|
|
range.convertToCels(m_document->sprite());
|
|
|
|
}
|
2016-08-26 07:19:29 +08:00
|
|
|
else {
|
2018-07-07 21:07:21 +08:00
|
|
|
range.startRange(m_cel->layer(), m_cel->frame(), DocRange::kCels);
|
2016-08-26 07:19:29 +08:00
|
|
|
range.endRange(m_cel->layer(), m_cel->frame());
|
|
|
|
}
|
|
|
|
|
|
|
|
Sprite* sprite = m_document->sprite();
|
2023-04-11 04:44:22 +08:00
|
|
|
bool redrawTimeline = false;
|
|
|
|
|
|
|
|
// For each unique cel (don't repeat on links)
|
2016-08-26 07:19:29 +08:00
|
|
|
for (Cel* cel : sprite->uniqueCels(range.selectedFrames())) {
|
|
|
|
if (range.contains(cel->layer())) {
|
2023-05-23 05:29:02 +08:00
|
|
|
if (opacityChanged && !cel->layer()->isBackground() && newOpacity != cel->opacity()) {
|
2018-08-21 03:00:59 +08:00
|
|
|
tx(new cmd::SetCelOpacity(cel, newOpacity));
|
2016-08-26 07:19:29 +08:00
|
|
|
}
|
2015-12-11 05:34:25 +08:00
|
|
|
|
2021-06-11 21:45:49 +08:00
|
|
|
if (newUserData != cel->data()->userData()) {
|
2023-05-23 05:29:02 +08:00
|
|
|
if (!colorChanged)
|
|
|
|
newUserData.setColor(cel->data()->userData().color());
|
|
|
|
if (!textChanged)
|
|
|
|
newUserData.setText(cel->data()->userData().text());
|
2020-09-11 02:49:08 +08:00
|
|
|
tx(new cmd::SetUserData(cel->data(), newUserData, m_document));
|
2015-12-23 00:18:08 +08:00
|
|
|
|
2016-08-26 07:19:29 +08:00
|
|
|
// Redraw timeline because the cel's user data/color
|
|
|
|
// might have changed.
|
2021-06-11 21:45:49 +08:00
|
|
|
if (newUserData.color() != cel->data()->userData().color()) {
|
2023-04-11 04:44:22 +08:00
|
|
|
redrawTimeline = true;
|
2021-06-11 21:45:49 +08:00
|
|
|
}
|
2015-12-23 00:18:08 +08:00
|
|
|
}
|
2015-08-21 22:01:49 +08:00
|
|
|
}
|
|
|
|
}
|
2015-08-21 19:35:29 +08:00
|
|
|
|
2023-04-11 04:44:22 +08:00
|
|
|
// For all cels (repeat links)
|
2023-05-23 05:29:02 +08:00
|
|
|
if (newZIndex != m_lastValues.zIndex) {
|
|
|
|
for (Cel* cel : sprite->cels(range.selectedFrames())) {
|
|
|
|
if (range.contains(cel->layer())) {
|
|
|
|
if (newZIndex != cel->zIndex()) {
|
|
|
|
tx(new cmd::SetCelZIndex(cel, newZIndex));
|
|
|
|
redrawTimeline = true;
|
|
|
|
}
|
2023-04-11 04:44:22 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-23 05:29:02 +08:00
|
|
|
m_lastValues.opacity = newOpacity;
|
|
|
|
m_lastValues.zIndex = newZIndex;
|
|
|
|
m_lastValues.color = newUserData.color();
|
|
|
|
m_lastValues.text = newUserData.text();
|
|
|
|
|
2023-04-11 04:44:22 +08:00
|
|
|
if (redrawTimeline)
|
2023-06-09 06:00:49 +08:00
|
|
|
App::instance()->timeline()->invalidate(); // TODO avoid this invalidating in tx.commit()
|
2023-04-11 04:44:22 +08:00
|
|
|
|
2018-08-21 03:00:59 +08:00
|
|
|
tx.commit();
|
2015-08-21 19:35:29 +08:00
|
|
|
}
|
|
|
|
catch (const std::exception& e) {
|
|
|
|
Console::showException(e);
|
|
|
|
}
|
|
|
|
|
2015-08-21 22:01:49 +08:00
|
|
|
update_screen_for_document(m_document);
|
2015-08-21 19:35:29 +08:00
|
|
|
}
|
2022-05-20 06:15:32 +08:00
|
|
|
|
2023-12-06 23:47:52 +08:00
|
|
|
// TODO this is similar to LayerPropertiesWindow::onCommitChange()
|
2022-05-20 06:15:32 +08:00
|
|
|
m_pendingChanges = false;
|
2015-08-21 19:35:29 +08:00
|
|
|
}
|
|
|
|
|
2020-09-11 02:49:08 +08:00
|
|
|
void onToggleUserData()
|
|
|
|
{
|
2021-06-11 22:04:52 +08:00
|
|
|
if (countCels() > 0) {
|
2020-09-11 02:49:08 +08:00
|
|
|
m_userDataView.toggleVisibility();
|
2025-08-26 03:20:37 +08:00
|
|
|
expandWindow(gfx::Size(bounds().w, sizeHint().h));
|
2015-12-11 05:34:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-21 19:35:29 +08:00
|
|
|
// ContextObserver impl
|
|
|
|
void onActiveSiteChange(const Site& site) override
|
|
|
|
{
|
2020-11-06 01:25:45 +08:00
|
|
|
onCommitChange();
|
2015-08-21 19:35:29 +08:00
|
|
|
if (isVisible())
|
2018-07-07 22:54:44 +08:00
|
|
|
setCel(const_cast<Doc*>(site.document()), const_cast<Cel*>(site.cel()));
|
2015-08-21 22:01:49 +08:00
|
|
|
else if (m_document)
|
|
|
|
setCel(nullptr, nullptr);
|
2015-08-21 19:35:29 +08:00
|
|
|
}
|
|
|
|
|
2018-07-07 08:06:03 +08:00
|
|
|
// DocObserver impl
|
2020-08-04 21:40:42 +08:00
|
|
|
void onBeforeRemoveCel(DocEvent& ev) override
|
|
|
|
{
|
|
|
|
if (m_cel == ev.cel())
|
|
|
|
setCel(m_document, nullptr);
|
|
|
|
}
|
|
|
|
|
2018-07-07 08:06:03 +08:00
|
|
|
void onCelOpacityChange(DocEvent& ev) override
|
|
|
|
{
|
2015-08-21 22:01:49 +08:00
|
|
|
if (m_cel == ev.cel())
|
|
|
|
updateFromCel();
|
2015-08-21 19:35:29 +08:00
|
|
|
}
|
|
|
|
|
2023-04-11 04:44:22 +08:00
|
|
|
void onCelZIndexChange(DocEvent& ev) override
|
|
|
|
{
|
|
|
|
if (m_cel == ev.cel())
|
|
|
|
updateFromCel();
|
|
|
|
}
|
|
|
|
|
2020-09-11 02:49:08 +08:00
|
|
|
void onUserDataChange(DocEvent& ev) override
|
|
|
|
{
|
|
|
|
if (m_cel && m_cel->data() == ev.withUserData())
|
|
|
|
updateFromCel();
|
|
|
|
}
|
|
|
|
|
2015-08-21 22:01:49 +08:00
|
|
|
void updateFromCel()
|
|
|
|
{
|
2015-08-21 19:35:29 +08:00
|
|
|
if (m_selfUpdate)
|
|
|
|
return;
|
|
|
|
|
2015-08-21 22:01:49 +08:00
|
|
|
m_timer.stop(); // Cancel current editions (just in case)
|
|
|
|
|
2023-04-15 00:43:36 +08:00
|
|
|
base::ScopedValue switchSelf(m_selfUpdate, true);
|
2015-08-21 22:01:49 +08:00
|
|
|
|
2016-02-01 21:52:05 +08:00
|
|
|
int bgCount = 0;
|
|
|
|
int count = countCels(&bgCount);
|
2015-08-21 22:01:49 +08:00
|
|
|
|
2023-05-23 05:29:02 +08:00
|
|
|
// Dafault cel values when the active cel is empty
|
|
|
|
m_lastValues.opacity = 0;
|
|
|
|
m_lastValues.zIndex = 0;
|
|
|
|
m_lastValues.color = 0;
|
|
|
|
m_lastValues.text = "";
|
|
|
|
|
2015-08-21 22:01:49 +08:00
|
|
|
if (count > 0) {
|
|
|
|
if (m_cel) {
|
|
|
|
opacity()->setValue(m_cel->opacity());
|
2023-04-11 04:44:22 +08:00
|
|
|
zindex()->setTextf("%d", m_cel->zIndex());
|
2020-09-11 02:49:08 +08:00
|
|
|
color_t c = m_cel->data()->userData().color();
|
|
|
|
m_userDataView.color()->setColor(
|
|
|
|
Color::fromRgb(rgba_getr(c), rgba_getg(c), rgba_getb(c), rgba_geta(c)));
|
2024-12-18 20:19:30 +08:00
|
|
|
m_userDataView.textEdit()->setText(m_cel->data()->userData().text());
|
2023-05-23 05:29:02 +08:00
|
|
|
// Set last filled values in CelPropertiesWindow
|
|
|
|
m_lastValues.opacity = m_cel->opacity();
|
|
|
|
m_lastValues.zIndex = m_cel->zIndex();
|
|
|
|
m_lastValues.color = m_cel->data()->userData().color();
|
|
|
|
m_lastValues.text = m_cel->data()->userData().text();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
opacity()->setValue(0);
|
|
|
|
zindex()->setText("0");
|
2015-08-21 22:01:49 +08:00
|
|
|
}
|
2016-02-01 21:52:05 +08:00
|
|
|
opacity()->setEnabled(bgCount < count);
|
2015-08-21 22:01:49 +08:00
|
|
|
}
|
|
|
|
else {
|
2023-05-23 05:29:02 +08:00
|
|
|
opacity()->setValue(0);
|
|
|
|
zindex()->setText("0");
|
2015-08-21 22:01:49 +08:00
|
|
|
opacity()->setEnabled(false);
|
2020-09-11 02:49:08 +08:00
|
|
|
m_userDataView.setVisible(false, false);
|
2015-08-21 22:01:49 +08:00
|
|
|
}
|
2015-08-21 19:35:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Timer m_timer;
|
2022-05-20 06:15:32 +08:00
|
|
|
bool m_pendingChanges = false;
|
|
|
|
Doc* m_document = nullptr;
|
|
|
|
Cel* m_cel = nullptr;
|
2023-06-09 06:00:49 +08:00
|
|
|
view::RealRange m_range;
|
2022-05-20 06:15:32 +08:00
|
|
|
bool m_selfUpdate = false;
|
2020-09-11 02:49:08 +08:00
|
|
|
UserDataView m_userDataView;
|
2023-05-23 05:29:02 +08:00
|
|
|
CelPropsLastValues m_lastValues;
|
2015-08-21 10:42:05 +08:00
|
|
|
};
|
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
class CelPropertiesCommand : public Command {
|
2012-01-06 06:45:03 +08:00
|
|
|
public:
|
|
|
|
CelPropertiesCommand();
|
|
|
|
|
|
|
|
protected:
|
2015-08-21 19:35:29 +08:00
|
|
|
bool onEnabled(Context* context) override;
|
|
|
|
void onExecute(Context* context) override;
|
2012-01-06 06:45:03 +08:00
|
|
|
};
|
|
|
|
|
2025-08-06 02:59:31 +08:00
|
|
|
CelPropertiesCommand::CelPropertiesCommand() : Command(CommandId::CelProperties())
|
2012-01-06 06:45:03 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CelPropertiesCommand::onEnabled(Context* context)
|
|
|
|
{
|
2025-08-06 02:59:31 +08:00
|
|
|
return context->isUIAvailable() && context->checkFlags(ContextFlags::ActiveDocumentIsWritable |
|
|
|
|
ContextFlags::ActiveLayerIsImage);
|
2012-01-06 06:45:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CelPropertiesCommand::onExecute(Context* context)
|
|
|
|
{
|
2015-08-21 19:35:29 +08:00
|
|
|
ContextReader reader(context);
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2015-08-21 19:35:29 +08:00
|
|
|
if (!g_window)
|
|
|
|
g_window = new CelPropertiesWindow;
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2015-08-21 22:01:49 +08:00
|
|
|
g_window->setCel(reader.document(), reader.cel());
|
2015-08-21 19:35:29 +08:00
|
|
|
g_window->openWindow();
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2015-08-21 19:35:29 +08:00
|
|
|
// Focus layer name
|
|
|
|
g_window->opacity()->requestFocus();
|
2012-01-06 06:45:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Command* CommandFactory::createCelPropertiesCommand()
|
|
|
|
{
|
|
|
|
return new CelPropertiesCommand;
|
|
|
|
}
|
2013-08-06 08:20:19 +08:00
|
|
|
|
|
|
|
} // namespace app
|