mirror of
https://github.com/aseprite/aseprite.git
synced 2024-12-27 12:20:58 +00:00
Add tooltips to FilterTargetButtons (fix #786)
This commit is contained in:
parent
110aa74dae
commit
9231e9bd51
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user