Sketcher: Add contextual input hints to transform tools (InputHints Phase 4) (#21840)
* Add hints to symettry tool * Add hint system for transform tools - Design decision: Keep hints simple and focused on primary mouse actions - Avoid redundancy with dialog UI which already shows keyboard shortcuts clearly - Implements progressive hints for multi-state tools (Rotate, Scale, Translate) using declarative hint tables, and focused hints for single-state tools (Symmetry, Offset) using direct return implementations. * Cleanup unused declarative hint decls * Change hint to 'pick axis, edge, or point" per PR feedback
This commit is contained in:
@@ -191,6 +191,15 @@ private:
|
||||
generateSourceWires();
|
||||
}
|
||||
|
||||
public:
|
||||
std::list<Gui::InputHint> getToolHints() const override
|
||||
{
|
||||
using enum Gui::InputHint::UserInput;
|
||||
|
||||
return {{QObject::tr("%1 set offset direction and distance", "Sketcher Offset: hint"),
|
||||
{MouseLeft}}};
|
||||
}
|
||||
|
||||
private:
|
||||
class CoincidencePointPos
|
||||
{
|
||||
|
||||
@@ -455,8 +455,49 @@ private:
|
||||
|
||||
return pointToRotate;
|
||||
}
|
||||
|
||||
struct HintEntry
|
||||
{
|
||||
SelectMode state;
|
||||
std::list<Gui::InputHint> hints;
|
||||
};
|
||||
|
||||
using HintTable = std::vector<HintEntry>;
|
||||
|
||||
static HintTable getRotateHintTable();
|
||||
static std::list<Gui::InputHint> lookupRotateHints(SelectMode state);
|
||||
|
||||
public:
|
||||
std::list<Gui::InputHint> getToolHints() const override
|
||||
{
|
||||
return lookupRotateHints(state());
|
||||
}
|
||||
};
|
||||
|
||||
DrawSketchHandlerRotate::HintTable DrawSketchHandlerRotate::getRotateHintTable()
|
||||
{
|
||||
using enum Gui::InputHint::UserInput;
|
||||
|
||||
return {
|
||||
{.state = SelectMode::SeekFirst,
|
||||
.hints = {{QObject::tr("%1 pick center point", "Sketcher Rotate: hint"), {MouseLeft}}}},
|
||||
{.state = SelectMode::SeekSecond,
|
||||
.hints = {{QObject::tr("%1 set start angle", "Sketcher Rotate: hint"), {MouseLeft}}}},
|
||||
{.state = SelectMode::SeekThird,
|
||||
.hints = {{QObject::tr("%1 set rotation angle", "Sketcher Rotate: hint"), {MouseLeft}}}}};
|
||||
}
|
||||
|
||||
std::list<Gui::InputHint> DrawSketchHandlerRotate::lookupRotateHints(SelectMode state)
|
||||
{
|
||||
const auto rotateHintTable = getRotateHintTable();
|
||||
|
||||
auto it = std::ranges::find_if(rotateHintTable, [state](const HintEntry& entry) {
|
||||
return entry.state == state;
|
||||
});
|
||||
|
||||
return (it != rotateHintTable.end()) ? it->hints : std::list<Gui::InputHint> {};
|
||||
}
|
||||
|
||||
template<>
|
||||
auto DSHRotateControllerBase::getState(int labelindex) const
|
||||
{
|
||||
|
||||
@@ -132,6 +132,11 @@ public:
|
||||
}
|
||||
|
||||
|
||||
std::list<Gui::InputHint> getToolHints() const override
|
||||
{
|
||||
return lookupScaleHints(state());
|
||||
}
|
||||
|
||||
private:
|
||||
void updateDataAndDrawToPosition(Base::Vector2d onSketchPos) override
|
||||
{
|
||||
@@ -228,6 +233,17 @@ private:
|
||||
bool allowOriginConstraint; // Conserve constraints with origin
|
||||
double refLength, length, scaleFactor;
|
||||
|
||||
struct HintEntry
|
||||
{
|
||||
SelectMode state;
|
||||
std::list<Gui::InputHint> hints;
|
||||
};
|
||||
|
||||
using HintTable = std::vector<HintEntry>;
|
||||
|
||||
static HintTable getScaleHintTable();
|
||||
static std::list<Gui::InputHint> lookupScaleHints(SelectMode state);
|
||||
|
||||
|
||||
void deleteOriginalGeos()
|
||||
{
|
||||
@@ -447,6 +463,30 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
DrawSketchHandlerScale::HintTable DrawSketchHandlerScale::getScaleHintTable()
|
||||
{
|
||||
using enum Gui::InputHint::UserInput;
|
||||
|
||||
return {
|
||||
{.state = SelectMode::SeekFirst,
|
||||
.hints = {{QObject::tr("%1 pick reference point", "Sketcher Scale: hint"), {MouseLeft}}}},
|
||||
{.state = SelectMode::SeekSecond,
|
||||
.hints = {{QObject::tr("%1 set reference length", "Sketcher Scale: hint"), {MouseLeft}}}},
|
||||
{.state = SelectMode::SeekThird,
|
||||
.hints = {{QObject::tr("%1 set scale factor", "Sketcher Scale: hint"), {MouseLeft}}}}};
|
||||
}
|
||||
|
||||
std::list<Gui::InputHint> DrawSketchHandlerScale::lookupScaleHints(SelectMode state)
|
||||
{
|
||||
const auto scaleHintTable = getScaleHintTable();
|
||||
|
||||
auto it = std::ranges::find_if(scaleHintTable, [state](const HintEntry& entry) {
|
||||
return entry.state == state;
|
||||
});
|
||||
|
||||
return (it != scaleHintTable.end()) ? it->hints : std::list<Gui::InputHint> {};
|
||||
}
|
||||
|
||||
template<>
|
||||
auto DSHScaleControllerBase::getState(int labelindex) const
|
||||
{
|
||||
|
||||
@@ -215,6 +215,15 @@ private:
|
||||
Sketcher::PointPos refPosId;
|
||||
bool deleteOriginal, createSymConstraints;
|
||||
|
||||
public:
|
||||
std::list<Gui::InputHint> getToolHints() const override
|
||||
{
|
||||
using enum Gui::InputHint::UserInput;
|
||||
|
||||
return {
|
||||
{QObject::tr("%1 pick axis, edge, or point", "Sketcher Symmetry: hint"), {MouseLeft}}};
|
||||
}
|
||||
|
||||
void deleteOriginalGeos()
|
||||
{
|
||||
std::stringstream stream;
|
||||
|
||||
@@ -426,8 +426,51 @@ private:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct HintEntry
|
||||
{
|
||||
SelectMode state;
|
||||
std::list<Gui::InputHint> hints;
|
||||
};
|
||||
|
||||
using HintTable = std::vector<HintEntry>;
|
||||
|
||||
static HintTable getTranslateHintTable();
|
||||
static std::list<Gui::InputHint> lookupTranslateHints(SelectMode state);
|
||||
|
||||
public:
|
||||
std::list<Gui::InputHint> getToolHints() const override
|
||||
{
|
||||
return lookupTranslateHints(state());
|
||||
}
|
||||
};
|
||||
|
||||
DrawSketchHandlerTranslate::HintTable DrawSketchHandlerTranslate::getTranslateHintTable()
|
||||
{
|
||||
using enum Gui::InputHint::UserInput;
|
||||
|
||||
return {{.state = SelectMode::SeekFirst,
|
||||
.hints = {{QObject::tr("%1 pick reference point", "Sketcher Translate: hint"),
|
||||
{MouseLeft}}}},
|
||||
{.state = SelectMode::SeekSecond,
|
||||
.hints = {{QObject::tr("%1 set translation vector", "Sketcher Translate: hint"),
|
||||
{MouseLeft}}}},
|
||||
{.state = SelectMode::SeekThird,
|
||||
.hints = {{QObject::tr("%1 set second translation vector", "Sketcher Translate: hint"),
|
||||
{MouseLeft}}}}};
|
||||
}
|
||||
|
||||
std::list<Gui::InputHint> DrawSketchHandlerTranslate::lookupTranslateHints(SelectMode state)
|
||||
{
|
||||
const auto translateHintTable = getTranslateHintTable();
|
||||
|
||||
auto it = std::ranges::find_if(translateHintTable, [state](const HintEntry& entry) {
|
||||
return entry.state == state;
|
||||
});
|
||||
|
||||
return (it != translateHintTable.end()) ? it->hints : std::list<Gui::InputHint> {};
|
||||
}
|
||||
|
||||
template<>
|
||||
auto DSHTranslateControllerBase::getState(int labelindex) const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user