From 621555163036cd0e4b9b144f3b0b880b5d65a795 Mon Sep 17 00:00:00 2001
From: Mikhail Svechnikov <m.svechnikov@fz-juelich.de>
Date: Fri, 24 Jun 2022 20:11:08 +0200
Subject: [PATCH] WidgetUtils are unified

---
 GUI/View/Common/DoubleSpinBox.cpp             |  9 +--
 GUI/View/Common/DoubleSpinBox.h               |  3 +-
 GUI/View/Fit/MinimizerSettingsWidget.cpp      | 36 ++--------
 GUI/View/Fit/MinimizerSettingsWidget.h        |  1 -
 .../Instrument/DetectorAlignmentEditor.cpp    |  8 +--
 GUI/View/Instrument/DetectorAlignmentEditor.h |  2 +-
 GUI/View/Instrument/DetectorEditor.cpp        |  2 +-
 GUI/View/Instrument/DistributionEditor.cpp    |  2 +-
 GUI/View/Instrument/EnvironmentEditor.cpp     |  4 +-
 .../Instrument/FootprintCorrectionEditor.cpp  |  6 +-
 .../Instrument/PolarizationAnalysisEditor.cpp | 10 +--
 .../Instrument/PolarizationAnalysisEditor.h   |  2 +-
 .../Instrument/RectangularDetectorEditor.cpp  |  4 +-
 .../Instrument/ResolutionFunctionEditor.cpp   |  2 +-
 GUI/View/Instrument/SphericalAxisEditor.cpp   |  2 +-
 GUI/View/Mask/MaskEditorPropertyPanel.cpp     |  2 +-
 .../PlotUtil/IntensityDataPropertyWidget.cpp  | 16 ++---
 .../SpecularDataPropertyWidget.cpp            | 10 +--
 GUI/View/SampleDesigner/FormLayouter.cpp      |  2 +-
 GUI/View/SampleDesigner/LayerEditorUtils.cpp  |  2 +-
 GUI/View/Tool/WidgetUtils.cpp                 | 65 +++++++++----------
 GUI/View/Tool/WidgetUtils.h                   | 39 ++++++++---
 22 files changed, 114 insertions(+), 115 deletions(-)

diff --git a/GUI/View/Common/DoubleSpinBox.cpp b/GUI/View/Common/DoubleSpinBox.cpp
index 559879f6ff1..df25318009c 100644
--- a/GUI/View/Common/DoubleSpinBox.cpp
+++ b/GUI/View/Common/DoubleSpinBox.cpp
@@ -16,9 +16,10 @@
 #include "GUI/View/Tool/EditUtil.h"
 #include <QWheelEvent>
 
-DoubleSpinBox::DoubleSpinBox(QWidget* parent, const DoubleDescriptor& d)
+DoubleSpinBox::DoubleSpinBox(const DoubleDescriptor& d, bool easyScrollable, QWidget* parent)
     : QDoubleSpinBox(parent)
     , m_valueDescriptor(d)
+    , easyScrollable(easyScrollable)
 {
     setFocusPolicy(Qt::StrongFocus);
     GUI::View::EditUtil::configSpinbox(this, d.decimals, d.limits);
@@ -80,10 +81,10 @@ void DoubleSpinBox::setBaseValue(double baseValue)
 
 void DoubleSpinBox::wheelEvent(QWheelEvent* event)
 {
-    if (!hasFocus())
-        event->ignore();
-    else
+    if (hasFocus() || easyScrollable)
         QDoubleSpinBox::wheelEvent(event);
+    else
+        event->ignore();
 }
 
 void DoubleSpinBox::onDisplayValueChanged(double newDisplayValue)
diff --git a/GUI/View/Common/DoubleSpinBox.h b/GUI/View/Common/DoubleSpinBox.h
index 23465e943b5..639a566bef5 100644
--- a/GUI/View/Common/DoubleSpinBox.h
+++ b/GUI/View/Common/DoubleSpinBox.h
@@ -28,7 +28,7 @@ public:
     //! Furthermore, the spin box will prohibit accidental changes by the mouse wheel. Otherwise it
     //! would be dangerous if the spin box is on a scrollable form - unintended and unnoticed
     //! changes would take place when just scrolling through the form.
-    DoubleSpinBox(QWidget* parent, const DoubleDescriptor& d);
+    DoubleSpinBox(const DoubleDescriptor& d, bool easyScrollable = false, QWidget* parent = nullptr);
 
     //! Set a display unit.
     //!
@@ -77,6 +77,7 @@ private:
     Unit m_displayUnit = Unit::unitless;
 
     DoubleDescriptor m_valueDescriptor;
+    bool easyScrollable;
 
     //! it was decided to not show the unit as a suffix. However, this may be user
     //! selectable once, therefore the code is kept and controlled by this flag
diff --git a/GUI/View/Fit/MinimizerSettingsWidget.cpp b/GUI/View/Fit/MinimizerSettingsWidget.cpp
index 439a5d81259..5cbd53ec430 100644
--- a/GUI/View/Fit/MinimizerSettingsWidget.cpp
+++ b/GUI/View/Fit/MinimizerSettingsWidget.cpp
@@ -17,6 +17,7 @@
 #include "GUI/Model/Job/JobItem.h"
 #include "GUI/Model/Job/MinimizerItem.h"
 #include "GUI/View/Common/DoubleSpinBox.h"
+#include "GUI/View/Common/SafeSpinBox.h"
 #include "GUI/View/Tool/LayoutUtils.h"
 #include "GUI/View/Tool/WidgetUtils.h"
 #include <QComboBox>
@@ -55,7 +56,7 @@ void MinimizerSettingsWidget::setItem(MinimizerContainerItem* minimizerItem)
         return;
 
     m_mainLayout->addRow("Minimizer:",
-                         GUI::Util::createComboBox(m_currentItem->minimizers(), &m_updaters,
+                         GUI::Util::createComboBoxUpdScroll(m_currentItem->minimizers(), &m_updaters,
                          [=](int) { createMimimizerEdits(); }));
 
     auto* w = new QWidget(this);
@@ -64,39 +65,14 @@ void MinimizerSettingsWidget::setItem(MinimizerContainerItem* minimizerItem)
     m_mainLayout->addRow(w);
 
     m_mainLayout->addRow("Objective metric:",
-                         GUI::Util::createComboBox(m_currentItem->objectiveMetric(), &m_updaters));
+                         GUI::Util::createComboBoxUpdScroll(m_currentItem->objectiveMetric(), &m_updaters));
     m_mainLayout->addRow("Norm function:",
-                         GUI::Util::createComboBox(m_currentItem->normFunction(), &m_updaters));
+                         GUI::Util::createComboBoxUpdScroll(m_currentItem->normFunction(), &m_updaters));
 
     createMimimizerEdits();
     updateUIValues();
 }
 
