Add shortcuts to setting dialogs for track widths, via sizes and grid sizes.

Fixes: lp:1803671
* https://bugs.launchpad.net/kicad/+bug/1803671
This commit is contained in:
Jeff Young 2018-11-17 00:33:20 +00:00
parent 3c6adbdf03
commit 0de9cb345c
21 changed files with 177 additions and 87 deletions

View File

@ -194,7 +194,12 @@ int BASE_SCREEN::BuildGridsChoiceList( wxArrayString& aGridsList, bool aMmFirst)
if( grid.m_CmdId == ID_POPUP_GRID_USER )
{
msg = _( "Custom User Grid" );
if( aMmFirst )
msg.Printf( _( "User grid: %.4f mm (%.2f mils)" ),
gridValue_mm, gridValueMils );
else
msg.Printf( _( "User grid: %.2f mils (%.4f mm)" ),
gridValueMils, gridValue_mm );
idx_usergrid = i;
}
else

View File

@ -444,6 +444,29 @@ void EDA_DRAW_FRAME::OnUpdateGrid( wxUpdateUIEvent& aEvent )
}
void EDA_DRAW_FRAME::OnUpdateSelectGrid( wxUpdateUIEvent& aEvent )
{
// No need to update the grid select box if it doesn't exist or the grid setting change
// was made using the select box.
if( m_gridSelectBox == NULL || m_auxiliaryToolBar == NULL )
return;
int select = wxNOT_FOUND;
for( size_t i = 0; i < GetScreen()->GetGridCount(); i++ )
{
if( GetScreen()->GetGridCmdId() == GetScreen()->GetGrid( i ).m_CmdId )
{
select = (int) i;
break;
}
}
if( select != m_gridSelectBox->GetSelection() )
m_gridSelectBox->SetSelection( select );
}
void EDA_DRAW_FRAME::OnUpdateCrossHairStyle( wxUpdateUIEvent& aEvent )
{
aEvent.Check( GetGalDisplayOptions().m_fullscreenCursor );
@ -506,6 +529,23 @@ void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event )
*/
int index = m_gridSelectBox->GetSelection();
wxASSERT( index != wxNOT_FOUND );
if( index == m_gridSelectBox->GetCount() - 2 )
{
// this is the separator
wxUpdateUIEvent dummy;
OnUpdateSelectGrid( dummy );
return;
}
else if( index == m_gridSelectBox->GetCount() - 1 )
{
wxUpdateUIEvent dummy;
OnUpdateSelectGrid( dummy );
wxCommandEvent dummy2;
OnGridSettings( dummy2 );
return;
}
clientData = (int*) m_gridSelectBox->wxItemContainer::GetClientData( index );
if( clientData != NULL )

View File

@ -447,6 +447,29 @@ void EDA_DRAW_FRAME::OnUpdateGrid( wxUpdateUIEvent& aEvent )
}
void EDA_DRAW_FRAME::OnUpdateSelectGrid( wxUpdateUIEvent& aEvent )
{
// No need to update the grid select box if it doesn't exist or the grid setting change
// was made using the select box.
if( m_gridSelectBox == NULL || m_auxiliaryToolBar == NULL )
return;
int select = wxNOT_FOUND;
for( size_t i = 0; i < GetScreen()->GetGridCount(); i++ )
{
if( GetScreen()->GetGridCmdId() == GetScreen()->GetGrid( i ).m_CmdId )
{
select = (int) i;
break;
}
}
if( select != m_gridSelectBox->GetSelection() )
m_gridSelectBox->SetSelection( select );
}
void EDA_DRAW_FRAME::OnUpdateCrossHairStyle( wxUpdateUIEvent& aEvent )
{
aEvent.Check( GetGalDisplayOptions().m_fullscreenCursor );
@ -507,6 +530,23 @@ void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event )
*/
int index = m_gridSelectBox->GetSelection();
wxASSERT( index != wxNOT_FOUND );
if( index == m_gridSelectBox->GetCount() - 2 )
{
// this is the separator
wxUpdateUIEvent dummy;
OnUpdateSelectGrid( dummy );
return;
}
else if( index == m_gridSelectBox->GetCount() - 1 )
{
wxUpdateUIEvent dummy;
OnUpdateSelectGrid( dummy );
wxCommandEvent dummy2;
OnGridSettings( dummy2 );
return;
}
clientData = (int*) m_gridSelectBox->wxItemContainer::GetClientData( index );
if( clientData != NULL )
@ -519,15 +559,7 @@ void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event )
int idx = eventId - ID_POPUP_GRID_LEVEL_1000;
// Notify GAL
TOOL_MANAGER* mgr = GetToolManager();
if( mgr && IsGalCanvasActive() )
{
mgr->RunAction( "common.Control.gridPreset", true, idx );
}
else
SetPresetGrid( idx );
SetPresetGrid( idx );
m_canvas->Refresh();
}

