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
89a138c0
Commit
89a138c0
authored
Aug 21, 2013
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added handling keyboard events for the Tool framework.
parent
5adba827
Changes
14
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
224 additions
and
145 deletions
+224
-145
drawframe.cpp
common/drawframe.cpp
+1
-0
drawpanel.cpp
common/drawpanel.cpp
+0
-1
drawpanel_gal.cpp
common/drawpanel_gal.cpp
+19
-11
cairo_gal.cpp
common/gal/cairo/cairo_gal.cpp
+7
-8
opengl_gal.cpp
common/gal/opengl/opengl_gal.cpp
+7
-8
tool_dispatcher.cpp
common/tool/tool_dispatcher.cpp
+47
-30
tool_event.cpp
common/tool/tool_event.cpp
+33
-9
wx_view_controls.cpp
common/view/wx_view_controls.cpp
+19
-19
class_drawpanel_gal.h
include/class_drawpanel_gal.h
+1
-0
cairo_gal.h
include/gal/cairo/cairo_gal.h
+1
-1
tool_dispatcher.h
include/tool/tool_dispatcher.h
+7
-9
tool_event.h
include/tool/tool_event.h
+77
-44
wx_view_controls.h
include/view/wx_view_controls.h
+4
-4
selection_tool.cpp
pcbnew/tools/selection_tool.cpp
+1
-1
No files found.
common/drawframe.cpp
View file @
89a138c0
...
...
@@ -1017,5 +1017,6 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
m_auimgr
.
GetPane
(
wxT
(
"DrawFrameGal"
)
).
Show
(
aEnable
);
m_auimgr
.
Update
();
m_galCanvas
->
SetFocus
();
m_galCanvasActive
=
aEnable
;
}
common/drawpanel.cpp
View file @
89a138c0
...
...
@@ -1334,7 +1334,6 @@ void EDA_DRAW_PANEL::OnKeyEvent( wxKeyEvent& event )
Screen
->
SetMousePosition
(
pos
);
GetParent
()
->
GeneralControl
(
&
DC
,
pos
,
localkey
);
}
...
...
common/drawpanel_gal.cpp
View file @
89a138c0
...
...
@@ -96,6 +96,7 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
Connect
(
wxEVT_MIDDLE_UP
,
wxEventHandler
(
EDA_DRAW_PANEL_GAL
::
onEvent
),
NULL
,
this
);
Connect
(
wxEVT_MIDDLE_DOWN
,
wxEventHandler
(
EDA_DRAW_PANEL_GAL
::
onEvent
),
NULL
,
this
);
Connect
(
wxEVT_MOUSEWHEEL
,
wxEventHandler
(
EDA_DRAW_PANEL_GAL
::
onEvent
),
NULL
,
this
);
Connect
(
wxEVT_CHAR_HOOK
,
wxEventHandler
(
EDA_DRAW_PANEL_GAL
::
skipEvent
),
NULL
,
this
);
Connect
(
wxEVT_KEY_UP
,
wxEventHandler
(
EDA_DRAW_PANEL_GAL
::
onEvent
),
NULL
,
this
);
Connect
(
wxEVT_KEY_DOWN
,
wxEventHandler
(
EDA_DRAW_PANEL_GAL
::
onEvent
),
NULL
,
this
);
}
...
...
@@ -209,3 +210,10 @@ void EDA_DRAW_PANEL_GAL::onEvent( wxEvent& aEvent )
m_eventDispatcher
->
DispatchWxEvent
(
aEvent
);
}
}
void
EDA_DRAW_PANEL_GAL
::
skipEvent
(
wxEvent
&
aEvent
)
{
// This is necessary for CHAR_HOOK event to generate KEY_UP and KEY_DOWN events
aEvent
.
Skip
();
}
common/gal/cairo/cairo_gal.cpp
View file @
89a138c0
...
...
@@ -56,13 +56,12 @@ CAIRO_GAL::CAIRO_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
// Mouse events are skipped to the parent
Connect
(
wxEVT_MOTION
,
wxMouseEventHandler
(
CAIRO_GAL
::
skipMouseEvent
)
);
Connect
(
wxEVT_MOUSEWHEEL
,
wxMouseEventHandler
(
CAIRO_GAL
::
skipMouseEvent
)
);
Connect
(
wxEVT_RIGHT_DOWN
,
wxMouseEventHandler
(
CAIRO_GAL
::
skipMouseEvent
)
);
Connect
(
wxEVT_RIGHT_UP
,
wxMouseEventHandler
(
CAIRO_GAL
::
skipMouseEvent
)
);
Connect
(
wxEVT_LEFT_DOWN
,
wxMouseEventHandler
(
CAIRO_GAL
::
skipMouseEvent
)
);
Connect
(
wxEVT_LEFT_UP
,
wxMouseEventHandler
(
CAIRO_GAL
::
skipMouseEvent
)
);
Connect
(
wxEVT_MIDDLE_DOWN
,
wxMouseEventHandler
(
CAIRO_GAL
::
skipMouseEvent
)
);
Connect
(
wxEVT_MIDDLE_UP
,
wxMouseEventHandler
(
CAIRO_GAL
::
skipMouseEvent
)
);
Connect
(
wxEVT_RIGHT_DOWN
,
wxMouseEventHandler
(
CAIRO_GAL
::
skipMouseEvent
)
);
Connect
(
wxEVT_RIGHT_UP
,
wxMouseEventHandler
(
CAIRO_GAL
::
skipMouseEvent
)
);
#if defined _WIN32 || defined _WIN64
Connect
(
wxEVT_ENTER_WINDOW
,
wxMouseEventHandler
(
CAIRO_GAL
::
skipMouseEvent
)
);
#endif
...
...
common/gal/opengl/opengl_gal.cpp
View file @
89a138c0
...
...
@@ -70,13 +70,12 @@ OPENGL_GAL::OPENGL_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
// Mouse events are skipped to the parent
Connect
(
wxEVT_MOTION
,
wxMouseEventHandler
(
OPENGL_GAL
::
skipMouseEvent
)
);
Connect
(
wxEVT_MOUSEWHEEL
,
wxMouseEventHandler
(
OPENGL_GAL
::
skipMouseEvent
)
);
Connect
(
wxEVT_RIGHT_DOWN
,
wxMouseEventHandler
(
OPENGL_GAL
::
skipMouseEvent
)
);
Connect
(
wxEVT_RIGHT_UP
,
wxMouseEventHandler
(
OPENGL_GAL
::
skipMouseEvent
)
);
Connect
(
wxEVT_LEFT_DOWN
,
wxMouseEventHandler
(
OPENGL_GAL
::
skipMouseEvent
)
);
Connect
(
wxEVT_LEFT_UP
,
wxMouseEventHandler
(
OPENGL_GAL
::
skipMouseEvent
)
);
Connect
(
wxEVT_MIDDLE_DOWN
,
wxMouseEventHandler
(
OPENGL_GAL
::
skipMouseEvent
)
);
Connect
(
wxEVT_MIDDLE_UP
,
wxMouseEventHandler
(
OPENGL_GAL
::
skipMouseEvent
)
);
Connect
(
wxEVT_RIGHT_DOWN
,
wxMouseEventHandler
(
OPENGL_GAL
::
skipMouseEvent
)
);
Connect
(
wxEVT_RIGHT_UP
,
wxMouseEventHandler
(
OPENGL_GAL
::
skipMouseEvent
)
);
#if defined _WIN32 || defined _WIN64
Connect
(
wxEVT_ENTER_WINDOW
,
wxMouseEventHandler
(
OPENGL_GAL
::
skipMouseEvent
)
);
#endif
...
...
common/tool/tool_dispatcher.cpp
View file @
89a138c0
...
...
@@ -44,7 +44,7 @@ using boost::optional;
struct
TOOL_DISPATCHER
::
ButtonState
{
ButtonState
(
TOOL_MouseButtons
aButton
,
const
wxEventType
&
aDownEvent
,
const
wxEventType
&
aUpEvent
,
bool
aTriggerMenu
=
false
)
:
const
wxEventType
&
aUpEvent
,
bool
aTriggerMenu
=
false
)
:
button
(
aButton
),
downEvent
(
aDownEvent
),
upEvent
(
aUpEvent
),
...
...
@@ -72,8 +72,8 @@ struct TOOL_DISPATCHER::ButtonState
};
TOOL_DISPATCHER
::
TOOL_DISPATCHER
(
TOOL_MANAGER
*
aToolMgr
,
PCB_BASE_FRAME
*
aEditFrame
)
:
m_toolMgr
(
aToolMgr
),
m_editFrame
(
aEditFrame
)
TOOL_DISPATCHER
::
TOOL_DISPATCHER
(
TOOL_MANAGER
*
aToolMgr
,
PCB_BASE_FRAME
*
aEditFrame
)
:
m_toolMgr
(
aToolMgr
),
m_editFrame
(
aEditFrame
)
{
m_buttons
.
push_back
(
new
ButtonState
(
MB_Left
,
wxEVT_LEFT_DOWN
,
wxEVT_LEFT_UP
)
);
m_buttons
.
push_back
(
new
ButtonState
(
MB_Right
,
wxEVT_RIGHT_DOWN
,
wxEVT_RIGHT_UP
,
true
)
);
...
...
@@ -103,23 +103,22 @@ KiGfx::VIEW* TOOL_DISPATCHER::getView()
}
int
TOOL_DISPATCHER
::
decodeModifiers
(
wxEvent
&
aEvent
)
int
TOOL_DISPATCHER
::
decodeModifiers
(
const
wxKeyboardState
*
aState
)
const
{
wxMouseEvent
*
me
=
static_cast
<
wxMouseEvent
*>
(
&
aEvent
);
int
mods
=
0
;
if
(
m
e
->
ControlDown
()
)
mods
|=
M
B
_ModCtrl
;
if
(
m
e
->
AltDown
()
)
mods
|=
M
B
_ModAlt
;
if
(
m
e
->
ShiftDown
()
)
mods
|=
M
B
_ModShift
;
if
(
aStat
e
->
ControlDown
()
)
mods
|=
M
D
_ModCtrl
;
if
(
aStat
e
->
AltDown
()
)
mods
|=
M
D
_ModAlt
;
if
(
aStat
e
->
ShiftDown
()
)
mods
|=
M
D
_ModShift
;
return
mods
;
}
bool
TOOL_DISPATCHER
::
handleMouseButton
(
wxEvent
&
aEvent
,
int
aIndex
,
bool
aMotion
)
bool
TOOL_DISPATCHER
::
handleMouseButton
(
wxEvent
&
aEvent
,
int
aIndex
,
bool
aMotion
)
{
ButtonState
*
st
=
m_buttons
[
aIndex
];
wxEventType
type
=
aEvent
.
GetEventType
();
...
...
@@ -128,7 +127,7 @@ bool TOOL_DISPATCHER::handleMouseButton ( wxEvent& aEvent, int aIndex, bool aMot
bool
up
=
type
==
st
->
upEvent
;
bool
down
=
type
==
st
->
downEvent
;
int
mods
=
decodeModifiers
(
aEvent
);
int
mods
=
decodeModifiers
(
static_cast
<
wxMouseEvent
*>
(
&
aEvent
)
);
int
args
=
st
->
button
|
mods
;
if
(
down
)
...
...
@@ -139,7 +138,7 @@ bool TOOL_DISPATCHER::handleMouseButton ( wxEvent& aEvent, int aIndex, bool aMot
st
->
pressed
=
true
;
evt
=
TOOL_EVENT
(
TC_Mouse
,
TA_MouseDown
,
args
);
}
else
if
(
up
)
else
if
(
up
)
{
bool
isClick
=
false
;
st
->
pressed
=
false
;
...
...
@@ -148,7 +147,8 @@ bool TOOL_DISPATCHER::handleMouseButton ( wxEvent& aEvent, int aIndex, bool aMot
{
wxLongLong
t
=
wxGetLocalTimeMillis
();
if
(
t
-
st
->
downTimestamp
<
DragTimeThreshold
&&
st
->
dragMaxDelta
<
DragDistanceThreshold
)
if
(
t
-
st
->
downTimestamp
<
DragTimeThreshold
&&
st
->
dragMaxDelta
<
DragDistanceThreshold
)
isClick
=
true
;
else
evt
=
TOOL_EVENT
(
TC_Mouse
,
TA_MouseUp
,
args
);
...
...
@@ -159,7 +159,7 @@ bool TOOL_DISPATCHER::handleMouseButton ( wxEvent& aEvent, int aIndex, bool aMot
if
(
isClick
)
{
if
(
st
->
triggerContextMenu
&&
!
mods
)
if
(
st
->
triggerContextMenu
&&
!
mods
)
{}
// evt = TOOL_EVENT( TC_Command, TA_ContextMenu );
else
...
...
@@ -197,7 +197,7 @@ bool TOOL_DISPATCHER::handleMouseButton ( wxEvent& aEvent, int aIndex, bool aMot
}
void
TOOL_DISPATCHER
::
DispatchWxEvent
(
wxEvent
&
aEvent
)
void
TOOL_DISPATCHER
::
DispatchWxEvent
(
wxEvent
&
aEvent
)
{
bool
motion
=
false
,
buttonEvents
=
false
;
VECTOR2D
pos
;
...
...
@@ -205,25 +205,42 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent &aEvent )
int
type
=
aEvent
.
GetEventType
();
if
(
type
==
wxEVT_MOTION
)
// Mouse handling
if
(
type
==
wxEVT_MOTION
||
type
==
wxEVT_MOUSEWHEEL
||
type
==
wxEVT_LEFT_DOWN
||
type
==
wxEVT_LEFT_UP
||
type
==
wxEVT_MIDDLE_DOWN
||
type
==
wxEVT_MIDDLE_UP
||
type
==
wxEVT_RIGHT_DOWN
||
type
==
wxEVT_RIGHT_UP
)
{
wxMouseEvent
*
me
=
static_cast
<
wxMouseEvent
*>
(
&
aEvent
);
wxMouseEvent
*
me
=
static_cast
<
wxMouseEvent
*>
(
&
aEvent
);
pos
=
getView
()
->
ToWorld
(
VECTOR2D
(
me
->
GetX
(),
me
->
GetY
()
)
);
if
(
pos
!=
m_lastMousePos
)
{
motion
=
true
;
m_lastMousePos
=
pos
;
}
}
for
(
unsigned
int
i
=
0
;
i
<
m_buttons
.
size
();
i
++
)
buttonEvents
|=
handleMouseButton
(
aEvent
,
i
,
motion
);
if
(
!
buttonEvents
&&
motion
)
{
evt
=
TOOL_EVENT
(
TC_Mouse
,
TA_MouseMotion
);
evt
=
TOOL_EVENT
(
TC_Mouse
,
TA_MouseMotion
);
evt
->
SetMousePosition
(
pos
);
}
}
// Keyboard handling
else
if
(
type
==
wxEVT_KEY_UP
||
type
==
wxEVT_KEY_DOWN
)
{
wxKeyEvent
*
ke
=
static_cast
<
wxKeyEvent
*>
(
&
aEvent
);
int
key
=
ke
->
GetKeyCode
();
int
mods
=
decodeModifiers
(
ke
);
if
(
type
==
wxEVT_KEY_UP
)
evt
=
TOOL_EVENT
(
TC_Keyboard
,
TA_KeyUp
,
key
|
mods
);
else
evt
=
TOOL_EVENT
(
TC_Keyboard
,
TA_KeyDown
,
key
|
mods
);
}
if
(
evt
)
m_toolMgr
->
ProcessEvent
(
*
evt
);
...
...
@@ -237,7 +254,7 @@ void TOOL_DISPATCHER::DispatchWxCommand( wxCommandEvent &aEvent )
bool
activateTool
=
false
;
std
::
string
toolName
;
switch
(
aEvent
.
GetId
()
)
switch
(
aEvent
.
GetId
()
)
{
case
ID_SELECTION_TOOL
:
toolName
=
"pcbnew.InteractiveSelection"
;
...
...
@@ -247,7 +264,7 @@ void TOOL_DISPATCHER::DispatchWxCommand( wxCommandEvent &aEvent )
if
(
activateTool
)
{
TOOL_EVENT
evt
(
TC_Command
,
TA_ActivateTool
,
toolName
);
TOOL_EVENT
evt
(
TC_Command
,
TA_ActivateTool
,
toolName
);
m_toolMgr
->
ProcessEvent
(
evt
);
}
}
common/tool/tool_event.cpp
View file @
89a138c0
...
...
@@ -44,9 +44,13 @@ struct FlagString
static
const
std
::
string
flag2string
(
int
flag
,
const
FlagString
*
exps
)
{
std
::
string
rv
;
for
(
int
i
=
0
;
exps
[
i
].
str
.
length
();
i
++
)
if
(
exps
[
i
].
flag
&
flag
)
rv
+=
exps
[
i
].
str
+
" "
;
for
(
int
i
=
0
;
exps
[
i
].
str
.
length
();
i
++
)
{
if
(
exps
[
i
].
flag
&
flag
)
rv
+=
exps
[
i
].
str
+
" "
;
}
return
rv
;
}
...
...
@@ -57,6 +61,7 @@ const std::string TOOL_EVENT::Format() const
const
FlagString
categories
[]
=
{
{
TC_Mouse
,
"mouse"
},
{
TC_Keyboard
,
"keyboard"
},
{
TC_Command
,
"command"
},
{
TC_Message
,
"message"
},
{
TC_View
,
"view"
},
...
...
@@ -70,6 +75,8 @@ const std::string TOOL_EVENT::Format() const
{
TA_MouseDrag
,
"drag"
},
{
TA_MouseMotion
,
"motion"
},
{
TA_MouseWheel
,
"wheel"
},
{
TA_KeyUp
,
"key-up"
},
{
TA_KeyDown
,
"key-down"
},
{
TA_ViewRefresh
,
"view-refresh"
},
{
TA_ViewZoom
,
"view-zoom"
},
{
TA_ViewPan
,
"view-pan"
},
...
...
@@ -87,22 +94,39 @@ const std::string TOOL_EVENT::Format() const
{
MB_Left
,
"left"
},
{
MB_Right
,
"right"
},
{
MB_Middle
,
"middle"
},
{
MB_ModShift
,
"shift"
},
{
MB_ModCtrl
,
"ctrl"
},
{
MB_ModAlt
,
"alt"
},
{
0
,
""
}
};
const
FlagString
modifiers
[]
=
{
{
MD_ModShift
,
"shift"
},
{
MD_ModCtrl
,
"ctrl"
},
{
MD_ModAlt
,
"alt"
},
{
0
,
""
}
};
ev
=
"category: "
;
ev
+=
flag2string
(
m_category
,
categories
);
ev
+=
" action: "
;
ev
+=
" action: "
;
ev
+=
flag2string
(
m_actions
,
actions
);
if
(
m_actions
&
TA_Mouse
)
{
ev
+=
" btns: "
;
ev
+=
" btns: "
;
ev
+=
flag2string
(
m_mouseButtons
,
buttons
);
};
}
if
(
m_actions
&
TA_Keyboard
)
{
char
tmp
[
128
];
sprintf
(
tmp
,
"key: %d"
,
m_keyCode
);
ev
+=
tmp
;
}
if
(
m_actions
&
(
TA_Mouse
|
TA_Keyboard
)
)
{
ev
+=
" mods: "
;
ev
+=
flag2string
(
m_modifiers
,
modifiers
);
}
if
(
m_commandId
)
{
...
...
common/view/wx_view_controls.cpp
View file @
89a138c0
...
...
@@ -53,11 +53,11 @@ WX_VIEW_CONTROLS::WX_VIEW_CONTROLS( VIEW* aView, wxWindow* aParentPanel ) :
}
void
WX_VIEW_CONTROLS
::
onMotion
(
wxMouseEvent
&
e
vent
)
void
WX_VIEW_CONTROLS
::
onMotion
(
wxMouseEvent
&
aE
vent
)
{
if
(
e
vent
.
Dragging
()
&&
m_isDragPanning
)
if
(
aE
vent
.
Dragging
()
&&
m_isDragPanning
)
{
VECTOR2D
mousePoint
(
event
.
GetX
(),
e
vent
.
GetY
()
);
VECTOR2D
mousePoint
(
aEvent
.
GetX
(),
aE
vent
.
GetY
()
);
VECTOR2D
d
=
m_dragStartPoint
-
mousePoint
;
VECTOR2D
delta
=
m_view
->
ToWorld
(
d
,
false
);
...
...
@@ -65,19 +65,19 @@ void WX_VIEW_CONTROLS::onMotion( wxMouseEvent& event )
m_parentPanel
->
Refresh
();
}
e
vent
.
Skip
();
aE
vent
.
Skip
();
}
void
WX_VIEW_CONTROLS
::
onWheel
(
wxMouseEvent
&
e
vent
)
void
WX_VIEW_CONTROLS
::
onWheel
(
wxMouseEvent
&
aE
vent
)
{
const
double
wheelPanSpeed
=
0.001
;
if
(
event
.
ControlDown
()
||
e
vent
.
ShiftDown
()
)
if
(
aEvent
.
ControlDown
()
||
aE
vent
.
ShiftDown
()
)
{
// Scrolling
VECTOR2D
scrollVec
=
m_view
->
ToWorld
(
m_view
->
GetScreenPixelSize
()
*
(
(
double
)
e
vent
.
GetWheelRotation
()
*
wheelPanSpeed
),
false
);
(
(
double
)
aE
vent
.
GetWheelRotation
()
*
wheelPanSpeed
),
false
);
double
scrollSpeed
;
if
(
abs
(
scrollVec
.
x
)
>
abs
(
scrollVec
.
y
)
)
...
...
@@ -85,8 +85,8 @@ void WX_VIEW_CONTROLS::onWheel( wxMouseEvent& event )
else
scrollSpeed
=
scrollVec
.
y
;
VECTOR2D
delta
(
e
vent
.
ControlDown
()
?
-
scrollSpeed
:
0.0
,
e
vent
.
ShiftDown
()
?
-
scrollSpeed
:
0.0
);
VECTOR2D
delta
(
aE
vent
.
ControlDown
()
?
-
scrollSpeed
:
0.0
,
aE
vent
.
ShiftDown
()
?
-
scrollSpeed
:
0.0
);
m_view
->
SetCenter
(
m_view
->
GetCenter
()
+
delta
);
m_parentPanel
->
Refresh
();
...
...
@@ -103,41 +103,41 @@ void WX_VIEW_CONTROLS::onWheel( wxMouseEvent& event )
// Set scaling speed depending on scroll wheel event interval
if
(
timeDiff
<
500
&&
timeDiff
>
0
)
{
zoomScale
=
(
e
vent
.
GetWheelRotation
()
>
0.0
)
?
2.05
-
timeDiff
/
500
:
zoomScale
=
(
aE
vent
.
GetWheelRotation
()
>
0.0
)
?
2.05
-
timeDiff
/
500
:
1.0
/
(
2.05
-
timeDiff
/
500
);
}
else
{
zoomScale
=
(
e
vent
.
GetWheelRotation
()
>
0.0
)
?
1.05
:
0.95
;
zoomScale
=
(
aE
vent
.
GetWheelRotation
()
>
0.0
)
?
1.05
:
0.95
;
}
VECTOR2D
anchor
=
m_view
->
ToWorld
(
VECTOR2D
(
event
.
GetX
(),
e
vent
.
GetY
()
)
);
VECTOR2D
anchor
=
m_view
->
ToWorld
(
VECTOR2D
(
aEvent
.
GetX
(),
aE
vent
.
GetY
()
)
);
m_view
->
SetScale
(
m_view
->
GetScale
()
*
zoomScale
,
anchor
);
m_parentPanel
->
Refresh
();
}
e
vent
.
Skip
();
aE
vent
.
Skip
();
}
void
WX_VIEW_CONTROLS
::
onButton
(
wxMouseEvent
&
e
vent
)
void
WX_VIEW_CONTROLS
::
onButton
(
wxMouseEvent
&
aE
vent
)
{
if
(
e
vent
.
MiddleDown
()
)
if
(
aE
vent
.
MiddleDown
()
)
{
m_isDragPanning
=
true
;
m_dragStartPoint
=
VECTOR2D
(
event
.
GetX
(),
e
vent
.
GetY
()
);
m_dragStartPoint
=
VECTOR2D
(
aEvent
.
GetX
(),
aE
vent
.
GetY
()
);
m_lookStartPoint
=
m_view
->
GetCenter
();
}
else
if
(
e
vent
.
MiddleUp
()
)
else
if
(
aE
vent
.
MiddleUp
()
)
{
m_isDragPanning
=
false
;
}
e
vent
.
Skip
();
aE
vent
.
Skip
();
}
void
WX_VIEW_CONTROLS
::
onEnter
(
wxMouseEvent
&
e
vent
)
void
WX_VIEW_CONTROLS
::
onEnter
(
wxMouseEvent
&
aE
vent
)
{
m_parentPanel
->
SetFocus
();
}
include/class_drawpanel_gal.h
View file @
89a138c0
...
...
@@ -115,6 +115,7 @@ protected:
void
onPaint
(
wxPaintEvent
&
WXUNUSED
(
aEvent
)
);
void
onSize
(
wxSizeEvent
&
aEvent
);
void
onEvent
(
wxEvent
&
aEvent
);
void
skipEvent
(
wxEvent
&
aEvent
);
KiGfx
::
GAL
*
m_gal
;
///< Interface for drawing objects on a 2D-surface
KiGfx
::
VIEW
*
m_view
;
///< Stores view settings (scale, center, etc.)
...
...
include/gal/cairo/cairo_gal.h
View file @
89a138c0
include/tool/tool_dispatcher.h
View file @
89a138c0
...
...
@@ -30,6 +30,7 @@
#include <tool/tool_event.h>
#include <wx/event.h>
#include <wx/kbdstate.h>
class
TOOL_MANAGER
;
class
PCB_BASE_FRAME
;
...
...
@@ -69,21 +70,18 @@ private:
static
const
int
DragTimeThreshold
=
300
;
static
const
int
DragDistanceThreshold
=
8
;
bool
handleMouseButton
(
wxEvent
&
aEvent
,
int
aIndex
,
bool
aMotion
);
bool
handleKeys
(
wxEvent
&
aEvent
);
bool
handlePopupMenu
(
wxEvent
&
aEvent
);
bool
handleMouseButton
(
wxEvent
&
aEvent
,
int
aIndex
,
bool
aMotion
);
bool
handlePopupMenu
(
wxEvent
&
aEvent
);
int
decodeModifiers
(
wxEvent
&
aEvent
);
KiGfx
::
VIEW
*
getView
();
int
decodeModifiers
(
const
wxKeyboardState
*
aState
)
const
;
struct
ButtonState
;
TOOL_MANAGER
*
m_toolMgr
;
PCB_BASE_FRAME
*
m_editFrame
;
VECTOR2D
m_lastMousePos
;
std
::
vector
<
ButtonState
*>
m_buttons
;
KiGfx
::
VIEW
*
getView
();
TOOL_MANAGER
*
m_toolMgr
;
PCB_BASE_FRAME
*
m_editFrame
;
};
#endif
include/tool/tool_event.h
View file @
89a138c0
...
...
@@ -40,28 +40,35 @@ class TOOL_MANAGER;
*/
enum
TOOL_EventCategory
{
TC_None
=
0x0
,
TC_Mouse
=
0x1
,
TC_Command
=
0x2
,
TC_Message
=
0x4
,
TC_View
=
0x8
,
TC_None
=
0x00
,
TC_Mouse
=
0x01
,
TC_Keyboard
=
0x02
,
TC_Command
=
0x04
,
TC_Message
=
0x08
,
TC_View
=
0x10
,
TC_Any
=
0xffffffff
};
enum
TOOL_Actions
{
TA_None
=
0x0
,
TA_MouseClick
=
0x1
,
TA_MouseUp
=
0x2
,
TA_MouseDown
=
0x4
,
TA_MouseDrag
=
0x8
,
TA_MouseMotion
=
0x10
,
TA_MouseWheel
=
0x20
,
TA_Mouse
=
0x3f
,
TA_ViewRefresh
=
0x40
,
TA_ViewZoom
=
0x80
,
TA_ViewPan
=
0x100
,
TA_ViewDirty
=
0x200
,
// UI input events
TA_None
=
0x0000
,
TA_MouseClick
=
0x0001
,
TA_MouseUp
=
0x0002
,
TA_MouseDown
=
0x0004
,
TA_MouseDrag
=
0x0008
,
TA_MouseMotion
=
0x0010
,
TA_MouseWheel
=
0x0020
,
TA_Mouse
=
0x003f
,
TA_KeyUp
=
0x0040
,
TA_KeyDown
=
0x0080
,
TA_Keyboard
=
TA_KeyUp
|
TA_KeyDown
,
// View related events
TA_ViewRefresh
=
0x0100
,
TA_ViewZoom
=
0x0200
,
TA_ViewPan
=
0x0400
,
TA_ViewDirty
=
0x0800
,
TA_ChangeLayer
=
0x1000
,
// Tool cancel event. Issued automagically when the user hits escape or selects End Tool from the context menu.
...
...
@@ -86,13 +93,16 @@ enum TOOL_MouseButtons
MB_Right
=
0x2
,
MB_Middle
=
0x4
,
MB_ButtonMask
=
MB_Left
|
MB_Right
|
MB_Middle
,
MB_ModShift
=
0x8
,
MB_ModCtrl
=
0x10
,
MB_ModAlt
=
0x20
,
MB_ModifierMask
=
MB_ModShift
|
MB_ModCtrl
|
MB_ModAlt
,
MB_Any
=
0xffffffff
};
enum
TOOL_Modifiers
{
MD_ModShift
=
0x1000
,
MD_ModCtrl
=
0x2000
,
MD_ModAlt
=
0x4000
,
MD_ModifierMask
=
MD_ModShift
|
MD_ModCtrl
|
MD_ModAlt
,
};
// Defines when a context menu is opened.
enum
TOOL_ContextMenuTrigger
...
...
@@ -112,22 +122,38 @@ class TOOL_EVENT
public
:
const
std
::
string
Format
()
const
;
TOOL_EVENT
(
TOOL_EventCategory
aCategory
=
TC_None
,
TOOL_Actions
aAction
=
TA_None
)
:
TOOL_EVENT
(
TOOL_EventCategory
aCategory
=
TC_None
,
TOOL_Actions
aAction
=
TA_None
)
:
m_category
(
aCategory
),
m_actions
(
aAction
),
m_mouseButtons
(
0
)
{}
m_mouseButtons
(
0
),
m_keyCode
(
0
),
m_modifiers
(
0
)
{}
TOOL_EVENT
(
TOOL_EventCategory
aCategory
,
TOOL_Actions
aAction
,
int
aExtraParam
)
:
TOOL_EVENT
(
TOOL_EventCategory
aCategory
,
TOOL_Actions
aAction
,
int
aExtraParam
)
:
m_category
(
aCategory
),
m_actions
(
aAction
)
{
if
(
aCategory
==
TC_Mouse
)
m_mouseButtons
=
aExtraParam
;
{
m_mouseButtons
=
aExtraParam
&
MB_ButtonMask
;
}
else
if
(
aCategory
==
TC_Keyboard
)
{
m_keyCode
=
aExtraParam
&
~
MD_ModifierMask
;
// Filter out modifiers
}
else
if
(
aCategory
==
TC_Command
)
{
m_commandId
=
aExtraParam
;
}
TOOL_EVENT
(
TOOL_EventCategory
aCategory
,
TOOL_Actions
aAction
,
const
std
::
string
&
aExtraParam
)
:
if
(
aCategory
&
(
TC_Mouse
|
TC_Keyboard
)
)
{
m_modifiers
=
aExtraParam
&
MD_ModifierMask
;
}
}
TOOL_EVENT
(
TOOL_EventCategory
aCategory
,
TOOL_Actions
aAction
,
const
std
::
string
&
aExtraParam
)
:
m_category
(
aCategory
),
m_actions
(
aAction
),
m_mouseButtons
(
0
)
...
...
@@ -193,9 +219,14 @@ public:
return
m_actions
==
TA_CancelTool
;
}
bool
Modifier
(
int
aMask
=
MB_ModifierMask
)
const
bool
Modifier
(
int
aMask
=
MD_ModifierMask
)
const
{
return
(
m_modifiers
&
aMask
);
}
int
KeyCode
()
const
{
return
(
m_mouseButtons
&
aMask
)
;
return
m_keyCode
;
}
void
Ignore
();
...
...
@@ -250,6 +281,8 @@ private:
VECTOR2D
m_mouseDragOrigin
;
int
m_mouseButtons
;
int
m_keyCode
;
int
m_modifiers
;
boost
::
optional
<
int
>
m_commandId
;
boost
::
optional
<
std
::
string
>
m_commandStr
;
};
...
...
@@ -354,7 +387,7 @@ private:
std
::
deque
<
TOOL_EVENT
>
m_events
;
};
inline
const
TOOL_EVENT_LIST
operator
||
(
const
TOOL_EVENT
&
a
,
const
TOOL_EVENT
&
b
)
inline
const
TOOL_EVENT_LIST
operator
||
(
const
TOOL_EVENT
&
a
,
const
TOOL_EVENT
&
b
)
{
TOOL_EVENT_LIST
l
;
...
...
@@ -364,7 +397,7 @@ inline const TOOL_EVENT_LIST operator||( const TOOL_EVENT& a, const TOOL_EVENT &
return
l
;
}
inline
const
TOOL_EVENT_LIST
operator
||
(
const
TOOL_EVENT
&
a
,
const
TOOL_EVENT_LIST
&
b
)
inline
const
TOOL_EVENT_LIST
operator
||
(
const
TOOL_EVENT
&
a
,
const
TOOL_EVENT_LIST
&
b
)
{
TOOL_EVENT_LIST
l
(
b
);
...
...
include/view/wx_view_controls.h
View file @
89a138c0
...
...
@@ -52,10 +52,10 @@ public:
WX_VIEW_CONTROLS
(
VIEW
*
aView
,
wxWindow
*
aParentPanel
);
~
WX_VIEW_CONTROLS
()
{};
void
onWheel
(
wxMouseEvent
&
e
vent
);
void
onMotion
(
wxMouseEvent
&
e
vent
);
void
onButton
(
wxMouseEvent
&
e
vent
);
void
onEnter
(
wxMouseEvent
&
e
vent
);
void
onWheel
(
wxMouseEvent
&
aE
vent
);
void
onMotion
(
wxMouseEvent
&
aE
vent
);
void
onButton
(
wxMouseEvent
&
aE
vent
);
void
onEnter
(
wxMouseEvent
&
aE
vent
);
void
SetEventDispatcher
(
TOOL_DISPATCHER
*
aEventDispatcher
);
...
...
pcbnew/tools/selection_tool.cpp
View file @
89a138c0
...
...
@@ -69,7 +69,7 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent )
// Main loop: keep receiving events
while
(
OPT_TOOL_EVENT
evt
=
Wait
()
)
{
m_additive
=
evt
->
Modifier
(
M
B
_ModShift
);
m_additive
=
evt
->
Modifier
(
M
D
_ModShift
);
if
(
evt
->
IsCancel
()
)
return
0
;
...
...
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