7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-21 00:21:25 +00:00

grids: make settings panel correctly implement cancel

Before we edited the grid settings directly so cancel would keep your
changes.

Also includes numerous QoL improvements borrowed from Ian's patch,
and a few other small fixes.
This commit is contained in:
Mike Williams 2024-09-16 16:21:38 -04:00
parent 06b1dd7bd8
commit 87a66d4df1
8 changed files with 128 additions and 73 deletions

View File

@ -47,12 +47,19 @@ DIALOG_GRID_SETTINGS::DIALOG_GRID_SETTINGS( wxWindow* aParent, wxWindow* aEventS
Layout();
if( !aGrid.x.IsEmpty() )
{
bool linked = ( aGrid.x == aGrid.y );
VECTOR2D grid = aGrid.ToDouble( aProvider->GetIuScale() );
// Now all widgets have the size fixed, call FinishDialogSettings
finishDialogSettings();
}
m_textName->SetValue( aGrid.name );
bool DIALOG_GRID_SETTINGS::TransferDataToWindow()
{
if( !m_grid.x.IsEmpty() )
{
bool linked = ( m_grid.x == m_grid.y );
VECTOR2D grid = m_grid.ToDouble( m_unitsProvider->GetIuScale() );
m_textName->SetValue( m_grid.name );
m_checkLinked->SetValue( linked );
m_gridSizeX.SetDoubleValue( grid.x );
@ -62,10 +69,10 @@ DIALOG_GRID_SETTINGS::DIALOG_GRID_SETTINGS( wxWindow* aParent, wxWindow* aEventS
m_textY->Enable( !linked );
}
// Now all widgets have the size fixed, call FinishDialogSettings
finishDialogSettings();
return true;
}
bool DIALOG_GRID_SETTINGS::TransferDataFromWindow()
{
double gridX = m_gridSizeX.GetDoubleValue();

View File

@ -47,7 +47,6 @@ PANEL_GRID_SETTINGS::PANEL_GRID_SETTINGS( wxWindow* aParent, UNITS_PROVIDER* aUn
m_eventSource( aEventSource )
{
m_currentGridCtrl->SetMinSize( FromDIP( m_currentGridCtrl->GetMinSize() ) );
RebuildGridSizes();
if( m_frameType == FRAME_PCB_EDITOR || m_frameType == FRAME_FOOTPRINT_EDITOR )
{
@ -102,9 +101,8 @@ PANEL_GRID_SETTINGS::PANEL_GRID_SETTINGS( wxWindow* aParent, UNITS_PROVIDER* aUn
void PANEL_GRID_SETTINGS::ResetPanel()
{
m_cfg->m_Window.grid.grids = m_cfg->DefaultGridSizeList();
m_grids = m_cfg->DefaultGridSizeList();
RebuildGridSizes();
m_cfg->m_Window.grid.last_size_idx = m_currentGridCtrl->GetSelection();
}
@ -129,7 +127,7 @@ void PANEL_GRID_SETTINGS::RebuildGridSizes()
m_unitsProvider->GetUnitPair( primaryUnit, secondaryUnit );
for( const struct GRID& grid : m_cfg->m_Window.grid.grids )
for( const struct GRID& grid : m_grids )
{
wxString name = grid.name;
@ -184,6 +182,8 @@ bool PANEL_GRID_SETTINGS::TransferDataFromWindow()
// Apply the new settings
GRID_SETTINGS& gridCfg = m_cfg->m_Window.grid;
gridCfg.grids = m_grids;
gridCfg.last_size_idx = m_currentGridCtrl->GetSelection();
gridCfg.fast_grid_1 = m_grid1Ctrl->GetSelection();
@ -209,9 +209,9 @@ bool PANEL_GRID_SETTINGS::TransferDataToWindow()
GRID_SETTINGS& gridCfg = m_cfg->m_Window.grid;
// lambda that gives us a safe index into grids regardless of config idx
auto safeGrid = [&gridCfg]( int idx ) -> int
auto safeGrid = [this]( int idx ) -> int
{
if( idx < 0 || idx >= (int) gridCfg.grids.size() )
if( idx < 0 || idx >= (int) m_grids.size() )
return 0;
return idx;
@ -219,6 +219,9 @@ bool PANEL_GRID_SETTINGS::TransferDataToWindow()
Layout();
m_grids = gridCfg.grids;
RebuildGridSizes();
m_currentGridCtrl->SetSelection( safeGrid( gridCfg.last_size_idx ) );
m_grid1Ctrl->SetSelection( safeGrid( gridCfg.fast_grid_1 ) );
@ -230,11 +233,11 @@ bool PANEL_GRID_SETTINGS::TransferDataToWindow()
m_gridOverrideTextChoice->SetSelection( safeGrid( gridCfg.override_text_idx ) );
m_gridOverrideGraphicsChoice->SetSelection( safeGrid( gridCfg.override_graphics_idx ) );
m_checkGridOverrideConnected->SetValue( safeGrid( gridCfg.override_connected ) );
m_checkGridOverrideWires->SetValue( safeGrid( gridCfg.override_wires ) );
m_checkGridOverrideVias->SetValue( safeGrid( gridCfg.override_vias ) );
m_checkGridOverrideText->SetValue( safeGrid( gridCfg.override_text ) );
m_checkGridOverrideGraphics->SetValue( safeGrid( gridCfg.override_graphics ) );
m_checkGridOverrideConnected->SetValue( gridCfg.override_connected );
m_checkGridOverrideWires->SetValue( gridCfg.override_wires );
m_checkGridOverrideVias->SetValue( gridCfg.override_vias );
m_checkGridOverrideText->SetValue( gridCfg.override_text );
m_checkGridOverrideGraphics->SetValue( gridCfg.override_graphics );
return RESETTABLE_PANEL::TransferDataToWindow();
}
@ -249,10 +252,9 @@ void PANEL_GRID_SETTINGS::OnAddGrid( wxCommandEvent& event )
if( dlg.ShowModal() != wxID_OK )
return;
int row = m_currentGridCtrl->GetSelection();
GRID_SETTINGS& gridCfg = m_cfg->m_Window.grid;
int row = m_currentGridCtrl->GetSelection();
for( GRID& g : gridCfg.grids )
for( GRID& g : m_grids )
{
if( newGrid == g )
{
@ -265,7 +267,7 @@ void PANEL_GRID_SETTINGS::OnAddGrid( wxCommandEvent& event )
}
}
gridCfg.grids.insert( gridCfg.grids.begin() + row, newGrid );
m_grids.insert( m_grids.begin() + row, newGrid );
RebuildGridSizes();
m_currentGridCtrl->SetSelection( row );
}
@ -277,12 +279,6 @@ void PANEL_GRID_SETTINGS::OnEditGrid( wxCommandEvent& event )
}
void PANEL_GRID_SETTINGS::OnDoubleClick( wxMouseEvent& event )
{
onEditGrid();
}
void PANEL_GRID_SETTINGS::onEditGrid()
{
int row = m_currentGridCtrl->GetSelection();
@ -290,18 +286,21 @@ void PANEL_GRID_SETTINGS::onEditGrid()
if( row < 0 )
return;
GRID newGrid = m_cfg->m_Window.grid.grids[row];
GRID editGrid = m_grids[row];
DIALOG_GRID_SETTINGS dlg( wxGetTopLevelParent( this ), m_eventSource, m_unitsProvider,
newGrid );
editGrid );
if( dlg.ShowModal() != wxID_OK )
return;
GRID_SETTINGS& gridCfg = m_cfg->m_Window.grid;
// If the user just clicked OK without changing anything,
// then return or we'll trigger the same grid check
if( editGrid == m_grids[row] )
return;
for( GRID& g : gridCfg.grids )
for( GRID& g : m_grids )
{
if( newGrid == g )
if( editGrid == g )
{
wxWindow* topLevelParent = wxGetTopLevelParent( this );
@ -312,7 +311,8 @@ void PANEL_GRID_SETTINGS::onEditGrid()
}
}
gridCfg.grids[row] = newGrid;
m_grids[row] = editGrid;
RebuildGridSizes();
m_currentGridCtrl->SetSelection( row );
}
@ -320,19 +320,12 @@ void PANEL_GRID_SETTINGS::onEditGrid()
void PANEL_GRID_SETTINGS::OnRemoveGrid( wxCommandEvent& event )
{
GRID_SETTINGS& gridCfg = m_cfg->m_Window.grid;
int row = m_currentGridCtrl->GetSelection();
int row = m_currentGridCtrl->GetSelection();
if( gridCfg.grids.size() <= 1 )
{
wxWindow* topLevelParent = wxGetTopLevelParent( this );
DisplayError( topLevelParent,
wxString::Format( _( "At least one grid size is required." ) ) );
if( m_grids.size() <= 1 )
return;
}
gridCfg.grids.erase( gridCfg.grids.begin() + row );
m_grids.erase( m_grids.begin() + row );
RebuildGridSizes();
if( row != 0 )
@ -342,13 +335,12 @@ void PANEL_GRID_SETTINGS::OnRemoveGrid( wxCommandEvent& event )
void PANEL_GRID_SETTINGS::OnMoveGridUp( wxCommandEvent& event )
{
GRID_SETTINGS& gridCfg = m_cfg->m_Window.grid;
int row = m_currentGridCtrl->GetSelection();
int row = m_currentGridCtrl->GetSelection();
if( gridCfg.grids.size() <= 1 || row == 0 )
if( m_grids.size() <= 1 || row == 0 )
return;
std::swap( gridCfg.grids[row], gridCfg.grids[row - 1] );
std::swap( m_grids[row], m_grids[row - 1] );
RebuildGridSizes();
if( row != 0 )
@ -358,15 +350,48 @@ void PANEL_GRID_SETTINGS::OnMoveGridUp( wxCommandEvent& event )
void PANEL_GRID_SETTINGS::OnMoveGridDown( wxCommandEvent& event )
{
GRID_SETTINGS& gridCfg = m_cfg->m_Window.grid;
int row = m_currentGridCtrl->GetSelection();
int row = m_currentGridCtrl->GetSelection();
if( gridCfg.grids.size() <= 1 || row == ( (int) gridCfg.grids.size() - 1 ) )
if( m_grids.size() <= 1 || row == ( (int) m_grids.size() - 1 ) )
return;
std::swap( gridCfg.grids[row], gridCfg.grids[row + 1] );
std::swap( m_grids[row], m_grids[row + 1] );
RebuildGridSizes();
if( row != 0 )
m_currentGridCtrl->SetSelection( row + 1 );
}
void PANEL_GRID_SETTINGS::OnUpdateEditGrid( wxUpdateUIEvent& event )
{
// Enable edit when there is a valid selection
event.Enable( m_currentGridCtrl->GetSelection() >= 0 );
}
void PANEL_GRID_SETTINGS::OnUpdateMoveUp( wxUpdateUIEvent& event )
{
int curRow = m_currentGridCtrl->GetSelection();
int numRows = (int) m_grids.size();
// Enable move up when there are multiple grids and it is not the first row
event.Enable( ( numRows > 1 ) && ( curRow > 0 ) );
}
void PANEL_GRID_SETTINGS::OnUpdateMoveDown( wxUpdateUIEvent& event )
{
int curRow = m_currentGridCtrl->GetSelection();
int numRows = (int) m_grids.size();
// Enable move down when there are multiple grids and it is not the last row
event.Enable( ( numRows > 1 ) && ( curRow < ( numRows - 1 ) ) );
}
void PANEL_GRID_SETTINGS::OnUpdateRemove( wxUpdateUIEvent& event )
{
// Enable remove if there is more than 1 grid
event.Enable( m_grids.size() > 1 );
}

View File

@ -41,7 +41,7 @@ PANEL_GRID_SETTINGS_BASE::PANEL_GRID_SETTINGS_BASE( wxWindow* parent, wxWindowID
bSizerGridButtons->Add( m_editGridButton, 0, wxRIGHT, 5 );
m_moveUpButton = new STD_BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 );
bSizerGridButtons->Add( m_moveUpButton, 0, wxLEFT|wxRIGHT, 5 );
bSizerGridButtons->Add( m_moveUpButton, 0, wxRIGHT, 5 );
m_moveDownButton = new STD_BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 );
bSizerGridButtons->Add( m_moveDownButton, 0, 0, 5 );
@ -114,7 +114,7 @@ PANEL_GRID_SETTINGS_BASE::PANEL_GRID_SETTINGS_BASE( wxWindow* parent, wxWindowID
bSizerRightCol->Add( m_staticline3, 0, wxEXPAND|wxTOP|wxBOTTOM, 2 );
wxFlexGridSizer* fgGridOverrides;
fgGridOverrides = new wxFlexGridSizer( 0, 2, 5, 0 );
fgGridOverrides = new wxFlexGridSizer( 0, 2, 4, 0 );
fgGridOverrides->AddGrowableCol( 1 );
fgGridOverrides->SetFlexibleDirection( wxBOTH );
fgGridOverrides->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
@ -125,7 +125,7 @@ PANEL_GRID_SETTINGS_BASE::PANEL_GRID_SETTINGS_BASE( wxWindow* parent, wxWindowID
wxArrayString m_gridOverrideConnectedChoiceChoices;
m_gridOverrideConnectedChoice = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_gridOverrideConnectedChoiceChoices, 0 );
m_gridOverrideConnectedChoice->SetSelection( 0 );
fgGridOverrides->Add( m_gridOverrideConnectedChoice, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
fgGridOverrides->Add( m_gridOverrideConnectedChoice, 0, wxALL, 5 );
m_checkGridOverrideWires = new wxCheckBox( this, wxID_ANY, _("Wires:"), wxDefaultPosition, wxDefaultSize, 0 );
fgGridOverrides->Add( m_checkGridOverrideWires, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxLEFT, 8 );
@ -133,7 +133,7 @@ PANEL_GRID_SETTINGS_BASE::PANEL_GRID_SETTINGS_BASE( wxWindow* parent, wxWindowID
wxArrayString m_gridOverrideWiresChoiceChoices;
m_gridOverrideWiresChoice = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_gridOverrideWiresChoiceChoices, 0 );
m_gridOverrideWiresChoice->SetSelection( 0 );
fgGridOverrides->Add( m_gridOverrideWiresChoice, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
fgGridOverrides->Add( m_gridOverrideWiresChoice, 0, wxALL, 5 );
m_checkGridOverrideVias = new wxCheckBox( this, wxID_ANY, _("Vias:"), wxDefaultPosition, wxDefaultSize, 0 );
fgGridOverrides->Add( m_checkGridOverrideVias, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxLEFT, 8 );
@ -141,7 +141,7 @@ PANEL_GRID_SETTINGS_BASE::PANEL_GRID_SETTINGS_BASE( wxWindow* parent, wxWindowID
wxArrayString m_gridOverrideViasChoiceChoices;
m_gridOverrideViasChoice = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_gridOverrideViasChoiceChoices, 0 );
m_gridOverrideViasChoice->SetSelection( 0 );
fgGridOverrides->Add( m_gridOverrideViasChoice, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
fgGridOverrides->Add( m_gridOverrideViasChoice, 0, wxALL, 5 );
m_checkGridOverrideText = new wxCheckBox( this, wxID_ANY, _("Text:"), wxDefaultPosition, wxDefaultSize, 0 );
fgGridOverrides->Add( m_checkGridOverrideText, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxLEFT, 8 );
@ -149,7 +149,7 @@ PANEL_GRID_SETTINGS_BASE::PANEL_GRID_SETTINGS_BASE( wxWindow* parent, wxWindowID
wxArrayString m_gridOverrideTextChoiceChoices;
m_gridOverrideTextChoice = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_gridOverrideTextChoiceChoices, 0 );
m_gridOverrideTextChoice->SetSelection( 0 );
fgGridOverrides->Add( m_gridOverrideTextChoice, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
fgGridOverrides->Add( m_gridOverrideTextChoice, 0, wxALL, 5 );
m_checkGridOverrideGraphics = new wxCheckBox( this, wxID_ANY, _("Graphics:"), wxDefaultPosition, wxDefaultSize, 0 );
fgGridOverrides->Add( m_checkGridOverrideGraphics, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxLEFT, 8 );
@ -157,7 +157,7 @@ PANEL_GRID_SETTINGS_BASE::PANEL_GRID_SETTINGS_BASE( wxWindow* parent, wxWindowID
wxArrayString m_gridOverrideGraphicsChoiceChoices;
m_gridOverrideGraphicsChoice = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_gridOverrideGraphicsChoiceChoices, 0 );
m_gridOverrideGraphicsChoice->SetSelection( 0 );
fgGridOverrides->Add( m_gridOverrideGraphicsChoice, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
fgGridOverrides->Add( m_gridOverrideGraphicsChoice, 0, wxALL, 5 );
bSizerRightCol->Add( fgGridOverrides, 0, wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT, 10 );
@ -174,22 +174,30 @@ PANEL_GRID_SETTINGS_BASE::PANEL_GRID_SETTINGS_BASE( wxWindow* parent, wxWindowID
bSizerMain->Fit( this );
// Connect Events
m_currentGridCtrl->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( PANEL_GRID_SETTINGS_BASE::OnDoubleClick ), NULL, this );
m_currentGridCtrl->Connect( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCommandEventHandler( PANEL_GRID_SETTINGS_BASE::OnEditGrid ), NULL, this );
m_addGridButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_GRID_SETTINGS_BASE::OnAddGrid ), NULL, this );
m_editGridButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_GRID_SETTINGS_BASE::OnEditGrid ), NULL, this );
m_editGridButton->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( PANEL_GRID_SETTINGS_BASE::OnUpdateEditGrid ), NULL, this );
m_moveUpButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_GRID_SETTINGS_BASE::OnMoveGridUp ), NULL, this );
m_moveUpButton->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( PANEL_GRID_SETTINGS_BASE::OnUpdateMoveUp ), NULL, this );
m_moveDownButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_GRID_SETTINGS_BASE::OnMoveGridDown ), NULL, this );
m_moveDownButton->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( PANEL_GRID_SETTINGS_BASE::OnUpdateMoveDown ), NULL, this );
m_removeGridButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_GRID_SETTINGS_BASE::OnRemoveGrid ), NULL, this );
m_removeGridButton->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( PANEL_GRID_SETTINGS_BASE::OnUpdateRemove ), NULL, this );
}
PANEL_GRID_SETTINGS_BASE::~PANEL_GRID_SETTINGS_BASE()
{
// Disconnect Events
m_currentGridCtrl->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( PANEL_GRID_SETTINGS_BASE::OnDoubleClick ), NULL, this );
m_currentGridCtrl->Disconnect( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCommandEventHandler( PANEL_GRID_SETTINGS_BASE::OnEditGrid ), NULL, this );
m_addGridButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_GRID_SETTINGS_BASE::OnAddGrid ), NULL, this );
m_editGridButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_GRID_SETTINGS_BASE::OnEditGrid ), NULL, this );
m_editGridButton->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( PANEL_GRID_SETTINGS_BASE::OnUpdateEditGrid ), NULL, this );
m_moveUpButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_GRID_SETTINGS_BASE::OnMoveGridUp ), NULL, this );
m_moveUpButton->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( PANEL_GRID_SETTINGS_BASE::OnUpdateMoveUp ), NULL, this );
m_moveDownButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_GRID_SETTINGS_BASE::OnMoveGridDown ), NULL, this );
m_moveDownButton->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( PANEL_GRID_SETTINGS_BASE::OnUpdateMoveDown ), NULL, this );
m_removeGridButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_GRID_SETTINGS_BASE::OnRemoveGrid ), NULL, this );
m_removeGridButton->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( PANEL_GRID_SETTINGS_BASE::OnUpdateRemove ), NULL, this );
}