View File

@ -102,6 +102,13 @@ void PAGED_DIALOG::finishInitialization()
}
void PAGED_DIALOG::SetInitialPage( const wxString& aPage, const wxString& aParentPage )
{
g_lastPage[ m_title ] = aPage;
g_lastParentPage[ m_title ] = aParentPage;
}
PAGED_DIALOG::~PAGED_DIALOG()
{
// Store the current parentPageTitle/pageTitle hierarchy so we can re-select it
@ -154,17 +161,17 @@ bool PAGED_DIALOG::TransferDataToWindow()
{
if( m_treebook->GetPageText( i ) == lastPage )
{
int parent = m_treebook->GetPageParent( i );
if( parent == wxNOT_FOUND )
if( lastParentPage.IsEmpty() )
{
if( lastParentPage.IsEmpty() )
lastPageIndex = i;
lastPageIndex = i;
break;
}
else
if( m_treebook->GetPageParent( i ) >= 0
&& m_treebook->GetPageText( (unsigned) m_treebook->GetPageParent( i ) ) == lastParentPage )
{
if( lastParentPage == m_treebook->GetPageText( (unsigned) parent ) )
lastPageIndex = i;
lastPageIndex = i;
break;
}
}
}

View File

@ -168,7 +168,7 @@ public:
}
void SetGridOrigin( const wxPoint& aPoint ) override {}
void OnGridSettings( wxCommandEvent& aEvent );
void OnGridSettings( wxCommandEvent& aEvent ) override;
const TITLE_BLOCK& GetTitleBlock() const override;
void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) override;

View File

@ -1285,29 +1285,6 @@ void GERBVIEW_FRAME::updateZoomSelectBox()
}
void GERBVIEW_FRAME::OnUpdateSelectGrid( wxUpdateUIEvent& aEvent )
{
// No need to update the grid select box if it doesn't exist or the grid setting change
// was made using the select box.
if( m_gridSelectBox == NULL || m_auxiliaryToolBar == NULL )
return;
int select = wxNOT_FOUND;
for( size_t i = 0; i < GetScreen()->GetGridCount(); i++ )
{
if( GetScreen()->GetGridCmdId() == GetScreen()->GetGrid( i ).m_CmdId )
{
select = (int) i;
break;
}
}
if( select != m_gridSelectBox->GetSelection() )
m_gridSelectBox->SetSelection( select );
}
void GERBVIEW_FRAME::OnUpdateSelectZoom( wxUpdateUIEvent& aEvent )
{
if( m_zoomSelectBox == NULL || m_auxiliaryToolBar == NULL )

View File

@ -250,7 +250,6 @@ public:
void OnLeftDClick( wxDC* aDC, const wxPoint& aMousePos ) override;
bool OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) override;
void OnUpdateSelectTool( wxUpdateUIEvent& aEvent );
void OnUpdateSelectGrid( wxUpdateUIEvent& aEvent );
void OnUpdateSelectZoom( wxUpdateUIEvent& aEvent );
double BestZoom() override;
void UpdateStatusBar() override;

View File

