Skip to content

Commit

Permalink
Merge pull request #5828 from ericmehl/lightToolDisableClick
Browse files Browse the repository at this point in the history
Light tool disable click
  • Loading branch information
johnhaddon authored May 16, 2024
2 parents 9ee52ee + fe9d82f commit 02b9d50
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 10 deletions.
2 changes: 2 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ Improvements
- Added support for multipart EXR renders by using the same file name parameter on multiple outputs.
- Added support for scalarformat, colorprofile, filterwidth and arbitrary custom NSI outputlayer and outputdriver attributes.
- Updated the default output presets to include scalarformat, colorprofile, filter and filterwidth output parameters.
- LightPositionTool : Changed the pointer to `notEditable` when using keyboard combinations that do not apply to the current tool mode.

Fixes
-----

- SceneReader, SceneWriter : Fixed handling of Arnold-specific parameters on UsdLux lights.
- SceneWriter : Fixed import of `treatAsPoint` and `treatAsLine` parameters on UsdLux lights.
- Linux : Fixed crashes at startup on platforms - including RHEL 9.4 - with a more recent `glibc` (#5856).
- LightPositionTool : Fixed bug that allowed a non-light object to be moved by clicking or dragging the target or pivot.

1.4.3.0 (relative to 1.4.2.0)
=======
Expand Down
3 changes: 3 additions & 0 deletions include/GafferSceneUI/LightPositionTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ 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 );
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
54 changes: 44 additions & 10 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,9 +823,25 @@ 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( !activePlug()->getValue() || getTargetMode() == TargetMode::None )
if(
!activePlug()->getValue() ||
getTargetMode() == TargetMode::None ||
!m_distanceHandle->visible()
)
{
return nullptr;
}
Expand Down Expand Up @@ -949,7 +969,7 @@ bool LightPositionTool::buttonPress( const ButtonEvent &event )

// We always return true to prevent the SelectTool defaults.

if( !selectionEditable() || !m_distanceHandle->enabled() )
if( !selectionEditable() || !m_distanceHandle->enabled() || !m_distanceHandle->visible() )
{
return true;
}
Expand Down Expand Up @@ -1111,15 +1131,29 @@ void LightPositionTool::setTargetMode( TargetMode targeted )

m_targetMode = targeted;

switch( m_targetMode )
updatePointer();
}

void LightPositionTool::updatePointer() const
{
if( m_targetMode == TargetMode::None )
{
case TargetMode::None : GafferUI::Pointer::setCurrent( "" ); break;
case TargetMode::Pivot :
GafferUI::Pointer::setCurrent(
modePlug()->getValue() == (int)Mode::Shadow ? "pivot" : ""
);
break;
case TargetMode::Target : GafferUI::Pointer::setCurrent( "target" ); break;
GafferUI::Pointer::setCurrent( "" );
}
else if( !m_distanceHandle->enabled() || !m_distanceHandle->visible() )
{
GafferUI::Pointer::setCurrent( "notEditable" );
}
else if( m_targetMode == TargetMode::Pivot )
{
auto distanceHandle = static_cast<DistanceHandle *>( m_distanceHandle.get() );
GafferUI::Pointer::setCurrent(
distanceHandle->getRequiresPivot() ? "pivot" : "notEditable"
);
}
else if( m_targetMode == TargetMode::Target )
{
GafferUI::Pointer::setCurrent( "target" );
}
}

Expand Down

0 comments on commit 02b9d50

Please sign in to comment.