Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
dbbe628b
Commit
dbbe628b
authored
Sep 09, 2013
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modified interfaces for [WX_]VIEW_CONTROLS.
parent
d2c47a74
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
100 additions
and
96 deletions
+100
-96
wx_view_controls.cpp
common/view/wx_view_controls.cpp
+6
-14
view_controls.h
include/view/view_controls.h
+85
-23
wx_view_controls.h
include/view/wx_view_controls.h
+9
-59
No files found.
common/view/wx_view_controls.cpp
View file @
dbbe628b
...
...
@@ -34,11 +34,6 @@ using namespace KiGfx;
WX_VIEW_CONTROLS
::
WX_VIEW_CONTROLS
(
VIEW
*
aView
,
wxWindow
*
aParentPanel
)
:
VIEW_CONTROLS
(
aView
),
m_state
(
IDLE
),
m_grabMouse
(
false
),
m_snappingEnabled
(
true
),
m_autoPanEnabled
(
false
),
m_autoPanMargin
(
0.1
),
m_autoPanSpeed
(
0.15
),
m_parentPanel
(
aParentPanel
)
{
m_parentPanel
->
Connect
(
wxEVT_MOTION
,
wxMouseEventHandler
(
...
...
@@ -64,6 +59,12 @@ void WX_VIEW_CONTROLS::onMotion( wxMouseEvent& aEvent )
{
m_mousePosition
.
x
=
aEvent
.
GetX
();
m_mousePosition
.
y
=
aEvent
.
GetY
();
if
(
m_snappingEnabled
)
m_cursorPosition
=
m_view
->
GetGAL
()
->
GetGridPoint
(
m_mousePosition
);
else
m_cursorPosition
=
m_mousePosition
;
bool
isAutoPanning
=
false
;
if
(
m_autoPanEnabled
)
...
...
@@ -210,15 +211,6 @@ void WX_VIEW_CONTROLS::SetGrabMouse( bool aEnabled )
}
VECTOR2D
WX_VIEW_CONTROLS
::
GetCursorPosition
()
const
{
if
(
m_snappingEnabled
)
return
m_view
->
GetGAL
()
->
GetGridPoint
(
m_mousePosition
);
return
m_mousePosition
;
}
bool
WX_VIEW_CONTROLS
::
handleAutoPanning
(
const
wxMouseEvent
&
aEvent
)
{
VECTOR2D
p
(
aEvent
.
GetX
(),
aEvent
.
GetY
()
);
...
...
include/view/view_controls.h
View file @
dbbe628b
...
...
@@ -46,23 +46,31 @@ class VIEW;
class
VIEW_CONTROLS
{
public
:
VIEW_CONTROLS
(
VIEW
*
aView
)
:
m_view
(
aView
)
{};
VIEW_CONTROLS
(
VIEW
*
aView
)
:
m_view
(
aView
),
m_snappingEnabled
(
false
),
m_grabMouse
(
false
),
m_autoPanEnabled
(
false
),
m_autoPanMargin
(
0
.
1
),
m_autoPanSpeed
(
0
.
15
)
{};
virtual
~
VIEW_CONTROLS
()
{};
/**
* Function
Activate
*
Determines if all view related events (mouse wheel, right click panning, etc.), should be
*
handled or not. If not - they can be processed by the legacy view.
* @param aEnabled
tells if events should be hand
led.
* Function
SetSnapping()
*
Enables/disables snapping cursor to grid.
*
* @param aEnabled
says whether the opion should be enabled or disab
led.
*/
virtual
void
Activate
(
bool
aEnabled
)
{};
void
SetSnapping
(
bool
aEnabled
)
{
m_snappingEnabled
=
aEnabled
;
}
/**
* Function SetGrabMouse
* Turns on/off mouse grabbing. When the mouse is grabbed, it cannot go outside the VIEW.
* @param aEnabled tells if mouse should be grabbed or not.
*/
virtual
void
SetGrabMouse
(
bool
aEnabled
)
{};
virtual
void
SetGrabMouse
(
bool
aEnabled
)
{
m_grabMouse
=
aEnabled
;
}
/**
* Function SetAutoPan
...
...
@@ -70,36 +78,90 @@ public:
* track) and user moves mouse to the VIEW edge - then the view can be translated or not).
* @param aEnabled tells if the autopanning should be active.
*/
virtual
void
SetAutoPan
(
bool
aEnabled
)
{}
virtual
void
SetAutoPan
(
bool
aEnabled
)
{
m_autoPanEnabled
=
aEnabled
;
}
/**
* Function Set
PanSpeed
* Sets speed of panning.
* @param aSpeed is a new speed for panning.
* Function Set
AutoPanSpeed()
* Sets speed of
auto
panning.
* @param aSpeed is a new speed for
auto
panning.
*/
virtual
void
SetPanSpeed
(
float
aSpeed
)
{};
virtual
void
SetAutoPanSpeed
(
float
aSpeed
)
{
m_autoPanSpeed
=
aSpeed
;
}
/**
* Function Set
ZoomSpeed
*
Determines how much zoom factor should be affected on one zoom event (eg. mouse wheel
).
* @param aSpeed is a new
zooming speed
.
* Function Set
AutoPanMArgin()
*
Sets margin for autopanning (ie. the area when autopanning becomes active
).
* @param aSpeed is a new
margin for autopanning
.
*/
virtual
void
SetZoomSpeed
(
float
aSpeed
)
{};
virtual
void
SetAutoPanMargin
(
float
aMargin
)
{
m_autoPanMargin
=
aMargin
;
};
/**
* Function AnimatedZoom
* // TODO
* Function GetMousePosition()
* Returns the current mouse pointer position in the screen coordinates. Note, that it may be
* different from the cursor position if snapping is enabled (@see GetCursorPosition()).
*
* @return The current mouse pointer position.
*/
virtual
void
AnimatedZoom
(
const
BOX2I
&
aExtents
)
{};
virtual
const
VECTOR2D
&
GetMousePosition
()
const
{
return
m_mousePosition
;
}
virtual
void
WarpCursor
(
const
VECTOR2D
&
aPosition
)
{};
virtual
void
ShowCursor
(
bool
aEnabled
)
{};
/**
* Function GetCursorPosition()
* Returns the current cursor position in the screen coordinates. Note, that it may be
* different from the mouse pointer position if snapping is enabled (@see GetMousePosition()).
*
* @return The current cursor position in screen coordinates.
*/
virtual
const
VECTOR2D
&
GetCursorPosition
()
const
{
return
m_cursorPosition
;
}
/**
* Function SetCursorPosition()
* Allows to move the cursor to a different location.
*
* @param aPosition is the new location expressed in screen coordinates.
*/
virtual
void
SetCursorPosition
(
const
VECTOR2D
&
aPosition
)
{
m_cursorPosition
=
aPosition
;
}
protected
:
/// Pointer to controlled VIEW.
VIEW
*
m_view
;
/// Current mouse position
VECTOR2D
m_mousePosition
;
/// Current cursor position
VECTOR2D
m_cursorPosition
;
/// Should the cursor snap to grid or move freely
bool
m_snappingEnabled
;
/// Flag for grabbing the mouse cursor
bool
m_grabMouse
;
/// Flag for turning on autopanning
bool
m_autoPanEnabled
;
/// Distance from cursor to VIEW edge when panning is active
float
m_autoPanMargin
;
/// How fast is panning when in auto mode
float
m_autoPanSpeed
;
};
}
// namespace KiGfx
...
...
include/view/wx_view_controls.h
View file @
dbbe628b
...
...
@@ -65,17 +65,6 @@ public:
*/
void
SetGrabMouse
(
bool
aEnabled
);
/**
* Function SetSnapping()
* Enables/disables snapping cursor to grid.
*
* @param aEnabled says whether the opion should be enabled or disabled.
*/
void
SetSnapping
(
bool
aEnabled
)
{
m_snappingEnabled
=
aEnabled
;
}
/**
* Function SetAutoPan()
* Enables/disables autopanning (panning when mouse cursor reaches the panel border).
...
...
@@ -89,29 +78,8 @@ public:
m_state
=
IDLE
;
}
/**
* Function GetMousePosition()
* Returns the current mouse pointer position in the screen coordinates. Note, that it may be
* different from the cursor position if snapping is enabled (@see GetCursorPosition()).
*
* @return The current mouse pointer position.
*/
const
VECTOR2D
&
GetMousePosition
()
const
{
return
m_mousePosition
;
}
/**
* Function GetCursorPosition()
* Returns the current cursor position in the screen coordinates. Note, that it may be
* different from the mouse pointer position if snapping is enabled (@see GetMousePosition()).
*
* @return The current cursor position.
*/
VECTOR2D
GetCursorPosition
()
const
;
private
:
/// Possible states for WX_VIEW_CONTROLS
enum
State
{
IDLE
=
1
,
DRAG_PANNING
,
...
...
@@ -131,24 +99,6 @@ private:
/// Current state of VIEW_CONTROLS
State
m_state
;
/// Current mouse position
VECTOR2D
m_mousePosition
;
/// Flag for grabbing the mouse cursor
bool
m_grabMouse
;
/// Should the cursor snap to grid or move freely
bool
m_snappingEnabled
;
/// Flag for turning on autopanning
bool
m_autoPanEnabled
;
/// Distance from cursor to VIEW edge when panning is active
float
m_autoPanMargin
;
/// How fast is panning when in auto mode
float
m_autoPanSpeed
;
/// Panel that is affected by VIEW_CONTROLS
wxWindow
*
m_parentPanel
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment