pcbnew: Hide routing options that are not available

Options that do not have code implementing them are now hidden from the
user so that they are not searching for ways to enable the greyed out
options.  Similarly, when selecting a routing option that disables
free-mode, we show the effect of disabling the mode in the dialog.
This commit is contained in:
Seth Hillbrand 2018-06-18 21:41:10 -07:00
parent f52763f22b
commit 6990824597
5 changed files with 23 additions and 6 deletions

View File

@ -29,9 +29,6 @@
DIALOG_PNS_SETTINGS::DIALOG_PNS_SETTINGS( wxWindow* aParent, PNS::ROUTING_SETTINGS& aSettings ) :
DIALOG_PNS_SETTINGS_BASE( aParent ), m_settings( aSettings )
{
// "Figure out what's best" is not available yet
m_mode->Enable( PNS::RM_Smart, false );
// Add tool tip to the mode radio box, one by option
// (cannot be made with wxFormBuilder for each item )
m_mode->SetItemToolTip( 0, _( "DRC violation: highlight obstacles" ) );
@ -51,6 +48,10 @@ DIALOG_PNS_SETTINGS::DIALOG_PNS_SETTINGS( wxWindow* aParent, PNS::ROUTING_SETTIN
m_freeAngleMode->SetValue( m_settings.GetFreeAngleMode() );
m_dragToolMode->SetSelection ( m_settings.InlineDragEnabled() ? 1 : 0 );
// Don't show options that are not implemented
m_suggestEnding->Hide();
m_shoveVias->Hide();
SetDefaultItem( m_stdButtonsOK );
GetSizer()->Fit( this );
GetSizer()->SetSizeHints( this );
@ -74,3 +75,15 @@ void DIALOG_PNS_SETTINGS::OnOkClick( wxCommandEvent& aEvent )
aEvent.Skip(); // ends returning wxID_OK (default behavior)
}
void DIALOG_PNS_SETTINGS::onModeChange( wxCommandEvent& aEvent )
{
if( m_mode->GetSelection() == PNS::RM_MarkObstacles )
m_freeAngleMode->Enable();
else
{
m_freeAngleMode->SetValue( false );
m_freeAngleMode->Enable( false );
}
}

View File

@ -41,6 +41,7 @@ class DIALOG_PNS_SETTINGS : public DIALOG_PNS_SETTINGS_BASE
private:
virtual void OnOkClick( wxCommandEvent& aEvent ) override;
virtual void onModeChange( wxCommandEvent& aEvent ) override;
PNS::ROUTING_SETTINGS& m_settings;
};

View File

@ -16,7 +16,7 @@ DIALOG_PNS_SETTINGS_BASE::DIALOG_PNS_SETTINGS_BASE( wxWindow* parent, wxWindowID
wxBoxSizer* bMainSizer;
bMainSizer = new wxBoxSizer( wxVERTICAL );
wxString m_modeChoices[] = { _("Highlight collisions"), _("Shove"), _("Walk around"), _("Figure out what's best") };
wxString m_modeChoices[] = { _("Highlight collisions"), _("Shove"), _("Walk around") };
int m_modeNChoices = sizeof( m_modeChoices ) / sizeof( wxString );
m_mode = new wxRadioBox( this, wxID_ANY, _("Mode:"), wxDefaultPosition, wxDefaultSize, m_modeNChoices, m_modeChoices, 1, wxRA_SPECIFY_COLS );
m_mode->SetSelection( 0 );
@ -149,6 +149,7 @@ DIALOG_PNS_SETTINGS_BASE::DIALOG_PNS_SETTINGS_BASE( wxWindow* parent, wxWindowID
bMainSizer->Fit( this );
// Connect Events
m_mode->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_PNS_SETTINGS_BASE::onModeChange ), NULL, this );
m_freeAngleMode->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_PNS_SETTINGS_BASE::onFreeAngleModeChange ), NULL, this );
m_stdButtonsOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PNS_SETTINGS_BASE::OnOkClick ), NULL, this );
}
@ -156,6 +157,7 @@ DIALOG_PNS_SETTINGS_BASE::DIALOG_PNS_SETTINGS_BASE( wxWindow* parent, wxWindowID
DIALOG_PNS_SETTINGS_BASE::~DIALOG_PNS_SETTINGS_BASE()
{
// Disconnect Events
m_mode->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_PNS_SETTINGS_BASE::onModeChange ), NULL, this );
m_freeAngleMode->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_PNS_SETTINGS_BASE::onFreeAngleModeChange ), NULL, this );
m_stdButtonsOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PNS_SETTINGS_BASE::OnOkClick ), NULL, this );

View File

@ -112,7 +112,7 @@
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="choices">&quot;Highlight collisions&quot; &quot;Shove&quot; &quot;Walk around&quot; &quot;Figure out what&apos;s best&quot;</property>
<property name="choices">&quot;Highlight collisions&quot; &quot;Shove&quot; &quot;Walk around&quot;</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
@ -175,7 +175,7 @@
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRadioBox"></event>
<event name="OnRadioBox">onModeChange</event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>

View File

@ -60,6 +60,7 @@ class DIALOG_PNS_SETTINGS_BASE : public DIALOG_SHIM
wxButton* m_stdButtonsCancel;
// Virtual event handlers, overide them in your derived class
virtual void onModeChange( wxCommandEvent& event ) { event.Skip(); }
virtual void onFreeAngleModeChange( wxCommandEvent& event ) { event.Skip(); }
virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); }