-QWidget* MinimizerSettingsWidget::createSpinbox(UIntDescriptor d)
-{
-    auto* spinBox = new QSpinBox(this);
-    spinBox->setToolTip(d.tooltip);
-    spinBox->setMaximum(std::numeric_limits<int>::max());
-    spinBox->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
-
-    if (d.limits.hasLowerLimit())
-        spinBox->setMinimum(static_cast<int>(d.limits.lowerLimit()));
-    if (d.limits.hasUpperLimit())
-        spinBox->setMaximum(static_cast<int>(d.limits.upperLimit()));
-
-    spinBox->setValue(d.get());
-
-    QObject::connect(spinBox, QOverload<int>::of(&QSpinBox::valueChanged),
-                     [=](int newValue) { d.set(newValue); });
-
-    m_updaters << [=]() {
-        QSignalBlocker b(spinBox);
-        spinBox->setValue(d.get());
-    };
-
-    return spinBox;
-}
-
 void MinimizerSettingsWidget::createMimimizerEdits()
 {
     GUI::Util::Layout::clearLayout(m_minimizerLayout);
@@ -107,10 +83,10 @@ void MinimizerSettingsWidget::createMimimizerEdits()
             m_minimizerLayout->addRow(d.label + ":", GUI::Util::createDoubleSpinbox(d, &m_updaters));
         } else if (std::holds_alternative<SelectionDescriptor<QString>>(v)) {
             auto d = std::get<SelectionDescriptor<QString>>(v);
-            m_minimizerLayout->addRow(d.label + ":", GUI::Util::createComboBox(d, &m_updaters));
+            m_minimizerLayout->addRow(d.label + ":", GUI::Util::createComboBoxUpdScroll(d, &m_updaters));
         } else if (std::holds_alternative<UIntDescriptor>(v)) {
             auto d = std::get<UIntDescriptor>(v);
-            m_minimizerLayout->addRow(d.label + ":", createSpinbox(d));
+            m_minimizerLayout->addRow(d.label + ":", GUI::Util::createSpinBoxScroll(d, &m_updaters));
         }
     }
 }
diff --git a/GUI/View/Fit/MinimizerSettingsWidget.h b/GUI/View/Fit/MinimizerSettingsWidget.h
index 7aa8cebd7e5..315f5aad338 100644
--- a/GUI/View/Fit/MinimizerSettingsWidget.h
+++ b/GUI/View/Fit/MinimizerSettingsWidget.h
@@ -42,7 +42,6 @@ public slots:
     void setItem(MinimizerContainerItem* minimizerItem);
 
 private:
-    QWidget* createSpinbox(UIntDescriptor d);
     void createMimimizerEdits();
 
     void updateUIValues();
diff --git a/GUI/View/Instrument/DetectorAlignmentEditor.cpp b/GUI/View/Instrument/DetectorAlignmentEditor.cpp
index 03736bf5444..ecae03211b6 100644
--- a/GUI/View/Instrument/DetectorAlignmentEditor.cpp
+++ b/GUI/View/Instrument/DetectorAlignmentEditor.cpp
@@ -53,7 +53,7 @@ DetectorAlignmentEditor::DetectorAlignmentEditor(QWidget* parent, RectangularDet
     auto* m_combo = GUI::Util::createComboBox(item->detectorAlignmentSelection(), [=](int) {
             createAligmentWidgets();
             emit dataChanged();
-        }, false);
+        });
 
     m_formLayout->addRow("Alignment:", m_combo);
 
@@ -73,9 +73,9 @@ DoubleSpinBox* DetectorAlignmentEditor::createSpinBox(QFormLayout* parentFormLay
     return sb;
 }
 
