Commit 902d0e3f authored by Maciej Suminski's avatar Maciej Suminski
Browse files

Tools are processing const TOOL_EVENT& (Tool Framework).

parent 69553d6f
Loading
Loading
Loading
Loading
+7 −7
Original line number Original line Diff line number Diff line
@@ -101,7 +101,7 @@ struct TOOL_MANAGER::TOOL_STATE
    CONTEXT_MENU_TRIGGER contextMenuTrigger;
    CONTEXT_MENU_TRIGGER contextMenuTrigger;


    /// Tool execution context
    /// Tool execution context
    COROUTINE<int, TOOL_EVENT&>* cofunc;
    COROUTINE<int, const TOOL_EVENT&>* cofunc;


    /// The event that triggered the execution/wakeup of the tool after Wait() call
    /// The event that triggered the execution/wakeup of the tool after Wait() call
    TOOL_EVENT wakeupEvent;
    TOOL_EVENT wakeupEvent;
@@ -464,7 +464,7 @@ optional<TOOL_EVENT> TOOL_MANAGER::ScheduleWait( TOOL_BASE* aTool,
}
}




void TOOL_MANAGER::dispatchInternal( TOOL_EVENT& aEvent )
void TOOL_MANAGER::dispatchInternal( const TOOL_EVENT& aEvent )
{
{
    // iterate over all registered tools
    // iterate over all registered tools
    BOOST_FOREACH( TOOL_ID toolId, m_activeTools )
    BOOST_FOREACH( TOOL_ID toolId, m_activeTools )
@@ -512,7 +512,7 @@ void TOOL_MANAGER::dispatchInternal( TOOL_EVENT& aEvent )
                    // as the state changes, the transition table has to be set up again
                    // as the state changes, the transition table has to be set up again
                    st->transitions.clear();
                    st->transitions.clear();


                    st->cofunc = new COROUTINE<int, TOOL_EVENT&>( tr.second );
                    st->cofunc = new COROUTINE<int, const TOOL_EVENT&>( tr.second );


                    // got match? Run the handler.
                    // got match? Run the handler.
                    st->cofunc->Call( aEvent );
                    st->cofunc->Call( aEvent );
@@ -529,7 +529,7 @@ void TOOL_MANAGER::dispatchInternal( TOOL_EVENT& aEvent )
}
}




