Skip to content

Commit

Permalink
+ restore arrow cursor when mouse moves into empty area in 3d view
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Apr 5, 2014
1 parent a1e049b commit b5b6d49
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
34 changes: 34 additions & 0 deletions src/Gui/SoFCUnifiedSelection.cpp
Expand Up @@ -103,6 +103,7 @@ SoFCUnifiedSelection::SoFCUnifiedSelection() : pcDocument(0)
SO_NODE_SET_SF_ENUM_TYPE (highlightMode, HighlightModes);

highlighted = FALSE;
preSelection = -1;
}

/*!
Expand Down Expand Up @@ -360,6 +361,7 @@ SoFCUnifiedSelection::handleEvent(SoHandleEventAction * action)
std::string objectName = vpd->getObject()->getNameInDocument();
std::string subElementName = vpd->getElement(pp ? pp->getDetail() : 0);

this->preSelection = 1;
static char buf[513];
snprintf(buf,512,"Preselected: %s.%s.%s (%f,%f,%f)",documentName.c_str()
,objectName.c_str()
Expand Down Expand Up @@ -396,6 +398,15 @@ SoFCUnifiedSelection::handleEvent(SoHandleEventAction * action)
}
}
}
// nothing picked
else if (!pp) {
if (this->preSelection > 0) {
this->preSelection = 0;
// touch() makes sure to call GLRenderBelowPath so that the cursor can be updated
// because only from there the SoGLWidgetElement delivers the OpenGL window
this->touch();
}
}

if (currenthighlight/* && old_state != highlighted*/) {
SoHighlightElementAction action;
Expand Down Expand Up @@ -513,6 +524,29 @@ SoFCUnifiedSelection::handleEvent(SoHandleEventAction * action)
inherited::handleEvent(action);
}

void SoFCUnifiedSelection::GLRenderBelowPath(SoGLRenderAction * action)
{
inherited::GLRenderBelowPath(action);

// nothing picked, so restore the arrow cursor if needed
if (this->preSelection == 0) {
// this is called when a selection gate forbad to select an object
// and the user moved the mouse to an empty area
this->preSelection = -1;
QGLWidget* window;
SoState *state = action->getState();
SoGLWidgetElement::get(state, window);
QWidget* parent = window ? window->parentWidget() : 0;
if (parent) {
QCursor c = parent->cursor();
if (c.shape() == Qt::ForbiddenCursor) {
c.setShape(Qt::ArrowCursor);
parent->setCursor(c);
}
}
}
}

// ---------------------------------------------------------------

SO_ACTION_SOURCE(SoHighlightElementAction);
Expand Down
4 changes: 3 additions & 1 deletion src/Gui/SoFCUnifiedSelection.h
Expand Up @@ -85,7 +85,7 @@ class GuiExport SoFCUnifiedSelection : public SoSeparator {
//virtual void GLRender(SoGLRenderAction * action);

virtual void handleEvent(SoHandleEventAction * action);
//virtual void GLRenderBelowPath(SoGLRenderAction * action);
virtual void GLRenderBelowPath(SoGLRenderAction * action);
//virtual void GLRenderInPath(SoGLRenderAction * action);
//static void turnOffCurrentHighlight(SoGLRenderAction * action);

Expand All @@ -107,6 +107,8 @@ class GuiExport SoFCUnifiedSelection : public SoSeparator {
static SoFullPath * currenthighlight;

SbBool highlighted;
// -1 = not handled, 0 = not selected, 1 = selected
int32_t preSelection;
SoColorPacker colorpacker;
};

Expand Down

0 comments on commit b5b6d49

Please sign in to comment.