View File

@ -200,7 +200,7 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnLeftDClick">OnDoubleClick</event>
<event name="OnListBoxDClick">OnEditGrid</event>
</object>
</object>
<object class="sizeritem" expanded="true">
@ -360,11 +360,12 @@
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">OnEditGrid</event>
<event name="OnUpdateUI">OnUpdateEditGrid</event>
</object>
</object>
<object class="sizeritem" expanded="true">
<property name="border">5</property>
<property name="flag">wxLEFT|wxRIGHT</property>
<property name="flag">wxRIGHT</property>
<property name="proportion">0</property>
<object class="wxBitmapButton" expanded="true">
<property name="BottomDockable">1</property>
@ -435,6 +436,7 @@
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">OnMoveGridUp</event>
<event name="OnUpdateUI">OnUpdateMoveUp</event>
</object>
</object>
<object class="sizeritem" expanded="true">
@ -510,6 +512,7 @@
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">OnMoveGridDown</event>
<event name="OnUpdateUI">OnUpdateMoveDown</event>
</object>
</object>
<object class="sizeritem" expanded="false">
@ -595,6 +598,7 @@
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">OnRemoveGrid</event>
<event name="OnUpdateUI">OnUpdateRemove</event>
</object>
</object>
</object>
@ -1273,7 +1277,7 @@
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property>
<property name="permission">none</property>
<property name="rows">0</property>
<property name="vgap">5</property>
<property name="vgap">4</property>
<object class="sizeritem" expanded="false">
<property name="border">8</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxLEFT</property>
@ -1341,7 +1345,7 @@
</object>
<object class="sizeritem" expanded="true">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxChoice" expanded="true">
<property name="BottomDockable">1</property>
@ -1471,7 +1475,7 @@
</object>
<object class="sizeritem" expanded="true">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxChoice" expanded="true">
<property name="BottomDockable">1</property>
@ -1601,7 +1605,7 @@
</object>
<object class="sizeritem" expanded="true">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxChoice" expanded="true">
<property name="BottomDockable">1</property>
@ -1731,7 +1735,7 @@
</object>
<object class="sizeritem" expanded="true">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxChoice" expanded="true">
<property name="BottomDockable">1</property>
@ -1861,7 +1865,7 @@
</object>
<object class="sizeritem" expanded="true">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxChoice" expanded="true">
<property name="BottomDockable">1</property>

