Implement undo for PageLayout drawing tools.

This commit is contained in:
Jeff Young 2019-05-24 10:23:05 +01:00
parent 323bb0f8e1
commit 431eae0492
2 changed files with 12 additions and 6 deletions

View File

@ -105,8 +105,8 @@ void PL_EDITOR_FRAME::GetLayoutFromRedoList()
pglayout.SetPageLayout( TO_UTF8(copyItem->m_Layout) ); pglayout.SetPageLayout( TO_UTF8(copyItem->m_Layout) );
delete copyItem; delete copyItem;
HardRedraw();
OnModify(); OnModify();
m_canvas->Refresh();
} }
@ -135,8 +135,8 @@ void PL_EDITOR_FRAME::GetLayoutFromUndoList()
pglayout.SetPageLayout( TO_UTF8(copyItem->m_Layout) ); pglayout.SetPageLayout( TO_UTF8(copyItem->m_Layout) );
delete copyItem; delete copyItem;
HardRedraw();
OnModify(); OnModify();
m_canvas->Refresh();
} }
/* Remove the last command in Undo List. /* Remove the last command in Undo List.
@ -147,9 +147,13 @@ void PL_EDITOR_FRAME::RollbackFromUndo()
if ( GetScreen()->GetUndoCommandCount() <= 0 ) if ( GetScreen()->GetUndoCommandCount() <= 0 )
return; return;
WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance();
PICKED_ITEMS_LIST* lastcmd = GetScreen()->PopCommandFromUndoList(); PICKED_ITEMS_LIST* lastcmd = GetScreen()->PopCommandFromUndoList();
ITEM_PICKER wrapper = lastcmd->PopItem(); ITEM_PICKER wrapper = lastcmd->PopItem();
PL_ITEM_LAYOUT* copyItem = static_cast<PL_ITEM_LAYOUT*>( wrapper.GetItem() ); PL_ITEM_LAYOUT* copyItem = static_cast<PL_ITEM_LAYOUT*>( wrapper.GetItem() );
pglayout.SetPageLayout( TO_UTF8(copyItem->m_Layout) );
delete copyItem; delete copyItem;
HardRedraw();
} }

View File

@ -289,8 +289,8 @@ int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
if( item ) if( item )
{ {
WORKSHEET_LAYOUT::GetTheInstance().Remove( item->GetPeer() );
item = nullptr; item = nullptr;
m_frame->RollbackFromUndo();
if( !evt->IsActivate() && !isImmediate ) if( !evt->IsActivate() && !isImmediate )
continue; continue;
@ -303,6 +303,7 @@ int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
{ {
if( !item ) // start drawing if( !item ) // start drawing
{ {
m_frame->SaveCopyInUndoList();
m_toolMgr->RunAction( PL_ACTIONS::clearSelection, true ); m_toolMgr->RunAction( PL_ACTIONS::clearSelection, true );
WORKSHEET_DATAITEM::WS_ITEM_TYPE dataType; WORKSHEET_DATAITEM::WS_ITEM_TYPE dataType;
@ -364,11 +365,12 @@ int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
void PL_DRAWING_TOOLS::setTransitions() void PL_DRAWING_TOOLS::setTransitions()
{ {
Go( &PL_DRAWING_TOOLS::DrawShape, PL_ACTIONS::drawLine.MakeEvent() ); Go( &PL_DRAWING_TOOLS::DrawShape, PL_ACTIONS::drawLine.MakeEvent() );
Go( &PL_DRAWING_TOOLS::DrawShape, PL_ACTIONS::addLine.MakeEvent() );
Go( &PL_DRAWING_TOOLS::DrawShape, PL_ACTIONS::drawRectangle.MakeEvent() ); Go( &PL_DRAWING_TOOLS::DrawShape, PL_ACTIONS::drawRectangle.MakeEvent() );
Go( &PL_DRAWING_TOOLS::DrawShape, PL_ACTIONS::addRectangle.MakeEvent() );
Go( &PL_DRAWING_TOOLS::PlaceItem, PL_ACTIONS::placeText.MakeEvent() ); Go( &PL_DRAWING_TOOLS::PlaceItem, PL_ACTIONS::placeText.MakeEvent() );
Go( &PL_DRAWING_TOOLS::PlaceItem, PL_ACTIONS::addText.MakeEvent() );
Go( &PL_DRAWING_TOOLS::PlaceItem, PL_ACTIONS::placeImage.MakeEvent() ); Go( &PL_DRAWING_TOOLS::PlaceItem, PL_ACTIONS::placeImage.MakeEvent() );
Go( &PL_DRAWING_TOOLS::DrawShape, PL_ACTIONS::addLine.MakeEvent() );
Go( &PL_DRAWING_TOOLS::DrawShape, PL_ACTIONS::addRectangle.MakeEvent() );
Go( &PL_DRAWING_TOOLS::PlaceItem, PL_ACTIONS::addText.MakeEvent() );
Go( &PL_DRAWING_TOOLS::PlaceItem, PL_ACTIONS::addImage.MakeEvent() ); Go( &PL_DRAWING_TOOLS::PlaceItem, PL_ACTIONS::addImage.MakeEvent() );
} }