KiCad PCB EDA Suite
Loading...
Searching...
No Matches
view_controls.cpp
Go to the documentation of this file.
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 <[email protected]>
7 * @author Maciej Suminski <[email protected]>
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
28#include <tool/actions.h>
29#include <view/view.h>
30#include <view/view_controls.h>
31
32using namespace KIGFX;
33
34void VIEW_CONTROLS::ShowCursor( bool aEnabled )
35{
36 m_settings.m_showCursor = aEnabled;
37 m_view->GetGAL()->SetCursorEnabled( aEnabled );
38}
39
40
42{
43 // this only says if the VIEW_CONTROLS say the cursor should be
44 // shown: m_view->GetGAL()->IsCursorEnabled() will say if the GAL is
45 // actually going to do show the cursor or not
47}
48
49
51{
52 // Get the default settings from the default constructor
55}
56
57
59{
60 m_showCursor = false;
62 m_cursorCaptured = false;
63 m_snappingEnabled = true;
64 m_grabMouse = false;
65 m_focusFollowSchPcb = false;
66 m_autoPanEnabled = false;
68 m_autoPanMargin = 0.02f;
69 m_autoPanSpeed = 0.15f;
71 m_warpCursor = false;
72 m_horizontalPan = false;
73 m_zoomAcceleration = false;
74 m_zoomSpeed = 5;
75 m_zoomSpeedAuto = true;
77 m_scrollModifierPanH = WXK_CONTROL;
78 m_scrollModifierPanV = WXK_SHIFT;
79 m_dragLeft = MOUSE_DRAG_ACTION::NONE;
80 m_dragMiddle = MOUSE_DRAG_ACTION::PAN;
81 m_dragRight = MOUSE_DRAG_ACTION::PAN;
83 m_lastKeyboardCursorPosition = { 0.0, 0.0 };
85 m_scrollReverseZoom = false;
86 m_scrollReversePanH = false;
87}
88
89
91{
92 ShowCursor( aSettings.m_showCursor );
94 SetGrabMouse( aSettings.m_grabMouse );
95 SetAutoPan( aSettings.m_autoPanEnabled );
99}
@ CURSOR_NONE
Definition: actions.h:251
void SetCursorEnabled(bool aCursorEnabled)
Enable/disable cursor.
virtual void CaptureCursor(bool aEnabled)
Force the cursor to stay within the drawing panel area.
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
virtual void SetAutoPanMargin(float aMargin)
Set the margin for autopanning (ie.
bool IsCursorShown() const
Return true when cursor is visible.
virtual void SetGrabMouse(bool aEnabled)
Turn on/off mouse grabbing.
virtual void Reset()
Restore the default VIEW_CONTROLS settings.
virtual void SetAutoPanSpeed(float aSpeed)
Set the speed of autopanning.
VC_SETTINGS m_settings
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
void ApplySettings(const VC_SETTINGS &aSettings)
Load new settings from program common settings.
VIEW * m_view
< Pointer to controlled VIEW.
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
Definition: view.h:203
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:247
static LIB_SYMBOL * dummy()
Used when a LIB_SYMBOL is not found in library to draw a dummy shape.
Structure to keep VIEW_CONTROLS settings for easy store/restore operations.
Definition: view_controls.h:43
float m_autoPanMargin
How fast is panning when in auto mode.
Definition: view_controls.h:80
VECTOR2D m_forcedPosition
Is the forced cursor position enabled.
Definition: view_controls.h:56
MOUSE_DRAG_ACTION m_dragLeft
bool m_horizontalPan
Enable the accelerating zoom controller.
Definition: view_controls.h:92
void Reset()
Flag determining the cursor visibility.
bool m_autoPanSettingEnabled
Distance from cursor to VIEW edge when panning is active.
Definition: view_controls.h:77
bool m_focusFollowSchPcb
Flag for turning on autopanning.
Definition: view_controls.h:71
float m_autoPanAcceleration
If the cursor is allowed to be warped.
Definition: view_controls.h:86
MOUSE_DRAG_ACTION m_dragMiddle
bool m_cursorCaptured
Should the cursor snap to grid or move freely.
Definition: view_controls.h:62
int m_zoomSpeed
When true, ignore zoom_speed and pick a platform-specific default.
Definition: view_controls.h:98
int m_scrollModifierZoom
What modifier key to enable horizontal pan with the (vertical) scroll wheel.
int m_scrollModifierPanH
What modifier key to enable vertical with the (vertical) scroll wheel.
VECTOR2D m_lastKeyboardCursorPosition
Whether to invert the scroll wheel movement for zoom.
float m_autoPanSpeed
How fast does panning accelerate when approaching the window boundary.
Definition: view_controls.h:83
bool m_warpCursor
Enable horizontal panning with the horizontal scroll/trackpad input.
Definition: view_controls.h:89
MOUSE_DRAG_ACTION m_dragRight
Is last cursor motion event coming from keyboard arrow cursor motion action.
bool m_grabMouse
Flag for automatic focus switching between Schematic and PCB editors.
Definition: view_controls.h:68
bool m_scrollReverseZoom
Whether to invert the scroll wheel movement for horizontal pan.
bool m_zoomAcceleration
Zoom speed for the non-accelerating zoom controller.
Definition: view_controls.h:95
bool m_lastKeyboardCursorPositionValid
ACTIONS::CURSOR_UP, ACTIONS::CURSOR_DOWN, etc.
bool m_zoomSpeedAuto
What modifier key to enable zoom with the (vertical) scroll wheel.
bool m_autoPanEnabled
Flag for turning on autopanning.
Definition: view_controls.h:74
bool m_snappingEnabled
Flag for grabbing the mouse cursor.
Definition: view_controls.h:65
bool m_showCursor
Forced cursor position (world coordinates).
Definition: view_controls.h:53
long m_lastKeyboardCursorCommand
Position of the above event.
bool m_forceCursorPosition
Should the cursor be locked within the parent window area.
Definition: view_controls.h:59