@ -594,6 +594,8 @@ public:
*/
virtual void OnSelectGrid( wxCommandEvent& event );
virtual void OnGridSettings( wxCommandEvent& event ) { };
/**
* Set the zoom factor when selected by the zoom list box in the main tool bar.
*
@ -613,6 +615,7 @@ public:
void OnUpdateUndo( wxUpdateUIEvent& aEvent );
void OnUpdateRedo( wxUpdateUIEvent& aEvent );
void OnUpdateGrid( wxUpdateUIEvent& aEvent );
void OnUpdateSelectGrid( wxUpdateUIEvent& aEvent );
void OnUpdateUnits( wxUpdateUIEvent& aEvent );
void OnUpdateCrossHairStyle( wxUpdateUIEvent& aEvent );

View File

@ -563,8 +563,6 @@ public:
void CommonSettingsChanged() override;
bool InvokeDialogGrid();
void OnTogglePolarCoords( wxCommandEvent& aEvent );
void OnTogglePadDrawMode( wxCommandEvent& aEvent );
void OnToggleGraphicDrawMode( wxCommandEvent& aEvent );
@ -579,7 +577,6 @@ public:
void OnUpdateGraphicDrawMode( wxUpdateUIEvent& aEvent );
void OnUpdateEdgeDrawMode( wxUpdateUIEvent& aEvent );
void OnUpdateTextDrawMode( wxUpdateUIEvent& aEvent );
void OnUpdateSelectGrid( wxUpdateUIEvent& aEvent );
void OnUpdateSelectZoom( wxUpdateUIEvent& aEvent );
virtual void OnUpdateLayerAlpha( wxUpdateUIEvent& aEvent ) {}

View File

@ -42,6 +42,8 @@ public:
wxTreebook* GetTreebook() { return m_treebook; }
void SetInitialPage( const wxString& aPage, const wxString& aParentPage = wxEmptyString );
void SetError( const wxString& aMessage, wxWindow* aPage, wxObject* aCtrl,
int aRow = -1, int aCol = -1 );

View File

@ -39,6 +39,11 @@ DIALOG_BOARD_SETUP::DIALOG_BOARD_SETUP( PCB_EDIT_FRAME* aFrame ) :
m_tracksAndVias = new PANEL_SETUP_TRACKS_AND_VIAS( this, aFrame, m_constraints );
m_maskAndPaste = new PANEL_SETUP_MASK_AND_PASTE( this, aFrame );
/*
* WARNING: If you change page names you MUST update callers which specifiy a
* particular page to be in sync.
*/
m_treebook->AddPage( m_layers, _( "Layers" ) );
m_treebook->AddSubPage( m_textAndGraphics, _( "Text & Graphics" ) );

View File

@ -32,7 +32,7 @@
#include <common.h>
#include <widgets/unit_binder.h>
#include <hotkeys.h>
#include <pcb_base_frame.h>
#include <pcb_base_edit_frame.h>
#include <class_drawpanel.h>
#include <class_draw_panel_gal.h>
@ -168,8 +168,14 @@ void DIALOG_SET_GRID::OnResetGridOrgClick( wxCommandEvent& event )
}
bool PCB_BASE_FRAME::InvokeDialogGrid()
bool PCB_BASE_EDIT_FRAME::InvokeDialogGrid()
{
DIALOG_SET_GRID dlg( this, m_gridSelectBox->GetStrings() );
return dlg.ShowModal();
}
void PCB_BASE_EDIT_FRAME::OnGridSettings( wxCommandEvent& event )
{
InvokeDialogGrid();
}

View File

