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 (C) 2013-2021 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
115
118
121
124
125
128
131};
132
133
139{
140public:
141 VIEW_CONTROLS( VIEW* aView ) :
142 m_view( aView ),
143 m_cursorWarped( false )
144 {
145 }
146
148 {
149 }
150
157 virtual void SetGrabMouse( bool aEnabled )
158 {
159 m_settings.m_grabMouse = aEnabled;
160 }
161
168 virtual void SetAutoPan( bool aEnabled )
169 {
170 m_settings.m_autoPanEnabled = aEnabled;
171 }
172
178 virtual void EnableAutoPan( bool aEnabled )
179 {
180 m_settings.m_autoPanSettingEnabled = aEnabled;
181 }
182
188 virtual void SetAutoPanSpeed( float aSpeed )
189 {
190 m_settings.m_autoPanSpeed = aSpeed;
191 }
192
198 virtual void SetAutoPanAcceleration( float aAcceleration )
199 {
200 m_settings.m_autoPanAcceleration = aAcceleration;
201 }
202
208 virtual void SetAutoPanMargin( float aMargin )
209 {
210 m_settings.m_autoPanMargin = aMargin;
211 }
212
213 virtual void PinCursorInsideNonAutoscrollArea( bool aWarpMouseCursor ) = 0;
214
227 virtual VECTOR2D GetMousePosition( bool aWorldCoordinates = true ) const = 0;
228
240 {
241 return GetCursorPosition( m_settings.m_snappingEnabled );
242 }
243
250 virtual VECTOR2D GetRawCursorPosition( bool aSnappingEnabled = true ) const = 0;
251
263 virtual VECTOR2D GetCursorPosition( bool aEnableSnapping ) const = 0;
264
273 virtual void ForceCursorPosition( bool aEnabled, const VECTOR2D& aPosition = VECTOR2D( 0, 0 ) )
274 {
275 m_settings.m_forceCursorPosition = aEnabled;
276 m_settings.m_forcedPosition = aPosition;
277 }
278
290 virtual void SetCursorPosition( const VECTOR2D& aPosition, bool aWarpView = true,
291 bool aTriggeredByArrows = false, long aArrowCommand = 0 ) = 0;
292
293
302 virtual void SetCrossHairCursorPosition( const VECTOR2D& aPosition, bool aWarpView = true ) = 0;
303
309 virtual void ShowCursor( bool aEnabled );
310
316 bool IsCursorShown() const;
317
323 virtual void CaptureCursor( bool aEnabled )
324 {
325 m_settings.m_cursorCaptured = aEnabled;
326 }
327
341 virtual void WarpMouseCursor( const VECTOR2D& aPosition, bool aWorldCoordinates = false,
342 bool aWarpView = false ) = 0;
343
349 void EnableCursorWarping( bool aEnable )
350 {
351 m_settings.m_warpCursor = aEnable;
352 }
353
358 {
359 return m_settings.m_warpCursor;
360 }
361
366 virtual void CenterOnCursor() = 0;
367
371 virtual void Reset();
372
375 {
376 return m_settings;
377 }
378
380 void ApplySettings( const VC_SETTINGS& aSettings );
381
383 virtual void LoadSettings() {}
384
385protected:
388
391
394};
395} // namespace KIGFX
396
397#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
Current VIEW_CONTROLS settings.
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()
VC_SETTINGS m_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
Apply VIEW_CONTROLS settings from an object.
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:68
MOUSE_DRAG_ACTION
void Reset() override
#define GAL_API
Definition: gal.h:28
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:247
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
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.
VC_SETTINGS()
Restore the default settings.
Definition: view_controls.h:44
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
VECTOR2< double > VECTOR2D
Definition: vector2d.h:690