-DoubleSpinBox* DetectorAlignmentEditor::createSpinBox(QWidget* parent, const DoubleDescriptor& d)
+DoubleSpinBox* DetectorAlignmentEditor::createSpinBox(const DoubleDescriptor& d)
 {
-    auto* sb = new DoubleSpinBox(parent, d);
+    auto* sb = new DoubleSpinBox(d);
     connect(sb, &DoubleSpinBox::baseValueChanged, [=](double v) {
         if (d.get() != v) {
             d.set(v);
@@ -91,7 +91,7 @@ void DetectorAlignmentEditor::addVector(QFormLayout* parentLayout, const VectorD
 
     const auto add = [&](const DoubleDescriptor& d) {
         layout->addWidget(new QLabel(GUI::Util::labelWithUnit(d) + ":"));
-        layout->addWidget(createSpinBox(parentLayout->parentWidget(), d));
+        layout->addWidget(createSpinBox(d));
     };
 
     add(d.x);
diff --git a/GUI/View/Instrument/DetectorAlignmentEditor.h b/GUI/View/Instrument/DetectorAlignmentEditor.h
index be96d94ec09..749d5f2e021 100644
--- a/GUI/View/Instrument/DetectorAlignmentEditor.h
+++ b/GUI/View/Instrument/DetectorAlignmentEditor.h
@@ -38,7 +38,7 @@ signals:
 private:
     void createAligmentWidgets();
     DoubleSpinBox* createSpinBox(QFormLayout* parentFormLayout, const DoubleDescriptor& d);
-    DoubleSpinBox* createSpinBox(QWidget* parent, const DoubleDescriptor& d);
+    DoubleSpinBox* createSpinBox(const DoubleDescriptor& d);
     void addVector(QFormLayout* parentLayout, const VectorDescriptor& d);
 
 private:
diff --git a/GUI/View/Instrument/DetectorEditor.cpp b/GUI/View/Instrument/DetectorEditor.cpp
index b5b40da9111..4e089410fa4 100644
--- a/GUI/View/Instrument/DetectorEditor.cpp
+++ b/GUI/View/Instrument/DetectorEditor.cpp
@@ -33,7 +33,7 @@ DetectorEditor::DetectorEditor(QWidget* parent, Instrument2DItem* instrument)
     auto* detectorTypeCombo = GUI::Util::createComboBox(instrument->detectorSelection(), [=](int) {
             createDetectorWidgets();
             emit dataChanged();
-        }, false);
+        });
     m_formLayout->addRow("Detector:", detectorTypeCombo);
 
     GroupBoxCollapser::installIntoGroupBox(this);
diff --git a/GUI/View/Instrument/DistributionEditor.cpp b/GUI/View/Instrument/DistributionEditor.cpp
index f9db76b7a67..36875c4b511 100644
--- a/GUI/View/Instrument/DistributionEditor.cpp
+++ b/GUI/View/Instrument/DistributionEditor.cpp
@@ -48,7 +48,7 @@ DistributionSelector::DistributionSelector(std::optional<MeanConfig> mean_config
     m_distributionCombo = GUI::Util::createComboBox(item->distributionSelection(), [=](int) {
             createDistributionWidgets();
             emit distributionChanged();
-        }, false);
+        });
     m_formLayout->addRow("Distribution:", m_distributionCombo);
 
     createDistributionWidgets();
diff --git a/GUI/View/Instrument/EnvironmentEditor.cpp b/GUI/View/Instrument/EnvironmentEditor.cpp
index 33c5ad596f0..fd09b840960 100644
--- a/GUI/View/Instrument/EnvironmentEditor.cpp
+++ b/GUI/View/Instrument/EnvironmentEditor.cpp
@@ -32,7 +32,7 @@ EnvironmentEditor::EnvironmentEditor(QWidget* parent, InstrumentItem* instrument
             GUI::Util::createComboBox(instrument->backgroundSelection(), [=](int) {
             createBackgroundWidgets();
             emit dataChanged();
-        }, false);
+        });
     m_formLayout->addRow("Background type:", backgroundTypeCombo);
 
     createBackgroundWidgets();
@@ -46,7 +46,7 @@ void EnvironmentEditor::createBackgroundWidgets()
 
     auto* backgroundItem = m_instrument->backgroundSelection().currentItem();
     if (auto* p = dynamic_cast<ConstantBackgroundItem*>(backgroundItem)) {
-        auto* spinbox = new DoubleSpinBox(this, p->backgroundValue());
+        auto* spinbox = new DoubleSpinBox(p->backgroundValue());
         spinbox->setSingleStep(0.01);
         m_formLayout->addRow("Background value:", spinbox);
 
diff --git a/GUI/View/Instrument/FootprintCorrectionEditor.cpp b/GUI/View/Instrument/FootprintCorrectionEditor.cpp
index 5ae99784eef..be8a338e5f5 100644
--- a/GUI/View/Instrument/FootprintCorrectionEditor.cpp
+++ b/GUI/View/Instrument/FootprintCorrectionEditor.cpp
@@ -31,7 +31,7 @@ FootprintCorrectionEditor::FootprintCorrectionEditor(QWidget* parent, SpecularBe
     auto* typeCombo = GUI::Util::createComboBox(item->footprintSelection(), [=](int) {
         createFootprintWidgets();
         emit dataChanged();
-    }, false);
+    });
     m_formLayout->addRow("Type:", typeCombo);
 
     GroupBoxCollapser::installIntoGroupBox(this);
@@ -46,7 +46,7 @@ void FootprintCorrectionEditor::createFootprintWidgets()
 
     auto* footprintItem = m_item->footprintSelection().currentItem();
     if (auto* square = dynamic_cast<FootprintSquareItem*>(footprintItem)) {
-        auto* spinbox = new DoubleSpinBox(this, square->squareFootprintValue());
+        auto* spinbox = new DoubleSpinBox(square->squareFootprintValue());
         spinbox->setSingleStep(0.01);
         m_formLayout->addRow("Width ratio:", spinbox);
         connect(spinbox, qOverload<double>(&DoubleSpinBox::baseValueChanged), [=](double newValue) {
@@ -54,7 +54,7 @@ void FootprintCorrectionEditor::createFootprintWidgets()
             emit dataChanged();
         });
     } else if (auto* gauss = dynamic_cast<FootprintGaussianItem*>(footprintItem)) {
-        auto* spinbox = new DoubleSpinBox(this, gauss->gaussianFootprintValue());
+        auto* spinbox = new DoubleSpinBox(gauss->gaussianFootprintValue());
         spinbox->setSingleStep(0.01);
         m_formLayout->addRow("Width ratio:", spinbox);
         connect(spinbox, qOverload<double>(&DoubleSpinBox::baseValueChanged), [=](double newValue) {
diff --git a/GUI/View/Instrument/PolarizationAnalysisEditor.cpp b/GUI/View/Instrument/PolarizationAnalysisEditor.cpp
index 34fc7a4c884..2f7590d933a 100644
--- a/GUI/View/Instrument/PolarizationAnalysisEditor.cpp
+++ b/GUI/View/Instrument/PolarizationAnalysisEditor.cpp
@@ -40,10 +40,10 @@ PolarizationAnalysisEditor::PolarizationAnalysisEditor(QWidget* parent, Instrume
     addVector(formlayout, m_instrument->polarization());
     addVector(formlayout, m_instrument->analyzerDirection());
     formlayout->addRow(GUI::Util::labelWithUnit(m_instrument->analyzerEfficiency()) + ":",
-                       createSpinBox(polarizerAnalyzerWidget, m_instrument->analyzerEfficiency()));
+                       createSpinBox(m_instrument->analyzerEfficiency()));
     formlayout->addRow(
         GUI::Util::labelWithUnit(m_instrument->analyzerTotalTransmission()) + ":",
-        createSpinBox(polarizerAnalyzerWidget, m_instrument->analyzerTotalTransmission()));
+        createSpinBox(m_instrument->analyzerTotalTransmission()));
 
     layout->addWidget(polarizerAnalyzerWidget);
     polarizerAnalyzerWidget->setVisible(m_instrument->withPolarizerAnalyzer());
@@ -57,9 +57,9 @@ PolarizationAnalysisEditor::PolarizationAnalysisEditor(QWidget* parent, Instrume
     GroupBoxCollapser::installIntoGroupBox(this);
 }
 
-DoubleSpinBox* PolarizationAnalysisEditor::createSpinBox(QWidget* parent, const DoubleDescriptor& d)
+DoubleSpinBox* PolarizationAnalysisEditor::createSpinBox(const DoubleDescriptor& d)
 {
-    auto* sb = new DoubleSpinBox(parent, d);
+    auto* sb = new DoubleSpinBox(d);
     connect(sb, &DoubleSpinBox::baseValueChanged, [=](double v) {
         if (d.get() != v) {
             d.set(v);
@@ -75,7 +75,7 @@ void PolarizationAnalysisEditor::addVector(QFormLayout* parentLayout, const Vect
 
     const auto add = [&](const DoubleDescriptor& d) {
         layout->addWidget(new QLabel(GUI::Util::labelWithUnit(d) + ":"));
-        layout->addWidget(createSpinBox(parentLayout->parentWidget(), d));
+        layout->addWidget(createSpinBox(d));
     };
 
     add(d.x);
diff --git a/GUI/View/Instrument/PolarizationAnalysisEditor.h b/GUI/View/Instrument/PolarizationAnalysisEditor.h
index 9bfceca2f0a..e5b23c34db7 100644
--- a/GUI/View/Instrument/PolarizationAnalysisEditor.h
+++ b/GUI/View/Instrument/PolarizationAnalysisEditor.h
@@ -36,7 +36,7 @@ signals:
     void dataChanged();
 
 private:
-    DoubleSpinBox* createSpinBox(QWidget* parent, const DoubleDescriptor& d);
+    DoubleSpinBox* createSpinBox(const DoubleDescriptor& d);
     void addVector(QFormLayout* parentLayout, const VectorDescriptor& d);
 
     InstrumentItem* m_instrument;
diff --git a/GUI/View/Instrument/RectangularDetectorEditor.cpp b/GUI/View/Instrument/RectangularDetectorEditor.cpp
index 3aa2953dc91..ec7da653667 100644
--- a/GUI/View/Instrument/RectangularDetectorEditor.cpp
+++ b/GUI/View/Instrument/RectangularDetectorEditor.cpp
@@ -47,7 +47,7 @@ RectangularDetectorEditor::RectangularDetectorEditor(QWidget* parent,
     xAxisNbinsSpinBox->setValue(detector->xSize());
     xAxisFormLayout->addRow("Nbins:", xAxisNbinsSpinBox);
 
-    auto* widthSpinBox = new DoubleSpinBox(xAxisGroupBox, detector->width());
+    auto* widthSpinBox = new DoubleSpinBox(detector->width());
     xAxisFormLayout->addRow("Width [mm]:", widthSpinBox);
 
     connect(xAxisNbinsSpinBox, qOverload<int>(&QSpinBox::valueChanged), [=](int newValue) {
@@ -74,7 +74,7 @@ RectangularDetectorEditor::RectangularDetectorEditor(QWidget* parent,
     yAxisNbinsSpinBox->setValue(detector->ySize());
     yAxisFormLayout->addRow("Nbins:", yAxisNbinsSpinBox);
 
-    auto* heightSpinBox = new DoubleSpinBox(yAxisGroupBox, detector->height());
+    auto* heightSpinBox = new DoubleSpinBox(detector->height());
     yAxisFormLayout->addRow("Height [mm]:", heightSpinBox);
 
     connect(yAxisNbinsSpinBox, qOverload<int>(&QSpinBox::valueChanged), [=](int newValue) {
diff --git a/GUI/View/Instrument/ResolutionFunctionEditor.cpp b/GUI/View/Instrument/ResolutionFunctionEditor.cpp
index eaf948dc3b3..2bec4e91dcb 100644
--- a/GUI/View/Instrument/ResolutionFunctionEditor.cpp
+++ b/GUI/View/Instrument/ResolutionFunctionEditor.cpp
@@ -35,7 +35,7 @@ ResolutionFunctionEditor::ResolutionFunctionEditor(Unit unit, QWidget* parent, D
         GUI::Util::createComboBox(item->resolutionFunctionSelection(), [=](int) {
             createResolutionWidgets();
             emit dataChanged();
-        }, false);
+        });
     m_formLayout->addRow("Type:", typeCombo);
 
     GroupBoxCollapser::installIntoGroupBox(this);
diff --git a/GUI/View/Instrument/SphericalAxisEditor.cpp b/GUI/View/Instrument/SphericalAxisEditor.cpp
index d5a184c4685..6dc75f65c2b 100644
--- a/GUI/View/Instrument/SphericalAxisEditor.cpp
+++ b/GUI/View/Instrument/SphericalAxisEditor.cpp
@@ -22,7 +22,7 @@ SphericalAxisForm::SphericalAxisForm(QFormLayout* form, QWidget* parent)
     : QObject(parent)
     , m_item(nullptr)
 {
-    m_nbinsSpinBox = new SafeSpinBox(false);
+    m_nbinsSpinBox = new SafeSpinBox;
     m_nbinsSpinBox->setRange(1, 65536);
     connect(m_nbinsSpinBox, qOverload<int>(&QSpinBox::valueChanged), this,
             &SphericalAxisForm::onNbinsValueChanged);
diff --git a/GUI/View/Mask/MaskEditorPropertyPanel.cpp b/GUI/View/Mask/MaskEditorPropertyPanel.cpp
index 0be0c3e7bba..5d4d2437353 100644
--- a/GUI/View/Mask/MaskEditorPropertyPanel.cpp
+++ b/GUI/View/Mask/MaskEditorPropertyPanel.cpp
@@ -222,7 +222,7 @@ void MaskEditorPropertyPanel::createMaskEditorUI()
 
 void MaskEditorPropertyPanel::addMaskSpinBox(DoubleDescriptor d)
 {
-    auto* spinBox = new DoubleSpinBox(m_maskPropertiesLayout->parentWidget(), d);
+    auto* spinBox = new DoubleSpinBox(d);
     spinBox->setBaseValue(d.get());
     QObject::connect(spinBox, &DoubleSpinBox::baseValueChanged,
                      [=](double newValue) { d.set(newValue); });
diff --git a/GUI/View/PlotUtil/IntensityDataPropertyWidget.cpp b/GUI/View/PlotUtil/IntensityDataPropertyWidget.cpp
index 56db3f133cf..102abea7bee 100644
--- a/GUI/View/PlotUtil/IntensityDataPropertyWidget.cpp
+++ b/GUI/View/PlotUtil/IntensityDataPropertyWidget.cpp
@@ -73,11 +73,11 @@ void IntensityDataPropertyWidget::setItem(QVector<IntensityDataItem*> items)
     if (!first_item)
         return;
 
-    m_mainLayout->addRow("Axes units:", GUI::Util::createComboBox(
+    m_mainLayout->addRow("Axes units:", GUI::Util::createComboBoxUpdScroll(
         first_item->axesUnits(), &m_updaters,
         [=](int newIndex) { FOR_OTHER_ITEMS item->axesUnits().setCurrentIndex(newIndex); }));
 
-    m_mainLayout->addRow("Color scheme:", GUI::Util::createComboBox(
+    m_mainLayout->addRow("Color scheme:", GUI::Util::createComboBoxUpdScroll(
         first_item->gradient(), &m_updaters,
         [=](int newIndex) { FOR_OTHER_ITEMS item->gradient().setCurrentIndex(newIndex); }));
 
@@ -92,11 +92,11 @@ void IntensityDataPropertyWidget::setItem(QVector<IntensityDataItem*> items)
     xFormLayout->setContentsMargins(0, 0, 0, 0);
     xFormLayout->setSpacing(5);
 
-    xFormLayout->addRow("Min:", GUI::Util::createDoubleSpinbox(
+    xFormLayout->addRow("Min:", GUI::Util::createDoubleSpinboxScroll(
         first_item->xAxisItem()->min(), &m_updaters,
         [=](double newValue) { FOR_OTHER_ITEMS item->xAxisItem()->min().set(newValue); }));
 
-    xFormLayout->addRow("Max:", GUI::Util::createDoubleSpinbox(
+    xFormLayout->addRow("Max:", GUI::Util::createDoubleSpinboxScroll(
         first_item->xAxisItem()->max(), &m_updaters,
         [=](double newValue) { FOR_OTHER_ITEMS item->xAxisItem()->max().set(newValue); }));
 
@@ -113,11 +113,11 @@ void IntensityDataPropertyWidget::setItem(QVector<IntensityDataItem*> items)
     yFormLayout->setContentsMargins(0, 0, 0, 0);
     yFormLayout->setSpacing(5);
 
-    yFormLayout->addRow("Min:", GUI::Util::createDoubleSpinbox(
+    yFormLayout->addRow("Min:", GUI::Util::createDoubleSpinboxScroll(
         first_item->yAxisItem()->min(), &m_updaters,
         [=](double newValue) { FOR_OTHER_ITEMS item->yAxisItem()->min().set(newValue); }));
 
-    yFormLayout->addRow("Max:", GUI::Util::createDoubleSpinbox(
+    yFormLayout->addRow("Max:", GUI::Util::createDoubleSpinboxScroll(
         first_item->yAxisItem()->max(), &m_updaters,
         [=](double newValue) { FOR_OTHER_ITEMS item->yAxisItem()->max().set(newValue); }));
 
@@ -134,11 +134,11 @@ void IntensityDataPropertyWidget::setItem(QVector<IntensityDataItem*> items)
     zFormLayout->setContentsMargins(0, 0, 0, 0);
     zFormLayout->setSpacing(5);
 
-    zFormLayout->addRow("Min:", GUI::Util::createDoubleSpinbox(
+    zFormLayout->addRow("Min:", GUI::Util::createDoubleSpinboxScroll(
         first_item->zAxisItem()->min(), &m_updaters,
         [=](double newValue) { FOR_OTHER_ITEMS item->zAxisItem()->min().set(newValue); }));
 
-    zFormLayout->addRow("Max:", GUI::Util::createDoubleSpinbox(
+    zFormLayout->addRow("Max:", GUI::Util::createDoubleSpinboxScroll(
         first_item->zAxisItem()->max(), &m_updaters,
         [=](double newValue) { FOR_OTHER_ITEMS item->zAxisItem()->max().set(newValue); }));
 
diff --git a/GUI/View/PropertyEditor/SpecularDataPropertyWidget.cpp b/GUI/View/PropertyEditor/SpecularDataPropertyWidget.cpp
index 28ea972adb0..bd14f263c34 100644
--- a/GUI/View/PropertyEditor/SpecularDataPropertyWidget.cpp
+++ b/GUI/View/PropertyEditor/SpecularDataPropertyWidget.cpp
@@ -77,7 +77,7 @@ void SpecularDataPropertyWidget::setItem(QVector<SpecularDataItem*> items)
     if (!first_item)
         return;
 
-    m_mainLayout->addRow("Axes units:", GUI::Util::createComboBox(
+    m_mainLayout->addRow("Axes units:", GUI::Util::createComboBoxUpdScroll(
         first_item->axesUnits(), &m_updaters,
         [=](int newIndex) { FOR_OTHER_ITEMS item->axesUnits().setCurrentIndex(newIndex); }));
 
@@ -87,11 +87,11 @@ void SpecularDataPropertyWidget::setItem(QVector<SpecularDataItem*> items)
     xFormLayout->setContentsMargins(0, 0, 0, 0);
     xFormLayout->setSpacing(5);
 
-    xFormLayout->addRow("Min:", GUI::Util::createDoubleSpinbox(
+    xFormLayout->addRow("Min:", GUI::Util::createDoubleSpinboxScroll(
         first_item->xAxisItem()->min(), &m_updaters,
         [=](double newValue) { FOR_OTHER_ITEMS item->xAxisItem()->min().set(newValue); }));
 
-    xFormLayout->addRow("Max:", GUI::Util::createDoubleSpinbox(
+    xFormLayout->addRow("Max:", GUI::Util::createDoubleSpinboxScroll(
         first_item->xAxisItem()->max(), &m_updaters,
         [=](double newValue) { FOR_OTHER_ITEMS item->xAxisItem()->max().set(newValue); }));
 
@@ -108,11 +108,11 @@ void SpecularDataPropertyWidget::setItem(QVector<SpecularDataItem*> items)
     yFormLayout->setContentsMargins(0, 0, 0, 0);
     yFormLayout->setSpacing(5);
 
-    yFormLayout->addRow("Min:", GUI::Util::createDoubleSpinbox(
+    yFormLayout->addRow("Min:", GUI::Util::createDoubleSpinboxScroll(
         first_item->yAxisItem()->min(), &m_updaters,
         [=](double newValue) { FOR_OTHER_ITEMS item->yAxisItem()->min().set(newValue); }));
 
-    yFormLayout->addRow("Max:", GUI::Util::createDoubleSpinbox(
+    yFormLayout->addRow("Max:", GUI::Util::createDoubleSpinboxScroll(
         first_item->yAxisItem()->max(), &m_updaters,
         [=](double newValue) { FOR_OTHER_ITEMS item->yAxisItem()->max().set(newValue); }));
 
diff --git a/GUI/View/SampleDesigner/FormLayouter.cpp b/GUI/View/SampleDesigner/FormLayouter.cpp
index 99c5fd526d4..32875725a36 100644
--- a/GUI/View/SampleDesigner/FormLayouter.cpp
+++ b/GUI/View/SampleDesigner/FormLayouter.cpp
@@ -183,7 +183,7 @@ void FormLayouter::insertValue(int row, const DoubleDescriptor& d,
     label->setAlignment(Qt::AlignLeft | Qt::AlignBottom);
     label->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::MinimumExpanding);
 
-    auto* editor = new DoubleSpinBox(m_formLayout->parentWidget(), d);
+    auto* editor = new DoubleSpinBox(d);
     QObject::connect(editor, &DoubleSpinBox::baseValueChanged, onValueChange);
 
     label->setBuddy(editor);
diff --git a/GUI/View/SampleDesigner/LayerEditorUtils.cpp b/GUI/View/SampleDesigner/LayerEditorUtils.cpp
index e9ef1ca6dc9..4bacabe3aee 100644
--- a/GUI/View/SampleDesigner/LayerEditorUtils.cpp
+++ b/GUI/View/SampleDesigner/LayerEditorUtils.cpp
@@ -83,7 +83,7 @@ void LayerEditorUtils::addMultiPropertyToGrid(QGridLayout* m_gridLayout, int fir
 {
     int col = firstCol;
     for (const auto& valueDescriptor : valueDescriptors) {
-        auto* editor = new DoubleSpinBox(m_gridLayout->parentWidget(), valueDescriptor);
+        auto* editor = new DoubleSpinBox(valueDescriptor);
         QObject::connect(editor, &DoubleSpinBox::baseValueChanged,
                          [=](double newValue) { setNewValue(newValue, valueDescriptor); });
 
diff --git a/GUI/View/Tool/WidgetUtils.cpp b/GUI/View/Tool/WidgetUtils.cpp
index f929b0827b2..833d0e95262 100644
--- a/GUI/View/Tool/WidgetUtils.cpp
+++ b/GUI/View/Tool/WidgetUtils.cpp
@@ -24,32 +24,8 @@
 #include <QCheckBox>
 #include <QLineEdit>
 
-//QWidget* MinimizerSettingsWidget::createSpinbox(UIntDescriptor d)
-//{
-//    auto* spinBox = new QSpinBox(this);
-//    spinBox->setToolTip(d.tooltip);
-//    spinBox->setMaximum(std::numeric_limits<int>::max());
-//    spinBox->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
-
-//    if (d.limits.hasLowerLimit())
-//        spinBox->setMinimum(static_cast<int>(d.limits.lowerLimit()));
-//    if (d.limits.hasUpperLimit())
-//        spinBox->setMaximum(static_cast<int>(d.limits.upperLimit()));
-
-//    spinBox->setValue(d.get());
-
-//    QObject::connect(spinBox, QOverload<int>::of(&QSpinBox::valueChanged),
-//                     [=](int newValue) { d.set(newValue); });
-
-//    m_updaters << [=]() {
-//        QSignalBlocker b(spinBox);
-//        spinBox->setValue(d.get());
-//    };
-
-//    return spinBox;
-//}
-
 SafeSpinBox* GUI::Util::createSpinBox(const UIntDescriptor& d,
+                                      QList<function<void()>>* updaters,                                      
                                       std::function<void(uint)> slot,
                                       bool easyScrollable)
 {
@@ -65,13 +41,28 @@ SafeSpinBox* GUI::Util::createSpinBox(const UIntDescriptor& d,
 
     spinBox->setValue(d.get());
 
-    if (slot)
-        QObject::connect(spinBox, qOverload<int>(&QSpinBox::valueChanged),
-                         [=](int v) { slot(static_cast<uint>(v)); });
+    QObject::connect(spinBox, QOverload<int>::of(&QSpinBox::valueChanged), [=](int newValue) {
+        d.set(newValue);
+        if (slot)
+            slot(static_cast<uint>(newValue));
+    });
+
+    if(updaters)
+        (*updaters) << [=]() {
+            QSignalBlocker b(spinBox);
+            spinBox->setValue(d.get());
+        };
 
     return spinBox;
 }
 
+SafeSpinBox* GUI::Util::createSpinBoxScroll(const UIntDescriptor& d,
+                                            QList<function<void()>>* updaters,
+                                            std::function<void(uint)> slot)
+{
+    return GUI::Util::createSpinBox(d, updaters, slot, true);
+}
+
 SafeSpinBox* GUI::Util::createSpinBoxRow(QFormLayout* parentLayout,
                                          const UIntDescriptor& d)
 {
@@ -84,7 +75,7 @@ DoubleSpinBox* GUI::Util::createDoubleSpinBoxRow(QFormLayout* parentLayout,
                                                  const DoubleDescriptor& d,
                                                  std::function<void(double)> slot)
 {
-    auto* sb = new DoubleSpinBox(parentLayout->parentWidget(), d);
+    auto* sb = new DoubleSpinBox(d);
     parentLayout->addRow(labelWithUnit(d.label, d.unit) + ":", sb);
 
     if (slot)
@@ -139,7 +130,7 @@ QCheckBox* GUI::Util::createCheckBox(const QString& title,
 
     if(updaters)
         (*updaters) << [=]() {
-            QSignalBlocker block(checkBox);
+            QSignalBlocker b(checkBox);
             checkBox->setChecked(getter());
         };
 
@@ -165,10 +156,11 @@ QLineEdit* GUI::Util::createTextEdit(function<QString()> getter,
 }
 
 DoubleSpinBox* GUI::Util::createDoubleSpinbox(DoubleDescriptor d,
-                                              QList<function<void()>>* updaters,
-                                              function<void(double)> slot)
+                                              QList<function<void()>>* updaters,                                              
+                                              function<void(double)> slot,
+                                              bool easyScrollable)
 {
-    DoubleSpinBox* spinBox = new DoubleSpinBox(nullptr, d);
+    DoubleSpinBox* spinBox = new DoubleSpinBox(d, easyScrollable);
     spinBox->setToolTip(d.tooltip);
     spinBox->updateValue();
 
@@ -183,3 +175,10 @@ DoubleSpinBox* GUI::Util::createDoubleSpinbox(DoubleDescriptor d,
 
     return spinBox;
 }
+
+DoubleSpinBox* GUI::Util::createDoubleSpinboxScroll(DoubleDescriptor d,
+                                                    QList<function<void()>>* updaters,
+                                                    function<void(double)> slot)
+{
+    return GUI::Util::createDoubleSpinbox(d, updaters, slot, true);
+}
diff --git a/GUI/View/Tool/WidgetUtils.h b/GUI/View/Tool/WidgetUtils.h
index 748dcbe0d3b..e2b9df035e4 100644
--- a/GUI/View/Tool/WidgetUtils.h
+++ b/GUI/View/Tool/WidgetUtils.h
@@ -47,9 +47,9 @@ namespace GUI::Util {
 //!
 template <typename T>
 QComboBox* createComboBox(SelectionDescriptor<T> d,
-                          QList<function<void()>>* updaters,
                           function<void(int)> slot = nullptr,
-                          bool isScrollable = true)
+                          QList<function<void()>>* updaters = nullptr,
+                          bool isScrollable = false)
 {
     QComboBox* combo = new QComboBox;
     combo->addItems(d.options);
@@ -74,12 +74,22 @@ QComboBox* createComboBox(SelectionDescriptor<T> d,
 
     return combo;
 }
+
+//! Scrollable and updatable version
 template <typename T>
-QComboBox* createComboBox(SelectionDescriptor<T> d,
-                          function<void(int)> slot = nullptr,
-                          bool isScrollable = true)
+QComboBox* createComboBoxUpdScroll(SelectionDescriptor<T> d,
+                                   QList<function<void()>>* updaters = nullptr,
+                                   function<void(int)> slot = nullptr)
+{
+    return GUI::Util::createComboBox(d, slot, updaters, true);
+}
+
+//! Scrollable, but non-updatable version
+template <typename T>
+QComboBox* createComboBoxScroll(SelectionDescriptor<T> d,
+                                function<void(int)> slot = nullptr)
 {
-    return GUI::Util::createComboBox(d, nullptr, slot, isScrollable);
+    return GUI::Util::createComboBox(d, slot, nullptr, true);
 }
 
 //! Create a spin box with the information found in a UIntDescriptor.
@@ -93,9 +103,15 @@ QComboBox* createComboBox(SelectionDescriptor<T> d,
 //! will *not* be notified to the descriptor. The additional (and optional) slot can be used to be
 //! notified about a value change.
 SafeSpinBox* createSpinBox(const UIntDescriptor& d,
+                           QList<function<void()>>* updaters = nullptr,
                            std::function<void(uint)> slot = nullptr,
                            bool easyScrollable = false);
 
+//! Creates a scrollable spinbox
+SafeSpinBox* createSpinBoxScroll(const UIntDescriptor& d,
+                                 QList<function<void()>>* updaters = nullptr,
+                                 std::function<void(uint)> slot = nullptr);
+
 //! Create a label and a spin box with the information found in a UIntDescriptor and place them in a
 //! row in a form layout.
 //!
@@ -157,8 +173,15 @@ QLineEdit* createTextEdit(function<QString()> getter,
 
 //! Creates an updatable doublespinBox
 DoubleSpinBox* createDoubleSpinbox(DoubleDescriptor d,
-                                   QList<function<void ()>>* updaters,
-                                   function<void(double)> slot = nullptr);
+                                   QList<function<void ()>>* updaters = nullptr,
+                                   function<void(double)> slot = nullptr,
+                                   bool easyScrollable = false);
+
+//! Creates a scrollable updatable doublespinBox
+DoubleSpinBox* createDoubleSpinboxScroll(DoubleDescriptor d,
+                                         QList<function<void()>>* updaters = nullptr,
+                                         function<void(double)> slot = nullptr);
+
 
 } // namespace GUI::Util
 
-- 
GitLab