refine radio button handling

This commit is contained in:
numzero 2026-07-20 14:41:09 +03:00
parent f880de181e
commit cf72e340c7
4 changed files with 8 additions and 8 deletions

View File

@ -42,6 +42,13 @@ using ffi::Mode;
using ffi::ShapeArgs;
using ffi::RedrawArgs;
/// Cast an integer to @c Mode, returning a fallback if the input is out of range.
inline static Mode modeFromInt(std::uint32_t mode) {
if (mode > (std::uint32_t)Mode::Mesh)
return Mode::Solid;
return (Mode)mode;
}
class MutCore {
friend class BoxCore;

View File

@ -37,7 +37,7 @@ void Hyperboloid::updateView() {
m_ui->layersDown->setMaximum(max_layers);
const auto color = m_ui->inBackground->color();
const ShapeArgs shape {
.mode = (Mode)m_ui->mode->checkedId(),
.mode = modeFromInt(m_ui->mode->checkedId()),
.sides = (std::uint32_t)m_ui->sides->value(),
.layers_up = (std::uint32_t)m_ui->layersUp->value(),
.layers_down = (std::uint32_t)m_ui->layersDown->value(),
@ -57,9 +57,4 @@ void Hyperboloid::updateView() {
m_ui->viewport->setView(args);
}
void Hyperboloid::updateViewIf(bool update) {
if (update)
updateView();
}
#include "moc_main_window.cpp"

View File

@ -17,7 +17,6 @@ public:
public slots:
void updateModeUi();
void updateView();
void updateViewIf(bool update); // for radio buttons
private:
const std::unique_ptr<Ui::MainWindow> m_ui;

View File

@ -618,7 +618,6 @@
</connections>
<slots>
<slot>updateView()</slot>
<slot>updateViewIf(bool)</slot>
<slot>updateModeUi()</slot>
</slots>
<buttongroups>