View File

@ -71,12 +71,15 @@ class PANEL_GRID_SETTINGS_BASE : public RESETTABLE_PANEL
wxChoice* m_gridOverrideGraphicsChoice;
// Virtual event handlers, override them in your derived class
virtual void OnDoubleClick( wxMouseEvent& event ) { event.Skip(); }
virtual void OnAddGrid( wxCommandEvent& event ) { event.Skip(); }
virtual void OnEditGrid( wxCommandEvent& event ) { event.Skip(); }
virtual void OnAddGrid( wxCommandEvent& event ) { event.Skip(); }
virtual void OnUpdateEditGrid( wxUpdateUIEvent& event ) { event.Skip(); }
virtual void OnMoveGridUp( wxCommandEvent& event ) { event.Skip(); }
virtual void OnUpdateMoveUp( wxUpdateUIEvent& event ) { event.Skip(); }
virtual void OnMoveGridDown( wxCommandEvent& event ) { event.Skip(); }
virtual void OnUpdateMoveDown( wxUpdateUIEvent& event ) { event.Skip(); }
virtual void OnRemoveGrid( wxCommandEvent& event ) { event.Skip(); }
virtual void OnUpdateRemove( wxUpdateUIEvent& event ) { event.Skip(); }
public:

View File

@ -61,7 +61,7 @@ VECTOR2D GRID::ToDouble( EDA_IU_SCALE aScale ) const
bool GRID::operator==( const GRID& aOther ) const
{
return x == aOther.x && y == aOther.y;
return x == aOther.x && y == aOther.y && name == aOther.name;
}

