Sketcher: Use generic tool hints table for DrawSketchHandlerArcOfEllipse

This commit is contained in:
Kacper Donat
2025-06-28 19:59:25 +02:00
parent b2453caaea
commit 20876d7b35

View File

@@ -407,48 +407,35 @@ protected:
private:
std::list<Gui::InputHint> getToolHints() const override
{
return lookupArcOfEllipseHints(Mode);
using enum Gui::InputHint::UserInput;
return Gui::lookupHints<SelectMode>(
Mode,
{
{.state = STATUS_SEEK_First,
.hints =
{
{QObject::tr("%1 pick ellipse center"), {MouseLeft}},
}},
{.state = STATUS_SEEK_Second,
.hints =
{
{QObject::tr("%1 pick axis point"), {MouseLeft}},
}},
{.state = STATUS_SEEK_Third,
.hints =
{
{QObject::tr("%1 pick arc start point"), {MouseLeft}},
}},
{.state = STATUS_SEEK_Fourth,
.hints =
{
{QObject::tr("%1 pick arc end point"), {MouseLeft}},
}},
});
}
private:
struct HintEntry
{
int mode;
std::list<Gui::InputHint> hints;
};
using HintTable = std::vector<HintEntry>;
static HintTable getArcOfEllipseHintTable();
static std::list<Gui::InputHint> lookupArcOfEllipseHints(int mode);
};
DrawSketchHandlerArcOfEllipse::HintTable DrawSketchHandlerArcOfEllipse::getArcOfEllipseHintTable()
{
return {// Structure: {mode, {hints...}}
{STATUS_SEEK_First,
{{QObject::tr("%1 pick ellipse center"), {Gui::InputHint::UserInput::MouseLeft}}}},
{STATUS_SEEK_Second,
{{QObject::tr("%1 pick axis point"), {Gui::InputHint::UserInput::MouseLeft}}}},
{STATUS_SEEK_Third,
{{QObject::tr("%1 pick arc start point"), {Gui::InputHint::UserInput::MouseLeft}}}},
{STATUS_SEEK_Fourth,
{{QObject::tr("%1 pick arc end point"), {Gui::InputHint::UserInput::MouseLeft}}}}};
}
std::list<Gui::InputHint> DrawSketchHandlerArcOfEllipse::lookupArcOfEllipseHints(int mode)
{
const auto arcOfEllipseHintTable = getArcOfEllipseHintTable();
auto it = std::find_if(arcOfEllipseHintTable.begin(),
arcOfEllipseHintTable.end(),
[mode](const HintEntry& entry) {
return entry.mode == mode;
});
return (it != arcOfEllipseHintTable.end()) ? it->hints : std::list<Gui::InputHint> {};
}
} // namespace SketcherGui