Bring various appearance managers into line over preset editing.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/15726
This commit is contained in:
parent
938001250d
commit
7835b8ddc7
|
@ -21,6 +21,7 @@
|
||||||
#include <dialogs/appearance_controls_3D.h>
|
#include <dialogs/appearance_controls_3D.h>
|
||||||
|
|
||||||
#include <bitmaps.h>
|
#include <bitmaps.h>
|
||||||
|
#include <confirm.h>
|
||||||
#include <pgm_base.h>
|
#include <pgm_base.h>
|
||||||
#include <dpi_scaling_common.h>
|
#include <dpi_scaling_common.h>
|
||||||
#include <eda_list_dialog.h>
|
#include <eda_list_dialog.h>
|
||||||
|
@ -616,6 +617,12 @@ void APPEARANCE_CONTROLS_3D::onLayerPresetChanged( wxCommandEvent& aEvent )
|
||||||
int index = m_cbLayerPresets->GetSelection();
|
int index = m_cbLayerPresets->GetSelection();
|
||||||
wxString name;
|
wxString name;
|
||||||
|
|
||||||
|
auto resetSelection =
|
||||||
|
[&]()
|
||||||
|
{
|
||||||
|
updateLayerPresetWidget( cfg->m_CurrentPreset );
|
||||||
|
};
|
||||||
|
|
||||||
if( index == 0 )
|
if( index == 0 )
|
||||||
{
|
{
|
||||||
name = FOLLOW_PCB;
|
name = FOLLOW_PCB;
|
||||||
|
@ -633,7 +640,7 @@ void APPEARANCE_CONTROLS_3D::onLayerPresetChanged( wxCommandEvent& aEvent )
|
||||||
else if( index == count - 3 )
|
else if( index == count - 3 )
|
||||||
{
|
{
|
||||||
// Separator: reject the selection
|
// Separator: reject the selection
|
||||||
updateLayerPresetWidget( cfg->m_CurrentPreset );
|
resetSelection();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if( index == count - 2 )
|
else if( index == count - 2 )
|
||||||
|
@ -642,30 +649,37 @@ void APPEARANCE_CONTROLS_3D::onLayerPresetChanged( wxCommandEvent& aEvent )
|
||||||
|
|
||||||
if( dlg.ShowModal() != wxID_OK )
|
if( dlg.ShowModal() != wxID_OK )
|
||||||
{
|
{
|
||||||
updateLayerPresetWidget( cfg->m_CurrentPreset );
|
resetSelection();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::bitset<LAYER_3D_END> visibleLayers = m_frame->GetAdapter().GetVisibleLayers();
|
||||||
|
std::map<int, COLOR4D> colors = m_frame->GetAdapter().GetLayerColors();
|
||||||
|
|
||||||
|
name = dlg.GetValue();
|
||||||
|
|
||||||
|
if( LAYER_PRESET_3D* preset = cfg->FindPreset( name ) )
|
||||||
|
{
|
||||||
|
if( !IsOK( this, _( "Overwrite existing preset?" ) ) )
|
||||||
|
{
|
||||||
|
resetSelection();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
preset->layers = visibleLayers;
|
||||||
|
preset->colors = colors;
|
||||||
|
m_cbLayerPresets->SetSelection( m_cbLayerPresets->FindString( name ) );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::bitset<LAYER_3D_END> visibleLayers = m_frame->GetAdapter().GetVisibleLayers();
|
cfg->m_LayerPresets.emplace_back( name, visibleLayers, colors );
|
||||||
std::map<int, COLOR4D> colors = m_frame->GetAdapter().GetLayerColors();
|
m_cbLayerPresets->SetSelection( m_cbLayerPresets->Insert( name, index - 1 ) );
|
||||||
|
|
||||||
name = dlg.GetValue();
|
|
||||||
|
|
||||||
if( LAYER_PRESET_3D* preset = cfg->FindPreset( name ) )
|
|
||||||
{
|
|
||||||
preset->layers = visibleLayers;
|
|
||||||
preset->colors = colors;
|
|
||||||
m_cbLayerPresets->SetSelection( m_cbLayerPresets->FindString( name ) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cfg->m_LayerPresets.emplace_back( name, visibleLayers, colors );
|
|
||||||
m_cbLayerPresets->SetSelection( m_cbLayerPresets->Insert( name, index - 1 ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
cfg->m_CurrentPreset = name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cfg->m_CurrentPreset = name;
|
||||||
|
m_presetMRU.Insert( name, 0 );
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else if( index == count - 1 )
|
else if( index == count - 1 )
|
||||||
{
|
{
|
||||||
|
@ -703,7 +717,7 @@ void APPEARANCE_CONTROLS_3D::onLayerPresetChanged( wxCommandEvent& aEvent )
|
||||||
m_presetMRU.Remove( name );
|
m_presetMRU.Remove( name );
|
||||||
}
|
}
|
||||||
|
|
||||||
updateLayerPresetWidget( cfg->m_CurrentPreset );
|
resetSelection();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if( LAYER_PRESET_3D* preset = cfg->FindPreset( m_cbLayerPresets->GetStringSelection() ) )
|
else if( LAYER_PRESET_3D* preset = cfg->FindPreset( m_cbLayerPresets->GetStringSelection() ) )
|
||||||
|
|
|
@ -1573,16 +1573,15 @@ void DIALOG_SYMBOL_FIELDS_TABLE::onBomPresetChanged( wxCommandEvent& aEvent )
|
||||||
}
|
}
|
||||||
else if( preset->readOnly )
|
else if( preset->readOnly )
|
||||||
{
|
{
|
||||||
wxMessageBox( _( "Cannot modify default presets." ), _( "Error" ), wxOK | wxICON_ERROR,
|
wxMessageBox( _( "Default presets cannot be modified.\nPlease use a different name." ),
|
||||||
this );
|
_( "Error" ), wxOK | wxICON_ERROR, this );
|
||||||
|
resetSelection();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Ask the user if they want to overwrite the existing preset
|
// Ask the user if they want to overwrite the existing preset
|
||||||
if( wxMessageBox( _( "Overwrite existing preset?" ), _( "Save BOM Preset" ),
|
if( !IsOK( this, _( "Overwrite existing preset?" ) ) )
|
||||||
wxYES_NO | wxICON_QUESTION, this )
|
|
||||||
!= wxYES )
|
|
||||||
{
|
{
|
||||||
resetSelection();
|
resetSelection();
|
||||||
return;
|
return;
|
||||||
|
@ -1975,16 +1974,15 @@ void DIALOG_SYMBOL_FIELDS_TABLE::onBomFmtPresetChanged( wxCommandEvent& aEvent )
|
||||||
}
|
}
|
||||||
else if( preset->readOnly )
|
else if( preset->readOnly )
|
||||||
{
|
{
|
||||||
wxMessageBox( _( "Cannot modify default presets." ), _( "Error" ), wxOK | wxICON_ERROR,
|
wxMessageBox( _( "Default presets cannot be modified.\nPlease use a different name." ),
|
||||||
this );
|
_( "Error" ), wxOK | wxICON_ERROR, this );
|
||||||
|
resetSelection();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Ask the user if they want to overwrite the existing preset
|
// Ask the user if they want to overwrite the existing preset
|
||||||
if( wxMessageBox( _( "Overwrite existing preset?" ), _( "Save BOM Preset" ),
|
if( !IsOK( this, _( "Overwrite existing preset?" ) ) )
|
||||||
wxYES_NO | wxICON_QUESTION, this )
|
|
||||||
!= wxYES )
|
|
||||||
{
|
{
|
||||||
resetSelection();
|
resetSelection();
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -25,11 +25,11 @@
|
||||||
#include <board_design_settings.h>
|
#include <board_design_settings.h>
|
||||||
#include <pad.h>
|
#include <pad.h>
|
||||||
#include <pcb_track.h>
|
#include <pcb_track.h>
|
||||||
#include <dpi_scaling_common.h>
|
|
||||||
#include <eda_list_dialog.h>
|
#include <eda_list_dialog.h>
|
||||||
#include <string_utils.h>
|
#include <string_utils.h>
|
||||||
#include <footprint_edit_frame.h>
|
#include <footprint_edit_frame.h>
|
||||||
#include <menus_helpers.h>
|
#include <menus_helpers.h>
|
||||||
|
#include <confirm.h>
|
||||||
#include <pcb_display_options.h>
|
#include <pcb_display_options.h>
|
||||||
#include <pcb_edit_frame.h>
|
#include <pcb_edit_frame.h>
|
||||||
#include <pcb_painter.h>
|
#include <pcb_painter.h>
|
||||||
|
@ -51,7 +51,6 @@
|
||||||
#include <widgets/wx_infobar.h>
|
#include <widgets/wx_infobar.h>
|
||||||
#include <widgets/wx_grid.h>
|
#include <widgets/wx_grid.h>
|
||||||
#include <dialogs/eda_view_switcher.h>
|
#include <dialogs/eda_view_switcher.h>
|
||||||
#include <wx/bmpbuttn.h>
|
|
||||||
#include <wx/checkbox.h>
|
#include <wx/checkbox.h>
|
||||||
#include <wx/hyperlink.h>
|
#include <wx/hyperlink.h>
|
||||||
#include <wx/radiobut.h>
|
#include <wx/radiobut.h>
|
||||||
|
@ -2639,20 +2638,33 @@ void APPEARANCE_CONTROLS::onLayerPresetChanged( wxCommandEvent& aEvent )
|
||||||
|
|
||||||
if( !exists )
|
if( !exists )
|
||||||
{
|
{
|
||||||
m_layerPresets[name] = LAYER_PRESET( name, getVisibleLayers(),
|
m_layerPresets[name] = LAYER_PRESET( name, getVisibleLayers(), getVisibleObjects(),
|
||||||
getVisibleObjects(), UNSELECTED_LAYER );
|
UNSELECTED_LAYER );
|
||||||
}
|
}
|
||||||
|
|
||||||
LAYER_PRESET* preset = &m_layerPresets[name];
|
LAYER_PRESET* preset = &m_layerPresets[name];
|
||||||
m_currentPreset = preset;
|
|
||||||
|
|
||||||
if( !exists )
|
if( !exists )
|
||||||
{
|
{
|
||||||
index = m_cbLayerPresets->Insert( name, index - 1, static_cast<void*>( preset ) );
|
index = m_cbLayerPresets->Insert( name, index - 1, static_cast<void*>( preset ) );
|
||||||
preset->flipBoard = m_cbFlipBoard->GetValue();
|
preset->flipBoard = m_cbFlipBoard->GetValue();
|
||||||
}
|
}
|
||||||
|
else if( preset->readOnly )
|
||||||
|
{
|
||||||
|
wxMessageBox( _( "Default presets cannot be modified.\nPlease use a different name." ),
|
||||||
|
_( "Error" ), wxOK | wxICON_ERROR, this );
|
||||||
|
resetSelection();
|
||||||
|
return;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// Ask the user if they want to overwrite the existing preset
|
||||||
|
if( !IsOK( this, _( "Overwrite existing preset?" ) ) )
|
||||||
|
{
|
||||||
|
resetSelection();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
preset->layers = getVisibleLayers();
|
preset->layers = getVisibleLayers();
|
||||||
preset->renderLayers = getVisibleObjects();
|
preset->renderLayers = getVisibleObjects();
|
||||||
preset->flipBoard = m_cbFlipBoard->GetValue();
|
preset->flipBoard = m_cbFlipBoard->GetValue();
|
||||||
|
@ -2661,6 +2673,7 @@ void APPEARANCE_CONTROLS::onLayerPresetChanged( wxCommandEvent& aEvent )
|
||||||
m_presetMRU.Remove( name );
|
m_presetMRU.Remove( name );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_currentPreset = preset;
|
||||||
m_cbLayerPresets->SetSelection( index );
|
m_cbLayerPresets->SetSelection( index );
|
||||||
m_presetMRU.Insert( name, 0 );
|
m_presetMRU.Insert( name, 0 );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue