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
This commit is contained in:
Jeff Young 2023-08-09 12:09:00 +01:00
parent 1b080ed02f
commit a6bceb8182
9 changed files with 24 additions and 1 deletions

View File

@ -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();

View File

@ -306,6 +306,7 @@ public:
{
m_legend->Move( aPosition );
m_legend->UpdateReference();
m_LastLegendPosition = aPosition;
}
/**
@ -353,6 +354,9 @@ public:
std::vector<std::pair<wxString, wxString>>& Measurements() { return m_measurements; }
public:
wxPoint m_LastLegendPosition;
private:
wxString getTraceId( const wxString& aVectorName, int aType ) const
{

View File

@ -783,6 +783,7 @@ void SIMULATOR_FRAME::OnModify()
{
KIWAY_PLAYER::OnModify();
m_workbookModified = true;
UpdateTitle();
}

View File

@ -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<SIM_PLOT_TAB*>( 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();
}

View File

@ -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 );

View File

@ -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 );

View File

@ -52,6 +52,7 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style">wxTAB_TRAVERSAL</property>
<event name="OnUpdateUI">OnUpdateUI</event>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">sizerMain</property>

View File

@ -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(); }

View File

@ -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;