diff --git a/src/GafferSceneUI/LightPositionTool.cpp b/src/GafferSceneUI/LightPositionTool.cpp index 2880fb538a3..ed1c356043a 100644 --- a/src/GafferSceneUI/LightPositionTool.cpp +++ b/src/GafferSceneUI/LightPositionTool.cpp @@ -73,13 +73,10 @@ size_t LightPositionTool::g_firstPlugIndex = 0; LightPositionTool::LightPositionTool( SceneView *view, const std::string &name ) : TransformTool( view, name ), - m_positionMode( PositionMode::ShadowPoint ), m_shadowPivot( std::nullopt ), m_shadowPoint( std::nullopt ) { SceneGadget *sg = runTimeCast( this->view()->viewportGadget()->getPrimaryChild() ); - sg->keyPressSignal().connect( boost::bind( &LightPositionTool::keyPress, this, ::_2 ) ); - sg->keyReleaseSignal().connect( boost::bind( &LightPositionTool::keyRelease, this, ::_2 ) ); // We have to insert this before the underlying SelectionTool connections or it starts an object drag. sg->buttonPressSignal().connectFront( boost::bind( &LightPositionTool::buttonPress, this, ::_2 ) ); @@ -90,6 +87,8 @@ LightPositionTool::LightPositionTool( SceneView *view, const std::string &name ) view->plugInputChangedSignal().connect( boost::bind( &LightPositionTool::plugInputChanged, this, ::_1 ) ); + selectionChangedSignal().connect( boost::bind( &LightPositionTool::selectionChanged, this, ::_1 ) ); + storeIndexOfNextChild( g_firstPlugIndex ); } @@ -196,15 +195,10 @@ bool LightPositionTool::keyRelease( const KeyEvent &event ) void LightPositionTool::plugSet( Plug *plug ) { - if( plug == activePlug() ) + if( plug == activePlug() && !activePlug()->getValue() ) { - m_positionMode = PositionMode::None; - if( !activePlug()->getValue() ) - { - m_shadowPivot = std::nullopt; - m_shadowPoint = std::nullopt; - } - + m_shadowPivot = std::nullopt; + m_shadowPoint = std::nullopt; } } @@ -219,7 +213,14 @@ void LightPositionTool::plugInputChanged( Plug *plug ) bool LightPositionTool::buttonPress( const ButtonEvent &event ) { - if( event.button != ButtonEvent::Left || !activePlug()->getValue() || m_positionMode == PositionMode::None ) + if( + event.button != ButtonEvent::Left || + !activePlug()->getValue() || + !( + event.modifiers == ButtonEvent::Control || + event.modifiers == ButtonEvent::Shift + ) + ) { return false; } @@ -238,11 +239,11 @@ bool LightPositionTool::buttonPress( const ButtonEvent &event ) return true; } - if( m_positionMode == PositionMode::ShadowPivot ) + if( event.modifiers == ButtonEvent::Control ) { m_shadowPivot = targetPos * sceneGadget->fullTransform(); } - else if( m_positionMode == PositionMode::ShadowPoint ) + else if( event.modifiers == ButtonEvent::Shift ) { m_shadowPoint = targetPos * sceneGadget->fullTransform(); } @@ -266,7 +267,6 @@ void LightPositionTool::contextChanged( const InternedString &name ) { if( ContextAlgo::affectsSelectedPaths( name ) ) { - m_positionMode = PositionMode::None; m_shadowPivot = std::nullopt; m_shadowPoint = std::nullopt; }