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 ),
139 m_cursorWarped( false )
140 {
141 }
142
144 {
145 }
146
153 virtual void SetGrabMouse( bool aEnabled )
154 {
155 m_settings.m_grabMouse = aEnabled;
156 }
157
164 virtual void SetAutoPan( bool aEnabled )
165 {
166 m_settings.m_autoPanEnabled = aEnabled;
167 }
168
174 virtual void EnableAutoPan( bool aEnabled )
175 {
176 m_settings.m_autoPanSettingEnabled = aEnabled;
177 }
178
184 virtual void SetAutoPanSpeed( float aSpeed )
185 {
186 m_settings.m_autoPanSpeed = aSpeed;
187 }
188
194 virtual void SetAutoPanAcceleration( float aAcceleration )
195 {
196 m_settings.m_autoPanAcceleration = aAcceleration;
197 }
198
204 virtual void SetAutoPanMargin( float aMargin )
205 {
206 m_settings.m_autoPanMargin = aMargin;
207 }
208
209 virtual void PinCursorInsideNonAutoscrollArea( bool aWarpMouseCursor ) = 0;
210
223 virtual VECTOR2D GetMousePosition( bool aWorldCoordinates = true ) const = 0;
224
236 {
237 return GetCursorPosition( m_settings.m_snappingEnabled );
238 }
239
246 virtual VECTOR2D GetRawCursorPosition( bool aSnappingEnabled = true ) const = 0;
247
259 virtual VECTOR2D GetCursorPosition( bool aEnableSnapping ) const = 0;
260
269 virtual void ForceCursorPosition( bool aEnabled, const VECTOR2D& aPosition = VECTOR2D( 0, 0 ) )
270 {
271 m_settings.m_forceCursorPosition = aEnabled;
272 m_settings.m_forcedPosition = aPosition;
273 }
274
286 virtual void SetCursorPosition( const VECTOR2D& aPosition, bool aWarpView = true,
287 bool aTriggeredByArrows = false, long aArrowCommand = 0 ) = 0;
288
289
298 virtual void SetCrossHairCursorPosition( const VECTOR2D& aPosition, bool aWarpView = true ) = 0;
299
305 virtual void ShowCursor( bool aEnabled );
306
312 bool IsCursorShown() const;
313
319 virtual void CaptureCursor( bool aEnabled )
320 {
321 m_settings.m_cursorCaptured = aEnabled;
322 }
323
337 virtual void WarpMouseCursor( const VECTOR2D& aPosition, bool aWorldCoordinates = false,
338 bool aWarpView = false ) = 0;
339
345 void EnableCursorWarping( bool aEnable )
346 {
347 m_settings.m_warpCursor = aEnable;
348 }
349
354 {
355 return m_settings.m_warpCursor;
356 }
357
362 virtual void CenterOnCursor() = 0;
363
367 virtual void Reset();
368
371 {
372 return m_settings;
373 }
374
376 void ApplySettings( const VC_SETTINGS& aSettings );
377
379 virtual void LoadSettings() {}
380
381protected:
384
387
390};
391} // namespace KIGFX
392
393#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