[aseprite] 194/308: Fix several problems with timeline and cel opacity slider
Tobias Hansen
thansen at moszumanska.debian.org
Tue Mar 8 02:45:10 UTC 2016
This is an automated email from the git hooks/post-receive script.
thansen pushed a commit to branch master
in repository aseprite.
commit 2f791b5ad147e05c778f5b3c6245c6974e861b3d
Author: David Capello <davidcapello at gmail.com>
Date: Mon Feb 1 10:52:05 2016 -0300
Fix several problems with timeline and cel opacity slider
* Enable cel opacity slider when any transparent cel is selected
(it doesn't matter if there are cels from a background layer selected
too, the slider must be enabled for the transparent ones)
* Enable editing user data when we have a range of cels selected
(it doesn't matter if the active cel is nullptr, we've to enable
editing user data if there is any selected cel in the timeline range)
---
src/app/commands/cmd_cel_properties.cpp | 46 +++++++++++++++++++--------------
1 file changed, 27 insertions(+), 19 deletions(-)
diff --git a/src/app/commands/cmd_cel_properties.cpp b/src/app/commands/cmd_cel_properties.cpp
index 39aea79..510b529 100644
--- a/src/app/commands/cmd_cel_properties.cpp
+++ b/src/app/commands/cmd_cel_properties.cpp
@@ -1,5 +1,5 @@
// Aseprite
-// Copyright (C) 2001-2015 David Capello
+// Copyright (C) 2001-2016 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
@@ -91,21 +91,27 @@ private:
return opacity()->getValue();
}
- int countCels() const {
+ int countCels(int* backgroundCount = nullptr) const {
+ if (backgroundCount)
+ *backgroundCount = 0;
+
if (!m_document)
return 0;
else if (m_cel &&
(!m_range.enabled() ||
(m_range.frames() == 1 &&
m_range.layers() == 1))) {
+ if (backgroundCount && m_cel->layer()->isBackground())
+ *backgroundCount = 1;
return 1;
}
else if (m_range.enabled()) {
int count = 0;
for (Cel* cel : m_document->sprite()->uniqueCels()) {
- if (!cel->layer()->isBackground() &&
- m_range.inRange(cel->sprite()->layerToIndex(cel->layer()),
+ if (m_range.inRange(cel->sprite()->layerToIndex(cel->layer()),
cel->frame())) {
+ if (backgroundCount && cel->layer()->isBackground())
+ ++(*backgroundCount);
++count;
}
}
@@ -157,15 +163,17 @@ private:
int count = countCels();
if ((count > 1) ||
- (count == 1 && (newOpacity != m_cel->opacity() ||
- m_userData != m_cel->data()->userData()))) {
+ (count == 1 && m_cel && (newOpacity != m_cel->opacity() ||
+ m_userData != m_cel->data()->userData()))) {
try {
ContextWriter writer(UIContext::instance());
Transaction transaction(writer.context(), "Set Cel Properties");
- if (count == 1) {
- if (newOpacity != m_cel->opacity())
+ if (count == 1 && m_cel) {
+ if (!m_cel->layer()->isBackground() &&
+ 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));
@@ -178,7 +186,8 @@ private:
else {
for (Cel* cel : m_document->sprite()->uniqueCels()) {
if (m_range.inRange(cel->sprite()->layerToIndex(cel->layer()), cel->frame())) {
- if (!cel->layer()->isBackground()) {
+ if (!cel->layer()->isBackground() &&
+ newOpacity != cel->opacity()) {
transaction.execute(new cmd::SetCelOpacity(cel, newOpacity));
}
@@ -204,8 +213,12 @@ private:
}
void onPopupUserData() {
- if (m_cel) {
- m_userData = m_cel->data()->userData();
+ if (countCels() > 0) {
+ if (m_cel)
+ m_userData = m_cel->data()->userData();
+ else
+ m_userData = UserData();
+
if (show_user_data_popup(userData()->bounds(), m_userData)) {
onCommitChange();
}
@@ -235,22 +248,17 @@ private:
base::ScopedValue<bool> switchSelf(m_selfUpdate, true, false);
- int count = countCels();
+ int bgCount = 0;
+ int count = countCels(&bgCount);
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
- opacity()->setEnabled(true);
- }
+ opacity()->setEnabled(bgCount < count);
}
else {
opacity()->setEnabled(false);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/aseprite.git
More information about the Pkg-games-commits
mailing list