diff --git a/src/app/commands/cmd_palette_editor.cpp b/src/app/commands/cmd_palette_editor.cpp index 3ea534863..0899d0350 100644 --- a/src/app/commands/cmd_palette_editor.cpp +++ b/src/app/commands/cmd_palette_editor.cpp @@ -277,8 +277,8 @@ PaletteEntryEditor::PaletteEntryEditor() m_vbox.addChild(&m_bottomBox); addChild(&m_vbox); - m_colorType.ItemChange.connect(&PaletteEntryEditor::onColorTypeClick, this); - m_changeMode.ItemChange.connect(&PaletteEntryEditor::onChangeModeClick, this); + m_colorType.ItemChange.connect(Bind(&PaletteEntryEditor::onColorTypeClick, this)); + m_changeMode.ItemChange.connect(Bind(&PaletteEntryEditor::onChangeModeClick, this)); m_rgbSliders.ColorChange.connect(&PaletteEntryEditor::onColorSlidersChange, this); m_hsvSliders.ColorChange.connect(&PaletteEntryEditor::onColorSlidersChange, this); diff --git a/src/app/commands/filters/filter_target_buttons.cpp b/src/app/commands/filters/filter_target_buttons.cpp index 0060b3054..50fbe2d08 100644 --- a/src/app/commands/filters/filter_target_buttons.cpp +++ b/src/app/commands/filters/filter_target_buttons.cpp @@ -132,11 +132,26 @@ void FilterTargetButtons::updateComponentTooltip(Item* item, const char* channel } } -void FilterTargetButtons::onItemChange() +void FilterTargetButtons::onItemChange(Item* item) { - ButtonSet::onItemChange(); + ButtonSet::onItemChange(item); Target flags = (m_target & (TARGET_ALL_FRAMES | TARGET_ALL_LAYERS)); + if (m_index && item && item->isSelected()) { + if (item == m_index) { + m_red->setSelected(false); + m_green->setSelected(false); + m_blue->setSelected(false); + m_alpha->setSelected(false); + } + else if (item == m_red || + item == m_green || + item == m_blue || + item == m_alpha) { + m_index->setSelected(false); + } + } + if (m_red && m_red->isSelected()) flags |= TARGET_RED_CHANNEL; if (m_green && m_green->isSelected()) flags |= TARGET_GREEN_CHANNEL; if (m_blue && m_blue->isSelected()) flags |= TARGET_BLUE_CHANNEL; diff --git a/src/app/commands/filters/filter_target_buttons.h b/src/app/commands/filters/filter_target_buttons.h index ee2e98e4a..51f1fea23 100644 --- a/src/app/commands/filters/filter_target_buttons.h +++ b/src/app/commands/filters/filter_target_buttons.h @@ -34,7 +34,7 @@ namespace app { Signal0 TargetChange; protected: - void onItemChange() override; + void onItemChange(Item* item) override; void onChannelChange(ui::ButtonBase* button); void onImagesChange(ui::ButtonBase* button); diff --git a/src/app/ui/brush_popup.cpp b/src/app/ui/brush_popup.cpp index 09c71915f..61cf54cfe 100644 --- a/src/app/ui/brush_popup.cpp +++ b/src/app/ui/brush_popup.cpp @@ -17,6 +17,7 @@ #include "app/ui/button_set.h" #include "app/ui/keyboard_shortcuts.h" #include "app/ui/skin/skin_theme.h" +#include "base/bind.h" #include "base/convert_to.h" #include "doc/brush.h" #include "doc/conversion_she.h" @@ -179,7 +180,7 @@ void BrushPopup::regenerate(const gfx::Rect& box, const Brushes& brushes) while (((slot-1) % columns) > 0) m_buttons->addItem(new Item(this, m_delegate, BrushRef(nullptr), slot++)); - m_buttons->ItemChange.connect(&BrushPopup::onButtonChange, this); + m_buttons->ItemChange.connect(Bind(&BrushPopup::onButtonChange, this)); m_buttons->setTransparent(true); m_buttons->setBgColor(gfx::ColorNone); addChild(m_buttons.get()); diff --git a/src/app/ui/button_set.cpp b/src/app/ui/button_set.cpp index a378b031d..d47d0f89f 100644 --- a/src/app/ui/button_set.cpp +++ b/src/app/ui/button_set.cpp @@ -155,7 +155,7 @@ bool ButtonSet::Item::onProcessMessage(ui::Message* msg) if (mnemonicPressed || (hasFocus() && keymsg->scancode() == kKeySpace)) { buttonSet()->setSelectedItem(this); - buttonSet()->onItemChange(); + buttonSet()->onItemChange(this); } } break; @@ -167,7 +167,7 @@ bool ButtonSet::Item::onProcessMessage(ui::Message* msg) if (static_cast(msg)->left() && !buttonSet()->m_triggerOnMouseUp) { - buttonSet()->onItemChange(); + buttonSet()->onItemChange(this); } break; @@ -178,7 +178,7 @@ bool ButtonSet::Item::onProcessMessage(ui::Message* msg) if (static_cast(msg)->left()) { if (buttonSet()->m_triggerOnMouseUp) - buttonSet()->onItemChange(); + buttonSet()->onItemChange(this); } else if (static_cast(msg)->right()) { buttonSet()->onRightClick(this); @@ -321,9 +321,9 @@ void ButtonSet::setMultipleSelection(bool state) m_multipleSelection = state; } -void ButtonSet::onItemChange() +void ButtonSet::onItemChange(Item* item) { - ItemChange(); + ItemChange(item); } void ButtonSet::onRightClick(Item* item) diff --git a/src/app/ui/button_set.h b/src/app/ui/button_set.h index d69f27d35..cc032515c 100644 --- a/src/app/ui/button_set.h +++ b/src/app/ui/button_set.h @@ -49,11 +49,11 @@ namespace app { void setTriggerOnMouseUp(bool state); void setMultipleSelection(bool state); - Signal0 ItemChange; + Signal1 ItemChange; Signal1 RightClick; protected: - virtual void onItemChange(); + virtual void onItemChange(Item* item); virtual void onRightClick(Item* item); private: diff --git a/src/app/ui/color_selector.cpp b/src/app/ui/color_selector.cpp index 152ec92b7..c2cd859b8 100644 --- a/src/app/ui/color_selector.cpp +++ b/src/app/ui/color_selector.cpp @@ -89,7 +89,7 @@ ColorSelector::ColorSelector() m_vbox.addChild(&m_maskLabel); addChild(&m_vbox); - m_colorType.ItemChange.connect(&ColorSelector::onColorTypeClick, this); + m_colorType.ItemChange.connect(Bind(&ColorSelector::onColorTypeClick, this)); m_rgbSliders.ColorChange.connect(&ColorSelector::onColorSlidersChange, this); m_hsvSliders.ColorChange.connect(&ColorSelector::onColorSlidersChange, this); diff --git a/src/app/ui/context_bar.cpp b/src/app/ui/context_bar.cpp index b6e7d9472..eee24b7de 100644 --- a/src/app/ui/context_bar.cpp +++ b/src/app/ui/context_bar.cpp @@ -95,8 +95,8 @@ public: } protected: - void onItemChange() override { - ButtonSet::onItemChange(); + void onItemChange(Item* item) override { + ButtonSet::onItemChange(item); if (!m_popupWindow.isVisible()) openPopup(); @@ -348,8 +348,8 @@ public: } protected: - void onItemChange() override { - ButtonSet::onItemChange(); + void onItemChange(Item* item) override { + ButtonSet::onItemChange(item); gfx::Rect bounds = getBounds(); @@ -691,8 +691,6 @@ public: : ButtonSet(1) { addItem(SkinTheme::instance()->parts.pivotCenter()); - ItemChange.connect(Bind(&PivotField::onPopup, this)); - Preferences::instance().selection.pivotPosition.AfterChange.connect( Bind(&PivotField::onPivotChange, this)); @@ -701,9 +699,10 @@ public: private: - void onPopup() { - SkinTheme* theme = static_cast(getTheme()); + void onItemChange(Item* item) override { + ButtonSet::onItemChange(item); + SkinTheme* theme = static_cast(getTheme()); gfx::Rect bounds = getBounds(); Menu menu; @@ -737,7 +736,7 @@ private: }); buttonset.ItemChange.connect( - [&buttonset](){ + [&buttonset](ButtonSet::Item* item){ Preferences::instance().selection.pivotPosition( app::gen::PivotPosition(buttonset.selectedItem())); }); @@ -1016,8 +1015,8 @@ public: } protected: - void onItemChange() override { - ButtonSet::onItemChange(); + void onItemChange(Item* item) override { + ButtonSet::onItemChange(item); Preferences::instance().selection.mode( (tools::SelectionMode)selectedItem()); @@ -1043,8 +1042,8 @@ public: Signal1 DropPixels; protected: - void onItemChange() override { - ButtonSet::onItemChange(); + void onItemChange(Item* item) override { + ButtonSet::onItemChange(item); switch (selectedItem()) { case 0: DropPixels(ContextBarObserver::DropPixels); break;