KiCad PCB EDA Suite
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>
5  * Copyright (C) 2013-2015 CERN
6  * @author Tomasz Wlostowski <>
7  * @author Maciej Suminski <>
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
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  *
22  * or you may search the 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  */
27 #include <view/view.h>
28 #include <view/view_controls.h>
31 using namespace KIGFX;
33 void VIEW_CONTROLS::ShowCursor( bool aEnabled )
34 {
35  m_settings.m_showCursor = aEnabled;
36  m_view->GetGAL()->SetCursorEnabled( aEnabled );
37 }
41 {
42  // this only says if the VIEW_CONTROLS say the cursor should be
43  // shown: m_view->GetGAL()->IsCursorEnabled() will say if the GAL is
44  // actually going to do show the cursor or not
45  return m_settings.m_showCursor;
46 }
50 {
51  // Get the default settings from the default constructor
53  ApplySettings( dummy );
54 }
58 {
59  m_showCursor = false;
60  m_forceCursorPosition = false;
61  m_cursorCaptured = false;
62  m_snappingEnabled = true;
63  m_grabMouse = false;
64  m_autoPanEnabled = false;
65  m_autoPanMargin = 0.1;
66  m_autoPanSpeed = 0.15;
67  m_warpCursor = false;
68  m_enableMousewheelPan = false;
69  m_panWithRightButton = false;
70  m_panWithLeftButton = false;
71 }
74 void VIEW_CONTROLS::ApplySettings( const VC_SETTINGS& aSettings )
75 {
76  ShowCursor( aSettings.m_showCursor );
77  CaptureCursor( aSettings.m_cursorCaptured );
78  SetSnapping( aSettings.m_snappingEnabled );
79  SetGrabMouse( aSettings.m_grabMouse );
80  SetAutoPan( aSettings.m_autoPanEnabled );
81  SetAutoPanMargin( aSettings.m_autoPanMargin );
82  SetAutoPanSpeed( aSettings.m_autoPanSpeed );
84 }
bool m_enableMousewheelPan
Mousewheel (2-finger touchpad) panning
Definition: view_controls.h:85
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
void Reset()
Restores the default settings
virtual void SetAutoPanSpeed(float aSpeed)
Function SetAutoPanSpeed() Sets speed of autopanning.
float m_autoPanSpeed
How fast is panning when in auto mode
Definition: view_controls.h:79
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: class_module.h:58
bool m_snappingEnabled
Should the cursor snap to grid or move freely
Definition: view_controls.h:67
bool m_grabMouse
Flag for grabbing the mouse cursor
Definition: view_controls.h:70
VIEW_CONTROLS class definition.
void SetCursorEnabled(bool aCursorEnabled)
Enable/disable cursor.
void ApplySettings(const VC_SETTINGS &aSettings)
Applies VIEW_CONTROLS settings from an object
VC_SETTINGS m_settings
Current VIEW_CONTROLS settings
VECTOR2D m_forcedPosition
Forced cursor position (world coordinates)
Definition: view_controls.h:58
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
bool m_panWithRightButton
Allow panning with the right button in addition to middle
Definition: view_controls.h:88
virtual void SetAutoPanMargin(float aMargin)
Function SetAutoPanMArgin() Sets margin for autopanning (ie.
VIEW * m_view
Pointer to controlled VIEW.
virtual void Reset()
Function Reset() Restores the default VIEW_CONTROLS settings.
bool m_forceCursorPosition
Is the forced cursor position enabled
Definition: view_controls.h:61
GAL * GetGAL() const
Function GetGAL() Returns the GAL this view is using to draw graphical primitives.
Definition: view.h:177
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area. ...
bool IsCursorShown() const
Function IsCursorShown() Returns true when cursor is visible.
Structure to keep VIEW_CONTROLS settings for easy store/restore operations
Definition: view_controls.h:44
bool m_warpCursor
If the cursor is allowed to be warped
Definition: view_controls.h:82
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
float m_autoPanMargin
Distance from cursor to VIEW edge when panning is active
Definition: view_controls.h:76
bool m_autoPanEnabled
Flag for turning on autopanning
Definition: view_controls.h:73
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg...
bool m_showCursor
Flag determining the cursor visibility
Definition: view_controls.h:55
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape This component is a 400 mils squar...
virtual void SetGrabMouse(bool aEnabled)
Function SetGrabMouse Turns on/off mouse grabbing.
bool m_cursorCaptured
Should the cursor be locked within the parent window area
Definition: view_controls.h:64
bool m_panWithLeftButton
Allow panning with the left button in addition to middle
Definition: view_controls.h:91