Restore valid force cursor setting before saving VIEW_CONTROLS settings
There are times, when TOOL_MANAGER has to force cursor position to make tools work as expected (e.g. when popping up a menu, so tools get the right click position instead of current position pointing to an entry in the menu). If another tool is invoked, VIEW_CONTROLS settings have to be stored in the TOOL_STATE object. In such case, it is necessary to revert the force cursor setting when saving VIEW_CONTROLS settings. Fixes: lp:1668712 * https://bugs.launchpad.net/kicad/+bug/1668712
This commit is contained in:
parent
ca985791bc
commit
1d8730752c
|
@ -562,7 +562,7 @@ void TOOL_MANAGER::dispatchInternal( const TOOL_EVENT& aEvent )
|
|||
{
|
||||
// store the VIEW_CONTROLS settings if we launch a subtool
|
||||
if( GetCurrentToolState() == st )
|
||||
st->vcSettings = m_viewControls->GetSettings();
|
||||
saveViewControls( st );
|
||||
|
||||
st->Push();
|
||||
}
|
||||
|
@ -697,17 +697,7 @@ TOOL_MANAGER::ID_LIST::iterator TOOL_MANAGER::finishTool( TOOL_STATE* aState )
|
|||
|
||||
// Store the current VIEW_CONTROLS settings
|
||||
if( TOOL_STATE* state = GetCurrentToolState() )
|
||||
{
|
||||
state->vcSettings = m_viewControls->GetSettings();
|
||||
|
||||
// If context menu has overridden the cursor position, restore the original one
|
||||
// (see dispatchContextMenu())
|
||||
if( m_origCursor )
|
||||
{
|
||||
state->vcSettings.m_forceCursorPosition = true;
|
||||
state->vcSettings.m_forcedPosition = *m_origCursor;
|
||||
}
|
||||
}
|
||||
saveViewControls( state );
|
||||
|
||||
if( !aState->Pop() )
|
||||
{
|
||||
|
@ -827,3 +817,21 @@ bool TOOL_MANAGER::isActive( TOOL_BASE* aTool )
|
|||
// Just check if the tool is on the active tools stack
|
||||
return std::find( m_activeTools.begin(), m_activeTools.end(), aTool->GetId() ) != m_activeTools.end();
|
||||
}
|
||||
|
||||
|
||||
void TOOL_MANAGER::saveViewControls( TOOL_STATE* aState )
|
||||
{
|
||||
aState->vcSettings = m_viewControls->GetSettings();
|
||||
|
||||
// If context menu has overridden the cursor position, reaStateore the original one
|
||||
// (see dispatchContextMenu())
|
||||
if( m_origCursor )
|
||||
{
|
||||
aState->vcSettings.m_forceCursorPosition = true;
|
||||
aState->vcSettings.m_forcedPosition = *m_origCursor;
|
||||
}
|
||||
else
|
||||
{
|
||||
aState->vcSettings.m_forceCursorPosition = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -450,6 +450,13 @@ private:
|
|||
*/
|
||||
bool isActive( TOOL_BASE* aTool );
|
||||
|
||||
/**
|
||||
* Function saveViewControls()
|
||||
* Saves the VIEW_CONTROLS settings to the tool state object. If VIEW_CONTROLS
|
||||
* settings are affected by TOOL_MANAGER, the original settings are saved.
|
||||
*/
|
||||
void saveViewControls( TOOL_STATE* aState );
|
||||
|
||||
/// Index of registered tools current states, associated by tools' objects.
|
||||
TOOL_STATE_MAP m_toolState;
|
||||
|
||||
|
|
Loading…
Reference in New Issue