Commit 4b85c011 authored by charras's avatar charras

Libedit: fixed incorrect undo/redo after moving a field

parent aa35b980
...@@ -45,7 +45,6 @@ set(COMMON_SRCS ...@@ -45,7 +45,6 @@ set(COMMON_SRCS
msgpanel.cpp msgpanel.cpp
newstroke_font.cpp newstroke_font.cpp
projet_config.cpp projet_config.cpp
# pyhandler.cpp
richio.cpp richio.cpp
selcolor.cpp selcolor.cpp
string.cpp string.cpp
......
...@@ -19,10 +19,10 @@ static void ShowMoveField( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); ...@@ -19,10 +19,10 @@ static void ShowMoveField( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
extern int m_unit; extern int m_unit;
static wxPoint StartCursor, LastTextPosition; static wxPoint s_InitialPosition, s_LastPosition;
static void ExitMoveField( WinEDA_DrawPanel* Panel, wxDC* DC ) static void AbortMoveField( WinEDA_DrawPanel* Panel, wxDC* DC )
{ {
Panel->ManageCurseur = NULL; Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL; Panel->ForceCloseManageCurseur = NULL;
...@@ -39,8 +39,8 @@ static void ExitMoveField( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -39,8 +39,8 @@ static void ExitMoveField( WinEDA_DrawPanel* Panel, wxDC* DC )
wxPoint curpos = Panel->GetScreen()->m_Curseur; wxPoint curpos = Panel->GetScreen()->m_Curseur;
Panel->GetScreen()->m_Curseur = StartCursor; Panel->GetScreen()->m_Curseur = s_InitialPosition;
ShowMoveField( Panel, DC, TRUE ); ShowMoveField( Panel, DC, true );
Panel->GetScreen()->m_Curseur = curpos; Panel->GetScreen()->m_Curseur = curpos;
item->m_Flags = 0; item->m_Flags = 0;
parent->SetDrawItem( NULL ); parent->SetDrawItem( NULL );
...@@ -55,19 +55,19 @@ void WinEDA_LibeditFrame::StartMoveField( wxDC* DC, LIB_FIELD* field ) ...@@ -55,19 +55,19 @@ void WinEDA_LibeditFrame::StartMoveField( wxDC* DC, LIB_FIELD* field )
return; return;
m_drawItem = field; m_drawItem = field;
LastTextPosition = field->m_Pos; s_InitialPosition = field->m_Pos;
NEGATE(s_InitialPosition.y);
m_drawItem->m_Flags |= IS_MOVED; m_drawItem->m_Flags |= IS_MOVED;
startPos.x = LastTextPosition.x;
startPos.y = -LastTextPosition.y;
DrawPanel->CursorOff( DC ); DrawPanel->CursorOff( DC );
GetScreen()->m_Curseur = startPos; s_LastPosition = s_InitialPosition;
GetScreen()->m_Curseur = s_InitialPosition;
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
DrawPanel->ManageCurseur = ShowMoveField; DrawPanel->ManageCurseur = ShowMoveField;
DrawPanel->ForceCloseManageCurseur = ExitMoveField; DrawPanel->ForceCloseManageCurseur = AbortMoveField;
DrawPanel->ManageCurseur( DrawPanel, DC, TRUE ); DrawPanel->ManageCurseur( DrawPanel, DC, true );
StartCursor = GetScreen()->m_Curseur; s_InitialPosition = GetScreen()->m_Curseur;
DrawPanel->CursorOn( DC ); DrawPanel->CursorOn( DC );
} }
...@@ -90,16 +90,19 @@ static void ShowMoveField( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) ...@@ -90,16 +90,19 @@ static void ShowMoveField( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
return; return;
wxString text = Field->GetFullText( parent->GetUnit() ); wxString text = Field->GetFullText( parent->GetUnit() );
wxPoint offset ;
offset.x = s_LastPosition.x - Field->m_Pos.x;
offset.y = s_LastPosition.y + Field->m_Pos.y;
if( erase ) if( erase )
Field->Draw( panel, DC, wxPoint( 0, 0 ), -1, g_XorMode, &text, Field->Draw( panel, DC, offset, -1, g_XorMode, &text,
DefaultTransformMatrix ); DefaultTransformMatrix );
LastTextPosition.x = panel->GetScreen()->m_Curseur.x; s_LastPosition = panel->GetScreen()->m_Curseur;
LastTextPosition.y = -panel->GetScreen()->m_Curseur.y; offset.x = s_LastPosition.x - Field->m_Pos.x;
offset.y = s_LastPosition.y + Field->m_Pos.y;
Field->m_Pos = LastTextPosition; Field->Draw( panel, DC, offset, -1, g_XorMode, &text,
Field->Draw( panel, DC, wxPoint( 0, 0 ), -1, g_XorMode, &text,
DefaultTransformMatrix ); DefaultTransformMatrix );
} }
...@@ -240,19 +243,25 @@ void WinEDA_LibeditFrame::RotateField( wxDC* DC, LIB_FIELD* Field ) ...@@ -240,19 +243,25 @@ void WinEDA_LibeditFrame::RotateField( wxDC* DC, LIB_FIELD* Field )
wxString fieldText = Field->GetFullText( m_unit ); wxString fieldText = Field->GetFullText( m_unit );
if( (Field->m_Flags & IS_MOVED) )
ShowMoveField( DrawPanel, DC, false );
else
Field->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode, &fieldText, Field->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode, &fieldText,
DefaultTransformMatrix ); DefaultTransformMatrix );
if( Field->m_Orient ) if( Field->m_Orient == TEXT_ORIENT_VERT)
Field->m_Orient = 0; Field->m_Orient = TEXT_ORIENT_HORIZ;
else else
Field->m_Orient = 900; Field->m_Orient = TEXT_ORIENT_VERT;
int drawMode = g_XorMode; int drawMode = g_XorMode;
if( Field->m_Flags == 0 ) if( Field->m_Flags == 0 )
drawMode = GR_DEFAULT_DRAWMODE; drawMode = GR_DEFAULT_DRAWMODE;
if( (Field->m_Flags & IS_MOVED) )
ShowMoveField( DrawPanel, DC, false );
else
Field->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, drawMode, &fieldText, Field->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, drawMode, &fieldText,
DefaultTransformMatrix ); DefaultTransformMatrix );
......
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