Avoid including ColorBar in PaletteView

This commit is contained in:
David Capello 2015-05-20 11:38:38 -03:00
parent 23a4cb3a0b
commit ae048f5756
4 changed files with 17 additions and 4 deletions

View File

@ -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)

View File

@ -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();

View File

@ -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);

View File

@ -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