Add a method to facilitate Tools handling in main frame toolbars.
Fix also a bug in gerbview_frame.cpp, about a broken toolbar accessor (fortunately not used in current code)
This commit is contained in:
parent
c867de53b8
commit
f8a3ec4974
|
@ -134,6 +134,7 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent,
|
|||
{
|
||||
m_drawToolBar = NULL;
|
||||
m_optionsToolBar = NULL;
|
||||
m_auxiliaryToolBar = NULL;
|
||||
m_gridSelectBox = NULL;
|
||||
m_zoomSelectBox = NULL;
|
||||
m_hotkeysDescrList = NULL;
|
||||
|
@ -306,6 +307,37 @@ void EDA_DRAW_FRAME::OnToggleGridState( wxCommandEvent& aEvent )
|
|||
m_canvas->Refresh();
|
||||
}
|
||||
|
||||
bool EDA_DRAW_FRAME::GetToolToggled( int aToolId )
|
||||
{
|
||||
// Checks all the toolbars and returns true if the given tool id is toggled.
|
||||
return ( ( m_mainToolBar && m_mainToolBar->GetToolToggled( aToolId ) ) ||
|
||||
( m_optionsToolBar && m_optionsToolBar->GetToolToggled( aToolId ) ) ||
|
||||
( m_drawToolBar && m_drawToolBar->GetToolToggled( aToolId ) ) ||
|
||||
( m_auxiliaryToolBar && m_auxiliaryToolBar->GetToolToggled( aToolId ) )
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
wxAuiToolBarItem* EDA_DRAW_FRAME::GetToolbarTool( int aToolId )
|
||||
{
|
||||
// Checks all the toolbars and returns a reference to the given tool id
|
||||
// (or the first tool found, but only one or 0 tool is expected, because on
|
||||
// Windows, when different tools have the same ID, it creates issues)
|
||||
if( m_mainToolBar && m_mainToolBar->FindTool( aToolId ) )
|
||||
return m_mainToolBar->FindTool( aToolId );
|
||||
|
||||
if( m_optionsToolBar && m_optionsToolBar->FindTool( aToolId ) )
|
||||
return m_optionsToolBar->FindTool( aToolId );
|
||||
|
||||
if( m_drawToolBar && m_drawToolBar->FindTool( aToolId ) )
|
||||
return m_drawToolBar->FindTool( aToolId );
|
||||
|
||||
if( m_auxiliaryToolBar && m_auxiliaryToolBar->FindTool( aToolId ) )
|
||||
return m_auxiliaryToolBar->FindTool( aToolId );
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
void EDA_DRAW_FRAME::OnSelectUnits( wxCommandEvent& aEvent )
|
||||
{
|
||||
|
|
|
@ -68,7 +68,6 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ):
|
|||
EDA_DRAW_FRAME( aKiway, aParent, FRAME_GERBER, wxT( "GerbView" ),
|
||||
wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, GERBVIEW_FRAME_NAME )
|
||||
{
|
||||
m_auxiliaryToolBar = NULL;
|
||||
m_colorsSettings = &g_ColorsSettings;
|
||||
m_gerberLayout = NULL;
|
||||
m_zoomLevelCoeff = ZOOM_FACTOR( 110 ); // Adjusted to roughly displays zoom level = 1
|
||||
|
|
|
@ -182,10 +182,6 @@ public:
|
|||
COLORS_DESIGN_SETTINGS* m_colorsSettings;
|
||||
|
||||
private:
|
||||
/// Auxiliary tool bar typically shown below the main tool bar at the top of the
|
||||
/// main window.
|
||||
wxAuiToolBar* m_auxiliaryToolBar;
|
||||
|
||||
// list of PARAM_CFG_xxx to read/write parameters saved in config
|
||||
PARAM_CFG_ARRAY m_configSettings;
|
||||
|
||||
|
@ -258,8 +254,6 @@ public:
|
|||
double BestZoom() override;
|
||||
void UpdateStatusBar() override;
|
||||
|
||||
wxAuiToolBar* GetMainToolBar() { return m_optionsToolBar; }
|
||||
|
||||
/**
|
||||
* Function GetZoomLevelIndicator
|
||||
* returns a human readable value which can be displayed as zoom
|
||||
|
|
|
@ -121,6 +121,10 @@ protected:
|
|||
/// Choice box to choose the zoom value.
|
||||
wxChoice* m_zoomSelectBox;
|
||||
|
||||
/// Auxiliary tool bar typically shown below the main tool bar at the top of the
|
||||
/// main window.
|
||||
wxAuiToolBar* m_auxiliaryToolBar;
|
||||
|
||||
/// The tool bar that contains the buttons for quick access to the application draw
|
||||
/// tools. It typically is located on the right side of the main window.
|
||||
wxAuiToolBar* m_drawToolBar;
|
||||
|
@ -434,20 +438,23 @@ public:
|
|||
|
||||
// Toolbar accessors
|
||||
wxAuiToolBar* GetMainToolBar() const { return m_mainToolBar; }
|
||||
wxAuiToolBar* GetOptionsToolBar() const { return m_optionsToolBar; }
|
||||
wxAuiToolBar* GetDrawToolBar() const { return m_drawToolBar; }
|
||||
wxAuiToolBar* GetAuxiliaryToolBar() const { return m_auxiliaryToolBar; }
|
||||
|
||||
/**
|
||||
* Checks all the toolbars and returns true if the given tool id is toggled.
|
||||
*
|
||||
* This is needed because GerbView and Pcbnew put some of the same tools in
|
||||
* different toolbars (for example, zoom selection is in the main bar in
|
||||
* Pcbnew and in the options bar in GerbView).
|
||||
* This is needed because GerbView and Pcbnew can put some of the same tools in
|
||||
* different toolbars.
|
||||
*/
|
||||
bool GetToolToggled( int aToolId )
|
||||
{
|
||||
return ( ( m_mainToolBar && m_mainToolBar->GetToolToggled( aToolId ) ) ||
|
||||
( m_optionsToolBar && m_optionsToolBar->GetToolToggled( aToolId ) ) ||
|
||||
( m_drawToolBar && m_drawToolBar->GetToolToggled( aToolId ) ) );
|
||||
}
|
||||
bool GetToolToggled( int aToolId );
|
||||
|
||||
/**
|
||||
* Checks all the toolbars and returns a reference to the given tool id
|
||||
* or nullptr if not found
|
||||
*/
|
||||
wxAuiToolBarItem* GetToolbarTool( int aToolId );
|
||||
|
||||
/**
|
||||
* Function SetToolID
|
||||
|
|
|
@ -78,10 +78,6 @@ protected:
|
|||
GENERAL_COLLECTOR* m_Collector;
|
||||
PCB_GENERAL_SETTINGS m_configSettings;
|
||||
|
||||
/// Auxiliary tool bar typically shown below the main tool bar at the top of the
|
||||
/// main window.
|
||||
wxAuiToolBar* m_auxiliaryToolBar;
|
||||
|
||||
void updateGridSelectBox();
|
||||
void updateZoomSelectBox();
|
||||
virtual void unitsChangeRefresh() override;
|
||||
|
|
|
@ -115,8 +115,6 @@ PCB_BASE_FRAME::PCB_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame
|
|||
m_FastGrid1 = 0;
|
||||
m_FastGrid2 = 0;
|
||||
|
||||
m_auxiliaryToolBar = NULL;
|
||||
|
||||
m_zoomLevelCoeff = 11.0 * IU_PER_MILS; // Adjusted to roughly displays zoom level = 1
|
||||
// when the screen shows a 1:1 image
|
||||
// obviously depends on the monitor,
|
||||
|
|
Loading…
Reference in New Issue