diff --git a/toonz/sources/tnztools/fullcolorbrushtool.cpp b/toonz/sources/tnztools/fullcolorbrushtool.cpp index 808efaa..5b7d27e 100644 --- a/toonz/sources/tnztools/fullcolorbrushtool.cpp +++ b/toonz/sources/tnztools/fullcolorbrushtool.cpp @@ -184,20 +184,7 @@ void FullColorBrushTool::updateTranslation() { void FullColorBrushTool::onActivate() { if (!m_notifier) m_notifier = new FullColorBrushToolNotifier(this); - TTool::Application *app = getApplication(); - - if (app->getCurrentObject()->isSpline()) { - m_currentColor = TPixel32::Red; - return; - } - - int styleIndex = app->getCurrentLevelStyleIndex(); - TPalette *plt = app->getCurrentPalette()->getPalette(); - if (plt) { - int style = app->getCurrentLevelStyleIndex(); - TColorStyle *colorStyle = plt->getStyle(style); - m_currentColor = colorStyle->getMainColor(); - } + updateCurrentColor(); if (m_firstTime) { m_firstTime = false; @@ -271,6 +258,10 @@ void FullColorBrushTool::leftButtonDown(const TPointD &pos, if (!ri) return; + /* update color here since the current style might be switched with numpad + * shortcut keys */ + updateCurrentColor(); + TRasterP ras = ri->getRaster(); TDimension dim = ras->getSize(); @@ -511,18 +502,8 @@ void FullColorBrushTool::onEnter() { m_minThick = 0; m_maxThick = 0; } - Application *app = getApplication(); - if (app->getCurrentObject()->isSpline()) { - m_currentColor = TPixel32::Red; - return; - } - TPalette *plt = app->getCurrentPalette()->getPalette(); - if (!plt) return; - - int style = app->getCurrentLevelStyleIndex(); - TColorStyle *colorStyle = plt->getStyle(style); - m_currentColor = colorStyle->getMainColor(); + updateCurrentColor(); } //---------------------------------------------------------------------------------------------------------- @@ -680,6 +661,22 @@ void FullColorBrushTool::removePreset() { m_preset.setValue(CUSTOM_WSTR); } +//------------------------------------------------------------------ + +void FullColorBrushTool::updateCurrentColor() { + TTool::Application *app = getApplication(); + if (app->getCurrentObject()->isSpline()) { + m_currentColor = TPixel32::Red; + return; + } + TPalette *plt = app->getCurrentPalette()->getPalette(); + if (!plt) return; + + int style = app->getCurrentLevelStyleIndex(); + TColorStyle *colorStyle = plt->getStyle(style); + m_currentColor = colorStyle->getMainColor(); +} + //========================================================================================================== FullColorBrushToolNotifier::FullColorBrushToolNotifier(FullColorBrushTool *tool) diff --git a/toonz/sources/tnztools/fullcolorbrushtool.h b/toonz/sources/tnztools/fullcolorbrushtool.h index 2eebc70..f6aff57 100644 --- a/toonz/sources/tnztools/fullcolorbrushtool.h +++ b/toonz/sources/tnztools/fullcolorbrushtool.h @@ -23,6 +23,8 @@ class FullColorBrushToolNotifier; class FullColorBrushTool final : public TTool { Q_DECLARE_TR_FUNCTIONS(FullColorBrushTool) + void updateCurrentColor(); + public: FullColorBrushTool(std::string name);