Commit 657f62ab authored by jean-pierre charras's avatar jean-pierre charras

fixing bug 626875. Cleaning code

Try to fix block selection issue with some windows managers.
parent fe6591b2
......@@ -1071,11 +1071,13 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
#define MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND 5
/* Count the drag events. Used to filter mouse moves before starting a
* block command. A block command can be started only if MinDragEventCount >
* MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND in order to avoid spurious block
* commands. */
* block command. A block command can be started only if
* MinDragEventCount > MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND
* and m_CanStartBlock >= 0
* in order to avoid spurious block commands.
*/
static int MinDragEventCount;
if( event.Leaving() || event.Entering() )
if( event.Leaving() /*|| event.Entering()*/ )
{
m_CanStartBlock = -1;
}
......@@ -1118,11 +1120,6 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
if( event.MiddleDown() )
localbutt = GR_M_MIDDLE_DOWN;
if( event.ButtonDClick( 2 ) )
{
}
; // Unused
localrealbutt |= localbutt; /* compensation default wxGTK */
/* Compute the cursor position in screen (device) units. */
......
update=22/07/2010 13:46:39
update=31/08/2010 17:44:34
version=1
last_client=pcbnew
[common]
......
/***************************************************************/
/* Edition des Modules: Structures et variables de gestion des */
/* fonctions de "DRAG" des segments de piste */
/***************************************************************/
/**************************************************/
/* Useful class and functions used to drag tracks */
/**************************************************/
/*** Class to handle a list of track segments to drag ***/
/** Helper class to handle a list of track segments to drag
* and has info to undo/abort the move command
* a DRAG_SEGM manage one track segment or a via
*/
class DRAG_SEGM
{
public:
DRAG_SEGM* Pnext; /* Pointeur de chainage */
TRACK* m_Segm; /* pointeur sur le segment a "dragger */
D_PAD* m_Pad_Start; /* pointeur sur le Pad origine si origine segment sur pad */
D_PAD* m_Pad_End; /* pointeur sur le Pad fin si fin segment sur pad */
int m_Flag; /* indicateur divers */
TRACK* m_Segm; /* pointeur sur le segment a "dragger */
D_PAD* m_Pad_Start; /* pointeur sur le Pad origine si origine segment sur pad */
D_PAD* m_Pad_End; /* pointeur sur le Pad fin si fin segment sur pad */
int m_Flag; /* indicateur divers */
private:
wxPoint m_StartInitialValue;
wxPoint m_EndInitialValue; /* For abort: initial m_Start and m_End values for m_Segm */
wxPoint m_StartInitialValue;
wxPoint m_EndInitialValue; // For abort: initial m_Start and m_End values for m_Segm
public:
DRAG_SEGM( TRACK * segm );
~DRAG_SEGM();
DRAG_SEGM( TRACK* segm );
~DRAG_SEGM() {};
void SetInitialValues();
void SetInitialValues()
{
m_Segm->m_Start = m_StartInitialValue;
m_Segm->m_End = m_EndInitialValue;
}
};
/* Variables */
extern DRAG_SEGM* g_DragSegmentList; /* pointe le debut de la liste
* des structures DRAG_SEGM */
// a list of DRAG_SEGM items used to move or drag tracks.
// Each DRAG_SEGM item points a segment to move.
extern std::vector<DRAG_SEGM> g_DragSegmentList;
/* routines specifiques */
void Dessine_Segments_Dragges( WinEDA_DrawPanel* panel, wxDC* DC );
void Build_Drag_Liste( WinEDA_DrawPanel* panel, wxDC* DC, MODULE* Module );
void Build_1_Pad_SegmentsToDrag( WinEDA_DrawPanel* panel, wxDC* DC, D_PAD* PtPad );
void Collect_TrackSegmentsToDrag( WinEDA_DrawPanel* panel, wxDC* DC,
wxPoint& point, int MasqueLayer, int net_code );
void EraseDragListe();
/* Functions */
void Dessine_Segments_Dragges( WinEDA_DrawPanel* panel, wxDC* DC );
void Build_Drag_Liste( WinEDA_DrawPanel* panel, wxDC* DC, MODULE* Module );
void Build_1_Pad_SegmentsToDrag( WinEDA_DrawPanel* panel, wxDC* DC, D_PAD* PtPad );
void Collect_TrackSegmentsToDrag( WinEDA_DrawPanel* panel, wxDC* DC,
wxPoint& point, int MasqueLayer, int net_code );
/** function EraseDragList
* clear the .m_Flags of all track segments managed by in g_DragSegmentList
* and clear the list.
* In order to avoid useless memory allocation, the memory is not freed
* and will be reused when creating a new list
*/
void EraseDragList();
/* Add the segment"Track" to the drag list, and erase it from screen
* flag = STARTPOINT (if the point to drag is the start point of Track)
* or ENDPOINT
* flag = STARTPOINT (if the point to drag is the start point of Track)
* or ENDPOINT
*/
void AddSegmentToDragList( WinEDA_DrawPanel* panel, wxDC* DC,
int flag, TRACK* Track );
void AddSegmentToDragList( WinEDA_DrawPanel* panel, wxDC* DC,
int flag, TRACK* Track );
This diff is collapsed.
......@@ -112,20 +112,15 @@ void WinEDA_PcbFrame::StartMove_Module( MODULE* module, wxDC* DC )
if( GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) )
DrawGeneralRatsnest( DC );
if( g_DragSegmentList ) /* Should not occur ! */
{
EraseDragListe();
}
EraseDragList();
if( g_Drag_Pistes_On )
{
Build_Drag_Liste( DrawPanel, DC, module );
ITEM_PICKER itemWrapper( NULL, UR_CHANGED );
for( DRAG_SEGM* pt_drag = g_DragSegmentList;
pt_drag != NULL;
pt_drag = pt_drag->Pnext )
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
{
TRACK* segm = pt_drag->m_Segm;
TRACK* segm = g_DragSegmentList[ii].m_Segm;
itemWrapper.m_PickedItem = segm;
itemWrapper.m_Link = segm->Copy();
itemWrapper.m_Link->SetState( EDIT, OFF );
......@@ -155,7 +150,6 @@ void WinEDA_PcbFrame::StartMove_Module( MODULE* module, wxDC* DC )
*/
void Abort_MoveOrCopyModule( WinEDA_DrawPanel* Panel, wxDC* DC )
{
DRAG_SEGM* pt_drag;
TRACK* pt_segm;
MODULE* module;
WinEDA_PcbFrame* pcbframe = (WinEDA_PcbFrame*) Panel->GetParent();
......@@ -176,24 +170,23 @@ void Abort_MoveOrCopyModule( WinEDA_DrawPanel* Panel, wxDC* DC )
if( g_Drag_Pistes_On )
{
/* Erase on screen dragged tracks */
pt_drag = g_DragSegmentList;
for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext )
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
{
pt_segm = pt_drag->m_Segm;
pt_segm = g_DragSegmentList[ii].m_Segm;
pt_segm->Draw( Panel, DC, GR_XOR );
}
}
/* Go to old position for dragged tracks */
pt_drag = g_DragSegmentList;
for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext )
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
{
pt_segm = pt_drag->m_Segm; pt_segm->SetState( EDIT, OFF );
pt_drag->SetInitialValues();
pt_segm = g_DragSegmentList[ii].m_Segm;
pt_segm->SetState( EDIT, OFF );
g_DragSegmentList[ii].SetInitialValues();
pt_segm->Draw( Panel, DC, GR_OR );
}
EraseDragListe();
EraseDragList();
module->m_Flags = 0;
}
......@@ -466,21 +459,19 @@ void WinEDA_BasePcbFrame::Place_Module( MODULE* module,
if( DC )
module->Draw( DrawPanel, DC, GR_OR );
if( g_DragSegmentList )
if( g_DragSegmentList.size() )
{
/* Redraw dragged track segments */
for( DRAG_SEGM* pt_drag = g_DragSegmentList;
pt_drag != NULL;
pt_drag = pt_drag->Pnext )
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
{
pt_segm = pt_drag->m_Segm;
pt_segm = g_DragSegmentList[ii].m_Segm;
pt_segm->SetState( EDIT, OFF );
if( DC )
pt_segm->Draw( DrawPanel, DC, GR_OR );
}
// Delete drag list
EraseDragListe();
EraseDragList();
}
g_Drag_Pistes_On = FALSE;
......
......@@ -39,18 +39,17 @@ static void Exit_Move_Pad( WinEDA_DrawPanel* Panel, wxDC* DC )
/* Pad move in progress: the restore origin. */
if( g_Drag_Pistes_On )
{
DRAG_SEGM* pt_drag = g_DragSegmentList;
for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext )
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
{
TRACK* Track = pt_drag->m_Segm;
TRACK* Track = g_DragSegmentList[ii].m_Segm;
Track->Draw( Panel, DC, GR_XOR );
Track->SetState( EDIT, OFF );
pt_drag->SetInitialValues();
g_DragSegmentList[ii].SetInitialValues();
Track->Draw( Panel, DC, GR_OR );
}
}
EraseDragListe();
EraseDragList();
s_CurrentSelectedPad = NULL;
g_Drag_Pistes_On = FALSE;
}
......@@ -61,7 +60,6 @@ static void Exit_Move_Pad( WinEDA_DrawPanel* Panel, wxDC* DC )
static void Show_Pad_Move( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
{
TRACK* Track;
DRAG_SEGM* pt_drag;
BASE_SCREEN* screen = panel->GetScreen();
D_PAD* pad = s_CurrentSelectedPad;
......@@ -74,17 +72,16 @@ static void Show_Pad_Move( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
if( !g_Drag_Pistes_On )
return;
pt_drag = g_DragSegmentList;
for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext )
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
{
Track = pt_drag->m_Segm;
Track = g_DragSegmentList[ii].m_Segm;
if( erase )
Track->Draw( panel, DC, GR_XOR );
if( pt_drag->m_Pad_Start )
if( g_DragSegmentList[ii].m_Pad_Start )
{
Track->m_Start = pad->m_Pos;
}
if( pt_drag->m_Pad_End )
if( g_DragSegmentList[ii].m_Pad_End )
{
Track->m_End = pad->m_Pos;
}
......@@ -288,7 +285,7 @@ void WinEDA_BasePcbFrame::StartMovePad( D_PAD* Pad, wxDC* DC )
if( g_Drag_Pistes_On )
Build_1_Pad_SegmentsToDrag( DrawPanel, DC, Pad );
else
EraseDragListe();
EraseDragList();
}
......@@ -308,18 +305,16 @@ void WinEDA_BasePcbFrame::PlacePad( D_PAD* Pad, wxDC* DC )
PICKED_ITEMS_LIST pickList;
/* Save dragged track segments in undo list */
for( DRAG_SEGM* pt_drag = g_DragSegmentList;
pt_drag;
pt_drag = pt_drag->Pnext )
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
{
Track = pt_drag->m_Segm;
Track = g_DragSegmentList[ii].m_Segm;
// Set the old state
wxPoint t_start = Track->m_Start;
wxPoint t_end = Track->m_End;
if( pt_drag->m_Pad_Start )
if( g_DragSegmentList[ii].m_Pad_Start )
Track->m_Start = Pad_OldPos;
if( pt_drag->m_Pad_End )
if( g_DragSegmentList[ii].m_Pad_End )
Track->m_End = Pad_OldPos;
picker.m_PickedItem = Track;
......@@ -330,32 +325,27 @@ void WinEDA_BasePcbFrame::PlacePad( D_PAD* Pad, wxDC* DC )
wxPoint pad_curr_position = Pad->m_Pos;
Pad->m_Pos = Pad_OldPos;
if( g_DragSegmentList == NULL )
if( g_DragSegmentList.size() == 0 )
SaveCopyInUndoList( Module, UR_CHANGED );
else
{
picker.m_PickedItem = Module;
pickList.PushItem( picker );
}
if( g_DragSegmentList )
SaveCopyInUndoList( pickList, UR_CHANGED );
}
Pad->m_Pos = pad_curr_position;
Pad->Draw( DrawPanel, DC, GR_XOR );
/* Redraw dragged track segments */
for( DRAG_SEGM* pt_drag = g_DragSegmentList;
pt_drag;
pt_drag = pt_drag->Pnext )
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
{
Track = pt_drag->m_Segm;
Track = g_DragSegmentList[ii].m_Segm;
// Set the new state
if( pt_drag->m_Pad_Start )
if( g_DragSegmentList[ii].m_Pad_Start )
Track->m_Start = Pad->m_Pos;
if( pt_drag->m_Pad_End )
if( g_DragSegmentList[ii].m_Pad_End )
Track->m_End = Pad->m_Pos;
Track->SetState( EDIT, OFF );
......@@ -380,7 +370,7 @@ void WinEDA_BasePcbFrame::PlacePad( D_PAD* Pad, wxDC* DC )
Module->Set_Rectangle_Encadrement();
Module->m_LastEdit_Time = time( NULL );
EraseDragListe();
EraseDragList();
OnModify();
DrawPanel->ManageCurseur = NULL;
......
This diff is collapsed.
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