Add context menu for simulation cursors.
Fixes https://gitlab.com/kicad/code/kicad/issues/13580
This commit is contained in:
parent
28f14482a6
commit
0e778f17db
|
@ -1487,9 +1487,9 @@ void SIM_PLOT_FRAME::onSignalDblClick( wxMouseEvent& event )
|
|||
}
|
||||
|
||||
|
||||
void SIM_PLOT_FRAME::onSignalRClick( wxListEvent& event )
|
||||
void SIM_PLOT_FRAME::onSignalRClick( wxListEvent& aEvent )
|
||||
{
|
||||
int idx = event.GetIndex();
|
||||
long idx = aEvent.GetIndex();
|
||||
|
||||
if( idx != wxNOT_FOUND )
|
||||
m_signals->Select( idx );
|
||||
|
@ -1505,6 +1505,24 @@ void SIM_PLOT_FRAME::onSignalRClick( wxListEvent& event )
|
|||
}
|
||||
|
||||
|
||||
void SIM_PLOT_FRAME::onCursorRClick( wxListEvent& aEvent )
|
||||
{
|
||||
long idx = aEvent.GetIndex();
|
||||
|
||||
if( idx != wxNOT_FOUND )
|
||||
m_signals->Select( idx );
|
||||
|
||||
idx = m_signals->GetFirstSelected();
|
||||
|
||||
if( idx != wxNOT_FOUND )
|
||||
{
|
||||
const wxString& netName = m_signals->GetItemText( idx, 0 );
|
||||
CURSOR_CONTEXT_MENU ctxMenu( netName, this );
|
||||
m_signals->PopupMenu( &ctxMenu );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SIM_PLOT_FRAME::onWorkbookModified( wxCommandEvent& event )
|
||||
{
|
||||
updateTitle();
|
||||
|
@ -2016,6 +2034,31 @@ void SIM_PLOT_FRAME::SIGNAL_CONTEXT_MENU::onMenuEvent( wxMenuEvent& aEvent )
|
|||
}
|
||||
|
||||
|
||||
SIM_PLOT_FRAME::CURSOR_CONTEXT_MENU::CURSOR_CONTEXT_MENU( const wxString& aSignal,
|
||||
SIM_PLOT_FRAME* aPlotFrame ) :
|
||||
m_signal( aSignal ),
|
||||
m_plotFrame( aPlotFrame )
|
||||
{
|
||||
SIM_PLOT_PANEL* plot = m_plotFrame->GetCurrentPlot();
|
||||
|
||||
AddMenuItem( this, HIDE_CURSOR, _( "Hide Cursor" ), KiBitmap( BITMAPS::pcb_target ) );
|
||||
|
||||
Connect( wxEVT_COMMAND_MENU_SELECTED, wxMenuEventHandler( CURSOR_CONTEXT_MENU::onMenuEvent ),
|
||||
nullptr, this );
|
||||
}
|
||||
|
||||
|
||||
void SIM_PLOT_FRAME::CURSOR_CONTEXT_MENU::onMenuEvent( wxMenuEvent& aEvent )
|
||||
{
|
||||
SIM_PLOT_PANEL* plot = m_plotFrame->GetCurrentPlot();
|
||||
|
||||
switch( aEvent.GetId() )
|
||||
{
|
||||
case HIDE_CURSOR: plot->EnableCursor( m_signal, false ); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SIM_PLOT_FRAME::menuExit( wxCommandEvent& event )
|
||||
{
|
||||
if( event.GetId() == wxID_EXIT )
|
||||
|
|
|
@ -288,7 +288,9 @@ private:
|
|||
void onPlotDragged( wxAuiNotebookEvent& event ) override;
|
||||
|
||||
void onSignalDblClick( wxMouseEvent& event ) override;
|
||||
void onSignalRClick( wxListEvent& event ) override;
|
||||
void onSignalRClick( wxListEvent& aEvent ) override;
|
||||
|
||||
void onCursorRClick( wxListEvent& aEvent ) override;
|
||||
|
||||
void onWorkbookModified( wxCommandEvent& event );
|
||||
void onWorkbookClrModified( wxCommandEvent& event );
|
||||
|
@ -330,6 +332,13 @@ private:
|
|||
///< List of currently displayed tuners
|
||||
std::list<TUNER_SLIDER*> m_tuners;
|
||||
|
||||
enum CONTEXT_MENU_EVENTS
|
||||
{
|
||||
REMOVE_SIGNAL = 944,
|
||||
SHOW_CURSOR,
|
||||
HIDE_CURSOR
|
||||
};
|
||||
|
||||
// Right click context menu for signals in the listbox
|
||||
class SIGNAL_CONTEXT_MENU : public wxMenu
|
||||
{
|
||||
|
@ -341,13 +350,19 @@ private:
|
|||
|
||||
const wxString& m_signal;
|
||||
SIM_PLOT_FRAME* m_plotFrame;
|
||||
|
||||
enum SIGNAL_CONTEXT_MENU_EVENTS
|
||||
{
|
||||
REMOVE_SIGNAL = 944,
|
||||
SHOW_CURSOR,
|
||||
HIDE_CURSOR
|
||||
};
|
||||
|
||||
// Right click context menu for cursors in the listbox
|
||||
class CURSOR_CONTEXT_MENU : public wxMenu
|
||||
{
|
||||
public:
|
||||
CURSOR_CONTEXT_MENU( const wxString& aSignal, SIM_PLOT_FRAME* aPlotFrame );
|
||||
|
||||
private:
|
||||
void onMenuEvent( wxMenuEvent& aEvent );
|
||||
|
||||
const wxString& m_signal;
|
||||
SIM_PLOT_FRAME* m_plotFrame;
|
||||
};
|
||||
|
||||
///< Panel that was used as the most recent one for simulations
|
||||
|
|
|
@ -304,6 +304,7 @@ SIM_PLOT_FRAME_BASE::SIM_PLOT_FRAME_BASE( wxWindow* parent, wxWindowID id, const
|
|||
m_workbook->Connect( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSED, wxAuiNotebookEventHandler( SIM_PLOT_FRAME_BASE::onPlotClosed ), NULL, this );
|
||||
m_signals->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( SIM_PLOT_FRAME_BASE::onSignalDblClick ), NULL, this );
|
||||
m_signals->Connect( wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK, wxListEventHandler( SIM_PLOT_FRAME_BASE::onSignalRClick ), NULL, this );
|
||||
m_cursors->Connect( wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK, wxListEventHandler( SIM_PLOT_FRAME_BASE::onCursorRClick ), NULL, this );
|
||||
}
|
||||
|
||||
SIM_PLOT_FRAME_BASE::~SIM_PLOT_FRAME_BASE()
|
||||
|
@ -323,5 +324,6 @@ SIM_PLOT_FRAME_BASE::~SIM_PLOT_FRAME_BASE()
|
|||
m_workbook->Disconnect( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSED, wxAuiNotebookEventHandler( SIM_PLOT_FRAME_BASE::onPlotClosed ), NULL, this );
|
||||
m_signals->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( SIM_PLOT_FRAME_BASE::onSignalDblClick ), NULL, this );
|
||||
m_signals->Disconnect( wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK, wxListEventHandler( SIM_PLOT_FRAME_BASE::onSignalRClick ), NULL, this );
|
||||
m_cursors->Disconnect( wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK, wxListEventHandler( SIM_PLOT_FRAME_BASE::onCursorRClick ), NULL, this );
|
||||
|
||||
}
|
||||
|
|
|
@ -1506,6 +1506,7 @@
|
|||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
<event name="OnListItemRightClick">onCursorRClick</event>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
|
|
|
@ -122,6 +122,7 @@ class SIM_PLOT_FRAME_BASE : public KIWAY_PLAYER
|
|||
virtual void onPlotClosed( wxAuiNotebookEvent& event ) { event.Skip(); }
|
||||
virtual void onSignalDblClick( wxMouseEvent& event ) { event.Skip(); }
|
||||
virtual void onSignalRClick( wxListEvent& event ) { event.Skip(); }
|
||||
virtual void onCursorRClick( wxListEvent& event ) { event.Skip(); }
|
||||
|
||||
|
||||
public:
|
||||
|
|
Loading…
Reference in New Issue