Re-enable custom grid settings for Pcbnew
Add a reset button that will only show up if the user edits the JSON configuration for grids. This is a temporary measure until we have a real grid editor GUI in V7. Fixes https://gitlab.com/kicad/code/kicad/-/issues/7595
This commit is contained in:
parent
2d28ed8eda
commit
6fa0ac45af
|
@ -43,11 +43,7 @@ DIALOG_GRID_SETTINGS::DIALOG_GRID_SETTINGS( EDA_DRAW_FRAME* aParent ):
|
|||
m_gridOriginX.SetCoordType( ORIGIN_TRANSFORMS::ABS_X_COORD );
|
||||
m_gridOriginY.SetCoordType( ORIGIN_TRANSFORMS::ABS_Y_COORD );
|
||||
|
||||
wxArrayString grids;
|
||||
GRID_MENU::BuildChoiceList( &grids, m_parent->config(), m_parent );
|
||||
m_currentGridCtrl->Append( grids );
|
||||
m_grid1Ctrl->Append( grids );
|
||||
m_grid2Ctrl->Append( grids );
|
||||
RebuildGridSizes();
|
||||
|
||||
if( m_parent->IsType( FRAME_SCH )
|
||||
|| m_parent->IsType( FRAME_SCH_SYMBOL_EDITOR )
|
||||
|
@ -56,7 +52,7 @@ DIALOG_GRID_SETTINGS::DIALOG_GRID_SETTINGS( EDA_DRAW_FRAME* aParent ):
|
|||
|| m_parent->IsType( FRAME_SIMULATOR ) )
|
||||
{
|
||||
m_book->SetSelection( 1 );
|
||||
m_buttonReset->Hide(); // Eeschema and friends don't use grid origin
|
||||
m_buttonResetOrigin->Hide(); // Eeschema and friends don't use grid origin
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -70,6 +66,36 @@ DIALOG_GRID_SETTINGS::DIALOG_GRID_SETTINGS( EDA_DRAW_FRAME* aParent ):
|
|||
|
||||
// Now all widgets have the size fixed, call FinishDialogSettings
|
||||
finishDialogSettings();
|
||||
|
||||
m_buttonResetSizes->Bind( wxEVT_BUTTON,
|
||||
[&]( wxCommandEvent )
|
||||
{
|
||||
APP_SETTINGS_BASE* settings = m_parent->config();
|
||||
settings->m_Window.grid.sizes = settings->DefaultGridSizeList();
|
||||
RebuildGridSizes();
|
||||
settings->m_Window.grid.last_size_idx = m_currentGridCtrl->GetSelection();
|
||||
} );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_GRID_SETTINGS::RebuildGridSizes()
|
||||
{
|
||||
APP_SETTINGS_BASE* settings = m_parent->config();
|
||||
|
||||
wxString savedCurrentGrid = m_currentGridCtrl->GetStringSelection();
|
||||
wxString savedGrid1 = m_grid1Ctrl->GetStringSelection();
|
||||
wxString savedGrid2 = m_grid2Ctrl->GetStringSelection();
|
||||
|
||||
wxArrayString grids;
|
||||
GRID_MENU::BuildChoiceList( &grids, settings, m_parent );
|
||||
|
||||
m_currentGridCtrl->Set( grids );
|
||||
m_grid1Ctrl->Set( grids );
|
||||
m_grid2Ctrl->Set( grids );
|
||||
|
||||
m_currentGridCtrl->SetStringSelection( savedCurrentGrid );
|
||||
m_grid1Ctrl->SetStringSelection( savedGrid1 );
|
||||
m_grid2Ctrl->SetStringSelection( savedGrid2 );
|
||||
}
|
||||
|
||||
|
||||
|
@ -108,9 +134,14 @@ bool DIALOG_GRID_SETTINGS::TransferDataFromWindow()
|
|||
|
||||
bool DIALOG_GRID_SETTINGS::TransferDataToWindow()
|
||||
{
|
||||
GRID_SETTINGS& gridCfg = m_parent->config()->m_Window.grid;
|
||||
APP_SETTINGS_BASE* settings = m_parent->config();
|
||||
|
||||
m_currentGridCtrl->SetSelection( m_parent->config()->m_Window.grid.last_size_idx );
|
||||
GRID_SETTINGS& gridCfg = settings->m_Window.grid;
|
||||
|
||||
m_buttonResetSizes->Show( gridCfg.sizes != settings->DefaultGridSizeList() );
|
||||
Layout();
|
||||
|
||||
m_currentGridCtrl->SetSelection( settings->m_Window.grid.last_size_idx );
|
||||
|
||||
m_userGridX.SetValue( ValueFromString( GetUserUnits(), gridCfg.user_grid_x ) );
|
||||
m_userGridY.SetValue( ValueFromString( GetUserUnits(), gridCfg.user_grid_y ) );
|
||||
|
|
|
@ -170,8 +170,14 @@ DIALOG_GRID_SETTINGS_BASE::DIALOG_GRID_SETTINGS_BASE( wxWindow* parent, wxWindow
|
|||
wxBoxSizer* bButtonSizer;
|
||||
bButtonSizer = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
m_buttonReset = new wxButton( this, wxID_ANY, _("Reset Grid Origin"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bButtonSizer->Add( m_buttonReset, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
||||
m_buttonResetOrigin = new wxButton( this, wxID_ANY, _("Reset Grid Origin"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bButtonSizer->Add( m_buttonResetOrigin, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
||||
|
||||
m_buttonResetSizes = new wxButton( this, wxID_ANY, _("Reset Grid Sizes"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_buttonResetSizes->Hide();
|
||||
m_buttonResetSizes->SetToolTip( _("Resets the list of grid sizes to default values") );
|
||||
|
||||
bButtonSizer->Add( m_buttonResetSizes, 0, wxALL, 5 );
|
||||
|
||||
|
||||
bButtonSizer->Add( 0, 0, 1, wxEXPAND, 5 );
|
||||
|
@ -195,7 +201,7 @@ DIALOG_GRID_SETTINGS_BASE::DIALOG_GRID_SETTINGS_BASE( wxWindow* parent, wxWindow
|
|||
|
||||
// Connect Events
|
||||
this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_GRID_SETTINGS_BASE::OnInitDlg ) );
|
||||
m_buttonReset->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GRID_SETTINGS_BASE::OnResetGridOriginClick ), NULL, this );
|
||||
m_buttonResetOrigin->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GRID_SETTINGS_BASE::OnResetGridOriginClick ), NULL, this );
|
||||
m_sdbSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GRID_SETTINGS_BASE::OnCancelClick ), NULL, this );
|
||||
m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GRID_SETTINGS_BASE::OnOkClick ), NULL, this );
|
||||
}
|
||||
|
@ -204,7 +210,7 @@ DIALOG_GRID_SETTINGS_BASE::~DIALOG_GRID_SETTINGS_BASE()
|
|||
{
|
||||
// Disconnect Events
|
||||
this->Disconnect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_GRID_SETTINGS_BASE::OnInitDlg ) );
|
||||
m_buttonReset->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GRID_SETTINGS_BASE::OnResetGridOriginClick ), NULL, this );
|
||||
m_buttonResetOrigin->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GRID_SETTINGS_BASE::OnResetGridOriginClick ), NULL, this );
|
||||
m_sdbSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GRID_SETTINGS_BASE::OnCancelClick ), NULL, this );
|
||||
m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GRID_SETTINGS_BASE::OnOkClick ), NULL, this );
|
||||
|
||||
|
|
|
@ -1633,7 +1633,7 @@
|
|||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">m_buttonReset</property>
|
||||
<property name="name">m_buttonResetOrigin</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
|
@ -1659,6 +1659,78 @@
|
|||
<event name="OnButtonClick">OnResetGridOriginClick</event>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxALL</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxButton" expanded="1">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="bitmap"></property>
|
||||
<property name="caption"></property>
|
||||
<property name="caption_visible">1</property>
|
||||
<property name="center_pane">0</property>
|
||||
<property name="close_button">1</property>
|
||||
<property name="context_help"></property>
|
||||
<property name="context_menu">1</property>
|
||||
<property name="current"></property>
|
||||
<property name="default">0</property>
|
||||
<property name="default_pane">0</property>
|
||||
<property name="disabled"></property>
|
||||
<property name="dock">Dock</property>
|
||||
<property name="dock_fixed">0</property>
|
||||
<property name="docking">Left</property>
|
||||
<property name="enabled">1</property>
|
||||
<property name="fg"></property>
|
||||
<property name="floatable">1</property>
|
||||
<property name="focus"></property>
|
||||
<property name="font"></property>
|
||||
<property name="gripper">0</property>
|
||||
<property name="hidden">1</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="label">Reset Grid Sizes</property>
|
||||
<property name="margins"></property>
|
||||
<property name="markup">0</property>
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
<property name="min_size"></property>
|
||||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">m_buttonResetSizes</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
<property name="permission">protected</property>
|
||||
<property name="pin_button">1</property>
|
||||
<property name="pos"></property>
|
||||
<property name="position"></property>
|
||||
<property name="pressed"></property>
|
||||
<property name="resize">Resizable</property>
|
||||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
<property name="style"></property>
|
||||
<property name="subclass">; ; forward_declare</property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip">Resets the list of grid sizes to default values</property>
|
||||
<property name="validator_data_type"></property>
|
||||
<property name="validator_style">wxFILTER_NONE</property>
|
||||
<property name="validator_type">wxDefaultValidator</property>
|
||||
<property name="validator_variable"></property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND</property>
|
||||
|
|
|
@ -62,7 +62,8 @@ class DIALOG_GRID_SETTINGS_BASE : public DIALOG_SHIM
|
|||
wxChoice* m_grid2Ctrl;
|
||||
wxStaticText* m_grid2HotKey;
|
||||
wxStaticLine* m_staticline1;
|
||||
wxButton* m_buttonReset;
|
||||
wxButton* m_buttonResetOrigin;
|
||||
wxButton* m_buttonResetSizes;
|
||||
wxStdDialogButtonSizer* m_sdbSizer;
|
||||
wxButton* m_sdbSizerOK;
|
||||
wxButton* m_sdbSizerCancel;
|
||||
|
|
|
@ -287,7 +287,7 @@ void APP_SETTINGS_BASE::addParamsForWindow( WINDOW_SETTINGS* aWindow, const std:
|
|||
&aWindow->grid.axes_enabled, false ) );
|
||||
|
||||
m_params.emplace_back( new PARAM_LIST<wxString>( aJsonPath + ".grid.sizes",
|
||||
&aWindow->grid.sizes, {} ) );
|
||||
&aWindow->grid.sizes, DefaultGridSizeList() ) );
|
||||
|
||||
// pcbnew default grid doesn't matter much, but eeschema does, so default to the index
|
||||
// of the 50mil grid in eeschema
|
||||
|
|
|
@ -320,6 +320,18 @@ void JSON_SETTINGS::ResetToDefaults()
|
|||
}
|
||||
|
||||
|
||||
bool JSON_SETTINGS::IsDefault( const std::string& aParamName )
|
||||
{
|
||||
for( const PARAM_BASE* param : m_params )
|
||||
{
|
||||
if( param->GetJsonPath() == aParamName )
|
||||
return param->IsDefault();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool JSON_SETTINGS::SaveToFile( const wxString& aDirectory, bool aForce )
|
||||
{
|
||||
if( !m_writeFile )
|
||||
|
|
|
@ -42,6 +42,8 @@ public:
|
|||
private:
|
||||
void OnResetGridOriginClick( wxCommandEvent& event ) override;
|
||||
|
||||
void RebuildGridSizes();
|
||||
|
||||
UNIT_BINDER m_gridOriginX;
|
||||
UNIT_BINDER m_gridOriginY;
|
||||
UNIT_BINDER m_userGridX;
|
||||
|
|
|
@ -155,6 +155,9 @@ public:
|
|||
|
||||
virtual bool MigrateFromLegacy( wxConfigBase* aCfg ) override;
|
||||
|
||||
/// Override in child classes to define the default for the window.grid.sizes parameter
|
||||
virtual const std::vector<wxString> DefaultGridSizeList() const { return {}; }
|
||||
|
||||
public:
|
||||
CROSS_PROBING_SETTINGS m_CrossProbing;
|
||||
|
||||
|
|
|
@ -105,6 +105,13 @@ c * @return true if the file was saved
|
|||
*/
|
||||
void ResetToDefaults();
|
||||
|
||||
/**
|
||||
* Checks if the current state of a parameter matches its default value
|
||||
* @param aParamName is the JSON path to the parameter
|
||||
* @return true if the given parameter is at its default value
|
||||
*/
|
||||
bool IsDefault( const std::string& aParamName );
|
||||
|
||||
/**
|
||||
* Fetches a JSON object that is a subset of this JSON_SETTINGS object, using a path of the
|
||||
* form "key1.key2.key3" to refer to nested objects.
|
||||
|
|
|
@ -71,7 +71,7 @@ public:
|
|||
* @return the path name of the parameter used to store it in the json file
|
||||
* mainly usefull in error messages
|
||||
*/
|
||||
const std::string& GetJsonPath() { return m_path; }
|
||||
const std::string& GetJsonPath() const { return m_path; }
|
||||
|
||||
protected:
|
||||
/**
|
||||
|
|
|
@ -162,33 +162,8 @@ FOOTPRINT_PREVIEW_PANEL* FOOTPRINT_PREVIEW_PANEL::New( KIWAY* aKiway, wxWindow*
|
|||
{
|
||||
PCBNEW_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<PCBNEW_SETTINGS>();
|
||||
|
||||
// Currently values read from config file are not used because the user cannot
|
||||
// change this config
|
||||
// if( cfg->m_Window.grid.sizes.empty() )
|
||||
{
|
||||
cfg->m_Window.grid.sizes = { "1000 mil",
|
||||
"500 mil",
|
||||
"250 mil",
|
||||
"200 mil",
|
||||
"100 mil",
|
||||
"50 mil",
|
||||
"25 mil",
|
||||
"20 mil",
|
||||
"10 mil",
|
||||
"5 mil",
|
||||
"2 mil",
|
||||
"1 mil",
|
||||
"5.0 mm",
|
||||
"2.5 mm",
|
||||
"1.0 mm",
|
||||
"0.5 mm",
|
||||
"0.25 mm",
|
||||
"0.2 mm",
|
||||
"0.1 mm",
|
||||
"0.05 mm",
|
||||
"0.025 mm",
|
||||
"0.01 mm" };
|
||||
}
|
||||
if( cfg->m_Window.grid.sizes.empty() )
|
||||
cfg->m_Window.grid.sizes = cfg->DefaultGridSizeList();
|
||||
|
||||
// Currently values read from config file are not used because the user cannot
|
||||
// change this config
|
||||
|
|
|
@ -590,33 +590,8 @@ void PCB_BASE_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
|
|||
{
|
||||
EDA_DRAW_FRAME::LoadSettings( aCfg );
|
||||
|
||||
// Currently values read from config file are not used because the user cannot
|
||||
// change this config
|
||||
// if( aCfg->m_Window.grid.sizes.empty() )
|
||||
{
|
||||
aCfg->m_Window.grid.sizes = { "1000 mil",
|
||||
"500 mil",
|
||||
"250 mil",
|
||||
"200 mil",
|
||||
"100 mil",
|
||||
"50 mil",
|
||||
"25 mil",
|
||||
"20 mil",
|
||||
"10 mil",
|
||||
"5 mil",
|
||||
"2 mil",
|
||||
"1 mil",
|
||||
"5.0 mm",
|
||||
"2.5 mm",
|
||||
"1.0 mm",
|
||||
"0.5 mm",
|
||||
"0.25 mm",
|
||||
"0.2 mm",
|
||||
"0.1 mm",
|
||||
"0.05 mm",
|
||||
"0.025 mm",
|
||||
"0.01 mm" };
|
||||
}
|
||||
if( aCfg->m_Window.grid.sizes.empty() )
|
||||
aCfg->m_Window.grid.sizes = aCfg->DefaultGridSizeList();
|
||||
|
||||
// Currently values read from config file are not used because the user cannot
|
||||
// change this config
|
||||
|
|
|
@ -790,3 +790,30 @@ bool PCBNEW_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
const std::vector<wxString> PCBNEW_SETTINGS::DefaultGridSizeList() const
|
||||
{
|
||||
return { "1000 mil",
|
||||
"500 mil",
|
||||
"250 mil",
|
||||
"200 mil",
|
||||
"100 mil",
|
||||
"50 mil",
|
||||
"25 mil",
|
||||
"20 mil",
|
||||
"10 mil",
|
||||
"5 mil",
|
||||
"2 mil",
|
||||
"1 mil",
|
||||
"5.0 mm",
|
||||
"2.5 mm",
|
||||
"1.0 mm",
|
||||
"0.5 mm",
|
||||
"0.25 mm",
|
||||
"0.2 mm",
|
||||
"0.1 mm",
|
||||
"0.05 mm",
|
||||
"0.025 mm",
|
||||
"0.01 mm" };
|
||||
}
|
||||
|
|
|
@ -234,6 +234,8 @@ public:
|
|||
|
||||
virtual bool MigrateFromLegacy( wxConfigBase* aLegacyConfig ) override;
|
||||
|
||||
const std::vector<wxString> DefaultGridSizeList() const override;
|
||||
|
||||
AUI_PANELS m_AuiPanels;
|
||||
|
||||
DIALOG_CLEANUP m_Cleanup;
|
||||
|
|
Loading…
Reference in New Issue