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 Oct 30, 2023
1 parent 8253f66 commit f3b6342
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Improvements

- LightTool : Changed spot light and quad light edge tool tip locations so that they follow the cone and edge during drag.
- 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.

Fixes
-----
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
16 changes: 16 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,17 @@ 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 );
m_cropWindowEnabledPlug->setValue( newState );
}
}
return false;
}

0 comments on commit f3b6342

Please sign in to comment.