Sketcher: Use generic tool hints table for DrawSketchHandlerArcOfParabola

This commit is contained in:
Kacper Donat
2025-06-28 19:59:26 +02:00
parent 43208d2d2e
commit dea79014ef

View File

@@ -336,48 +336,35 @@ protected:
private:
std::list<Gui::InputHint> getToolHints() const override
{
return lookupParabolaHints(Mode);
using enum Gui::InputHint::UserInput;
return Gui::lookupHints<SelectMode>(
Mode,
{
{.state = STATUS_SEEK_First,
.hints =
{
{QObject::tr("%1 pick focus point"), {MouseLeft}},
}},
{.state = STATUS_SEEK_Second,
.hints =
{
{QObject::tr("%1 pick axis point"), {MouseLeft}},
}},
{.state = STATUS_SEEK_Third,
.hints =
{
{QObject::tr("%1 pick starting point"), {MouseLeft}},
}},
{.state = STATUS_SEEK_Fourth,
.hints =
{
{QObject::tr("%1 pick end point"), {MouseLeft}},
}},
});
}
private:
struct HintEntry
{
int mode;
std::list<Gui::InputHint> hints;
};
using HintTable = std::vector<HintEntry>;
static HintTable getParabolaHintTable();
static std::list<Gui::InputHint> lookupParabolaHints(int mode);
};
DrawSketchHandlerArcOfParabola::HintTable DrawSketchHandlerArcOfParabola::getParabolaHintTable()
{
return {// Structure: {mode, {hints...}}
{STATUS_SEEK_First,
{{QObject::tr("%1 pick focus point"), {Gui::InputHint::UserInput::MouseLeft}}}},
{STATUS_SEEK_Second,
{{QObject::tr("%1 pick axis point"), {Gui::InputHint::UserInput::MouseLeft}}}},
{STATUS_SEEK_Third,
{{QObject::tr("%1 pick starting point"), {Gui::InputHint::UserInput::MouseLeft}}}},
{STATUS_SEEK_Fourth,
{{QObject::tr("%1 pick end point"), {Gui::InputHint::UserInput::MouseLeft}}}}};
}
std::list<Gui::InputHint> DrawSketchHandlerArcOfParabola::lookupParabolaHints(int mode)
{
const auto parabolaHintTable = getParabolaHintTable();
auto it = std::find_if(parabolaHintTable.begin(),
parabolaHintTable.end(),
[mode](const HintEntry& entry) {
return entry.mode == mode;
});
return (it != parabolaHintTable.end()) ? it->hints : std::list<Gui::InputHint> {};
}
} // namespace SketcherGui
#endif // SKETCHERGUI_DrawSketchHandlerArcOfParabola_H