Avoid schematic editor frame to go on top when selecting a symbol.

It was s side effect of a CrossProbe called on a symbol selection.
This also replace commit e51594cdf5.
Fixes #14316
https://gitlab.com/kicad/code/kicad/issues/14316
This commit is contained in:
jean-pierre charras 2023-03-17 16:32:18 +01:00
parent ee1d9c561c
commit 5bd491bd74
3 changed files with 22 additions and 35 deletions

View File

@ -78,6 +78,8 @@ bool SYMBOL_EDIT_FRAME::m_showDeMorgan = false;
BEGIN_EVENT_TABLE( SYMBOL_EDIT_FRAME, SCH_BASE_FRAME )
EVT_SIZE( SYMBOL_EDIT_FRAME::OnSize )
EVT_COMBOBOX( ID_LIBEDIT_SELECT_UNIT_NUMBER, SYMBOL_EDIT_FRAME::OnSelectUnit )
// menubar commands
@ -98,9 +100,8 @@ SYMBOL_EDIT_FRAME::SYMBOL_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH_SYMBOL_EDITOR, _( "Library Editor" ),
wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE,
LIB_EDIT_FRAME_NAME ),
m_unitSelectBox( nullptr ),
m_isSymbolFromSchematic( false ),
m_initialRaise( false )
m_unitSelectBox( nullptr ),
m_isSymbolFromSchematic( false )
{
SetShowDeMorgan( false );
m_SyncPinEdit = false;
@ -220,6 +221,9 @@ SYMBOL_EDIT_FRAME::SYMBOL_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
treePane.MinSize( 250, -1 );
}
Raise();
Show( true );
SyncView();
GetCanvas()->GetView()->UseDrawPriority( true );
GetCanvas()->GetGAL()->SetAxesEnabled( true );
@ -247,14 +251,11 @@ SYMBOL_EDIT_FRAME::SYMBOL_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
Bind( wxEVT_CHAR, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
Bind( wxEVT_CHAR_HOOK, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
// Ensure the window is on top
Raise();
if( loadingCancelled )
ShowInfoBarWarning( _( "Symbol library loading was cancelled by user." ) );
// This is an ugly hack to ensure that the symbol editor window gets raised to the top when
// launched from the schematic editor edit symbol in symbol editor tool.
Bind( wxEVT_IDLE, &SYMBOL_EDIT_FRAME::onIdle, this );
Show( true );
}
@ -284,18 +285,6 @@ SYMBOL_EDIT_FRAME::~SYMBOL_EDIT_FRAME()
}
void SYMBOL_EDIT_FRAME::onIdle( wxIdleEvent& aEvent )
{
if( !m_initialRaise )
{
Unbind( wxEVT_IDLE, &SYMBOL_EDIT_FRAME::onIdle, this );
Raise();
GetCanvas()->SetFocus();
m_initialRaise = true;
}
}
void SYMBOL_EDIT_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
{
wxCHECK_RET( m_settings, "Call to SYMBOL_EDIT_FRAME::LoadSettings with null m_boardAdapter" );

View File

@ -399,8 +399,6 @@ protected:
void doReCreateMenuBar() override;
void onIdle( wxIdleEvent& aEvent );
private:
// Set up the tool framework
void setupTools();
@ -566,7 +564,6 @@ private:
///< Flag if the symbol being edited was loaded directly from a schematic.
bool m_isSymbolFromSchematic;
bool m_initialRaise;
KIID m_schematicSymbolUUID;
///< RefDes of the symbol (only valid if symbol was loaded from schematic)

View File

@ -148,14 +148,6 @@ int EE_INSPECTION_TOOL::NextMarker( const TOOL_EVENT& aEvent )
int EE_INSPECTION_TOOL::CrossProbe( const TOOL_EVENT& aEvent )
{
SCH_EDIT_FRAME* frame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame );
wxCHECK( frame, 0 );
DIALOG_ERC* dlg = frame->GetErcDialog();
wxCHECK( dlg, 0 );
EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
wxCHECK( selectionTool, 0 );
@ -164,10 +156,19 @@ int EE_INSPECTION_TOOL::CrossProbe( const TOOL_EVENT& aEvent )
if( selection.GetSize() == 1 && selection.Front()->Type() == SCH_MARKER_T )
{
if( !dlg->IsShown() )
dlg->Show( true );
SCH_EDIT_FRAME* frame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame );
DIALOG_ERC* dlg = frame ? frame->GetErcDialog() : nullptr;
dlg->SelectMarker( static_cast<SCH_MARKER*>( selection.Front() ) );
if( dlg )
{
if( !dlg->IsShown() )
{
dlg->Show( true );
dlg->Raise();
}
dlg->SelectMarker( static_cast<SCH_MARKER*>( selection.Front() ) );
}
}
// Show the item info on a left click on this item