You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

139 lines
4.7 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
  5. * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
  6. * Copyright (C) 2012 Wayne Stambaugh <stambaughw@gmail.com>
  7. * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
  8. *
  9. * This program is free software: you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License as published by the
  11. * Free Software Foundation, either version 3 of the License, or (at your
  12. * option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful, but
  15. * WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License along
  20. * with this program. If not, see <http://www.gnu.org/licenses/>.
  21. */
  22. #include <advanced_config.h>
  23. #include <macros.h>
  24. #include <bitmaps.h>
  25. #include <tool/action_toolbar.h>
  26. #include <tool/conditional_menu.h>
  27. #include <tool/tool_manager.h>
  28. #include <tools/pcb_selection_tool.h>
  29. #include <tools/pcb_actions.h>
  30. #include "footprint_viewer_frame.h"
  31. #include "pcbnew_id.h"
  32. #include <widgets/wx_menubar.h>
  33. #include <wx/choice.h>
  34. #include <toolbars_footprint_viewer.h>
  35. std::optional<TOOLBAR_CONFIGURATION> FOOTPRINT_VIEWER_TOOLBAR_SETTINGS::DefaultToolbarConfig( TOOLBAR_LOC aToolbar )
  36. {
  37. TOOLBAR_CONFIGURATION config;
  38. // clang-format off
  39. switch( aToolbar )
  40. {
  41. case TOOLBAR_LOC::RIGHT:
  42. case TOOLBAR_LOC::TOP_AUX:
  43. return std::nullopt;
  44. case TOOLBAR_LOC::TOP_MAIN:
  45. config.AppendAction( PCB_ACTIONS::previousFootprint )
  46. .AppendAction( PCB_ACTIONS::nextFootprint );
  47. config.AppendSeparator()
  48. .AppendAction( ACTIONS::zoomRedraw )
  49. .AppendAction( ACTIONS::zoomInCenter )
  50. .AppendAction( ACTIONS::zoomOutCenter )
  51. .AppendAction( ACTIONS::zoomFitScreen )
  52. .AppendAction( ACTIONS::zoomTool );
  53. config.AppendSeparator()
  54. .AppendAction( ACTIONS::show3DViewer )
  55. .AppendAction( PCB_ACTIONS::saveFpToBoard );
  56. config.AppendSeparator()
  57. .AppendControl( ACTION_TOOLBAR_CONTROLS::gridSelect );
  58. config.AppendSeparator()
  59. .AppendControl( ACTION_TOOLBAR_CONTROLS::zoomSelect )
  60. .AppendAction( PCB_ACTIONS::fpAutoZoom);
  61. break;
  62. case TOOLBAR_LOC::LEFT:
  63. config.AppendAction( ACTIONS::selectionTool )
  64. .AppendAction( ACTIONS::measureTool );
  65. config.AppendSeparator()
  66. .AppendAction( ACTIONS::toggleGrid )
  67. .AppendAction( ACTIONS::togglePolarCoords )
  68. .AppendAction( ACTIONS::inchesUnits )
  69. .AppendAction( ACTIONS::milsUnits )
  70. .AppendAction( ACTIONS::millimetersUnits )
  71. .AppendAction( ACTIONS::toggleCursorStyle );
  72. config.AppendSeparator()
  73. .AppendAction( PCB_ACTIONS::showPadNumbers )
  74. .AppendAction( PCB_ACTIONS::padDisplayMode )
  75. .AppendAction( PCB_ACTIONS::textOutlines )
  76. .AppendAction( PCB_ACTIONS::graphicsOutlines );
  77. if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes )
  78. config.AppendAction( ACTIONS::toggleBoundingBoxes );
  79. break;
  80. }
  81. // clang-format on
  82. return config;
  83. }
  84. void FOOTPRINT_VIEWER_FRAME::doReCreateMenuBar()
  85. {
  86. PCB_SELECTION_TOOL* selTool = m_toolManager->GetTool<PCB_SELECTION_TOOL>();
  87. // wxWidgets handles the Mac Application menu behind the scenes, but that means
  88. // we always have to start from scratch with a new wxMenuBar.
  89. wxMenuBar* oldMenuBar = GetMenuBar();
  90. WX_MENUBAR* menuBar = new WX_MENUBAR();
  91. //----- File menu -----------------------------------------------------------
  92. //
  93. ACTION_MENU* fileMenu = new ACTION_MENU( false, selTool );
  94. fileMenu->AddClose( _( "Footprint Viewer" ) );
  95. //----- View menu -----------------------------------------------------------
  96. //
  97. ACTION_MENU* viewMenu = new ACTION_MENU( false, selTool );
  98. viewMenu->AppendSeparator();
  99. viewMenu->Add( ACTIONS::zoomInCenter );
  100. viewMenu->Add( ACTIONS::zoomOutCenter );
  101. viewMenu->Add( ACTIONS::zoomFitScreen );
  102. viewMenu->Add( ACTIONS::zoomRedraw );
  103. viewMenu->AppendSeparator();
  104. viewMenu->Add( ACTIONS::show3DViewer );
  105. //----- Menubar -------------------------------------------------------------
  106. //
  107. menuBar->Append( fileMenu, _( "&File" ) );
  108. menuBar->Append( viewMenu, _( "&View" ) );
  109. AddStandardHelpMenu( menuBar );
  110. SetMenuBar( menuBar );
  111. delete oldMenuBar;
  112. }