Make sure DRC inspection dialogs come up in front

of DRC dialog.
This commit is contained in:
Jeff Young 2025-09-10 16:15:59 +01:00
parent 6e316d9faa
commit 2f1a91279f
5 changed files with 30 additions and 20 deletions

View File

@ -25,6 +25,7 @@
class wxChoice;
class wxNonOwnedWindow;
class wxTopLevelWindow;
class wxWindow;
namespace KIPLATFORM
@ -71,6 +72,8 @@ namespace KIPLATFORM
*/
void ReparentModal( wxNonOwnedWindow* aWindow );
void ReparentWindow( wxNonOwnedWindow* aWindow, wxTopLevelWindow* aParent );
/*
* An ugly hack to fix an issue on OSX: cmd+c closes the dialog instead of copying the
* text if a button with wxID_CANCEL is used in a wxStdDialogButtonSizer created by

View File

@ -103,24 +103,21 @@ void KIPLATFORM::UI::EnsureVisible( wxWindow* aWindow )
}
void KIPLATFORM::UI::ReparentModal( wxNonOwnedWindow* aWindow )
void KIPLATFORM::UI::ReparentWindow( wxNonOwnedWindow* aWindow, wxTopLevelWindow* aParent )
{
wxTopLevelWindow* parent =
static_cast<wxTopLevelWindow*>( wxGetTopLevelParent( aWindow->GetParent() ) );
// Quietly return if no parent is found
if( !parent )
{
return;
}
NSWindow* parentWindow = parent->GetWXWindow();
NSWindow* parentWindow = aParent->GetWXWindow();
NSWindow* theWindow = aWindow->GetWXWindow();
if( parentWindow && theWindow )
{
[parentWindow addChildWindow:theWindow ordered:NSWindowAbove];
}
}
void KIPLATFORM::UI::ReparentModal( wxNonOwnedWindow* aWindow )
{
// Quietly return if no parent is found
if( wxTopLevelWindow* parent = static_cast<wxTopLevelWindow*>( wxGetTopLevelParent( aWindow->GetParent() ) ) )
ReparentWindow( aWindow, parent );
}

View File

@ -27,6 +27,7 @@
#include <tools/pcb_selection_tool.h>
#include <tools/pcb_picker_tool.h>
#include <tools/edit_tool.h>
#include <tools/drc_tool.h>
#include <pcb_painter.h>
#include <connectivity/connectivity_data.h>
#include <drc/drc_engine.h>
@ -34,11 +35,12 @@
#include <dialogs/dialog_book_reporter.h>
#include <dialogs/panel_setup_rules_base.h>
#include <dialogs/dialog_footprint_associations.h>
#include <dialogs/dialog_drc.h>
#include <kiplatform/ui.h>
#include <string_utils.h>
#include <tools/board_inspection_tool.h>
#include <fp_lib_table.h>
#include <pcb_shape.h>
#include <pcbnew_settings.h>
#include <widgets/appearance_controls.h>
#include <widgets/wx_html_report_box.h>
#include <widgets/footprint_diff_widget.h>
@ -338,7 +340,9 @@ wxString BOARD_INSPECTION_TOOL::InspectDRCErrorMenuText( const std::shared_ptr<R
void BOARD_INSPECTION_TOOL::InspectDRCError( const std::shared_ptr<RC_ITEM>& aDRCItem )
{
wxCHECK( m_frame, /* void */ );
DRC_TOOL* drcTool = m_toolMgr->GetTool<DRC_TOOL>();
wxCHECK( drcTool && m_frame, /* void */ );
BOARD_ITEM* a = m_frame->GetBoard()->ResolveItem( aDRCItem->GetMainItemID() );
BOARD_ITEM* b = m_frame->GetBoard()->ResolveItem( aDRCItem->GetAuxItemID() );
@ -349,7 +353,7 @@ void BOARD_INSPECTION_TOOL::InspectDRCError( const std::shared_ptr<RC_ITEM>& aDR
if( aDRCItem->GetErrorCode() == DRCE_LIB_FOOTPRINT_MISMATCH )
{
if( FOOTPRINT* footprint = dynamic_cast<FOOTPRINT*>( a ) )
DiffFootprint( footprint );
DiffFootprint( footprint, drcTool->GetDRCDialog() );
return;
}
@ -698,7 +702,7 @@ void BOARD_INSPECTION_TOOL::InspectDRCError( const std::shared_ptr<RC_ITEM>& aDR
r->Flush();
dialog->Raise();
KIPLATFORM::UI::ReparentWindow( dialog, drcTool->GetDRCDialog() );
dialog->Show( true );
}
@ -1613,7 +1617,7 @@ int BOARD_INSPECTION_TOOL::ShowFootprintLinks( const TOOL_EVENT& aEvent )
}
void BOARD_INSPECTION_TOOL::DiffFootprint( FOOTPRINT* aFootprint )
void BOARD_INSPECTION_TOOL::DiffFootprint( FOOTPRINT* aFootprint, wxTopLevelWindow* aReparentTo )
{
DIALOG_BOOK_REPORTER* dialog = m_frame->GetFootprintDiffDialog();
@ -1694,7 +1698,11 @@ void BOARD_INSPECTION_TOOL::DiffFootprint( FOOTPRINT* aFootprint )
r->Flush();
dialog->Raise();
if( aReparentTo )
KIPLATFORM::UI::ReparentWindow( dialog, aReparentTo );
else
dialog->Raise();
dialog->Show( true );
}

View File

@ -90,7 +90,7 @@ public:
int ShowFootprintLinks( const TOOL_EVENT& aEvent );
int DiffFootprint( const TOOL_EVENT& aEvent );
void DiffFootprint( FOOTPRINT* aFootprint );
void DiffFootprint( FOOTPRINT* aFootprint, wxTopLevelWindow* aReparentTo = nullptr );
/**
* @return true if a net or nets to highlight have been set

View File

@ -60,6 +60,8 @@ public:
int ShowDRCDialog( const TOOL_EVENT& aEvent );
DIALOG_DRC* GetDRCDialog() { return m_drcDialog; }
/**
* Check to see if the DRC_TOOL dialog is currently shown
*/