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
c21ae6ef
Commit
c21ae6ef
authored
Nov 28, 2013
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Double click support for the Tool Framework.
parent
183afdd0
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
89 additions
and
56 deletions
+89
-56
drawpanel_gal.cpp
common/drawpanel_gal.cpp
+15
-12
cairo_gal.cpp
common/gal/cairo/cairo_gal.cpp
+11
-8
opengl_gal.cpp
common/gal/opengl/opengl_gal.cpp
+11
-8
tool_dispatcher.cpp
common/tool/tool_dispatcher.cpp
+19
-6
tool_event.cpp
common/tool/tool_event.cpp
+2
-1
tool_event.h
include/tool/tool_event.h
+31
-21
No files found.
common/drawpanel_gal.cpp
View file @
c21ae6ef
...
...
@@ -81,10 +81,13 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
Connect
(
wxEVT_MOTION
,
wxEventHandler
(
EDA_DRAW_PANEL_GAL
::
onEvent
),
NULL
,
this
);
Connect
(
wxEVT_LEFT_UP
,
wxEventHandler
(
EDA_DRAW_PANEL_GAL
::
onEvent
),
NULL
,
this
);
Connect
(
wxEVT_LEFT_DOWN
,
wxEventHandler
(
EDA_DRAW_PANEL_GAL
::
onEvent
),
NULL
,
this
);
Connect
(
wxEVT_LEFT_DCLICK
,
wxEventHandler
(
EDA_DRAW_PANEL_GAL
::
onEvent
),
NULL
,
this
);
Connect
(
wxEVT_RIGHT_UP
,
wxEventHandler
(
EDA_DRAW_PANEL_GAL
::
onEvent
),
NULL
,
this
);
Connect
(
wxEVT_RIGHT_DOWN
,
wxEventHandler
(
EDA_DRAW_PANEL_GAL
::
onEvent
),
NULL
,
this
);
Connect
(
wxEVT_RIGHT_DCLICK
,
wxEventHandler
(
EDA_DRAW_PANEL_GAL
::
onEvent
),
NULL
,
this
);
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_MIDDLE_DCLICK
,
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
)
);
Connect
(
wxEVT_KEY_UP
,
wxEventHandler
(
EDA_DRAW_PANEL_GAL
::
onEvent
),
NULL
,
this
);
...
...
common/gal/cairo/cairo_gal.cpp
View file @
c21ae6ef
...
...
@@ -60,10 +60,13 @@ CAIRO_GAL::CAIRO_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
Connect
(
wxEVT_MOTION
,
wxMouseEventHandler
(
CAIRO_GAL
::
skipMouseEvent
)
);
Connect
(
wxEVT_LEFT_DOWN
,
wxMouseEventHandler
(
CAIRO_GAL
::
skipMouseEvent
)
);
Connect
(
wxEVT_LEFT_UP
,
wxMouseEventHandler
(
CAIRO_GAL
::
skipMouseEvent
)
);
Connect
(
wxEVT_LEFT_DCLICK
,
wxMouseEventHandler
(
CAIRO_GAL
::
skipMouseEvent
)
);
Connect
(
wxEVT_MIDDLE_DOWN
,
wxMouseEventHandler
(
CAIRO_GAL
::
skipMouseEvent
)
);
Connect
(
wxEVT_MIDDLE_UP
,
wxMouseEventHandler
(
CAIRO_GAL
::
skipMouseEvent
)
);
Connect
(
wxEVT_MIDDLE_DCLICK
,
wxMouseEventHandler
(
CAIRO_GAL
::
skipMouseEvent
)
);
Connect
(
wxEVT_RIGHT_DOWN
,
wxMouseEventHandler
(
CAIRO_GAL
::
skipMouseEvent
)
);
Connect
(
wxEVT_RIGHT_UP
,
wxMouseEventHandler
(
CAIRO_GAL
::
skipMouseEvent
)
);
Connect
(
wxEVT_RIGHT_DCLICK
,
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 @
c21ae6ef
...
...
@@ -73,10 +73,13 @@ OPENGL_GAL::OPENGL_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
Connect
(
wxEVT_MOTION
,
wxMouseEventHandler
(
OPENGL_GAL
::
skipMouseEvent
)
);
Connect
(
wxEVT_LEFT_DOWN
,
wxMouseEventHandler
(
OPENGL_GAL
::
skipMouseEvent
)
);
Connect
(
wxEVT_LEFT_UP
,
wxMouseEventHandler
(
OPENGL_GAL
::
skipMouseEvent
)
);
Connect
(
wxEVT_LEFT_DCLICK
,
wxMouseEventHandler
(
OPENGL_GAL
::
skipMouseEvent
)
);
Connect
(
wxEVT_MIDDLE_DOWN
,
wxMouseEventHandler
(
OPENGL_GAL
::
skipMouseEvent
)
);
Connect
(
wxEVT_MIDDLE_UP
,
wxMouseEventHandler
(
OPENGL_GAL
::
skipMouseEvent
)
);
Connect
(
wxEVT_MIDDLE_DCLICK
,
wxMouseEventHandler
(
OPENGL_GAL
::
skipMouseEvent
)
);
Connect
(
wxEVT_RIGHT_DOWN
,
wxMouseEventHandler
(
OPENGL_GAL
::
skipMouseEvent
)
);
Connect
(
wxEVT_RIGHT_UP
,
wxMouseEventHandler
(
OPENGL_GAL
::
skipMouseEvent
)
);
Connect
(
wxEVT_RIGHT_DCLICK
,
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 @
c21ae6ef
...
...
@@ -43,10 +43,11 @@ using boost::optional;
struct
TOOL_DISPATCHER
::
BUTTON_STATE
{
BUTTON_STATE
(
TOOL_MOUSE_BUTTONS
aButton
,
const
wxEventType
&
aDownEvent
,
const
wxEventType
&
aUpEvent
)
:
const
wxEventType
&
aUpEvent
,
const
wxEventType
&
aDblClickEvent
)
:
button
(
aButton
),
downEvent
(
aDownEvent
),
upEvent
(
aUpEvent
)
upEvent
(
aUpEvent
),
dblClickEvent
(
aDblClickEvent
)
{};
///> Flag indicating that dragging is active for the given button.
...
...
@@ -74,6 +75,9 @@ struct TOOL_DISPATCHER::BUTTON_STATE
///> The type of wxEvent that determines mouse button release.
wxEventType
upEvent
;
///> The type of wxEvent that determines mouse button double click.
wxEventType
dblClickEvent
;
///> Time stamp for the last mouse button press event.
wxLongLong
downTimestamp
;
...
...
@@ -89,9 +93,12 @@ struct TOOL_DISPATCHER::BUTTON_STATE
TOOL_DISPATCHER
::
TOOL_DISPATCHER
(
TOOL_MANAGER
*
aToolMgr
,
PCB_BASE_FRAME
*
aEditFrame
)
:
m_toolMgr
(
aToolMgr
),
m_editFrame
(
aEditFrame
)
{
m_buttons
.
push_back
(
new
BUTTON_STATE
(
BUT_LEFT
,
wxEVT_LEFT_DOWN
,
wxEVT_LEFT_UP
)
);
m_buttons
.
push_back
(
new
BUTTON_STATE
(
BUT_RIGHT
,
wxEVT_RIGHT_DOWN
,
wxEVT_RIGHT_UP
)
);
m_buttons
.
push_back
(
new
BUTTON_STATE
(
BUT_MIDDLE
,
wxEVT_MIDDLE_DOWN
,
wxEVT_MIDDLE_UP
)
);
m_buttons
.
push_back
(
new
BUTTON_STATE
(
BUT_LEFT
,
wxEVT_LEFT_DOWN
,
wxEVT_LEFT_UP
,
wxEVT_LEFT_DCLICK
)
);
m_buttons
.
push_back
(
new
BUTTON_STATE
(
BUT_RIGHT
,
wxEVT_RIGHT_DOWN
,
wxEVT_RIGHT_UP
,
wxEVT_RIGHT_DCLICK
)
);
m_buttons
.
push_back
(
new
BUTTON_STATE
(
BUT_MIDDLE
,
wxEVT_MIDDLE_DOWN
,
wxEVT_MIDDLE_UP
,
wxEVT_MIDDLE_DCLICK
)
);
ResetState
();
}
...
...
@@ -126,6 +133,7 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti
bool
up
=
type
==
st
->
upEvent
;
bool
down
=
type
==
st
->
downEvent
;
bool
dblClick
=
type
==
st
->
dblClickEvent
;
int
mods
=
decodeModifiers
<
wxMouseEvent
>
(
static_cast
<
wxMouseEvent
*>
(
&
aEvent
)
);
int
args
=
st
->
button
|
mods
;
...
...
@@ -162,6 +170,10 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti
st
->
dragging
=
false
;
}
else
if
(
dblClick
)
{
evt
=
TOOL_EVENT
(
TC_MOUSE
,
TA_MOUSE_DBLCLICK
,
args
);
}
if
(
st
->
pressed
&&
aMotion
)
{
...
...
@@ -204,8 +216,9 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
type
==
wxEVT_LEFT_DOWN
||
type
==
wxEVT_LEFT_UP
||
type
==
wxEVT_MIDDLE_DOWN
||
type
==
wxEVT_MIDDLE_UP
||
type
==
wxEVT_RIGHT_DOWN
||
type
==
wxEVT_RIGHT_UP
||
type
==
wxEVT_LEFT_DCLICK
||
type
==
wxEVT_MIDDLE_DCLICK
||
type
==
wxEVT_RIGHT_DCLICK
||
// Event issued whem mouse retains position in screen coordinates,
// but changes in world coordinates (eg. autopanning)
// but changes in world coordinates (e
.
g. autopanning)
type
==
KIGFX
::
WX_VIEW_CONTROLS
::
EVT_REFRESH_MOUSE
)
{
VECTOR2D
screenPos
=
m_toolMgr
->
GetViewControls
()
->
GetCursorPosition
();
...
...
common/tool/tool_event.cpp
View file @
c21ae6ef
...
...
@@ -77,6 +77,7 @@ const std::string TOOL_EVENT::Format() const
const
FlagString
actions
[]
=
{
{
TA_MOUSE_CLICK
,
"click"
},
{
TA_MOUSE_DBLCLICK
,
"double click"
},
{
TA_MOUSE_UP
,
"button-up"
},
{
TA_MOUSE_DOWN
,
"button-down"
},
{
TA_MOUSE_DRAG
,
"drag"
},
...
...
include/tool/tool_event.h
View file @
c21ae6ef
...
...
@@ -56,37 +56,41 @@ enum TOOL_ACTIONS
// UI input events
TA_NONE
=
0x0000
,
TA_MOUSE_CLICK
=
0x0001
,
TA_MOUSE_UP
=
0x0002
,
TA_MOUSE_DOWN
=
0x0004
,
TA_MOUSE_DRAG
=
0x0008
,
TA_MOUSE_MOTION
=
0x0010
,
TA_MOUSE_WHEEL
=
0x0020
,
TA_MOUSE
=
0x003f
,
TA_KEY_UP
=
0x0040
,
TA_KEY_DOWN
=
0x0080
,
TA_MOUSE_DBLCLICK
=
0x0002
,
TA_MOUSE_UP
=
0x0004
,
TA_MOUSE_DOWN
=
0x0008
,
TA_MOUSE_DRAG
=
0x0010
,
TA_MOUSE_MOTION
=
0x0020
,
TA_MOUSE_WHEEL
=
0x0040
,
TA_MOUSE
=
0x007f
,
TA_KEY_UP
=
0x0080
,
TA_KEY_DOWN
=
0x0100
,
TA_KEYBOARD
=
TA_KEY_UP
|
TA_KEY_DOWN
,
// View related events
TA_VIEW_REFRESH
=
0x0100
,
TA_VIEW_ZOOM
=
0x0200
,
TA_VIEW_PAN
=
0x0400
,
TA_VIEW_DIRTY
=
0x0800
,
TA_CHANGE_LAYER
=
0x1000
,
TA_VIEW_REFRESH
=
0x0200
,
TA_VIEW_ZOOM
=
0x0400
,
TA_VIEW_PAN
=
0x0800
,
TA_VIEW_DIRTY
=
0x1000
,
TA_VIEW
=
0x1e00
,
TA_CHANGE_LAYER
=
0x2000
,
// Tool cancel event. Issued automagically when the user hits escape or selects End Tool from
// the context menu.
TA_CANCEL_TOOL
=
0x2
000
,
TA_CANCEL_TOOL
=
0x4
000
,
// Context menu update. Issued whenever context menu is open and the user hovers the mouse
// over one of choices. Used in dynamic highligting in disambiguation menu
TA_CONTEXT_MENU_UPDATE
=
0x4
000
,
TA_CONTEXT_MENU_UPDATE
=
0x8
000
,
// Context menu choice. Sent if the user picked something from the context menu or
// closed it without selecting anything.
TA_CONTEXT_MENU_CHOICE
=
0x8
000
,
TA_CONTEXT_MENU_CHOICE
=
0x10
000
,
// Tool action (allows to control tools)
TA_ACTION
=
0x1
0000
,
TA_ACTION
=
0x2
0000
,
TA_ANY
=
0xffffffff
};
...
...
@@ -233,6 +237,12 @@ public:
&&
(
(
m_mouseButtons
&
aButtonMask
)
==
aButtonMask
);
}
bool
IsDblClick
(
int
aButtonMask
=
BUT_ANY
)
const
{
return
(
m_actions
==
TA_MOUSE_DBLCLICK
)
&&
(
(
m_mouseButtons
&
aButtonMask
)
==
aButtonMask
);
}
bool
IsDrag
(
int
aButtonMask
=
BUT_ANY
)
const
{
return
(
m_actions
==
TA_MOUSE_DRAG
)
&&
(
(
m_mouseButtons
&
aButtonMask
)
==
aButtonMask
);
...
...
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