Skip to content

Commit

Permalink
Fixed unhiding of disabled controls when showing the entire brush con…
Browse files Browse the repository at this point in the history
…trols UI
  • Loading branch information
ipochto committed Dec 9, 2024
1 parent 08a4df2 commit adae0f6
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
24 changes: 24 additions & 0 deletions src/editor/editor_brush_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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);
}
}
}
//@}
22 changes: 13 additions & 9 deletions src/include/editor_brush_ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -65,7 +59,17 @@ class CBrushControlsUI

private:
gcn::Container *container = nullptr;
std::list<gcn::Widget *> controls;

std::list<gcn::Widget *> 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<gcn::Widget *> 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<gcn::DropDown> brushSelect;
std::unique_ptr<StringListModel> brushesList;
Expand Down

0 comments on commit adae0f6

Please sign in to comment.