@ -77,7 +77,6 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
{
case wxID_CUT:
case wxID_COPY:
case ID_PCB_USER_GRID_SETUP:
case ID_TOOLBARH_PCB_SELECT_LAYER:
case ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR:
case ID_POPUP_PCB_ROTATE_TEXTEPCB:
@ -1227,10 +1226,6 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
Swap_Layers( event );
break;
case ID_PCB_USER_GRID_SETUP:
InvokeDialogGrid();
break;
case ID_POPUP_PCB_DISPLAY_FOOTPRINT_DOC:
{
wxConfigBase* cfg = Pgm().CommonSettings();

View File

@ -117,13 +117,39 @@ void PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event( wxCommandEvent& event )
break;
case ID_AUX_TOOLBAR_PCB_TRACK_WIDTH:
ii = m_SelTrackWidthBox->GetCurrentSelection();
GetDesignSettings().SetTrackWidthIndex( ii );
ii = m_SelTrackWidthBox->GetSelection();
if( ii == m_SelViaSizeBox->GetCount() - 2 )
{
// this is the separator
m_SelTrackWidthBox->SetSelection( GetDesignSettings().GetTrackWidthIndex() );
}
else if( ii == m_SelTrackWidthBox->GetCount() - 1 )
{
m_SelTrackWidthBox->SetSelection( GetDesignSettings().GetTrackWidthIndex() );
DoShowBoardSetupDialog( _( "Tracks & Vias" ) );
}
else
GetDesignSettings().SetTrackWidthIndex( ii );
break;
case ID_AUX_TOOLBAR_PCB_VIA_SIZE:
ii = m_SelViaSizeBox->GetCurrentSelection();
GetDesignSettings().SetViaSizeIndex( ii );
ii = m_SelViaSizeBox->GetSelection();
if( ii == m_SelViaSizeBox->GetCount() - 2 )
{
// this is the separator
m_SelViaSizeBox->SetSelection( GetDesignSettings().GetViaSizeIndex() );
}
else if( ii == m_SelViaSizeBox->GetCount() - 1 )
{
m_SelViaSizeBox->SetSelection( GetDesignSettings().GetViaSizeIndex() );
DoShowBoardSetupDialog( _( "Tracks & Vias" ) );
}
else
GetDesignSettings().SetViaSizeIndex( ii );
break;
default:

View File

@ -164,7 +164,7 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME )
EVT_MENU( ID_MODEDIT_MODULE_MIRROR, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_MENU( ID_MODEDIT_MODULE_MOVE_EXACT, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_MENU( ID_PCB_USER_GRID_SETUP, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_MENU( ID_PCB_USER_GRID_SETUP, FOOTPRINT_EDIT_FRAME::OnGridSettings )
// Menu Help
EVT_MENU( wxID_HELP, EDA_DRAW_FRAME::GetKicadHelp )

View File

@ -249,7 +249,6 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case wxID_COPY:
case ID_TOOLBARH_PCB_SELECT_LAYER:
case ID_MODEDIT_PAD_SETTINGS:
case ID_PCB_USER_GRID_SETUP:
case ID_POPUP_PCB_ROTATE_TEXTEPCB:
case ID_POPUP_PCB_EDIT_TEXTEPCB:
case ID_POPUP_PCB_ROTATE_TEXTMODULE:
@ -745,10 +744,6 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
m_canvas->Refresh();
break;
case ID_PCB_USER_GRID_SETUP:
InvokeDialogGrid();
break;
case ID_POPUP_PLACE_BLOCK:
GetScreen()->m_BlockLocate.SetCommand( BLOCK_MOVE );
m_canvas->SetAutoPanRequest( false );

View File

@ -172,6 +172,9 @@ public:
///> @copydoc PCB_BASE_FRAME::SetBoard()
virtual void SetBoard( BOARD* aBoard ) override;
void OnGridSettings( wxCommandEvent& aEvent ) override;
bool InvokeDialogGrid();
protected:
/// User defined rotation angle (in tenths of a degree).
int m_rotationAngle;

View File

@ -677,29 +677,6 @@ void PCB_BASE_FRAME::OnUpdateTextDrawMode( wxUpdateUIEvent& aEvent )
}
void PCB_BASE_FRAME::OnUpdateSelectGrid( wxUpdateUIEvent& aEvent )
{
// No need to update the grid select box if it doesn't exist or the grid setting change
// was made using the select box.
if( m_gridSelectBox == NULL || m_auxiliaryToolBar == NULL )
return;
int select = wxNOT_FOUND;
for( size_t i = 0; i < GetScreen()->GetGridCount(); i++ )
{
if( GetScreen()->GetGridCmdId() == GetScreen()->GetGrid( i ).m_CmdId )
{
select = (int) i;
break;
}
}
if( select != m_gridSelectBox->GetSelection() )
m_gridSelectBox->SetSelection( select );
}
void PCB_BASE_FRAME::OnUpdateSelectZoom( wxUpdateUIEvent& aEvent )
{
if( m_zoomSelectBox == NULL || m_zoomSelectBox->GetParent() == NULL )
@ -1053,6 +1030,9 @@ void PCB_BASE_FRAME::updateGridSelectBox()
m_gridSelectBox->Append( gridsList[i], (void*) &grid.m_CmdId );
}
m_gridSelectBox->Append( wxT( "---" ) );
m_gridSelectBox->Append( _( "Edit user grid..." ) );
m_gridSelectBox->SetSelection( icurr );
}

View File

@ -144,7 +144,7 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
EVT_MENU( ID_PREFERENCES_CONFIGURE_PATHS, PCB_EDIT_FRAME::OnConfigurePaths )
EVT_MENU( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, PCB_EDIT_FRAME::Process_Config )
EVT_MENU( wxID_PREFERENCES, PCB_EDIT_FRAME::Process_Config )
EVT_MENU( ID_PCB_USER_GRID_SETUP, PCB_EDIT_FRAME::Process_Special_Functions )
EVT_MENU( ID_PCB_USER_GRID_SETUP, PCB_EDIT_FRAME::OnGridSettings )
// menu Postprocess
EVT_MENU( ID_PCB_GEN_POS_MODULES_FILE, PCB_EDIT_FRAME::GenFootprintsPositionFile )
@ -719,9 +719,19 @@ void PCB_EDIT_FRAME::enableGALSpecificMenus()
void PCB_EDIT_FRAME::ShowBoardSetupDialog( wxCommandEvent& event )
{
DoShowBoardSetupDialog();
}
void PCB_EDIT_FRAME::DoShowBoardSetupDialog( const wxString& aInitialPage,
const wxString& aInitialParentPage )
{
DIALOG_BOARD_SETUP dlg( this );
if( !aInitialPage.IsEmpty() )
dlg.SetInitialPage( aInitialPage, aInitialParentPage );
if( dlg.ShowModal() == wxID_OK )
{
Prj().ConfigSave( Kiface().KifaceSearch(), GROUP_PCB, GetProjectFileParameters() );

View File

@ -708,6 +708,8 @@ public:
* Function ShowBoardSetupDialog
*/
void ShowBoardSetupDialog( wxCommandEvent& event );
void DoShowBoardSetupDialog( const wxString& aInitialPage = wxEmptyString,
const wxString& aInitialParentPage = wxEmptyString );
/* toolbars update UI functions: */

View File

@ -661,6 +661,9 @@ void PCB_EDIT_FRAME::UpdateTrackWidthSelectBox( wxChoice* aTrackWidthSelectBox )
aTrackWidthSelectBox->Append( msg );
}
aTrackWidthSelectBox->Append( wxT( "---" ) );
aTrackWidthSelectBox->Append( _( "Edit pre-defined sizes..." ) );
if( GetDesignSettings().GetTrackWidthIndex() >= GetDesignSettings().m_TrackWidthList.size() )
GetDesignSettings().SetTrackWidthIndex( 0 );
@ -707,6 +710,9 @@ void PCB_EDIT_FRAME::UpdateViaSizeSelectBox( wxChoice* aViaSizeSelectBox )
aViaSizeSelectBox->Append( msg );
}
aViaSizeSelectBox->Append( wxT( "---" ) );
aViaSizeSelectBox->Append( _( "Edit pre-defined sizes..." ) );
if( GetDesignSettings().GetViaSizeIndex() >= GetDesignSettings().m_ViasDimensionsList.size() )
GetDesignSettings().SetViaSizeIndex( 0 );