Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VisualiserTool : Drag value from buttonPress() #6192

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
1.5.x.x (relative to 1.5.2.0)
=======

Fixes
-----

- VisualiserTool : Fixed bug where the value dragged from the visualiser would be slightly different from the initial value on button press. (#6191)


1.5.2.0 (relative to 1.5.1.0)
Expand Down
2 changes: 1 addition & 1 deletion include/GafferSceneUI/Private/VisualiserTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class GAFFERSCENEUI_API VisualiserTool : public SelectionTool
bool m_gadgetDirty;
mutable bool m_selectionDirty;
bool m_priorityPathsDirty;
bool m_acceptedButtonPress;
IECore::DataPtr m_valueAtButtonPress;
bool m_initiatedDrag;

static ToolDescription<VisualiserTool, SceneView> m_toolDescription;
Expand Down
33 changes: 14 additions & 19 deletions src/GafferSceneUI/VisualiserTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ VisualiserTool::VisualiserTool( SceneView *view, const std::string &name ) : Sel
m_gadgetDirty( true ),
m_selectionDirty( true ),
m_priorityPathsDirty( true ),
m_acceptedButtonPress( false ),
m_valueAtButtonPress(),
m_initiatedDrag( false )
{
view->viewportGadget()->addChild( m_gadget );
Expand Down Expand Up @@ -956,15 +956,15 @@ bool VisualiserTool::keyPress( const KeyEvent &event )

bool VisualiserTool::buttonPress( const ButtonEvent &event )
{
m_acceptedButtonPress = false;
m_valueAtButtonPress.reset();
m_initiatedDrag = false;

if( event.button & ButtonEvent::Left && !( event.modifiers & GafferUI::ButtonEvent::Modifiers::Control ) )
{
updateCursorValue();
if( m_cursorValue )
{
m_acceptedButtonPress = true;
m_valueAtButtonPress = m_cursorValue->copy();
return true;
}
}
Expand All @@ -974,7 +974,7 @@ bool VisualiserTool::buttonPress( const ButtonEvent &event )

bool VisualiserTool::buttonRelease( const ButtonEvent &event )
{
m_acceptedButtonPress = false;
m_valueAtButtonPress.reset();
m_initiatedDrag = false;

return false;
Expand All @@ -984,27 +984,22 @@ RunTimeTypedPtr VisualiserTool::dragBegin( const DragDropEvent &event )
{
m_initiatedDrag = false;

if( !m_acceptedButtonPress )
if( !m_valueAtButtonPress )
{
return RunTimeTypedPtr();
}

m_acceptedButtonPress = false;
// NOTE : There is a possibility that the tool has become inactive since the button
// press event that triggered the drag was accepted, the cutoff point is the
// button press event, so any change to the active state after that does not
// affect an ongoing drag operation. We therefore always request a redraw
// here so that the displayed value is cleared.

if( m_cursorValue )
{
// NOTE : There is a possibility that the tool has become inactive since the button
// press event that triggered the drag was accepted, the cutoff point is the
// button press event, so any change to the active state after that does not
// affect an ongoing drag operation. We therefore always request a redraw
// here so that the displayed value is cleared.

m_initiatedDrag = true;
view()->viewportGadget()->renderRequestSignal()( view()->viewportGadget() );
Pointer::setCurrent( "values" );
}
m_initiatedDrag = true;
view()->viewportGadget()->renderRequestSignal()( view()->viewportGadget() );
Pointer::setCurrent( "values" );

return m_cursorValue;
return m_valueAtButtonPress;
}

bool VisualiserTool::dragEnd( const DragDropEvent &event )
Expand Down