diff --git a/src/editor/editor_brush_ui.cpp b/src/editor/editor_brush_ui.cpp index 40bca7c529..b54ddfd151 100644 --- a/src/editor/editor_brush_ui.cpp +++ b/src/editor/editor_brush_ui.cpp @@ -134,11 +134,29 @@ void CBrushControlsUI::Init(gcn::Container* parrent, const gcn::Rectangle &recta + verticalGap / 2); updateSizeCtrls(); + allowResizeRadioListener = std::make_unique([this](const std::string &) { + const auto brush = Editor.brushes.getCurrentBrush(); + + if (allowResize["Both"]->isSelected() || allowResize["WidthOnly"]->isSelected()) { + sizeSlider->setScale(brush.getMinSize().x, brush.getMaxSize().x); + sizeSlider->setStepLength(brush.getResizeSteps().x); + sizeSlider->setValue(brush.getWidth()); + } else { + sizeSlider->setScale(brush.getMinSize().y, brush.getMaxSize().y); + sizeSlider->setStepLength(brush.getResizeSteps().y); + sizeSlider->setValue(brush.getHeight()); + } + + }); + + allowResize["Both"]->addActionListener(allowResizeRadioListener.get()); + allowResize["WidthOnly"]->addActionListener(allowResizeRadioListener.get()); + allowResize["HeightOnly"]->addActionListener(allowResizeRadioListener.get()); + brushSizeSliderListener = std::make_unique([this](const std::string&) { const uint8_t size = sizeSlider->getValue(); - DebugPrint("Brush size: %d\n", int(size)); if (allowResize["Both"]->isSelected()) { Editor.brushes.getCurrentBrush().resize(size, size); diff --git a/src/include/editor_brush_ui.h b/src/include/editor_brush_ui.h index bbc18d34bd..0467cf4359 100644 --- a/src/include/editor_brush_ui.h +++ b/src/include/editor_brush_ui.h @@ -80,6 +80,7 @@ class CBrushControlsUI enum ResizeAllowed { cBoth = 0, cWidthOnly, cHeightOnly }; std::map> allowResize; + std::unique_ptr allowResizeRadioListener; std::unique_ptr enableRnd; std::unique_ptr enableRndListener;