From 16953edf6d8cf359ca58f1520944ee47b3216ca7 Mon Sep 17 00:00:00 2001 From: Marek Roszko Date: Sun, 3 Mar 2024 14:16:40 -0500 Subject: [PATCH] Move APPEARANCE_CONTROLS_3D to the lang change event --- 3d-viewer/3d_viewer/eda_3d_viewer_frame.cpp | 2 -- 3d-viewer/dialogs/appearance_controls_3D.cpp | 15 +++++++++++++-- 3d-viewer/dialogs/appearance_controls_3D.h | 5 +++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/3d-viewer/3d_viewer/eda_3d_viewer_frame.cpp b/3d-viewer/3d_viewer/eda_3d_viewer_frame.cpp index cb757782dc..b3ffb75272 100644 --- a/3d-viewer/3d_viewer/eda_3d_viewer_frame.cpp +++ b/3d-viewer/3d_viewer/eda_3d_viewer_frame.cpp @@ -658,8 +658,6 @@ void EDA_3D_VIEWER_FRAME::ShowChangedLanguage() { wxAuiPaneInfo& lm_pane_info = m_auimgr.GetPane( m_appearancePanel ); lm_pane_info.Caption( _( "Appearance" ) ); - - m_appearancePanel->OnLanguageChanged(); } SetStatusText( wxEmptyString, ACTIVITY ); diff --git a/3d-viewer/dialogs/appearance_controls_3D.cpp b/3d-viewer/dialogs/appearance_controls_3D.cpp index ae543868e9..f38c9b9c76 100644 --- a/3d-viewer/dialogs/appearance_controls_3D.cpp +++ b/3d-viewer/dialogs/appearance_controls_3D.cpp @@ -153,11 +153,14 @@ APPEARANCE_CONTROLS_3D::APPEARANCE_CONTROLS_3D( EDA_3D_VIEWER_FRAME* aParent, m_toggleGridRenderer = new GRID_BITMAP_TOGGLE_RENDERER( KiBitmap( BITMAPS::visibility ), KiBitmap( BITMAPS::visibility_off ) ); + + m_frame->Bind( EDA_LANG_CHANGED, &APPEARANCE_CONTROLS_3D::OnLanguageChanged, this ); } APPEARANCE_CONTROLS_3D::~APPEARANCE_CONTROLS_3D() { + m_frame->Unbind( EDA_LANG_CHANGED, &APPEARANCE_CONTROLS_3D::OnLanguageChanged, this ); } @@ -192,7 +195,7 @@ void APPEARANCE_CONTROLS_3D::OnSize( wxSizeEvent& aEvent ) } -void APPEARANCE_CONTROLS_3D::OnLanguageChanged() +void APPEARANCE_CONTROLS_3D::rebuildControls() { Freeze(); @@ -206,6 +209,14 @@ void APPEARANCE_CONTROLS_3D::OnLanguageChanged() } +void APPEARANCE_CONTROLS_3D::OnLanguageChanged( wxCommandEvent& aEvent ) +{ + rebuildControls(); + + aEvent.Skip(); +} + + void APPEARANCE_CONTROLS_3D::OnDarkModeToggle() { // This is essentially a list of hacks because DarkMode isn't yet implemented inside @@ -229,7 +240,7 @@ void APPEARANCE_CONTROLS_3D::OnDarkModeToggle() void APPEARANCE_CONTROLS_3D::CommonSettingsChanged() { - OnLanguageChanged(); + rebuildControls(); UpdateLayerCtls(); syncLayerPresetSelection(); diff --git a/3d-viewer/dialogs/appearance_controls_3D.h b/3d-viewer/dialogs/appearance_controls_3D.h index 17a9346d36..3e7e24e2d9 100644 --- a/3d-viewer/dialogs/appearance_controls_3D.h +++ b/3d-viewer/dialogs/appearance_controls_3D.h @@ -114,8 +114,6 @@ public: ~APPEARANCE_CONTROLS_3D(); wxSize GetBestSize() const; - - void OnLanguageChanged(); void OnDarkModeToggle(); void OnLayerVisibilityChanged( int aLayer, bool isVisible ); @@ -140,8 +138,11 @@ public: protected: void OnSetFocus( wxFocusEvent& aEvent ) override; void OnSize( wxSizeEvent& aEvent ) override; + void OnLanguageChanged( wxCommandEvent& aEvent ); private: + void rebuildControls(); + void rebuildLayers(); void rebuildLayerPresetsWidget();