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
143f52eb
Commit
143f52eb
authored
Mar 10, 2015
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
VIEW_CONTROLS::CaptureCursor()
parent
a72a0465
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
2 deletions
+56
-2
wx_view_controls.cpp
common/view/wx_view_controls.cpp
+39
-0
view_controls.h
include/view/view_controls.h
+16
-2
wx_view_controls.h
include/view/wx_view_controls.h
+1
-0
No files found.
common/view/wx_view_controls.cpp
View file @
143f52eb
...
...
@@ -53,6 +53,8 @@ WX_VIEW_CONTROLS::WX_VIEW_CONTROLS( VIEW* aView, wxWindow* aParentPanel ) :
m_parentPanel
->
Connect
(
wxEVT_ENTER_WINDOW
,
wxMouseEventHandler
(
WX_VIEW_CONTROLS
::
onEnter
),
NULL
,
this
);
#endif
m_parentPanel
->
Connect
(
wxEVT_LEAVE_WINDOW
,
wxMouseEventHandler
(
WX_VIEW_CONTROLS
::
onLeave
),
NULL
,
this
);
m_panTimer
.
SetOwner
(
this
);
this
->
Connect
(
wxEVT_TIMER
,
...
...
@@ -211,6 +213,43 @@ void WX_VIEW_CONTROLS::onEnter( wxMouseEvent& aEvent )
}
void
WX_VIEW_CONTROLS
::
onLeave
(
wxMouseEvent
&
aEvent
)
{
if
(
m_cursorCaptured
)
{
bool
warp
=
false
;
int
x
=
aEvent
.
GetX
();
int
y
=
aEvent
.
GetY
();
wxSize
parentSize
=
m_parentPanel
->
GetClientSize
();
if
(
x
<
0
)
{
x
=
0
;
warp
=
true
;
}
else
if
(
x
>=
parentSize
.
x
)
{
x
=
parentSize
.
x
-
1
;
warp
=
true
;
}
if
(
y
<
0
)
{
y
=
0
;
warp
=
true
;
}
else
if
(
y
>=
parentSize
.
y
)
{
y
=
parentSize
.
y
-
1
;
warp
=
true
;
}
if
(
warp
)
m_parentPanel
->
WarpPointer
(
x
,
y
);
}
}
void
WX_VIEW_CONTROLS
::
onTimer
(
wxTimerEvent
&
aEvent
)
{
switch
(
m_state
)
...
...
include/view/view_controls.h
View file @
143f52eb
...
...
@@ -47,8 +47,9 @@ class VIEW_CONTROLS
{
public
:
VIEW_CONTROLS
(
VIEW
*
aView
)
:
m_view
(
aView
),
m_minScale
(
4
.
0
),
m_maxScale
(
15000
),
m_forceCursorPosition
(
false
),
m_snappingEnabled
(
false
),
m_grabMouse
(
false
),
m_autoPanEnabled
(
false
),
m_autoPanMargin
(
0
.
1
),
m_autoPanSpeed
(
0
.
15
)
m_forceCursorPosition
(
false
),
m_cursorCaptured
(
false
),
m_snappingEnabled
(
false
),
m_grabMouse
(
false
),
m_autoPanEnabled
(
false
),
m_autoPanMargin
(
0
.
1
),
m_autoPanSpeed
(
0
.
15
)
{
m_panBoundary
.
SetMaximum
();
}
...
...
@@ -171,6 +172,16 @@ public:
*/
virtual
void
ShowCursor
(
bool
aEnabled
);
/**
* Function CaptureCursor()
* Forces the cursor to stay within the drawing panel area.
* @param aEnabled determines if the cursor should be captured.
*/
virtual
void
CaptureCursor
(
bool
aEnabled
)
{
m_cursorCaptured
=
aEnabled
;
}
protected
:
/// Sets center for VIEW, takes into account panning boundaries.
void
setCenter
(
const
VECTOR2D
&
aCenter
);
...
...
@@ -199,6 +210,9 @@ protected:
/// Is the forced cursor position enabled
bool
m_forceCursorPosition
;
/// Should the cursor be locked within the parent window area
bool
m_cursorCaptured
;
/// Should the cursor snap to grid or move freely
bool
m_snappingEnabled
;
...
...
include/view/wx_view_controls.h
View file @
143f52eb
...
...
@@ -56,6 +56,7 @@ public:
void
onMotion
(
wxMouseEvent
&
aEvent
);
void
onButton
(
wxMouseEvent
&
aEvent
);
void
onEnter
(
wxMouseEvent
&
WXUNUSED
(
aEvent
)
);
void
onLeave
(
wxMouseEvent
&
WXUNUSED
(
aEvent
)
);
void
onTimer
(
wxTimerEvent
&
WXUNUSED
(
aEvent
)
);
/**
...
...
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