Sketcher: Use generic tool hints table for DrawSketchHandlerArcSlot

This commit is contained in:
Kacper Donat
2025-06-28 19:59:26 +02:00
parent f0c6cd7a0f
commit e86a43c183

View File

@@ -93,24 +93,37 @@ public:
~DrawSketchHandlerArcSlot() override = default;
private:
std::list<Gui::InputHint> getToolHints() const override
{
return lookupArcSlotHints(state());
using enum Gui::InputHint::UserInput;
return Gui::lookupHints<SelectMode>(
state(),
{
{.state = SelectMode::SeekFirst,
.hints =
{
{QObject::tr("%1 pick slot center"), {MouseLeft}},
}},
{.state = SelectMode::SeekSecond,
.hints =
{
{QObject::tr("%1 pick slot radius"), {MouseLeft}},
}},
{.state = SelectMode::SeekThird,
.hints =
{
{QObject::tr("%1 pick slot angle"), {MouseLeft}},
}},
{.state = SelectMode::SeekFourth,
.hints =
{
{QObject::tr("%1 pick slot width"), {MouseLeft}},
}},
});
}
private:
struct HintEntry
{
SelectMode state;
std::list<Gui::InputHint> hints;
};
using HintTable = std::vector<HintEntry>;
static HintTable getArcSlotHintTable();
static std::list<Gui::InputHint> lookupArcSlotHints(SelectMode state);
void updateDataAndDrawToPosition(Base::Vector2d onSketchPos) override
{
switch (state()) {
@@ -976,32 +989,6 @@ void DSHArcSlotController::addConstraints()
}
}
DrawSketchHandlerArcSlot::HintTable DrawSketchHandlerArcSlot::getArcSlotHintTable()
{
return {// Structure: {SelectMode, {hints...}}
{SelectMode::SeekFirst,
{{QObject::tr("%1 pick slot center"), {Gui::InputHint::UserInput::MouseLeft}}}},
{SelectMode::SeekSecond,
{{QObject::tr("%1 pick slot radius"), {Gui::InputHint::UserInput::MouseLeft}}}},
{SelectMode::SeekThird,
{{QObject::tr("%1 pick slot angle"), {Gui::InputHint::UserInput::MouseLeft}}}},
{SelectMode::SeekFourth,
{{QObject::tr("%1 pick slot width"), {Gui::InputHint::UserInput::MouseLeft}}}}};
}
std::list<Gui::InputHint> DrawSketchHandlerArcSlot::lookupArcSlotHints(SelectMode state)
{
const auto arcSlotHintTable = getArcSlotHintTable();
auto it = std::find_if(arcSlotHintTable.begin(),
arcSlotHintTable.end(),
[state](const HintEntry& entry) {
return entry.state == state;
});
return (it != arcSlotHintTable.end()) ? it->hints : std::list<Gui::InputHint> {};
}
} // namespace SketcherGui