Skip to content

Commit

Permalink
CropWindowTool : Alt+C to enable / disable crop
Browse files Browse the repository at this point in the history
  • Loading branch information
ericmehl committed Nov 9, 2023
1 parent 901240e commit 9272959
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Improvements
------------

- Toolbars : Changed hotkey behavior to toogle any tool on and off. Exclusive tools such as the Translate and Crop Window tools activate the first tool (currently Selection Tool) when they are toggled off.
- CropWindowTool : Added <kbd>`Alt` + <kbd>`C` for toggling both the crop window tool and the relevant crop window `enabled` plug.

Breaking Changes
----------------
Expand Down
1 change: 1 addition & 0 deletions doc/source/Interface/ControlsAndShortcuts/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ Cycle Transform Tool Orientation | {kbd}`O`
Scale Tool | {kbd}`R`
Camera Tool | {kbd}`T`
Crop Window Tool | {kbd}`C`
Crop Window Tool and crop enabled | {kbd}`Alt` + {kbd}`C`
Pin to numeric bookmark | {kbd}`1` … {kbd}`9`

### 3D scenes ###
Expand Down
2 changes: 2 additions & 0 deletions include/GafferSceneUI/CropWindowTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ class GAFFERSCENEUI_API CropWindowTool : public GafferUI::Tool

Imath::Box2f resolutionGate() const;

bool keyPress( const GafferUI::KeyEvent &event );

Gaffer::Signals::ScopedConnection m_overlayRectangleChangedConnection;

std::string m_overlayMessage;
Expand Down
21 changes: 21 additions & 0 deletions src/GafferSceneUI/CropWindowTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,8 @@ CropWindowTool::CropWindowTool( View *view, const std::string &name )

Metadata::plugValueChangedSignal().connect( boost::bind( &CropWindowTool::metadataChanged, this, ::_3 ) );
Metadata::nodeValueChangedSignal().connect( boost::bind( &CropWindowTool::metadataChanged, this, ::_2 ) );

view->viewportGadget()->keyPressSignal().connect( boost::bind( &CropWindowTool::keyPress, this, ::_2 ) );
}

CropWindowTool::~CropWindowTool()
Expand Down Expand Up @@ -1018,3 +1020,22 @@ Box2f CropWindowTool::resolutionGate() const
}
return resolutionGate;
}

bool CropWindowTool::keyPress( const KeyEvent &event )
{
if( const auto hotkey = Gaffer::Metadata::value<StringData>( this, "viewer:shortCut" ) )
{
if( event.key == hotkey->readable() && event.modifiers == KeyEvent::Modifiers::Alt )
{
const bool newState = !activePlug()->getValue();

activePlug()->setValue( newState );
if( m_cropWindowEnabledPlug )
{
UndoScope undoScope( m_cropWindowPlug->ancestor<ScriptNode>() );
m_cropWindowEnabledPlug->setValue( newState );
}
}
}
return false;
}

0 comments on commit 9272959

Please sign in to comment.