From a6bceb8182a3af5e8bed6188cb0f8e9bba8b06f8 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 9 Aug 2023 12:09:00 +0100 Subject: [PATCH] Don't set modified when loading workbook. Also keep a shadow variable of the legend position so we can notice when the mpWindow's OnMouseMove() handler changes it. Fixes https://gitlab.com/kicad/code/kicad/-/issues/15363 --- eeschema/sim/sim_plot_tab.cpp | 1 + eeschema/sim/sim_plot_tab.h | 4 ++++ eeschema/sim/simulator_frame.cpp | 1 + eeschema/sim/simulator_frame_ui.cpp | 12 +++++++++++- eeschema/sim/simulator_frame_ui.h | 2 ++ eeschema/sim/simulator_frame_ui_base.cpp | 2 ++ eeschema/sim/simulator_frame_ui_base.fbp | 1 + eeschema/sim/simulator_frame_ui_base.h | 1 + eeschema/tools/simulator_control.cpp | 1 + 9 files changed, 24 insertions(+), 1 deletion(-) diff --git a/eeschema/sim/sim_plot_tab.cpp b/eeschema/sim/sim_plot_tab.cpp index e8a1e05402..6f7852c5f6 100644 --- a/eeschema/sim/sim_plot_tab.cpp +++ b/eeschema/sim/sim_plot_tab.cpp @@ -441,6 +441,7 @@ SIM_PLOT_TAB::SIM_PLOT_TAB( const wxString& aSimCommand, wxWindow* parent ) : m_legend = new mpInfoLegend( wxRect( 0, 0, 200, 40 ), wxTRANSPARENT_BRUSH ); m_legend->SetVisible( false ); m_plotWin->AddLayer( m_legend ); + m_LastLegendPosition = m_legend->GetPosition(); m_plotWin->EnableDoubleBuffer( true ); m_plotWin->UpdateAll(); diff --git a/eeschema/sim/sim_plot_tab.h b/eeschema/sim/sim_plot_tab.h index 6984e4c22b..6d5785f1a6 100644 --- a/eeschema/sim/sim_plot_tab.h +++ b/eeschema/sim/sim_plot_tab.h @@ -306,6 +306,7 @@ public: { m_legend->Move( aPosition ); m_legend->UpdateReference(); + m_LastLegendPosition = aPosition; } /** @@ -353,6 +354,9 @@ public: std::vector>& Measurements() { return m_measurements; } +public: + wxPoint m_LastLegendPosition; + private: wxString getTraceId( const wxString& aVectorName, int aType ) const { diff --git a/eeschema/sim/simulator_frame.cpp b/eeschema/sim/simulator_frame.cpp index a4e59c3738..7495324e72 100644 --- a/eeschema/sim/simulator_frame.cpp +++ b/eeschema/sim/simulator_frame.cpp @@ -783,6 +783,7 @@ void SIMULATOR_FRAME::OnModify() { KIWAY_PLAYER::OnModify(); m_workbookModified = true; + UpdateTitle(); } diff --git a/eeschema/sim/simulator_frame_ui.cpp b/eeschema/sim/simulator_frame_ui.cpp index ee17b9ada6..73d30c1028 100644 --- a/eeschema/sim/simulator_frame_ui.cpp +++ b/eeschema/sim/simulator_frame_ui.cpp @@ -924,7 +924,6 @@ SIM_TAB* SIMULATOR_FRAME_UI::NewSimTab( const wxString& aSimCommand ) m_plotNotebook->AddPage( simTab, pageTitle, true ); - m_simulatorFrame->OnModify(); return simTab; } @@ -1198,6 +1197,16 @@ void SIMULATOR_FRAME_UI::onMeasurementsGridCellChanged( wxGridEvent& aEvent ) } +void SIMULATOR_FRAME_UI::OnUpdateUI( wxUpdateUIEvent& event ) +{ + if( SIM_PLOT_TAB* plotTab = dynamic_cast( GetCurrentSimTab() ) ) + { + if( plotTab->GetLegendPosition() != plotTab->m_LastLegendPosition ) + m_simulatorFrame->OnModify(); + } +} + + /** * The user measurement looks something like: * MAX V(out) @@ -2244,6 +2253,7 @@ void SIMULATOR_FRAME_UI::ToggleDarkModePlots() void SIMULATOR_FRAME_UI::onPlotClose( wxAuiNotebookEvent& event ) { + m_simulatorFrame->OnModify(); } diff --git a/eeschema/sim/simulator_frame_ui.h b/eeschema/sim/simulator_frame_ui.h index 49f2549aec..c606372695 100644 --- a/eeschema/sim/simulator_frame_ui.h +++ b/eeschema/sim/simulator_frame_ui.h @@ -304,6 +304,8 @@ private: void onCursorsGridCellChanged( wxGridEvent& aEvent ) override; void onMeasurementsGridCellChanged( wxGridEvent& aEvent ) override; + void OnUpdateUI( wxUpdateUIEvent& event ) override; + bool loadLegacyWorkbook( const wxString & aPath ); bool loadJsonWorkbook( const wxString & aPath ); diff --git a/eeschema/sim/simulator_frame_ui_base.cpp b/eeschema/sim/simulator_frame_ui_base.cpp index a0252c940a..d639d05115 100644 --- a/eeschema/sim/simulator_frame_ui_base.cpp +++ b/eeschema/sim/simulator_frame_ui_base.cpp @@ -278,6 +278,7 @@ SIMULATOR_FRAME_UI_BASE::SIMULATOR_FRAME_UI_BASE( wxWindow* parent, wxWindowID i sizerMain->Fit( this ); // Connect Events + this->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( SIMULATOR_FRAME_UI_BASE::OnUpdateUI ) ); m_plotNotebook->Connect( wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, wxAuiNotebookEventHandler( SIMULATOR_FRAME_UI_BASE::onPlotDragged ), NULL, this ); m_plotNotebook->Connect( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, wxAuiNotebookEventHandler( SIMULATOR_FRAME_UI_BASE::onPlotChanged ), NULL, this ); m_plotNotebook->Connect( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, wxAuiNotebookEventHandler( SIMULATOR_FRAME_UI_BASE::onPlotChanging ), NULL, this ); @@ -293,6 +294,7 @@ SIMULATOR_FRAME_UI_BASE::SIMULATOR_FRAME_UI_BASE( wxWindow* parent, wxWindowID i SIMULATOR_FRAME_UI_BASE::~SIMULATOR_FRAME_UI_BASE() { // Disconnect Events + this->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( SIMULATOR_FRAME_UI_BASE::OnUpdateUI ) ); m_plotNotebook->Disconnect( wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, wxAuiNotebookEventHandler( SIMULATOR_FRAME_UI_BASE::onPlotDragged ), NULL, this ); m_plotNotebook->Disconnect( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, wxAuiNotebookEventHandler( SIMULATOR_FRAME_UI_BASE::onPlotChanged ), NULL, this ); m_plotNotebook->Disconnect( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, wxAuiNotebookEventHandler( SIMULATOR_FRAME_UI_BASE::onPlotChanging ), NULL, this ); diff --git a/eeschema/sim/simulator_frame_ui_base.fbp b/eeschema/sim/simulator_frame_ui_base.fbp index e0e5c52419..f4044cae51 100644 --- a/eeschema/sim/simulator_frame_ui_base.fbp +++ b/eeschema/sim/simulator_frame_ui_base.fbp @@ -52,6 +52,7 @@ wxTAB_TRAVERSAL + OnUpdateUI sizerMain diff --git a/eeschema/sim/simulator_frame_ui_base.h b/eeschema/sim/simulator_frame_ui_base.h index 6b447d92cc..808a718696 100644 --- a/eeschema/sim/simulator_frame_ui_base.h +++ b/eeschema/sim/simulator_frame_ui_base.h @@ -64,6 +64,7 @@ class SIMULATOR_FRAME_UI_BASE : public wxPanel wxBoxSizer* m_sizerTuners; // Virtual event handlers, override them in your derived class + virtual void OnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); } virtual void onPlotDragged( wxAuiNotebookEvent& event ) { event.Skip(); } virtual void onPlotChanged( wxAuiNotebookEvent& event ) { event.Skip(); } virtual void onPlotChanging( wxAuiNotebookEvent& event ) { event.Skip(); } diff --git a/eeschema/tools/simulator_control.cpp b/eeschema/tools/simulator_control.cpp index 4f27944a82..f2a7e924d9 100644 --- a/eeschema/tools/simulator_control.cpp +++ b/eeschema/tools/simulator_control.cpp @@ -82,6 +82,7 @@ int SIMULATOR_CONTROL::NewAnalysisTab( const TOOL_EVENT& aEvent ) { SIM_TAB* tab = m_simulatorFrame->NewSimTab( dlg.GetSimCommand() ); dlg.ApplySettings( tab ); + m_simulatorFrame->OnModify(); } return 0;