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
88ee2884
Commit
88ee2884
authored
Sep 18, 2013
by
tomasz.wlostowski@cern.ch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
VIEW_CONTROLS: added ForceCursorPosition() and ShowCursor() methods
parent
dea79320
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
27 deletions
+39
-27
wx_view_controls.cpp
common/view/wx_view_controls.cpp
+23
-20
view_controls.h
include/view/view_controls.h
+16
-7
No files found.
common/view/wx_view_controls.cpp
View file @
88ee2884
...
...
@@ -28,7 +28,6 @@
#include <view/view.h>
#include <view/wx_view_controls.h>
#include <gal/graphics_abstraction_layer.h>
#include <tool/tool_dispatcher.h>
using
namespace
KiGfx
;
...
...
@@ -59,13 +58,19 @@ WX_VIEW_CONTROLS::WX_VIEW_CONTROLS( VIEW* aView, wxWindow* aParentPanel ) :
WX_VIEW_CONTROLS
::
onTimer
),
NULL
,
this
);
}
void
VIEW_CONTROLS
::
ShowCursor
(
bool
aEnabled
)
{
m_view
->
GetGAL
()
->
SetCursorEnabled
(
aEnabled
);
}
void
WX_VIEW_CONTROLS
::
onMotion
(
wxMouseEvent
&
aEvent
)
{
m_mousePosition
.
x
=
aEvent
.
GetX
();
m_mousePosition
.
y
=
aEvent
.
GetY
();
if
(
m_snappingEnabled
)
if
(
m_forceCursorPosition
)
m_cursorPosition
=
m_view
->
ToScreen
(
m_forcedPosition
);
else
if
(
m_snappingEnabled
)
m_cursorPosition
=
m_view
->
GetGAL
()
->
GetGridPoint
(
m_mousePosition
);
else
m_cursorPosition
=
m_mousePosition
;
...
...
@@ -185,28 +190,26 @@ void WX_VIEW_CONTROLS::onTimer( wxTimerEvent& aEvent )
{
switch
(
m_state
)
{
case
AUTO_PANNING
:
{
double
borderSize
=
std
::
min
(
m_autoPanMargin
*
m_view
->
GetScreenPixelSize
().
x
,
m_autoPanMargin
*
m_view
->
GetScreenPixelSize
().
y
);
VECTOR2D
dir
(
m_panDirection
);
if
(
dir
.
EuclideanNorm
()
>
borderSize
)
dir
=
dir
.
Resize
(
borderSize
);
case
AUTO_PANNING
:
{
double
borderSize
=
std
::
min
(
m_autoPanMargin
*
m_view
->
GetScreenPixelSize
().
x
,
m_autoPanMargin
*
m_view
->
GetScreenPixelSize
().
y
);
dir
=
m_view
->
ToWorld
(
dir
,
false
);
m_view
->
SetCenter
(
m_view
->
GetCenter
()
+
dir
*
m_autoPanSpeed
);
VECTOR2D
dir
(
m_panDirection
);
// Notify tools that the cursor position has changed in the world coordinates
wxCommandEvent
moveEvent
(
TOOL_DISPATCHER
::
EVT_REFRESH_MOUSE
);
wxPostEvent
(
m_parentPanel
,
moveEvent
);
}
break
;
if
(
dir
.
EuclideanNorm
()
>
borderSize
)
dir
=
dir
.
Resize
(
borderSize
);
case
IDLE
:
// Just remove unnecessary warnings
case
DRAG_PANNING
:
dir
=
m_view
->
ToWorld
(
dir
,
false
);
m_view
->
SetCenter
(
m_view
->
GetCenter
()
+
dir
*
m_autoPanSpeed
);
m_parentPanel
->
Refresh
();
}
break
;
case
IDLE
:
// Just remove unnecessary warnings
case
DRAG_PANNING
:
break
;
}
}
...
...
include/view/view_controls.h
View file @
88ee2884
...
...
@@ -127,17 +127,21 @@ public:
return
m_cursorPosition
;
}
/**
* Function SetCursorPosition()
* Allows to move the cursor to a different location.
*
* @param aPosition is the new location expressed in screen coordinates.
/**
* Function ForceCursorPosition()
* Places the cursor immediately at a given point. Mouse movement is ignored.
* @param aEnabled enable forced cursor position
* @param aPosition the position
*/
virtual
void
SetCursorPosition
(
const
VECTOR2D
&
aPosition
)
virtual
void
ForceCursorPosition
(
bool
aEnabled
,
const
VECTOR2D
&
aPosition
=
VECTOR2D
(
0
,
0
)
)
{
m_cursorPosition
=
aPosition
;
m_forcedPosition
=
aPosition
;
m_forceCursorPosition
=
aEnabled
;
}
virtual
void
ShowCursor
(
bool
aEnabled
);
protected
:
/// Pointer to controlled VIEW.
VIEW
*
m_view
;
...
...
@@ -148,6 +152,9 @@ protected:
/// Current cursor position
VECTOR2D
m_cursorPosition
;
/// Forced cursor position
VECTOR2D
m_forcedPosition
;
/// Should the cursor snap to grid or move freely
bool
m_snappingEnabled
;
...
...
@@ -157,6 +164,8 @@ protected:
/// Flag for turning on autopanning
bool
m_autoPanEnabled
;
bool
m_forceCursorPosition
;
/// Distance from cursor to VIEW edge when panning is active
float
m_autoPanMargin
;
...
...
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