Skip to content

Commit

Permalink
Viewports can be panned/tracked using middle mouse with no modifier key.
Browse files Browse the repository at this point in the history
This affects all viewports (3d, 2d, and Node Graph).

Fixes Issue #28
  • Loading branch information
andrewkaufman committed Apr 20, 2013
1 parent 3ed95e2 commit ad3fe2f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
2 changes: 2 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

* Added drag and drop node connection re-wiring (#78).

* Viewports can be panned/tracked using middle mouse with no modifier key (#28).

0.58.0
======

Expand Down
41 changes: 20 additions & 21 deletions src/GafferUI/ViewportGadget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,17 +244,21 @@ bool ViewportGadget::buttonPress( GadgetPtr gadget, const ButtonEvent &event )
gadgetsAt( V2f( event.line.p0.x, event.line.p0.y ), gadgets );

GadgetPtr handler = 0;
m_lastButtonPressGadget = 0;
bool result = dispatchEvent( gadgets, &Gadget::buttonPressSignal, event, handler );
if( result )
{
m_lastButtonPressGadget = handler;
return true;
}
else

if ( event.buttons == ButtonEvent::Middle && event.modifiers == ModifiableEvent::None )
{
m_lastButtonPressGadget = 0;
// accept press so we get a dragBegin opportunity for camera movement
return true;
}

return result;
return false;
}

bool ViewportGadget::buttonRelease( GadgetPtr gadget, const ButtonEvent &event )
Expand Down Expand Up @@ -346,7 +350,19 @@ bool ViewportGadget::mouseMove( GadgetPtr gadget, const ButtonEvent &event )

IECore::RunTimeTypedPtr ViewportGadget::dragBegin( GadgetPtr gadget, const DragDropEvent &event )
{
if( event.modifiers & ModifiableEvent::Alt )
if ( !(event.modifiers & ModifiableEvent::Alt) && m_lastButtonPressGadget )
{
// see if a child gadget would like to start a drag
RunTimeTypedPtr data = dispatchEvent( m_lastButtonPressGadget, &Gadget::dragBeginSignal, event );
if( data )
{
const_cast<DragDropEvent &>( event ).sourceGadget = m_lastButtonPressGadget;

return data;
}
}

if ( event.modifiers & ModifiableEvent::Alt || ( event.buttons == ButtonEvent::Middle && event.modifiers == ModifiableEvent::None ) )
{
// start camera motion

Expand Down Expand Up @@ -392,23 +408,6 @@ IECore::RunTimeTypedPtr ViewportGadget::dragBegin( GadgetPtr gadget, const DragD
return 0;
}
}
else
{
// see if a child gadget would like to start a drag
if( m_lastButtonPressGadget )
{
RunTimeTypedPtr data = dispatchEvent( m_lastButtonPressGadget, &Gadget::dragBeginSignal, event );
if( data )
{
const_cast<DragDropEvent &>( event ).sourceGadget = m_lastButtonPressGadget;
}
return data;
}
else
{
return 0;
}
}

return 0;
}
Expand Down

0 comments on commit ad3fe2f

Please sign in to comment.