DrawSketchHandler: refactor crosshairCursor
====================================================== -DrawSketchHandler manages both cursor bitmap setting and unsetting
This commit is contained in:
@@ -221,10 +221,20 @@ DrawSketchHandler::DrawSketchHandler() : sketchgui(nullptr) {}
|
||||
|
||||
DrawSketchHandler::~DrawSketchHandler() {}
|
||||
|
||||
QString DrawSketchHandler::getCrosshairCursorString() const
|
||||
{
|
||||
return QString::fromLatin1("None");
|
||||
}
|
||||
|
||||
void DrawSketchHandler::activate(ViewProviderSketch * vp)
|
||||
{
|
||||
sketchgui = vp;
|
||||
|
||||
auto cursorstring = getCrosshairCursorString();
|
||||
|
||||
if(cursorstring != QString::fromLatin1("None"))
|
||||
setCrosshairCursor(cursorstring);
|
||||
|
||||
this->preActivated();
|
||||
this->activated();
|
||||
}
|
||||
@@ -280,8 +290,7 @@ unsigned long DrawSketchHandler::getCrosshairColor()
|
||||
return color;
|
||||
}
|
||||
|
||||
void DrawSketchHandler::setCrosshairCursor(const char* svgName) {
|
||||
QString cursorName = QString::fromLatin1(svgName);
|
||||
void DrawSketchHandler::setCrosshairCursor(const QString & svgName) {
|
||||
const unsigned long defaultCrosshairColor = 0xFFFFFF;
|
||||
unsigned long color = getCrosshairColor();
|
||||
auto colorMapping = std::map<unsigned long, unsigned long>();
|
||||
@@ -289,7 +298,12 @@ void DrawSketchHandler::setCrosshairCursor(const char* svgName) {
|
||||
// hot spot of all SVG icons should be 8,8 for 32x32 size (16x16 for 64x64)
|
||||
int hotX = 8;
|
||||
int hotY = 8;
|
||||
setSvgCursor(cursorName, hotX, hotY, colorMapping);
|
||||
setSvgCursor(svgName, hotX, hotY, colorMapping);
|
||||
}
|
||||
|
||||
void DrawSketchHandler::setCrosshairCursor(const char* svgName) {
|
||||
QString cursorName = QString::fromLatin1(svgName);
|
||||
setCrosshairCursor(cursorName);
|
||||
}
|
||||
|
||||
void DrawSketchHandler::setSvgCursor(const QString & cursorName, int x, int y, const std::map<unsigned long, unsigned long>& colorMapping)
|
||||
|
||||
@@ -148,6 +148,7 @@ private:
|
||||
virtual void activated(){}
|
||||
virtual void deactivated(){}
|
||||
virtual void postDeactivated(){}
|
||||
virtual void onWidgetChanged(){}
|
||||
|
||||
protected:
|
||||
// helpers
|
||||
@@ -166,6 +167,7 @@ protected:
|
||||
void applyCursor(QCursor &newCursor);
|
||||
unsigned long getCrosshairColor();
|
||||
qreal devicePixelRatio();
|
||||
void setCrosshairCursor(const QString & svgName);
|
||||
void setCrosshairCursor(const char* svgName);
|
||||
|
||||
void drawEdit(const std::vector<Base::Vector2d> &EditCurve);
|
||||
@@ -178,6 +180,7 @@ protected:
|
||||
int getPreselectCurve(void) const;
|
||||
int getPreselectCross(void) const;
|
||||
|
||||
virtual QString getCrosshairCursorString() const;
|
||||
|
||||
/**
|
||||
* Returns constraints icons scaled to width.
|
||||
|
||||
Reference in New Issue
Block a user