From f6041fb52dd1b4b50b01ba13f88c1f492d148496 Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Fri, 26 Mar 2021 01:24:12 +0000 Subject: [PATCH] Force update of some text when activation status changes The text areas aren't always redrawn when the window is activated or deactivated, so we need to force a refresh of the text to ensure it is the correct font color. --- common/eda_draw_frame.cpp | 20 ++++++++++++++++++++ include/eda_draw_frame.h | 7 +++++++ pcbnew/pcb_base_edit_frame.cpp | 8 ++++++++ pcbnew/pcb_base_edit_frame.h | 2 ++ pcbnew/widgets/appearance_controls.cpp | 6 ++++++ pcbnew/widgets/appearance_controls.h | 5 +++++ 6 files changed, 48 insertions(+) diff --git a/common/eda_draw_frame.cpp b/common/eda_draw_frame.cpp index 1b242cf6a4..5987f7dff2 100644 --- a/common/eda_draw_frame.cpp +++ b/common/eda_draw_frame.cpp @@ -55,6 +55,7 @@ #include #include #include +#include #include #include #include @@ -65,6 +66,8 @@ BEGIN_EVENT_TABLE( EDA_DRAW_FRAME, KIWAY_PLAYER ) EVT_UPDATE_UI( ID_ON_GRID_SELECT, EDA_DRAW_FRAME::OnUpdateSelectGrid ) EVT_UPDATE_UI( ID_ON_ZOOM_SELECT, EDA_DRAW_FRAME::OnUpdateSelectZoom ) + + EVT_ACTIVATE( EDA_DRAW_FRAME::onActivate ) END_EVENT_TABLE() @@ -1066,3 +1069,20 @@ void EDA_DRAW_FRAME::resolveCanvasType() SaveSettings( config() ); } } + + +void EDA_DRAW_FRAME::handleActivateEvent( wxActivateEvent& aEvent ) +{ + // Force a refresh of the message panel to ensure that the text is the right color + // when the window activates + if( !IsIconized() ) + m_messagePanel->Refresh(); +} + + +void EDA_DRAW_FRAME::onActivate( wxActivateEvent& aEvent ) +{ + handleActivateEvent( aEvent ); + + aEvent.Skip(); +} diff --git a/include/eda_draw_frame.h b/include/eda_draw_frame.h index 6619014d40..ac2fc3b6c5 100644 --- a/include/eda_draw_frame.h +++ b/include/eda_draw_frame.h @@ -474,6 +474,13 @@ protected: */ bool saveCanvasTypeSetting( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType ); + /** + * Handle a window activation event. + */ + virtual void handleActivateEvent( wxActivateEvent& aEvent ); + void onActivate( wxActivateEvent& aEvent ); + + wxSocketServer* m_socketServer; std::vector m_sockets; ///< interprocess communication diff --git a/pcbnew/pcb_base_edit_frame.cpp b/pcbnew/pcb_base_edit_frame.cpp index 0b81e6e84e..b1314b83a2 100644 --- a/pcbnew/pcb_base_edit_frame.cpp +++ b/pcbnew/pcb_base_edit_frame.cpp @@ -222,3 +222,11 @@ wxString PCB_BASE_EDIT_FRAME::GetDesignRulesPath() fn.SetExt( DesignRulesFileExtension ); return Prj().AbsolutePath( fn.GetFullName() ); } + +void PCB_BASE_EDIT_FRAME::handleActivateEvent( wxActivateEvent& aEvent ) +{ + EDA_DRAW_FRAME::handleActivateEvent( aEvent ); + + // The text in the collapsible pane headers need to be updated + m_appearancePanel->RefreshCollapsiblePanes(); +} diff --git a/pcbnew/pcb_base_edit_frame.h b/pcbnew/pcb_base_edit_frame.h index e6b84c6c6a..14fb80a747 100644 --- a/pcbnew/pcb_base_edit_frame.h +++ b/pcbnew/pcb_base_edit_frame.h @@ -222,6 +222,8 @@ protected: * @return Pointer to library table selected or nullptr if none selected/canceled */ FP_LIB_TABLE* selectLibTable( bool aOptional = false ); + + void handleActivateEvent( wxActivateEvent& aEvent ) override; }; #endif diff --git a/pcbnew/widgets/appearance_controls.cpp b/pcbnew/widgets/appearance_controls.cpp index 80f75cb0b2..515f744fcf 100644 --- a/pcbnew/widgets/appearance_controls.cpp +++ b/pcbnew/widgets/appearance_controls.cpp @@ -2826,3 +2826,9 @@ void APPEARANCE_CONTROLS::onReadOnlySwatch() "Preferences to enable color editing." ), 10000, wxICON_INFORMATION ); } + + +void APPEARANCE_CONTROLS::RefreshCollapsiblePanes() +{ + m_paneLayerDisplayOptions->Refresh(); +} diff --git a/pcbnew/widgets/appearance_controls.h b/pcbnew/widgets/appearance_controls.h index fabaf8ec8c..a6c2c1a908 100644 --- a/pcbnew/widgets/appearance_controls.h +++ b/pcbnew/widgets/appearance_controls.h @@ -270,6 +270,11 @@ public: ///< Set the current notebook tab. void SetTabIndex( int aTab ); + /** + * Function to force a redraw of the collapsible panes in this control. + */ + void RefreshCollapsiblePanes(); + protected: void OnNotebookPageChanged( wxNotebookEvent& event ) override;