Commit 55f65292 authored by Marco Mattila's avatar Marco Mattila

Fix sheet resizing in eeschema.

parent 84572d37
...@@ -572,7 +572,7 @@ void SCH_SCREEN::Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC, int aDrawMode, int aC ...@@ -572,7 +572,7 @@ void SCH_SCREEN::Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC, int aDrawMode, int aC
{ {
for( SCH_ITEM* item = GetDrawItems(); item != NULL; item = item->Next() ) for( SCH_ITEM* item = GetDrawItems(); item != NULL; item = item->Next() )
{ {
if( item->IsMoving() ) if( item->IsMoving() || item->IsResized() )
continue; continue;
// uncomment line below when there is a virtual // uncomment line below when there is a virtual
......
...@@ -214,7 +214,6 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -214,7 +214,6 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_POPUP_SCH_RESIZE_SHEET: case ID_POPUP_SCH_RESIZE_SHEET:
DrawPanel->MoveCursorToCrossHair();
ReSizeSheet( (SCH_SHEET*) item, &dc ); ReSizeSheet( (SCH_SHEET*) item, &dc );
screen->TestDanglingEnds( DrawPanel, &dc ); screen->TestDanglingEnds( DrawPanel, &dc );
break; break;
......
...@@ -198,7 +198,7 @@ static void MoveOrResizeSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& ...@@ -198,7 +198,7 @@ static void MoveOrResizeSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
if( aErase ) if( aErase )
sheet->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode ); sheet->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
if( sheet->GetFlags() & IS_RESIZED ) if( sheet->IsResized() )
{ {
int width = screen->GetCrossHairPosition().x - sheet->m_Pos.x; int width = screen->GetCrossHairPosition().x - sheet->m_Pos.x;
int height = screen->GetCrossHairPosition().y - sheet->m_Pos.y; int height = screen->GetCrossHairPosition().y - sheet->m_Pos.y;
...@@ -223,7 +223,7 @@ static void MoveOrResizeSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& ...@@ -223,7 +223,7 @@ static void MoveOrResizeSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
sheet->m_Pos.y + height ) ); sheet->m_Pos.y + height ) );
sheet->Resize( wxSize( grid.x - sheet->m_Pos.x, grid.y - sheet->m_Pos.y ) ); sheet->Resize( wxSize( grid.x - sheet->m_Pos.x, grid.y - sheet->m_Pos.y ) );
} }
else /* Move Sheet */ else if( sheet->IsMoving() )
{ {
moveVector = screen->GetCrossHairPosition() - sheet->m_Pos; moveVector = screen->GetCrossHairPosition() - sheet->m_Pos;
sheet->Move( moveVector ); sheet->Move( moveVector );
...@@ -251,7 +251,7 @@ static void ExitSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC ) ...@@ -251,7 +251,7 @@ static void ExitSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
{ {
SAFE_DELETE( item ); SAFE_DELETE( item );
} }
else if( item->m_Flags & (IS_RESIZED | IS_MOVED) ) else if( item->IsMoving() || item->IsResized() )
{ {
screen->RemoveFromDrawList( item ); screen->RemoveFromDrawList( item );
delete item; delete item;
...@@ -266,10 +266,6 @@ static void ExitSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC ) ...@@ -266,10 +266,6 @@ static void ExitSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
item->Draw( aPanel, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); item->Draw( aPanel, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
item->ClearFlags(); item->ClearFlags();
SCH_SHEET* sheet = ( SCH_SHEET* ) item;
aPanel->CrossHairOff( aDC );
screen->SetCrossHairPosition( sheet->GetResizePosition() );
aPanel->CrossHairOn( aDC );
} }
else else
{ {
...@@ -300,6 +296,7 @@ SCH_SHEET* SCH_EDIT_FRAME::CreateSheet( wxDC* aDC ) ...@@ -300,6 +296,7 @@ SCH_SHEET* SCH_EDIT_FRAME::CreateSheet( wxDC* aDC )
DrawPanel->m_mouseCaptureCallback( DrawPanel, aDC, wxDefaultPosition, false ); DrawPanel->m_mouseCaptureCallback( DrawPanel, aDC, wxDefaultPosition, false );
DrawPanel->CrossHairOff( aDC ); DrawPanel->CrossHairOff( aDC );
GetScreen()->SetCrossHairPosition( sheet->GetResizePosition() ); GetScreen()->SetCrossHairPosition( sheet->GetResizePosition() );
DrawPanel->MoveCursorToCrossHair();
DrawPanel->CrossHairOn( aDC ); DrawPanel->CrossHairOn( aDC );
return sheet; return sheet;
...@@ -315,20 +312,19 @@ void SCH_EDIT_FRAME::ReSizeSheet( SCH_SHEET* aSheet, wxDC* aDC ) ...@@ -315,20 +312,19 @@ void SCH_EDIT_FRAME::ReSizeSheet( SCH_SHEET* aSheet, wxDC* aDC )
wxString::Format( wxT( "Cannot perform sheet resize on %s object." ), wxString::Format( wxT( "Cannot perform sheet resize on %s object." ),
GetChars( aSheet->GetClass() ) ) ); GetChars( aSheet->GetClass() ) ) );
DrawPanel->CrossHairOff( aDC );
GetScreen()->SetCrossHairPosition( aSheet->GetResizePosition() );
DrawPanel->MoveCursorToCrossHair();
DrawPanel->CrossHairOn( aDC );
SetUndoItem( aSheet ); SetUndoItem( aSheet );
OnModify();
aSheet->SetFlags( IS_RESIZED ); aSheet->SetFlags( IS_RESIZED );
DrawPanel->SetMouseCapture( MoveOrResizeSheet, ExitSheet ); DrawPanel->SetMouseCapture( MoveOrResizeSheet, ExitSheet );
DrawPanel->m_mouseCaptureCallback( DrawPanel, aDC, wxDefaultPosition, true ); DrawPanel->m_mouseCaptureCallback( DrawPanel, aDC, wxDefaultPosition, true );
if( aSheet->IsNew() ) // not already in edit, save a copy for undo/redo if( aSheet->IsNew() ) // not already in edit, save a copy for undo/redo
SetUndoItem( aSheet ); SetUndoItem( aSheet );
DrawPanel->CrossHairOff( aDC );
GetScreen()->SetCrossHairPosition( aSheet->GetResizePosition() );
DrawPanel->CrossHairOn( aDC );
} }
......
...@@ -412,6 +412,7 @@ public: ...@@ -412,6 +412,7 @@ public:
inline bool IsMoving() const { return m_Flags & IS_MOVED; } inline bool IsMoving() const { return m_Flags & IS_MOVED; }
inline bool IsDragging() const { return m_Flags & IS_DRAGGED; } inline bool IsDragging() const { return m_Flags & IS_DRAGGED; }
inline bool IsSelected() const { return m_Flags & SELECTED; } inline bool IsSelected() const { return m_Flags & SELECTED; }
inline bool IsResized() const { return m_Flags & IS_RESIZED; }
void SetModified(); void SetModified();
......
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