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.

98 lines
3.6 KiB

11 years ago
11 years ago
11 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2012 Torsten Hueter, torstenhtr <at> gmx.de
  5. * Copyright (C) 2013-2015 CERN
  6. * @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
  7. * @author Maciej Suminski <maciej.suminski@cern.ch>
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, you may find one here:
  21. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  22. * or you may search the http://www.gnu.org website for the version 2 license,
  23. * or you may write to the Free Software Foundation, Inc.,
  24. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  25. */
  26. #include <gal/graphics_abstraction_layer.h>
  27. #include <tool/actions.h>
  28. #include <view/view.h>
  29. #include <view/view_controls.h>
  30. using namespace KIGFX;
  31. void VIEW_CONTROLS::ShowCursor( bool aEnabled )
  32. {
  33. m_settings.m_showCursor = aEnabled;
  34. m_view->GetGAL()->SetCursorEnabled( aEnabled );
  35. }
  36. bool VIEW_CONTROLS::IsCursorShown() const
  37. {
  38. // this only says if the VIEW_CONTROLS say the cursor should be
  39. // shown: m_view->GetGAL()->IsCursorEnabled() will say if the GAL is
  40. // actually going to do show the cursor or not
  41. return m_settings.m_showCursor;
  42. }
  43. void VIEW_CONTROLS::Reset()
  44. {
  45. // Get the default settings from the default constructor
  46. VC_SETTINGS dummy;
  47. ApplySettings( dummy );
  48. }
  49. void VC_SETTINGS::Reset()
  50. {
  51. m_showCursor = false;
  52. m_forceCursorPosition = false;
  53. m_cursorCaptured = false;
  54. m_snappingEnabled = true;
  55. m_grabMouse = false;
  56. m_focusFollowSchPcb = false;
  57. m_autoPanEnabled = false;
  58. m_autoPanSettingEnabled = false;
  59. m_autoPanMargin = 0.02f;
  60. m_autoPanSpeed = 0.15f;
  61. m_autoPanAcceleration = 5.0f;
  62. m_warpCursor = false;
  63. m_horizontalPan = false;
  64. m_zoomAcceleration = false;
  65. m_zoomSpeed = 5;
  66. m_zoomSpeedAuto = true;
  67. m_scrollModifierZoom = 0;
  68. m_scrollModifierPanH = WXK_CONTROL;
  69. m_scrollModifierPanV = WXK_SHIFT;
  70. m_dragLeft = MOUSE_DRAG_ACTION::NONE;
  71. m_dragMiddle = MOUSE_DRAG_ACTION::PAN;
  72. m_dragRight = MOUSE_DRAG_ACTION::PAN;
  73. m_lastKeyboardCursorPositionValid = false;
  74. m_lastKeyboardCursorPosition = { 0.0, 0.0 };
  75. m_lastKeyboardCursorCommand = ACTIONS::CURSOR_NONE;
  76. m_scrollReversePanH = false;
  77. }
  78. void VIEW_CONTROLS::ApplySettings( const VC_SETTINGS& aSettings )
  79. {
  80. ShowCursor( aSettings.m_showCursor );
  81. CaptureCursor( aSettings.m_cursorCaptured );
  82. SetGrabMouse( aSettings.m_grabMouse );
  83. SetAutoPan( aSettings.m_autoPanEnabled );
  84. SetAutoPanMargin( aSettings.m_autoPanMargin );
  85. SetAutoPanSpeed( aSettings.m_autoPanSpeed );
  86. ForceCursorPosition( aSettings.m_forceCursorPosition, aSettings.m_forcedPosition );
  87. }