Commit a73e3865 authored by Maciej Suminski's avatar Maciej Suminski

Added a new tool event: TA_UNDO_REDO, sent after undo/redo operation is issued.

parent 57bfaca1
...@@ -91,6 +91,7 @@ const std::string TOOL_EVENT::Format() const ...@@ -91,6 +91,7 @@ const std::string TOOL_EVENT::Format() const
{ TA_CANCEL_TOOL, "cancel-tool" }, { TA_CANCEL_TOOL, "cancel-tool" },
{ TA_CONTEXT_MENU_UPDATE, "context-menu-update" }, { TA_CONTEXT_MENU_UPDATE, "context-menu-update" },
{ TA_CONTEXT_MENU_CHOICE, "context-menu-choice" }, { TA_CONTEXT_MENU_CHOICE, "context-menu-choice" },
{ TA_UNDO_REDO, "undo-redo" },
{ TA_ACTION, "action" }, { TA_ACTION, "action" },
{ 0, "" } { 0, "" }
}; };
......
...@@ -89,8 +89,11 @@ enum TOOL_ACTIONS ...@@ -89,8 +89,11 @@ enum TOOL_ACTIONS
// closed it without selecting anything. // closed it without selecting anything.
TA_CONTEXT_MENU_CHOICE = 0x10000, TA_CONTEXT_MENU_CHOICE = 0x10000,
// This event is sent *after* undo/redo command is finished.
TA_UNDO_REDO = 0x20000,
// Tool action (allows to control tools) // Tool action (allows to control tools)
TA_ACTION = 0x20000, TA_ACTION = 0x40000,
TA_ANY = 0xffffffff TA_ANY = 0xffffffff
}; };
......
...@@ -704,7 +704,7 @@ public: ...@@ -704,7 +704,7 @@ public:
* - Get an old version of the board from Redo list * - Get an old version of the board from Redo list
* @return none * @return none
*/ */
void GetBoardFromRedoList( wxCommandEvent& event ); void GetBoardFromRedoList( wxCommandEvent& aEvent );
/** /**
* Function GetBoardFromUndoList * Function GetBoardFromUndoList
...@@ -713,7 +713,7 @@ public: ...@@ -713,7 +713,7 @@ public:
* - Get an old version of the board from Undo list * - Get an old version of the board from Undo list
* @return none * @return none
*/ */
void GetBoardFromUndoList( wxCommandEvent& event ); void GetBoardFromUndoList( wxCommandEvent& aEvent );
/* Block operations: */ /* Block operations: */
......
...@@ -621,16 +621,11 @@ void PCB_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed ...@@ -621,16 +621,11 @@ void PCB_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
} }
void PCB_EDIT_FRAME::GetBoardFromUndoList( wxCommandEvent& event ) void PCB_EDIT_FRAME::GetBoardFromUndoList( wxCommandEvent& aEvent )
{ {
if( GetScreen()->GetUndoCommandCount() <= 0 ) if( GetScreen()->GetUndoCommandCount() <= 0 )
return; return;
// Clear the selection, as it may be altered with undone items
SELECTION_TOOL* selectionTool = static_cast<SELECTION_TOOL*>( m_toolManager->FindTool(
"pcbnew.InteractiveSelection" ) );
selectionTool->ClearSelection();
/* Get the old list */ /* Get the old list */
PICKED_ITEMS_LIST* List = GetScreen()->PopCommandFromUndoList(); PICKED_ITEMS_LIST* List = GetScreen()->PopCommandFromUndoList();
/* Undo the command */ /* Undo the command */
...@@ -640,21 +635,20 @@ void PCB_EDIT_FRAME::GetBoardFromUndoList( wxCommandEvent& event ) ...@@ -640,21 +635,20 @@ void PCB_EDIT_FRAME::GetBoardFromUndoList( wxCommandEvent& event )
List->ReversePickersListOrder(); List->ReversePickersListOrder();
GetScreen()->PushCommandToRedoList( List ); GetScreen()->PushCommandToRedoList( List );
// Inform tools that undo has just occurred
TOOL_EVENT event( TC_MESSAGE, TA_UNDO_REDO, AS_GLOBAL );
m_toolManager->ProcessEvent( event );
OnModify(); OnModify();
m_canvas->Refresh(); m_canvas->Refresh();
} }
void PCB_EDIT_FRAME::GetBoardFromRedoList( wxCommandEvent& event ) void PCB_EDIT_FRAME::GetBoardFromRedoList( wxCommandEvent& aEvent )
{ {
if( GetScreen()->GetRedoCommandCount() == 0 ) if( GetScreen()->GetRedoCommandCount() == 0 )
return; return;
// Clear the selection, as it may be altered with redone items
SELECTION_TOOL* selectionTool = static_cast<SELECTION_TOOL*>( m_toolManager->FindTool(
"pcbnew.InteractiveSelection" ) );
selectionTool->ClearSelection();
/* Get the old list */ /* Get the old list */
PICKED_ITEMS_LIST* List = GetScreen()->PopCommandFromRedoList(); PICKED_ITEMS_LIST* List = GetScreen()->PopCommandFromRedoList();
...@@ -665,6 +659,10 @@ void PCB_EDIT_FRAME::GetBoardFromRedoList( wxCommandEvent& event ) ...@@ -665,6 +659,10 @@ void PCB_EDIT_FRAME::GetBoardFromRedoList( wxCommandEvent& event )
List->ReversePickersListOrder(); List->ReversePickersListOrder();
GetScreen()->PushCommandToUndoList( List ); GetScreen()->PushCommandToUndoList( List );
// Inform tools that redo has just occurred
TOOL_EVENT event( TC_MESSAGE, TA_UNDO_REDO, AS_GLOBAL );
m_toolManager->ProcessEvent( event );
OnModify(); OnModify();
m_canvas->Refresh(); m_canvas->Refresh();
} }
......
...@@ -100,6 +100,12 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent ) ...@@ -100,6 +100,12 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent )
// This tool never exits // This tool never exits
} }
else if( evt->Action() == TA_UNDO_REDO )
{
// Clear the selection, as it may be altered with undone items
ClearSelection();
}
// single click? Select single object // single click? Select single object
else if( evt->IsClick( BUT_LEFT ) ) else if( evt->IsClick( BUT_LEFT ) )
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment