diff --git a/Changes.md b/Changes.md index e242ebe39c2..b0044f2f3fb 100644 --- a/Changes.md +++ b/Changes.md @@ -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 `Alt` + `C` for toggling both the crop window tool and the relevant crop window `enabled` plug. Breaking Changes ---------------- diff --git a/doc/source/Interface/ControlsAndShortcuts/index.md b/doc/source/Interface/ControlsAndShortcuts/index.md index 2cb36ba0291..acf54bc9e36 100644 --- a/doc/source/Interface/ControlsAndShortcuts/index.md +++ b/doc/source/Interface/ControlsAndShortcuts/index.md @@ -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 ### diff --git a/include/GafferSceneUI/CropWindowTool.h b/include/GafferSceneUI/CropWindowTool.h index 860116010cc..31ce29e9527 100644 --- a/include/GafferSceneUI/CropWindowTool.h +++ b/include/GafferSceneUI/CropWindowTool.h @@ -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; diff --git a/src/GafferSceneUI/CropWindowTool.cpp b/src/GafferSceneUI/CropWindowTool.cpp index c826f11a4a0..0d12b366c46 100644 --- a/src/GafferSceneUI/CropWindowTool.cpp +++ b/src/GafferSceneUI/CropWindowTool.cpp @@ -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() @@ -1018,3 +1020,22 @@ Box2f CropWindowTool::resolutionGate() const } return resolutionGate; } + +bool CropWindowTool::keyPress( const KeyEvent &event ) +{ + if( const auto hotkey = Gaffer::Metadata::value( 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() ); + m_cropWindowEnabledPlug->setValue( newState ); + } + } + } + return false; +}