From 7263a3d3ab19d977198dc88c954eb2a86eb920cf Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Wed, 10 Mar 2010 18:04:23 -0800 Subject: [PATCH] Fix flicker during palette update. --- src/ui/dialog/swatches.cpp | 40 +++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index caa2fb610..a142e619d 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -123,26 +123,32 @@ private: ColorItem::ColorItem(ege::PaintDef::ColorType type) : def(type), ptr(0), + tips(), + _previews(), _isFill(false), _isStroke(false), _isLive(false), _linkIsTone(false), _linkPercent(0), _linkGray(0), - _linkSrc(0) + _linkSrc(0), + _listeners() { } ColorItem::ColorItem( unsigned int r, unsigned int g, unsigned int b, Glib::ustring& name ) : def( r, g, b, name ), ptr(0), + tips(), + _previews(), _isFill(false), _isStroke(false), _isLive(false), _linkIsTone(false), _linkPercent(0), _linkGray(0), - _linkSrc(0) + _linkSrc(0), + _listeners() { } @@ -1504,7 +1510,35 @@ void SwatchesPanel::handleGradientsChange() void SwatchesPanel::handleDefsModified() { - handleGradientsChange(); +#if USE_DOCUMENT_PALETTE + if ( _ptr ) { + std::vector tmpColors; + std::map tmpPrevs; + std::map tmpGrads; + + recalSwatchContents(_currentDocument, tmpColors, tmpPrevs, tmpGrads, this); + + JustForNow *docPalette = reinterpret_cast(_ptr); + if (docPalette) { + int cap = std::min(docPalette->_colors.size(), tmpColors.size()); + for (int i = 0; i < cap; i++) { + ColorItem* newColor = tmpColors[i]; + ColorItem* oldColor = docPalette->_colors[i]; + if ( (newColor->def.getType() != oldColor->def.getType()) || + (newColor->def.getR() != oldColor->def.getR()) || + (newColor->def.getG() != oldColor->def.getG()) || + (newColor->def.getB() != oldColor->def.getB()) ) { + oldColor->def.setRGB(newColor->def.getR(), newColor->def.getG(), newColor->def.getB()); + } + } + } + + for (std::map::iterator it = tmpPrevs.begin(); it != tmpPrevs.end(); ++it) + { + g_free(it->second); + } + } +#endif // USE_DOCUMENT_PALETTE } void SwatchesPanel::_updateFromSelection() -- 2.30.2