Fix dithering matrix selection in Gradient tool (fix #4184)

Regression introduced in 8d435e02d8
This commit is contained in:
David Capello 2023-11-30 11:02:52 -03:00
parent 29b76353ef
commit 60b4524e41
1 changed files with 17 additions and 11 deletions

View File

@ -19,6 +19,7 @@
#include "app/commands/quick_command.h" #include "app/commands/quick_command.h"
#include "app/doc.h" #include "app/doc.h"
#include "app/doc_event.h" #include "app/doc_event.h"
#include "app/extensions.h"
#include "app/i18n/strings.h" #include "app/i18n/strings.h"
#include "app/ini_file.h" #include "app/ini_file.h"
#include "app/match_words.h" #include "app/match_words.h"
@ -1149,11 +1150,9 @@ private:
class ContextBar::DynamicsField : public ButtonSet class ContextBar::DynamicsField : public ButtonSet
, public DynamicsPopup::Delegate { , public DynamicsPopup::Delegate {
public: public:
DynamicsField(ContextBar* ctxBar, DynamicsField(ContextBar* ctxBar)
DitheringSelector* ditheringSelector)
: ButtonSet(1) : ButtonSet(1)
, m_ctxBar(ctxBar) , m_ctxBar(ctxBar) {
, m_ditheringSelector(ditheringSelector) {
addItem(SkinTheme::get(this)->parts.dynamics(), "dynamics_field"); addItem(SkinTheme::get(this)->parts.dynamics(), "dynamics_field");
loadDynamicsPref(); loadDynamicsPref();
@ -1253,11 +1252,19 @@ public:
m_dynamics.maxVelocityThreshold = dynaPref.maxVelocityThreshold(); m_dynamics.maxVelocityThreshold = dynaPref.maxVelocityThreshold();
m_dynamics.colorFromTo = dynaPref.colorFromTo(); m_dynamics.colorFromTo = dynaPref.colorFromTo();
m_ditheringSelector->setSelectedItemIndex( // Get the dithering matrix by name from the extensions.
m_ditheringSelector->findItemIndex(dynaPref.matrixName())); bool found = false;
auto ditheringMatrices = App::instance()
m_dynamics.ditheringMatrix = ->extensions().ditheringMatrices();
m_ditheringSelector->ditheringMatrix(); for (const auto& it : ditheringMatrices) {
if (it.name() == dynaPref.matrixName()) {
m_dynamics.ditheringMatrix = it.matrix();
found = true;
break;
}
}
if (!found)
m_dynamics.ditheringMatrix = render::DitheringMatrix();
} }
private: private:
@ -1291,7 +1298,6 @@ private:
std::unique_ptr<DynamicsPopup> m_popup; std::unique_ptr<DynamicsPopup> m_popup;
ContextBar* m_ctxBar; ContextBar* m_ctxBar;
DitheringSelector* m_ditheringSelector;
mutable tools::DynamicsOptions m_dynamics; mutable tools::DynamicsOptions m_dynamics;
bool m_optionsGridVisibility = true; bool m_optionsGridVisibility = true;
bool m_sameInAllTools = false; bool m_sameInAllTools = false;
@ -1849,7 +1855,7 @@ ContextBar::ContextBar(TooltipManager* tooltipManager,
addChild(m_selectBoxHelp = new Label("")); addChild(m_selectBoxHelp = new Label(""));
addChild(m_freehandBox = new HBox()); addChild(m_freehandBox = new HBox());
m_freehandBox->addChild(m_dynamics = new DynamicsField(this, m_ditheringSelector)); m_freehandBox->addChild(m_dynamics = new DynamicsField(this));
m_freehandBox->addChild(m_freehandAlgo = new FreehandAlgorithmField()); m_freehandBox->addChild(m_freehandAlgo = new FreehandAlgorithmField());
addChild(m_symmetry = new SymmetryField()); addChild(m_symmetry = new SymmetryField());