[aseprite] 06/250: Add tooltips to FilterTargetButtons (fix #786)

Tobias Hansen thansen at moszumanska.debian.org
Sun Dec 20 15:26:57 UTC 2015


This is an automated email from the git hooks/post-receive script.

thansen pushed a commit to branch master
in repository aseprite.

commit 9231e9bd51082d169283b28b661eb860c8d1bfec
Author: David Capello <davidcapello at gmail.com>
Date:   Fri Aug 28 15:33:53 2015 -0300

    Add tooltips to FilterTargetButtons (fix #786)
---
 src/app/commands/filters/filter_target_buttons.cpp | 50 +++++++++++++++++++---
 src/app/commands/filters/filter_target_buttons.h   |  4 ++
 2 files changed, 49 insertions(+), 5 deletions(-)

diff --git a/src/app/commands/filters/filter_target_buttons.cpp b/src/app/commands/filters/filter_target_buttons.cpp
index e649870..07eebc0 100644
--- a/src/app/commands/filters/filter_target_buttons.cpp
+++ b/src/app/commands/filters/filter_target_buttons.cpp
@@ -42,6 +42,7 @@ FilterTargetButtons::FilterTargetButtons(int imgtype, bool withChannels)
   , m_cels(nullptr)
 {
   setMultipleSelection(true);
+  addChild(&m_tooltips);
 
   if (withChannels) {
     switch (imgtype) {
@@ -53,9 +54,8 @@ FilterTargetButtons::FilterTargetButtons(int imgtype, bool withChannels)
         m_blue  = addItem("B");
         m_alpha = addItem("A");
 
-        if (imgtype == IMAGE_INDEXED) {
+        if (imgtype == IMAGE_INDEXED)
           m_index = addItem("Index", 4, 1);
-        }
         break;
 
       case IMAGE_GRAYSCALE:
@@ -81,7 +81,7 @@ void FilterTargetButtons::setTarget(int target)
   selectTargetButton(m_gray,  TARGET_GRAY_CHANNEL);
   selectTargetButton(m_index, TARGET_INDEX_CHANNEL);
 
-  m_cels->setIcon(getCelsIcon());
+  updateFromTarget();
 }
 
 void FilterTargetButtons::selectTargetButton(Item* item, Target specificTarget)
@@ -90,6 +90,47 @@ void FilterTargetButtons::selectTargetButton(Item* item, Target specificTarget)
     item->setSelected((m_target & specificTarget) == specificTarget);
 }
 
+void FilterTargetButtons::updateFromTarget()
+{
+  m_cels->setIcon(getCelsIcon());
+
+  updateComponentTooltip(m_red, "Red", BOTTOM);
+  updateComponentTooltip(m_green, "Green", BOTTOM);
+  updateComponentTooltip(m_blue, "Blue", BOTTOM);
+  updateComponentTooltip(m_gray, "Gray", BOTTOM);
+  updateComponentTooltip(m_alpha, "Alpha", BOTTOM);
+  updateComponentTooltip(m_index, "Index", LEFT);
+
+  const char* celsTooltip = "";
+  switch (m_target & (TARGET_ALL_FRAMES | TARGET_ALL_LAYERS)) {
+    case 0:
+      celsTooltip = "Apply to the active frame/layer (the active cel)";
+      break;
+    case TARGET_ALL_FRAMES:
+      celsTooltip = "Apply to all frames in the active layer";
+      break;
+    case TARGET_ALL_LAYERS:
+      celsTooltip = "Apply to all layers in the active frame";
+      break;
+    case TARGET_ALL_FRAMES | TARGET_ALL_LAYERS:
+      celsTooltip = "Apply to all cels in the sprite";
+      break;
+  }
+
+  m_tooltips.addTooltipFor(m_cels, celsTooltip, LEFT);
+}
+
+void FilterTargetButtons::updateComponentTooltip(Item* item, const char* channelName, int align)
+{
+  if (item) {
+    char buf[256];
+    std::sprintf(buf, "%s %s Component",
+                 (item->isSelected() ? "Modify": "Ignore"),
+                 channelName);
+    m_tooltips.addTooltipFor(item, buf, align);
+  }
+}
+
 void FilterTargetButtons::onItemChange()
 {
   ButtonSet::onItemChange();
@@ -122,8 +163,7 @@ void FilterTargetButtons::onItemChange()
 
   if (m_target != flags) {
     m_target = flags;
-    m_cels->setIcon(getCelsIcon());
-
+    updateFromTarget();
     TargetChange();
   }
 }
diff --git a/src/app/commands/filters/filter_target_buttons.h b/src/app/commands/filters/filter_target_buttons.h
index 255badd..ee2e98e 100644
--- a/src/app/commands/filters/filter_target_buttons.h
+++ b/src/app/commands/filters/filter_target_buttons.h
@@ -13,6 +13,7 @@
 #include "app/ui/skin/skin_part.h"
 #include "base/signal.h"
 #include "filters/target.h"
+#include "ui/tooltips.h"
 
 namespace ui {
   class ButtonBase;
@@ -39,6 +40,8 @@ namespace app {
 
   private:
     void selectTargetButton(Item* item, Target specificTarget);
+    void updateFromTarget();
+    void updateComponentTooltip(Item* item, const char* channelName, int align);
     skin::SkinPartPtr getCelsIcon() const;
 
     Target m_target;
@@ -49,6 +52,7 @@ namespace app {
     Item* m_gray;
     Item* m_index;
     Item* m_cels;
+    ui::TooltipManager m_tooltips;
   };
 
 } // namespace app

-- 
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