Sketcher: Use generic tool hints table for DrawSketchHandlerPolygon
This commit is contained in:
@@ -265,20 +265,26 @@ private:
|
||||
|
||||
std::list<Gui::InputHint> getToolHints() const override
|
||||
{
|
||||
return lookupPolygonHints(state());
|
||||
using enum Gui::InputHint::UserInput;
|
||||
|
||||
return Gui::lookupHints<SelectMode>(
|
||||
state(),
|
||||
{
|
||||
{.state = SelectMode::SeekFirst,
|
||||
.hints =
|
||||
{
|
||||
{QObject::tr("%1 pick polygon center"), {MouseLeft}},
|
||||
{QObject::tr("%1/%2 increase / decrease number of sides"), {KeyU, KeyJ}},
|
||||
}},
|
||||
{.state = SelectMode::SeekSecond,
|
||||
.hints =
|
||||
{
|
||||
{QObject::tr("%1 pick rotation and size"), {MouseMove}},
|
||||
{QObject::tr("%1 confirm"), {MouseLeft}},
|
||||
{QObject::tr("%1/%2 increase / decrease number of sides"), {KeyU, KeyJ}},
|
||||
}},
|
||||
});
|
||||
}
|
||||
|
||||
private:
|
||||
struct HintEntry
|
||||
{
|
||||
SelectMode state;
|
||||
std::list<Gui::InputHint> hints;
|
||||
};
|
||||
|
||||
using HintTable = std::vector<HintEntry>;
|
||||
|
||||
static HintTable getPolygonHintTable();
|
||||
static std::list<Gui::InputHint> lookupPolygonHints(SelectMode state);
|
||||
};
|
||||
|
||||
template<>
|
||||
@@ -558,33 +564,6 @@ void DSHPolygonController::addConstraints()
|
||||
}
|
||||
}
|
||||
|
||||
DrawSketchHandlerPolygon::HintTable DrawSketchHandlerPolygon::getPolygonHintTable()
|
||||
{
|
||||
return {// Structure: {SelectMode, {hints...}}
|
||||
{SelectMode::SeekFirst,
|
||||
{{QObject::tr("%1 pick polygon center"), {Gui::InputHint::UserInput::MouseLeft}},
|
||||
{QObject::tr("%1/%2 increase / decrease number of sides"),
|
||||
{Gui::InputHint::UserInput::KeyU, Gui::InputHint::UserInput::KeyJ}}}},
|
||||
{SelectMode::SeekSecond,
|
||||
{{QObject::tr("%1 pick rotation and size"), {Gui::InputHint::UserInput::MouseMove}},
|
||||
{QObject::tr("%1 confirm"), {Gui::InputHint::UserInput::MouseLeft}},
|
||||
{QObject::tr("%1/%2 increase / decrease number of sides"),
|
||||
{Gui::InputHint::UserInput::KeyU, Gui::InputHint::UserInput::KeyJ}}}}};
|
||||
}
|
||||
|
||||
std::list<Gui::InputHint> DrawSketchHandlerPolygon::lookupPolygonHints(SelectMode state)
|
||||
{
|
||||
const auto polygonHintTable = getPolygonHintTable();
|
||||
|
||||
auto it = std::find_if(polygonHintTable.begin(),
|
||||
polygonHintTable.end(),
|
||||
[state](const HintEntry& entry) {
|
||||
return entry.state == state;
|
||||
});
|
||||
|
||||
return (it != polygonHintTable.end()) ? it->hints : std::list<Gui::InputHint> {};
|
||||
}
|
||||
|
||||
} // namespace SketcherGui
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user