Skip to content

Commit

Permalink
LightPositionTool : Default pointer on handles
Browse files Browse the repository at this point in the history
When we moved to showing the `notEditable` pointer for key combinations
that are not clickable / draggable, the `notEditable` pointer would
persist on the rotate and distance handles even when they are editable.

This sets the pointer to the default when the cursor is over those
handles, leaving it to the handle color to indicate editability as is
done elsewhere.
  • Loading branch information
ericmehl committed Apr 30, 2024
1 parent ffa7ad1 commit 6d559b2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
5 changes: 4 additions & 1 deletion include/GafferSceneUI/LightPositionTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ class GAFFERSCENEUI_API LightPositionTool : public GafferSceneUI::TransformTool
IECore::RunTimeTypedPtr handleDragBegin( GafferUI::Gadget *gadget );
bool handleDragMove( GafferUI::Gadget *gadget, const GafferUI::DragDropEvent &event );
bool handleDragEnd();

bool handleEnter( const GafferUI::ButtonEvent &event );
void handleLeave();

IECore::RunTimeTypedPtr sceneGadgetDragBegin( GafferUI::Gadget *gadget, const GafferUI::DragDropEvent &event );
bool sceneGadgetDragEnter( GafferUI::Gadget *gadget, const GafferUI::DragDropEvent &event );
bool sceneGadgetDragMove( const GafferUI::DragDropEvent &event );
Expand Down Expand Up @@ -159,6 +161,7 @@ class GAFFERSCENEUI_API LightPositionTool : public GafferSceneUI::TransformTool

void setTargetMode( TargetMode mode );
TargetMode getTargetMode() const { return m_targetMode; }
void updatePointer() const;

void setPivot( const Imath::V3f &p, Gaffer::ScriptNodePtr scriptNode );
std::optional<Imath::V3f> getPivot() const;
Expand Down
21 changes: 21 additions & 0 deletions src/GafferSceneUI/LightPositionTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,12 +567,16 @@ LightPositionTool::LightPositionTool( SceneView *view, const std::string &name )
m_distanceHandle->dragBeginSignal().connectFront( boost::bind( &LightPositionTool::handleDragBegin, this, ::_1 ) );
m_distanceHandle->dragMoveSignal().connect( boost::bind( &LightPositionTool::handleDragMove, this, ::_1, ::_2 ) );
m_distanceHandle->dragEndSignal().connect( boost::bind( &LightPositionTool::handleDragEnd, this ) );
m_distanceHandle->enterSignal().connect( boost::bind( &LightPositionTool::handleEnter, this, ::_2 ) );
m_distanceHandle->leaveSignal().connect( boost::bind( &LightPositionTool::handleLeave, this ) );

m_rotateHandle = new RotateHandle( GafferUI::Style::Axes::Z );
handles()->setChild( "rotateHandle", m_rotateHandle );
m_rotateHandle->dragBeginSignal().connectFront( boost::bind( &LightPositionTool::handleDragBegin, this, ::_1 ) );
m_rotateHandle->dragMoveSignal().connect( boost::bind( &LightPositionTool::handleDragMove, this, ::_1, ::_2 ) );
m_rotateHandle->dragEndSignal().connect( boost::bind( &LightPositionTool::handleDragEnd, this ) );
m_rotateHandle->enterSignal().connect( boost::bind( &LightPositionTool::handleEnter, this, ::_2 ) );
m_rotateHandle->leaveSignal().connect( boost::bind( &LightPositionTool::handleLeave, this ) );

SceneGadget *sg = runTimeCast<SceneGadget>( this->view()->viewportGadget()->getPrimaryChild() );
sg->keyPressSignal().connect( boost::bind( &LightPositionTool::keyPress, this, ::_2 ) );
Expand Down Expand Up @@ -819,6 +823,18 @@ bool LightPositionTool::handleDragEnd()
return false;
}

bool LightPositionTool::handleEnter( const GafferUI::ButtonEvent &event )
{
// Always use the default pointer, the handle appearance indicates editability
GafferUI::Pointer::setCurrent( "" );
return true;
}

void LightPositionTool::handleLeave()
{
updatePointer();
}

RunTimeTypedPtr LightPositionTool::sceneGadgetDragBegin( Gadget *gadget, const DragDropEvent &event )
{
if(
Expand Down Expand Up @@ -1115,6 +1131,11 @@ void LightPositionTool::setTargetMode( TargetMode targeted )

m_targetMode = targeted;

updatePointer();
}

void LightPositionTool::updatePointer() const
{
if( m_targetMode == TargetMode::None )
{
GafferUI::Pointer::setCurrent( "" );
Expand Down

0 comments on commit 6d559b2

Please sign in to comment.