bool TOOL_MANAGER::dispatchStandardEvents( TOOL_EVENT& aEvent )
bool TOOL_MANAGER::dispatchStandardEvents( const TOOL_EVENT& aEvent )
{
{
    if( aEvent.Action() == TA_KEY_PRESSED )
    if( aEvent.Action() == TA_KEY_PRESSED )
    {
    {
@@ -542,7 +542,7 @@ bool TOOL_MANAGER::dispatchStandardEvents( TOOL_EVENT& aEvent )
}
}




bool TOOL_MANAGER::dispatchActivation( TOOL_EVENT& aEvent )
bool TOOL_MANAGER::dispatchActivation( const TOOL_EVENT& aEvent )
{
{
    if( aEvent.IsActivate() )
    if( aEvent.IsActivate() )
    {
    {
@@ -559,7 +559,7 @@ bool TOOL_MANAGER::dispatchActivation( TOOL_EVENT& aEvent )
}
}




void TOOL_MANAGER::dispatchContextMenu( TOOL_EVENT& aEvent )
void TOOL_MANAGER::dispatchContextMenu( const TOOL_EVENT& aEvent )
{
{
    BOOST_FOREACH( TOOL_ID toolId, m_activeTools )
    BOOST_FOREACH( TOOL_ID toolId, m_activeTools )
    {
    {
@@ -614,7 +614,7 @@ void TOOL_MANAGER::finishTool( TOOL_STATE* aState )
}
}




bool TOOL_MANAGER::ProcessEvent( TOOL_EVENT& aEvent )
bool TOOL_MANAGER::ProcessEvent( const TOOL_EVENT& aEvent )
{
{
    // Early dispatch of events destined for the TOOL_MANAGER
    // Early dispatch of events destined for the TOOL_MANAGER
    if( !dispatchStandardEvents( aEvent ) )
    if( !dispatchStandardEvents( aEvent ) )
+1 −1
Original line number Original line Diff line number Diff line
@@ -51,7 +51,7 @@ enum TOOL_TYPE


/// Unique identifier for tools
/// Unique identifier for tools
typedef int TOOL_ID;
typedef int TOOL_ID;
typedef DELEGATE<int, TOOL_EVENT&> TOOL_STATE_FUNC;
typedef DELEGATE<int, const TOOL_EVENT&> TOOL_STATE_FUNC;


/**
/**
 * Class TOOL_BASE
 * Class TOOL_BASE
+2 −2
Original line number Original line Diff line number Diff line
@@ -70,7 +70,7 @@ public:
     * No conditions means any event.
     * No conditions means any event.
     */
     */
    template <class T>
    template <class T>
    void Go( int (T::* aStateFunc)( TOOL_EVENT& ),
    void Go( int (T::* aStateFunc)( const TOOL_EVENT& ),
            const TOOL_EVENT_LIST& aConditions = TOOL_EVENT( TC_ANY, TA_ANY ) );
            const TOOL_EVENT_LIST& aConditions = TOOL_EVENT( TC_ANY, TA_ANY ) );


    /**
    /**
@@ -110,7 +110,7 @@ private:


// hide TOOL_MANAGER implementation
// hide TOOL_MANAGER implementation
template <class T>
template <class T>
void TOOL_INTERACTIVE::Go( int (T::* aStateFunc)( TOOL_EVENT& ),
void TOOL_INTERACTIVE::Go( int (T::* aStateFunc)( const TOOL_EVENT& ),
                           const TOOL_EVENT_LIST& aConditions )
                           const TOOL_EVENT_LIST& aConditions )
{
{
    TOOL_STATE_FUNC sptr( static_cast<T*>( this ), aStateFunc );
    TOOL_STATE_FUNC sptr( static_cast<T*>( this ), aStateFunc );
+5 −5
Original line number Original line Diff line number Diff line
@@ -169,7 +169,7 @@ public:
     * Propagates an event to tools that requested events of matching type(s).
     * Propagates an event to tools that requested events of matching type(s).
     * @param aEvent is the event to be processed.
     * @param aEvent is the event to be processed.
     */
     */
    bool ProcessEvent( TOOL_EVENT& aEvent );
    bool ProcessEvent( const TOOL_EVENT& aEvent );


    /**
    /**
     * Puts an event to the event queue to be processed at the end of event processing cycle.
     * Puts an event to the event queue to be processed at the end of event processing cycle.
@@ -309,7 +309,7 @@ private:
     * Function dispatchInternal
     * Function dispatchInternal
     * Passes an event at first to the active tools, then to all others.
     * Passes an event at first to the active tools, then to all others.
     */
     */
    void dispatchInternal( TOOL_EVENT& aEvent );
    void dispatchInternal( const TOOL_EVENT& aEvent );


    /**
    /**
     * Function dispatchStandardEvents()
     * Function dispatchStandardEvents()
@@ -317,7 +317,7 @@ private:
     * @param aEvent is the event to be processed.
     * @param aEvent is the event to be processed.
     * @return False if the event was processed and should not go any further.
     * @return False if the event was processed and should not go any further.
     */
     */
    bool dispatchStandardEvents( TOOL_EVENT& aEvent );
    bool dispatchStandardEvents( const TOOL_EVENT& aEvent );


    /**
    /**
     * Function dispatchActivation()
     * Function dispatchActivation()
@@ -325,13 +325,13 @@ private:
     * @param aEvent is an event to be tested.
     * @param aEvent is an event to be tested.
     * @return True if a tool was invoked, false otherwise.
     * @return True if a tool was invoked, false otherwise.
     */
     */
    bool dispatchActivation( TOOL_EVENT& aEvent );
    bool dispatchActivation( const TOOL_EVENT& aEvent );


    /**
    /**
     * Function dispatchContextMenu()
     * Function dispatchContextMenu()
     * Handles context menu related events.
     * Handles context menu related events.
     */
     */
    void dispatchContextMenu( TOOL_EVENT& aEvent );
    void dispatchContextMenu( const TOOL_EVENT& aEvent );


    /**
    /**
     * Function invokeTool()
     * Function invokeTool()
+1 −1
Original line number Original line Diff line number Diff line
@@ -725,7 +725,7 @@ void ROUTER_TOOL::performRouting()
}
}




int ROUTER_TOOL::Main( TOOL_EVENT& aEvent )
int ROUTER_TOOL::Main( const TOOL_EVENT& aEvent )
{
{
    VIEW_CONTROLS* ctls = getViewControls();
    VIEW_CONTROLS* ctls = getViewControls();
    PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();
    PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();
Loading