diff --git a/src/editor/editor_brush_ui.cpp b/src/editor/editor_brush_ui.cpp index c2d1b4ba0c..40bca7c529 100644 --- a/src/editor/editor_brush_ui.cpp +++ b/src/editor/editor_brush_ui.cpp @@ -187,6 +187,9 @@ void CBrushControlsUI::Init(gcn::Container* parrent, const gcn::Rectangle &recta void CBrushControlsUI::reloadCtrlSettings() { + if (!hiddenControls.empty()) { + hiddenControls.clear(); + } const auto brush = Editor.brushes.getCurrentBrush(); enableRnd->setVisible(brush.isRandomizeAllowed()); enableRnd->setSelected(brush.isAutoRandomizationEnabled()); @@ -243,4 +246,25 @@ void CBrushControlsUI::updateSizeCtrls() sizeSlider->setValue(brush.getHeight()); } } + +void CBrushControlsUI::show() +{ + for(auto &ctrl : hiddenControls) { + ctrl->setVisible(true); + } + hiddenControls.clear(); +} + +void CBrushControlsUI::hide() +{ + if (!hiddenControls.empty()) { + return; + } + for(auto &ctrl : controls) { + if (ctrl->isVisible()) { + ctrl->setVisible(false); + hiddenControls.push_back(ctrl); + } + } +} //@} diff --git a/src/include/editor_brush_ui.h b/src/include/editor_brush_ui.h index bbc00be838..bbc18d34bd 100644 --- a/src/include/editor_brush_ui.h +++ b/src/include/editor_brush_ui.h @@ -47,14 +47,8 @@ class CBrushControlsUI } ~CBrushControlsUI() = default; - void setVisibe(const bool value) - { - for(auto &ctrl : controls) { - ctrl->setVisible(value); - } - } - void show() { setVisibe(true); } - void hide() { setVisibe(false); } + void show(); + void hide(); void reloadBrushes(); private: @@ -65,7 +59,17 @@ class CBrushControlsUI private: gcn::Container *container = nullptr; - std::list controls; + + std::list controls; // List of all controls (both enabled and disabled for + // current brush). In order to improve readability, instead + // of disabling controls, we just hide them. + + std::list hiddenControls; // List of temporarily hidden controls that are + // _enabled_ for current brush. If we need to hide + // the entire BrushControlsUI we save all currently + // enabled controls into this list and then hide them. + // We use this list to avoid unhiding the disabled + // ones later. std::unique_ptr brushSelect; std::unique_ptr brushesList;