View File

@ -37,6 +37,7 @@ public:
GRID& aGrid );
~DIALOG_GRID_SETTINGS() override = default;
bool TransferDataToWindow() override;
bool TransferDataFromWindow() override;
protected:

View File

@ -29,6 +29,7 @@
#include <frame_type.h>
class APP_SETTINGS_BASE;
struct GRID;
class PANEL_GRID_SETTINGS : public PANEL_GRID_SETTINGS_BASE
@ -49,7 +50,11 @@ private:
void OnRemoveGrid( wxCommandEvent& event ) override;
void OnMoveGridUp( wxCommandEvent& event ) override;
void OnMoveGridDown( wxCommandEvent& event ) override;
void OnDoubleClick( wxMouseEvent& event ) override;
void OnUpdateEditGrid( wxUpdateUIEvent& event ) override;
void OnUpdateMoveUp( wxUpdateUIEvent& event ) override;
void OnUpdateMoveDown( wxUpdateUIEvent& event ) override;
void OnUpdateRemove( wxUpdateUIEvent& event ) override;
void RebuildGridSizes();
@ -60,6 +65,8 @@ private:
APP_SETTINGS_BASE* m_cfg;
FRAME_T m_frameType;
wxWindow* m_eventSource;
std::vector<GRID> m_grids;
};
#endif // PANEL_GRID_SETTINGS_H