From f59b3a021029b38fda14765c0031c6d0a092e798 Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Mon, 5 Aug 2019 17:10:58 +0200 Subject: [PATCH] pcbnew: Move layer toolbar icon previous values to struct The static variables posed problems on Linux, and also were not as portable for multiple instances of PCB_EDIT_FRAME. --- pcbnew/pcb_edit_frame.h | 26 ++++++++++++++++++++++++++ pcbnew/toolbars_pcb_editor.cpp | 33 +++++++++++++-------------------- 2 files changed, 39 insertions(+), 20 deletions(-) diff --git a/pcbnew/pcb_edit_frame.h b/pcbnew/pcb_edit_frame.h index f246160bf7..d00fa50330 100644 --- a/pcbnew/pcb_edit_frame.h +++ b/pcbnew/pcb_edit_frame.h @@ -109,6 +109,32 @@ protected: wxString m_lastPath[ LAST_PATH_SIZE ]; + + /** + * Store the previous layer toolbar icon state information + */ + struct LAYER_TOOLBAR_ICON_VALUES + { + int previous_requested_scale; + COLOR4D previous_active_layer_color; + COLOR4D previous_Route_Layer_TOP_color; + COLOR4D previous_Route_Layer_BOTTOM_color; + COLOR4D previous_via_color; + COLOR4D previous_background_color; + + LAYER_TOOLBAR_ICON_VALUES() + : previous_requested_scale( 0 ), + previous_active_layer_color( COLOR4D::UNSPECIFIED ), + previous_Route_Layer_TOP_color( COLOR4D::UNSPECIFIED ), + previous_Route_Layer_BOTTOM_color( COLOR4D::UNSPECIFIED ), + previous_via_color( COLOR4D::UNSPECIFIED ), + previous_background_color( COLOR4D::UNSPECIFIED ) + { + } + }; + + LAYER_TOOLBAR_ICON_VALUES m_prevIconVal; + // The Tool Framework initalization void setupTools(); diff --git a/pcbnew/toolbars_pcb_editor.cpp b/pcbnew/toolbars_pcb_editor.cpp index f7c8e0526d..d8b0edab42 100644 --- a/pcbnew/toolbars_pcb_editor.cpp +++ b/pcbnew/toolbars_pcb_editor.cpp @@ -90,60 +90,53 @@ void PCB_EDIT_FRAME::PrepareLayerIndicator( bool aForceRebuild ) COLOR4D active_layer_color, top_color, bottom_color, via_color, background_color; bool change = aForceRebuild; - static int previous_requested_scale; - static COLOR4D previous_active_layer_color = COLOR4D::UNSPECIFIED; - static COLOR4D previous_Route_Layer_TOP_color = COLOR4D::UNSPECIFIED; - static COLOR4D previous_Route_Layer_BOTTOM_color = COLOR4D::UNSPECIFIED; - static COLOR4D previous_via_color = COLOR4D::UNSPECIFIED; - static COLOR4D previous_background_color = COLOR4D::UNSPECIFIED; - int requested_scale; Pgm().CommonSettings()->Read( ICON_SCALE_KEY, &requested_scale, 0 ); - if( requested_scale != previous_requested_scale ) + if( m_prevIconVal.previous_requested_scale != requested_scale ) { - previous_requested_scale = requested_scale; + m_prevIconVal.previous_requested_scale = requested_scale; change = true; } - active_layer_color = Settings().Colors().GetLayerColor(GetActiveLayer()); + active_layer_color = Settings().Colors().GetLayerColor( GetActiveLayer() ); - if( previous_active_layer_color != active_layer_color ) + if( m_prevIconVal.previous_active_layer_color != active_layer_color ) { - previous_active_layer_color = active_layer_color; + m_prevIconVal.previous_active_layer_color = active_layer_color; change = true; } top_color = Settings().Colors().GetLayerColor( GetScreen()->m_Route_Layer_TOP ); - if( previous_Route_Layer_TOP_color != top_color ) + if( m_prevIconVal.previous_Route_Layer_TOP_color != top_color ) { - previous_Route_Layer_TOP_color = top_color; + m_prevIconVal.previous_Route_Layer_TOP_color = top_color; change = true; } bottom_color = Settings().Colors().GetLayerColor( GetScreen()->m_Route_Layer_BOTTOM ); - if( previous_Route_Layer_BOTTOM_color != bottom_color ) + if( m_prevIconVal.previous_Route_Layer_BOTTOM_color != bottom_color ) { - previous_Route_Layer_BOTTOM_color = bottom_color; + m_prevIconVal.previous_Route_Layer_BOTTOM_color = bottom_color; change = true; } int via_type = GetDesignSettings().m_CurrentViaType; via_color = Settings().Colors().GetItemColor( LAYER_VIAS + via_type ); - if( previous_via_color != via_color ) + if( m_prevIconVal.previous_via_color != via_color ) { - previous_via_color = via_color; + m_prevIconVal.previous_via_color = via_color; change = true; } background_color = Settings().Colors().GetItemColor( LAYER_PCB_BACKGROUND ); - if( previous_background_color != background_color ) + if( m_prevIconVal.previous_background_color != background_color ) { - previous_background_color = background_color; + m_prevIconVal.previous_background_color = background_color; change = true; }