KiCad PCB EDA Suite
Loading...
Searching...
No Matches
view_controls.h
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 CERN
6 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * @author Tomasz Wlostowski <[email protected]>
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, you may find one here:
22 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
23 * or you may search the http://www.gnu.org website for the version 2 license,
24 * or you may write to the Free Software Foundation, Inc.,
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
26 *
27 */
28
29#ifndef __VIEW_CONTROLS_H
30#define __VIEW_CONTROLS_H
31
32#include <math/box2.h>
34#include <gal/gal.h>
35
36namespace KIGFX
37{
38class VIEW;
39
40
43{
45 {
46 Reset();
47 }
48
50 void Reset();
51
54
57
60
63
66
69
72
75
78
81
84
87
90
93
96
99
102
105
108
111
114
118
121
124
127
128
131
134};
135
136
142{
143public:
144 VIEW_CONTROLS( VIEW* aView ) :
145 m_view( aView ),
146 m_cursorWarped( false )
147 {
148 }
149
151 {
152 }
153
160 virtual void SetGrabMouse( bool aEnabled )
161 {
162 m_settings.m_grabMouse = aEnabled;
163 }
164
171 virtual void SetAutoPan( bool aEnabled )
172 {
173 m_settings.m_autoPanEnabled = aEnabled;
174 }
175
181 virtual void EnableAutoPan( bool aEnabled )
182 {
183 m_settings.m_autoPanSettingEnabled = aEnabled;
184 }
185
191 virtual void SetAutoPanSpeed( float aSpeed )
192 {
193 m_settings.m_autoPanSpeed = aSpeed;
194 }
195
201 virtual void SetAutoPanAcceleration( float aAcceleration )
202 {
203 m_settings.m_autoPanAcceleration = aAcceleration;
204 }
205
211 virtual void SetAutoPanMargin( float aMargin )
212 {
213 m_settings.m_autoPanMargin = aMargin;
214 }
215
216 virtual void PinCursorInsideNonAutoscrollArea( bool aWarpMouseCursor ) = 0;
217
230 virtual VECTOR2D GetMousePosition( bool aWorldCoordinates = true ) const = 0;
231
243 {
244 return GetCursorPosition( m_settings.m_snappingEnabled );
245 }
246
253 virtual VECTOR2D GetRawCursorPosition( bool aSnappingEnabled = true ) const = 0;
254
266 virtual VECTOR2D GetCursorPosition( bool aEnableSnapping ) const = 0;
267
276 virtual void ForceCursorPosition( bool aEnabled, const VECTOR2D& aPosition = VECTOR2D( 0, 0 ) )
277 {
278 m_settings.m_forceCursorPosition = aEnabled;
279 m_settings.m_forcedPosition = aPosition;
280 }
281
293 virtual void SetCursorPosition( const VECTOR2D& aPosition, bool aWarpView = true,
294 bool aTriggeredByArrows = false, long aArrowCommand = 0 ) = 0;
295
296
305 virtual void SetCrossHairCursorPosition( const VECTOR2D& aPosition, bool aWarpView = true ) = 0;
306
312 virtual void ShowCursor( bool aEnabled );
313
319 bool IsCursorShown() const;
320
326 virtual void CaptureCursor( bool aEnabled )
327 {
328 m_settings.m_cursorCaptured = aEnabled;
329 }
330
344 virtual void WarpMouseCursor( const VECTOR2D& aPosition, bool aWorldCoordinates = false,
345 bool aWarpView = false ) = 0;
346
352 void EnableCursorWarping( bool aEnable )
353 {
354 m_settings.m_warpCursor = aEnable;
355 }
356
361 {
362 return m_settings.m_warpCursor;
363 }
364
369 virtual void CenterOnCursor() = 0;
370
374 virtual void Reset();
375
378 {
379 return m_settings;
380 }
381
383 void ApplySettings( const VC_SETTINGS& aSettings );
384
386 virtual void LoadSettings() {}
387
388protected:
391
394
397};
398} // namespace KIGFX
399
400#endif
An interface for classes handling user events controlling the view behavior such as zooming,...
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.
bool m_cursorWarped
Application warped the cursor, not the user (keyboard).
virtual void SetAutoPanMargin(float aMargin)
Set the margin for autopanning (ie.
virtual void EnableAutoPan(bool aEnabled)
Turn on/off auto panning (user setting to disable it entirely).
virtual VECTOR2D GetRawCursorPosition(bool aSnappingEnabled=true) const =0
Return the current cursor position in world coordinates ignoring the cursorUp position force mode.
virtual void SetAutoPanAcceleration(float aAcceleration)
Set the speed of autopanning.
bool IsCursorWarpingEnabled() const
virtual void WarpMouseCursor(const VECTOR2D &aPosition, bool aWorldCoordinates=false, bool aWarpView=false)=0
If enabled (.
virtual void SetGrabMouse(bool aEnabled)
Turn on/off mouse grabbing.
virtual void SetAutoPanSpeed(float aSpeed)
Set the speed of autopanning.
virtual void CenterOnCursor()=0
Set the viewport center to the current cursor position and warps the cursor to the screen center.
virtual void LoadSettings()
Load new settings from program common settings.
VC_SETTINGS m_settings
Current VIEW_CONTROLS settings.
virtual void SetCrossHairCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Move the graphic crosshair cursor to the requested position expressed in world coordinates.
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Return the current mouse pointer position.
virtual VECTOR2D GetCursorPosition(bool aEnableSnapping) const =0
Return the current cursor position in world coordinates.
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true, bool aTriggeredByArrows=false, long aArrowCommand=0)=0
Move cursor to the requested position expressed in world coordinates.
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
VIEW * m_view
Pointer to controlled VIEW.
virtual void PinCursorInsideNonAutoscrollArea(bool aWarpMouseCursor)=0
void EnableCursorWarping(bool aEnable)
Enable or disable warping the cursor.
const VC_SETTINGS & GetSettings() const
Return the current VIEW_CONTROLS settings.
VIEW_CONTROLS(VIEW *aView)
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:66
MOUSE_DRAG_ACTION
void Reset() override
#define GAL_API
Definition: gal.h:28
The Cairo implementation of the graphics abstraction layer.
Definition: eda_group.h:33
Structure to keep VIEW_CONTROLS settings for easy store/restore operations.
Definition: view_controls.h:43
float m_autoPanMargin
Distance from cursor to VIEW edge when panning is active.
Definition: view_controls.h:80
VECTOR2D m_forcedPosition
Forced cursor position (world coordinates).
Definition: view_controls.h:56
MOUSE_DRAG_ACTION m_dragLeft
bool m_horizontalPan
Enable horizontal panning with the horizontal scroll/trackpad input.
Definition: view_controls.h:92
bool m_scrollReversePanH
Whether to invert the scroll wheel movement for horizontal pan.
bool m_autoPanSettingEnabled
Flag for turning on autopanning.
Definition: view_controls.h:77
bool m_focusFollowSchPcb
Flag for automatic focus switching between Schematic and PCB editors.
Definition: view_controls.h:71
float m_autoPanAcceleration
How fast does panning accelerate when approaching the window boundary.
Definition: view_controls.h:86
MOUSE_DRAG_ACTION m_dragMiddle
bool m_cursorCaptured
Should the cursor be locked within the parent window area.
Definition: view_controls.h:62
int m_zoomSpeed
Zoom speed for the non-accelerating zoom controller.
Definition: view_controls.h:98
int m_scrollModifierZoom
What modifier key to enable zoom with the (vertical) scroll wheel.
int m_scrollModifierPanH
What modifier key to enable horizontal pan with the (vertical) scroll wheel.
VECTOR2D m_lastKeyboardCursorPosition
Position of the above event.
float m_autoPanSpeed
How fast is panning when in auto mode.
Definition: view_controls.h:83
bool m_warpCursor
If the cursor is allowed to be warped.
Definition: view_controls.h:89
MOUSE_DRAG_ACTION m_dragRight
bool m_grabMouse
Flag for grabbing the mouse cursor.
Definition: view_controls.h:68
bool m_scrollReverseZoom
Whether to invert the scroll wheel movement for zoom.
int m_motionPanModifier
What modifier key pans the view when the mouse moves with it held.
bool m_zoomAcceleration
Enable the accelerating zoom controller.
Definition: view_controls.h:95
bool m_lastKeyboardCursorPositionValid
Is last cursor motion event coming from keyboard arrow cursor motion action.
bool m_zoomSpeedAuto
When true, ignore zoom_speed and pick a platform-specific default.
bool m_autoPanEnabled
Flag for turning on autopanning.
Definition: view_controls.h:74
bool m_snappingEnabled
Should the cursor snap to grid or move freely.
Definition: view_controls.h:65
bool m_showCursor
Flag determining the cursor visibility.
Definition: view_controls.h:53
int m_scrollModifierPanV
What modifier key to enable vertical with the (vertical) scroll wheel.
long m_lastKeyboardCursorCommand
ACTIONS::CURSOR_UP, ACTIONS::CURSOR_DOWN, etc.
bool m_forceCursorPosition
Is the forced cursor position enabled.
Definition: view_controls.h:59
VECTOR2< double > VECTOR2D
Definition: vector2d.h:694