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
127};
128
129
135{
136public:
137 VIEW_CONTROLS( VIEW* aView ) :
138 m_view( aView ), m_cursorWarped( false )
139 {
140 }
141
143 {
144 }
145
152 virtual void SetGrabMouse( bool aEnabled )
153 {
154 m_settings.m_grabMouse = aEnabled;
155 }
156
163 virtual void SetAutoPan( bool aEnabled )
164 {
165 m_settings.m_autoPanEnabled = aEnabled;
166 }
167
173 virtual void EnableAutoPan( bool aEnabled )
174 {
175 m_settings.m_autoPanSettingEnabled = aEnabled;
176 }
177
183 virtual void SetAutoPanSpeed( float aSpeed )
184 {
185 m_settings.m_autoPanSpeed = aSpeed;
186 }
187
193 virtual void SetAutoPanAcceleration( float aAcceleration )
194 {
195 m_settings.m_autoPanAcceleration = aAcceleration;
196 }
197
203 virtual void SetAutoPanMargin( float aMargin )
204 {
205 m_settings.m_autoPanMargin = aMargin;
206 }
207
208 virtual void PinCursorInsideNonAutoscrollArea( bool aWarpMouseCursor ) = 0;
209
222 virtual VECTOR2D GetMousePosition( bool aWorldCoordinates = true ) const = 0;
223
235 {
236 return GetCursorPosition( m_settings.m_snappingEnabled );
237 }
238
245 virtual VECTOR2D GetRawCursorPosition( bool aSnappingEnabled = true ) const = 0;
246
258 virtual VECTOR2D GetCursorPosition( bool aEnableSnapping ) const = 0;
259
268 virtual void ForceCursorPosition( bool aEnabled, const VECTOR2D& aPosition = VECTOR2D( 0, 0 ) )
269 {
270 m_settings.m_forceCursorPosition = aEnabled;
271 m_settings.m_forcedPosition = aPosition;
272 }
273
285 virtual void SetCursorPosition( const VECTOR2D& aPosition, bool aWarpView = true,
286 bool aTriggeredByArrows = false, long aArrowCommand = 0 ) = 0;
287
288
297 virtual void SetCrossHairCursorPosition( const VECTOR2D& aPosition, bool aWarpView = true ) = 0;
298
304 virtual void ShowCursor( bool aEnabled );
305
311 bool IsCursorShown() const;
312
318 virtual void CaptureCursor( bool aEnabled )
319 {
320 m_settings.m_cursorCaptured = aEnabled;
321 }
322
336 virtual void WarpMouseCursor( const VECTOR2D& aPosition, bool aWorldCoordinates = false,
337 bool aWarpView = false ) = 0;
338
344 void EnableCursorWarping( bool aEnable )
345 {
346 m_settings.m_warpCursor = aEnable;
347 }
348
353 {
354 return m_settings.m_warpCursor;
355 }
356
361 virtual void CenterOnCursor() = 0;
362
366 virtual void Reset();
367
370 {
371 return m_settings;
372 }
373
375 void ApplySettings( const VC_SETTINGS& aSettings );
376
378 virtual void LoadSettings() {}
379
380protected:
383
386
389};
390} // namespace KIGFX
391
392#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
Wether to invert the scroll wheel movement for horizontal pan.
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_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:587