diff --git a/src/app/ui/color_popup.cpp b/src/app/ui/color_popup.cpp index 5ab2f71d1..ec54a40ca 100644 --- a/src/app/ui/color_popup.cpp +++ b/src/app/ui/color_popup.cpp @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2001-2017 David Capello +// Copyright (C) 2001-2018 David Capello // // This program is distributed under the terms of // the End-User License Agreement for Aseprite. @@ -23,6 +23,7 @@ #include "app/modules/palettes.h" #include "app/resource_finder.h" #include "app/transaction.h" +#include "app/ui/color_bar.h" #include "app/ui/palette_view.h" #include "app/ui/skin/skin_theme.h" #include "app/ui_context.h" @@ -387,7 +388,12 @@ void ColorPopup::onColorHexEntryChange(const app::Color& color) setColorWithSignal(color, ChangeType); findBestfitIndex(color); - m_disableHexUpdate = false; + // If we are in edit mode, the "m_disableHexUpdate" will be changed + // to false in onPaletteChange() after the color bar timer is + // triggered. In this way we don't modify the hex field when the + // user is editing it and the palette "edit mode" is enabled. + if (!inEditMode()) + m_disableHexUpdate = false; } void ColorPopup::onSimpleColorClick() @@ -462,6 +468,9 @@ void ColorPopup::onPaletteChange() { setColor(getColor(), DontChangeType); invalidate(); + + if (inEditMode()) + m_disableHexUpdate = false; } void ColorPopup::findBestfitIndex(const app::Color& color) @@ -539,4 +548,14 @@ void ColorPopup::selectColorType(app::Color::Type type) m_vbox.invalidate(); } +bool ColorPopup::inEditMode() +{ + return + // TODO use other flag instead of m_canPin, here we want to ask if + // this ColorPopup is related to the main ColorBar (instead of + // other ColorButtons like the one in "Replace Color", etc.) + (m_canPin) && + (ColorBar::instance()->inEditMode()); +} + } // namespace app diff --git a/src/app/ui/color_popup.h b/src/app/ui/color_popup.h index 73fdd8233..0e7e2af9b 100644 --- a/src/app/ui/color_popup.h +++ b/src/app/ui/color_popup.h @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2001-2017 David Capello +// Copyright (C) 2001-2018 David Capello // // This program is distributed under the terms of // the End-User License Agreement for Aseprite. @@ -62,6 +62,7 @@ namespace app { void setColorWithSignal(const app::Color& color, const SetColorOptions options); void findBestfitIndex(const app::Color& color); + bool inEditMode(); class SimpleColors; class CustomButtonSet : public ButtonSet {