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
18898fe8
Commit
18898fe8
authored
Nov 21, 2014
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tool: Added a generic parameter for RunAction().
parent
383fec15
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
19 deletions
+46
-19
tool_manager.cpp
common/tool/tool_manager.cpp
+10
-14
tool_event.h
include/tool/tool_event.h
+30
-3
tool_manager.h
include/tool/tool_manager.h
+6
-2
No files found.
common/tool/tool_manager.cpp
View file @
18898fe8
...
...
@@ -292,21 +292,19 @@ void TOOL_MANAGER::UnregisterAction( TOOL_ACTION* aAction )
}
bool
TOOL_MANAGER
::
RunAction
(
const
std
::
string
&
aActionName
,
bool
aNow
)
bool
TOOL_MANAGER
::
RunAction
(
const
std
::
string
&
aActionName
,
bool
aNow
,
void
*
aParam
)
{
TOOL_ACTION
*
action
=
m_actionMgr
->
FindAction
(
aActionName
);
if
(
action
)
{
if
(
aNow
)
{
TOOL_EVENT
event
=
action
->
MakeEvent
();
event
.
SetParameter
(
aParam
);
if
(
aNow
)
ProcessEvent
(
event
);
}
else
{
PostEvent
(
action
->
MakeEvent
()
);
}
PostEvent
(
event
);
return
true
;
}
...
...
@@ -315,17 +313,15 @@ bool TOOL_MANAGER::RunAction( const std::string& aActionName, bool aNow )
}
void
TOOL_MANAGER
::
RunAction
(
const
TOOL_ACTION
&
aAction
,
bool
aNow
)
void
TOOL_MANAGER
::
RunAction
(
const
TOOL_ACTION
&
aAction
,
bool
aNow
,
void
*
aParam
)
{
if
(
aNow
)
{
TOOL_EVENT
event
=
aAction
.
MakeEvent
();
event
.
SetParameter
(
aParam
);
if
(
aNow
)
ProcessEvent
(
event
);
}
else
{
PostEvent
(
aAction
.
MakeEvent
()
);
}
PostEvent
(
event
);
}
...
...
include/tool/tool_event.h
View file @
18898fe8
...
...
@@ -165,7 +165,8 @@ public:
m_scope
(
aScope
),
m_mouseButtons
(
0
),
m_keyCode
(
0
),
m_modifiers
(
0
)
{}
m_modifiers
(
0
),
m_param
(
NULL
)
{}
TOOL_EVENT
(
TOOL_EVENT_CATEGORY
aCategory
,
TOOL_ACTIONS
aAction
,
int
aExtraParam
,
TOOL_ACTION_SCOPE
aScope
=
AS_GLOBAL
)
:
...
...
@@ -174,7 +175,8 @@ public:
m_scope
(
aScope
),
m_mouseButtons
(
0
),
m_keyCode
(
0
),
m_modifiers
(
0
)
m_modifiers
(
0
),
m_param
(
NULL
)
{
if
(
aCategory
==
TC_MOUSE
)
{
...
...
@@ -202,7 +204,8 @@ public:
m_scope
(
aScope
),
m_mouseButtons
(
0
),
m_keyCode
(
0
),
m_modifiers
(
0
)
m_modifiers
(
0
),
m_param
(
NULL
)
{
if
(
aCategory
==
TC_COMMAND
||
aCategory
==
TC_MESSAGE
)
m_commandStr
=
aExtraParam
;
...
...
@@ -352,6 +355,27 @@ public:
*/
bool
IsAction
(
const
TOOL_ACTION
*
aAction
)
const
;
/**
* Function Parameter()
* Returns a non-standard parameter assigned to the event. Its meaning depends on the
* target tool.
*/
void
*
Parameter
()
const
{
return
m_param
;
}
/**
* Function SetParameter()
* Sets a non-standard parameter assigned to the event. Its meaning depends on the
* target tool.
* @param aParam is the new parameter.
*/
void
SetParameter
(
void
*
aParam
)
{
m_param
=
aParam
;
}
boost
::
optional
<
int
>
GetCommandId
()
const
{
return
m_commandId
;
...
...
@@ -388,6 +412,9 @@ private:
///> State of key modifierts (Ctrl/Alt/etc.)
int
m_modifiers
;
///> Generic parameter used for passing non-standard data.
void
*
m_param
;
boost
::
optional
<
int
>
m_commandId
;
boost
::
optional
<
std
::
string
>
m_commandStr
;
};
...
...
include/tool/tool_manager.h
View file @
18898fe8
...
...
@@ -108,9 +108,11 @@ public:
* @param aActionName is the name of action to be invoked.
* @param aNow decides if the action has to be run immediately or after the current coroutine
* is preemptied.
* @param aParam is an optional parameter that might be used by the invoked action. Its meaning
* depends on the action.
* @return False if the action was not found.
*/
bool
RunAction
(
const
std
::
string
&
aActionName
,
bool
aNow
=
false
);
bool
RunAction
(
const
std
::
string
&
aActionName
,
bool
aNow
=
false
,
void
*
aParam
=
NULL
);
/**
* Function RunAction()
...
...
@@ -119,8 +121,10 @@ public:
* @param aAction is the action to be invoked.
* @param aNow decides if the action has to be run immediately or after the current coroutine
* is preemptied.
* @param aParam is an optional parameter that might be used by the invoked action. Its meaning
* depends on the action.
*/
void
RunAction
(
const
TOOL_ACTION
&
aAction
,
bool
aNow
=
false
);
void
RunAction
(
const
TOOL_ACTION
&
aAction
,
bool
aNow
=
false
,
void
*
aParam
=
NULL
);
/**
* Function FindTool()
...
...
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