diff --git a/common/draw_panel_gal.cpp b/common/draw_panel_gal.cpp index 66c79d2830..b4bf651014 100644 --- a/common/draw_panel_gal.cpp +++ b/common/draw_panel_gal.cpp @@ -67,7 +67,8 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin m_options( aOptions ), m_eventDispatcher( nullptr ), m_lostFocus( false ), - m_stealsFocus( true ) + m_stealsFocus( true ), + m_statusPopup( nullptr ) { m_parent = aParentWindow; m_MouseCapturedLost = false; diff --git a/common/view/wx_view_controls.cpp b/common/view/wx_view_controls.cpp index d0343782fe..296a24c616 100644 --- a/common/view/wx_view_controls.cpp +++ b/common/view/wx_view_controls.cpp @@ -507,8 +507,11 @@ void WX_VIEW_CONTROLS::onTimer( wxTimerEvent& aEvent ) return; } - if( !m_parentPanel->HasFocus() ) - break; + if( !m_parentPanel->HasFocus() && !m_parentPanel->StatusPopupHasFocus() ) + { + m_state = IDLE; + return; + } double borderSize = std::min( m_settings.m_autoPanMargin * m_view->GetScreenPixelSize().x, m_settings.m_autoPanMargin * m_view->GetScreenPixelSize().y ); @@ -856,7 +859,6 @@ bool WX_VIEW_CONTROLS::handleAutoPanning( const wxMouseEvent& aEvent ) } return true; - break; case IDLE: if( borderHit ) @@ -868,7 +870,6 @@ bool WX_VIEW_CONTROLS::handleAutoPanning( const wxMouseEvent& aEvent ) } return false; - break; case DRAG_PANNING: case DRAG_ZOOMING: diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index 7b0ba9ebc0..28fe574e3b 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -42,8 +42,6 @@ #include #include -class STATUS_TEXT_POPUP; - class SCH_ITEM; class EDA_ITEM; class SCH_LINE; diff --git a/include/class_draw_panel_gal.h b/include/class_draw_panel_gal.h index 478e96969f..4d4081b278 100644 --- a/include/class_draw_panel_gal.h +++ b/include/class_draw_panel_gal.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013-2018 CERN - * Copyright (C) 2013-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2013-2022 KiCad Developers, see AUTHORS.txt for contributors. * * @author Tomasz Wlostowski * @author Maciej Suminski @@ -88,7 +88,17 @@ public: GAL_TYPE aGalType = GAL_TYPE_OPENGL ); ~EDA_DRAW_PANEL_GAL(); - virtual void SetFocus() override; + void SetFocus() override; + + bool StatusPopupHasFocus() + { + return m_statusPopup && m_statusPopup->HasFocus(); + } + + void SetStatusPopup( wxWindow* aPopup ) + { + m_statusPopup = aPopup; + } /** * Switch method of rendering graphics. @@ -292,6 +302,8 @@ protected: /// and on various mouse/key events) bool m_stealsFocus; + wxWindow* m_statusPopup; + /// Optional overlay for drawing transient debug objects std::shared_ptr m_debugOverlay; }; diff --git a/include/status_popup.h b/include/status_popup.h index 62f0f12c81..b586ca62be 100644 --- a/include/status_popup.h +++ b/include/status_popup.h @@ -59,6 +59,8 @@ public: */ void Expire( int aMsecs ); + wxWindow* GetPanel() { return m_panel; } + protected: void updateSize(); @@ -67,9 +69,10 @@ protected: ///< Expire timer even handler void onExpire( wxTimerEvent& aEvent ); - wxPanel* m_panel; +protected: + wxPanel* m_panel; wxBoxSizer* m_topSizer; - wxTimer m_expireTimer; + wxTimer m_expireTimer; }; diff --git a/pcbnew/router/length_tuner_tool.cpp b/pcbnew/router/length_tuner_tool.cpp index 48ff85072a..f66da76346 100644 --- a/pcbnew/router/length_tuner_tool.cpp +++ b/pcbnew/router/length_tuner_tool.cpp @@ -2,7 +2,7 @@ * KiRouter - a push-and-(sometimes-)shove PCB router * * Copyright (C) 2013-2017 CERN - * Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2016-2022 KiCad Developers, see AUTHORS.txt for contributors. * Author: Tomasz Wlostowski * * This program is free software: you can redistribute it and/or modify it @@ -19,7 +19,7 @@ * with this program. If not, see . */ -#include "class_draw_panel_gal.h" +#include #include #include #include @@ -166,6 +166,7 @@ void LENGTH_TUNER_TOOL::performTuning() // Create an instance of PNS_TUNE_STATUS_POPUP. PNS_TUNE_STATUS_POPUP statusPopup( frame() ); statusPopup.Popup(); + canvas()->SetStatusPopup( statusPopup.GetPanel() ); m_router->Move( end, nullptr ); updateStatusPopup( statusPopup ); @@ -243,6 +244,7 @@ void LENGTH_TUNER_TOOL::performTuning() m_router->StopRouting(); frame()->UndoRedoBlock( false ); + canvas()->SetStatusPopup( nullptr ); controls()->SetAutoPan( false ); controls()->ForceCursorPosition( false ); frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW ); diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index f89098358b..9c6ded4473 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -113,7 +113,7 @@ bool EDIT_TOOL::Init() { if( getView()->IsLayerVisible( LAYER_SCHEMATIC_DRAWINGSHEET ) ) { - DS_PROXY_VIEW_ITEM* ds = frame()->GetCanvas()->GetDrawingSheet(); + DS_PROXY_VIEW_ITEM* ds = canvas()->GetDrawingSheet(); VECTOR2D cursor = getViewControls()->GetCursorPosition( false ); if( ds && ds->HitTestDrawingSheetItems( getView(), cursor ) ) @@ -2032,6 +2032,7 @@ bool EDIT_TOOL::pickReferencePoint( const wxString& aTooltip, const wxString& aS m_statusPopup->Move( wxGetMousePosition() + wxPoint( 20, -50 ) ); m_statusPopup->Popup(); + canvas()->SetStatusPopup( m_statusPopup->GetPanel() ); std::string tool = ""; m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool ); @@ -2046,6 +2047,7 @@ bool EDIT_TOOL::pickReferencePoint( const wxString& aTooltip, const wxString& aS } // Ensure statusPopup is hidden after use and before deleting it: + canvas()->SetStatusPopup( nullptr ); m_statusPopup->Hide(); if( pickedPoint ) diff --git a/pcbnew/tools/group_tool.cpp b/pcbnew/tools/group_tool.cpp index eb4a70c55d..7c194e3208 100644 --- a/pcbnew/tools/group_tool.cpp +++ b/pcbnew/tools/group_tool.cpp @@ -193,6 +193,7 @@ int GROUP_TOOL::PickNewMember( const TOOL_EVENT& aEvent ) statusPopup.Move( wxGetMousePosition() + wxPoint( 20, -50 ) ); statusPopup.Popup(); + canvas()->SetStatusPopup( statusPopup.GetPanel() ); m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool ); @@ -205,6 +206,8 @@ int GROUP_TOOL::PickNewMember( const TOOL_EVENT& aEvent ) break; } + canvas()->SetStatusPopup( nullptr ); + return 0; } diff --git a/pcbnew/tools/pad_tool.cpp b/pcbnew/tools/pad_tool.cpp index 95e20e8907..6685d0073e 100644 --- a/pcbnew/tools/pad_tool.cpp +++ b/pcbnew/tools/pad_tool.cpp @@ -320,7 +320,7 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent ) auto setCursor = [&]() { - frame()->GetCanvas()->SetCurrentCursor( KICURSOR::BULLSEYE ); + canvas()->SetCurrentCursor( KICURSOR::BULLSEYE ); }; Activate(); @@ -335,6 +335,7 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent ) statusPopup.SetText( wxString::Format( msg, padPrefix, seqPadNum ) ); statusPopup.Popup(); statusPopup.Move( wxGetMousePosition() + wxPoint( 20, 20 ) ); + canvas()->SetStatusPopup( statusPopup.GetPanel() ); while( TOOL_EVENT* evt = Wait() ) { @@ -475,8 +476,10 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent ) getView()->Update( p ); } + canvas()->SetStatusPopup( nullptr ); statusPopup.Hide(); - frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW ); + + canvas()->SetCurrentCursor( KICURSOR::ARROW ); getViewControls()->ForceCursorPosition( false ); return 0; } diff --git a/pcbnew/tools/position_relative_tool.cpp b/pcbnew/tools/position_relative_tool.cpp index dbc6c6ab97..4a031d3800 100644 --- a/pcbnew/tools/position_relative_tool.cpp +++ b/pcbnew/tools/position_relative_tool.cpp @@ -220,6 +220,7 @@ int POSITION_RELATIVE_TOOL::SelectPositionRelativeItem( const TOOL_EVENT& aEvent statusPopup.Move( wxGetMousePosition() + wxPoint( 20, -50 ) ); statusPopup.Popup(); + canvas()->SetStatusPopup( statusPopup.GetPanel() ); m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool ); @@ -232,6 +233,8 @@ int POSITION_RELATIVE_TOOL::SelectPositionRelativeItem( const TOOL_EVENT& aEvent break; } + canvas()->SetStatusPopup( nullptr ); + return 0; }