From ad0d30b2df912ce092187788a6f21217e5e538b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Capello?= Date: Wed, 4 Dec 2024 10:10:40 -0300 Subject: [PATCH] Set appropriate default parameters values Take the default values for the command parameters from the UI when the UI is available and ui=false --- src/app/commands/cmd_mask_by_color.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/app/commands/cmd_mask_by_color.cpp b/src/app/commands/cmd_mask_by_color.cpp index 1865539df..7e6ef2d94 100644 --- a/src/app/commands/cmd_mask_by_color.cpp +++ b/src/app/commands/cmd_mask_by_color.cpp @@ -65,15 +65,6 @@ public: // ADD/SUBTRACT/INTERSECT Selection Mode , m_isOrigMaskVisible(reader.document()->isMaskVisible()) { - if (!params.color.isSet()) - params.color(ColorBar::instance()->getFgColor()); - - if (!params.tolerance.isSet()) - params.tolerance(get_config_int(ConfigSection, "Tolerance", 0)); - - if (!params.mode.isSet()) - params.mode(Preferences::instance().selection.mode()); - TooltipManager* tooltipManager = new TooltipManager(); addChild(tooltipManager); auto box1 = new Box(VERTICAL); @@ -237,7 +228,7 @@ void MaskByColorCommand::onExecute(Context* context) const ContextReader reader(context); const Sprite* sprite = reader.sprite(); - if (!App::instance()->isGui() || !sprite) + if (!sprite) return; int xpos, ypos; @@ -251,6 +242,19 @@ void MaskByColorCommand::onExecute(Context* context) bool apply = true; auto& params = this->params(); + + // If UI is available, set parameters default values from the UI/configuration + if (context->isUIAvailable()) { + if (!params.color.isSet()) + params.color(ColorBar::instance()->getFgColor()); + + if (!params.tolerance.isSet()) + params.tolerance(get_config_int(ConfigSection, "Tolerance", 0)); + + if (!params.mode.isSet()) + params.mode(Preferences::instance().selection.mode()); + } + if (ui) { MaskByColorWindow window(params, reader);