diff --git a/src/app/ui/color_bar.cpp b/src/app/ui/color_bar.cpp index 478c1d8e5..0665b4c69 100644 --- a/src/app/ui/color_bar.cpp +++ b/src/app/ui/color_bar.cpp @@ -466,6 +466,16 @@ void ColorBar::onPaletteViewPasteColors( setPalette(&newPalette, "Paste Colors"); } +app::Color ColorBar::onPaletteViewGetForegroundIndex() +{ + return getFgColor(); +} + +app::Color ColorBar::onPaletteViewGetBackgroundIndex() +{ + return getBgColor(); +} + void ColorBar::onFgColorChangeFromPreferences() { if (m_syncingWithPref) diff --git a/src/app/ui/color_bar.h b/src/app/ui/color_bar.h index 60cfd033e..f2ce7cffa 100644 --- a/src/app/ui/color_bar.h +++ b/src/app/ui/color_bar.h @@ -92,6 +92,8 @@ namespace app { void onPaletteViewRemapColors(const doc::Remap& remap, const doc::Palette* newPalette) override; void onPaletteViewChangeSize(int boxsize) override; void onPaletteViewPasteColors(const Palette* fromPal, const doc::PalettePicks& from, const doc::PalettePicks& to) override; + app::Color onPaletteViewGetForegroundIndex() override; + app::Color onPaletteViewGetBackgroundIndex() override; private: void destroyRemap(); diff --git a/src/app/ui/palette_view.cpp b/src/app/ui/palette_view.cpp index ca69b5046..b8be5ba6f 100644 --- a/src/app/ui/palette_view.cpp +++ b/src/app/ui/palette_view.cpp @@ -16,7 +16,6 @@ #include "app/modules/editors.h" #include "app/modules/gui.h" #include "app/modules/palettes.h" -#include "app/ui/color_bar.h" // TODO avoid depending on ColorBar #include "app/ui/editor/editor.h" #include "app/ui/palette_view.h" #include "app/ui/skin/skin_theme.h" @@ -407,9 +406,9 @@ void PaletteView::onPaint(ui::PaintEvent& ev) int fgIndex = -1; int bgIndex = -1; - if (m_style == FgBgColors) { - fgIndex = findExactIndex(ColorBar::instance()->getFgColor()); - bgIndex = findExactIndex(ColorBar::instance()->getBgColor()); + if (m_style == FgBgColors && m_delegate) { + fgIndex = findExactIndex(m_delegate->onPaletteViewGetForegroundIndex()); + bgIndex = findExactIndex(m_delegate->onPaletteViewGetBackgroundIndex()); } g->fillRect(gfx::rgba(0, 0, 0), bounds); diff --git a/src/app/ui/palette_view.h b/src/app/ui/palette_view.h index c1af2cec3..27b028f8e 100644 --- a/src/app/ui/palette_view.h +++ b/src/app/ui/palette_view.h @@ -34,6 +34,8 @@ namespace app { virtual void onPaletteViewChangeSize(int boxsize) { } virtual void onPaletteViewPasteColors( const doc::Palette* fromPal, const doc::PalettePicks& from, const doc::PalettePicks& to) { } + virtual app::Color onPaletteViewGetForegroundIndex() { return app::Color::fromMask(); } + virtual app::Color onPaletteViewGetBackgroundIndex() { return app::Color::fromMask(); } }; class PaletteView : public ui::Widget