Skip to content

Commit

Permalink
only send delegate update on closing ColorPickPopup
Browse files Browse the repository at this point in the history
  • Loading branch information
matcool committed Nov 15, 2024
1 parent bebc7b4 commit 3081164
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
1 change: 1 addition & 0 deletions loader/include/Geode/ui/ColorPickPopup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ namespace geode {

void onOpacitySlider(cocos2d::CCObject* sender);
void onReset(cocos2d::CCObject* sender);
void onClose(cocos2d::CCObject* sender) override;

void textChanged(CCTextInputNode* input) override;
void colorValueChanged(cocos2d::ccColor3B color) override;
Expand Down
18 changes: 11 additions & 7 deletions loader/src/ui/nodes/ColorPickPopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,10 @@ bool ColorPickPopup::setup(ccColor4B const& color, bool isRGBA) {
}

void ColorPickPopup::updateState(CCNode* except) {
#define IF_NOT_EXCEPT(inp, value) \
if (inp->getInputNode() != except) { \
inp->setString(value, false); \
}
#define IF_NOT_EXCEPT(inp, value) \
if (inp->getInputNode() != except) { \
inp->setString(value, false); \
}

IF_NOT_EXCEPT(m_impl->m_rInput, numToString<int>(m_impl->m_color.r));
IF_NOT_EXCEPT(m_impl->m_gInput, numToString<int>(m_impl->m_color.g));
Expand All @@ -357,9 +357,6 @@ void ColorPickPopup::updateState(CCNode* except) {
}
m_impl->m_resetBtn->setVisible(m_impl->m_originalColor != m_impl->m_color);
m_impl->m_newColorSpr->setColor(to3B(m_impl->m_color));
if (m_impl->m_delegate) {
m_impl->m_delegate->updateColor(m_impl->m_color);
}
}

void ColorPickPopup::onOpacitySlider(CCObject* sender) {
Expand All @@ -372,6 +369,13 @@ void ColorPickPopup::onReset(CCObject*) {
this->updateState();
}

void ColorPickPopup::onClose(CCObject* sender) {
if (m_impl->m_delegate) {
m_impl->m_delegate->updateColor(m_impl->m_color);
}
Popup::onClose(sender);
}

void ColorPickPopup::textChanged(CCTextInputNode* input) {
if (input->getString().size()) {
switch (input->getTag()) {
Expand Down

0 comments on commit 3081164

Please sign in to comment.