bool Slider::processMouseUp(const InputEvent& event) {
    if(m_mouseState != MOUSE_NONE && event.code == LEFT_MOUSE_BUTTON) {
        // We are now done with the modal mouse loop.
        switch(m_mouseState) {
            case MOUSE_PAGE_UP:
                if(hitTest(event.loc)) {
                    setPosition(position()-m_pageSize);
                }
                break;
            case MOUSE_PAGE_DOWN:
                if(hitTest(event.loc)) {
                    setPosition(position()+m_pageSize);
                }
                break;
            case MOUSE_THUMB_DRAG:
                // Whatever position we have is the correct one.
                // Do nothing.
                break;
            default:
                assert(false);          // Forgot an enum case.
        }

        // Make sure we get off the event chain.
        globalEventManager().removeResponder(this, true);
        setModal(false);
        m_mouseState = MOUSE_NONE;

        return Control::processMouseUp(event);
    }

    return false;
}
EventResponder::~EventResponder(void)
{
    // Make sure this responder is not in the event chain.
	if (hasGlobalEventManager()) {
		globalEventManager().removeResponder(this);
	}
}
void EventManager::ProcessMousePassive( int x, int y )
{
    ModifyMouseSensitivity( x, y );
    InputEvent event( MOUSE_MOVE_EVENT, 0, 0, Point( MouseXTo2dX( x ), MouseYTo2dY( y ) ) );
    globalEventManager().sendInputEvent( (event) );
    clearDeleteQueue();
}
void EventManager::ProcessMouseActive( int x, int y )
{
    ModifyMouseSensitivity( x, y );
    //FIXME mbyron -- Should provide info about which buttons are down.
    InputEvent event( MOUSE_DRAG_EVENT, 0, 0, Point( MouseXTo2dX( x ), MouseYTo2dY( y ) ) );
    globalEventManager().sendInputEvent( (event) );
    clearDeleteQueue();
}
// Send a command event into the event chain.
void EventResponder::sendCommand(const EventCommandId& command, Control* control) {
    if(m_commandTarget != NULL) {
        if(m_commandTarget->processCommand(command, control)) {
            return;
        }
    }

    globalEventManager().sendCommand(command, control);
}
void EventManager::ProcessMouseClick( int button, int state, int x, int y )
{
    ModifyMouseSensitivity( x, y );
    //Make sure we are working with the same "button" constants.
    assert( LEFT_MOUSE_BUTTON == WS_LEFT_BUTTON );
    assert( RIGHT_MOUSE_BUTTON == WS_RIGHT_BUTTON );
    assert( MIDDLE_MOUSE_BUTTON == WS_MIDDLE_BUTTON );
    assert( WHEELUP_MOUSE_BUTTON == WS_WHEEL_UP );
    assert( WHEELDOWN_MOUSE_BUTTON == WS_WHEEL_DOWN );
    if (state == WS_MOUSE_DOWN) {
        InputEvent event( MOUSE_DOWN_EVENT, button, 0, Point( MouseXTo2dX( x ), MouseYTo2dY( y ) ) );
        globalEventManager().sendInputEvent( (event) );
    } else {
        InputEvent event( MOUSE_UP_EVENT, button, 0, Point( MouseXTo2dX( x ), MouseYTo2dY( y ) ) );
        globalEventManager().sendInputEvent( (event) );
    }
    clearDeleteQueue();
}
Esempio n. 7
0
//Draw all visible windows.
void WindowManager::draw()
{
    GFXHudMode( true );            //Load identity matrices.
    GFXColorf( GUI_OPAQUE_WHITE() );

    GFXDisable( DEPTHTEST );
    GFXEnable( DEPTHWRITE );
    GFXDisable( LIGHTING );
    GFXDisable( CULLFACE );
    GFXClear( GFXTRUE );
    GFXDisable( DEPTHWRITE );
    GFXBlendMode( SRCALPHA, INVSRCALPHA );
    GFXDisable( TEXTURE1 );
    GFXEnable( TEXTURE0 );
    //Just loop through all the windows, and remember if anything gets drawn.
    //Since the first window in the list is drawn first, z-order is
    //maintained.  First entry is the bottom window, last is the top window.
    //FIXME mbyron -- I think the event manager needs to get involved with window z-order.
    //(Mouse events should go to windows in zorder, shouldn't they?)
    for (size_t i = 0; i < m_windows.size(); i++) 
    {
        if ( m_windows[i]->controller() )//it's a controller
            m_windows[i]->controller()->draw();//that can draw
        if ( i < m_windows.size() ) 
        m_windows[i]->draw();
    }
    //Emulate EndGUIFrame.
    static VSSprite MouseVSSprite( "mouse.spr", BILINEAR, GFXTRUE );
    static Texture  dummy( "white.bmp", 0, NEAREST, TEXTURE2D, TEXTURE_2D, GFXTRUE );
    GFXDisable( CULLFACE );
    ConditionalCursorDraw( true );
    //Figure position of cursor sprite.
    float sizex     = 0.0, sizey = 0.0;
    const Point loc = globalEventManager().mouseLoc();
    MouseVSSprite.GetSize( sizex, sizey );
    float tempx     = 0.0, tempy = 0.0;
    MouseVSSprite.GetPosition( tempx, tempy );
    MouseVSSprite.SetPosition( tempx+loc.x+sizex/2, tempy+loc.y+sizey/2 );

    dummy.MakeActive();
    GFXBlendMode( SRCALPHA, INVSRCALPHA );
    GFXColorf( GUI_OPAQUE_WHITE() );

    //Draw the cursor sprite.
    GFXEnable( TEXTURE0 );
    GFXDisable( DEPTHTEST );
    GFXDisable( TEXTURE1 );
    MouseVSSprite.Draw();

    GFXHudMode( false );
    GFXEnable( CULLFACE );
    MouseVSSprite.SetPosition( tempx, tempy );
}
Esempio n. 8
0
//A window has been closed.
void WindowManager::closeWindow( Window *w, //Old window.
                                 bool deleteWindow //True = delete window.
                               )
{
    vector< Window* >::iterator iter;
    for (iter = m_windows.begin(); iter != m_windows.end(); iter++)
        if ( (*iter) == w ) {
            m_windows.erase( iter );
            globalEventManager().removeResponder( w );             //Have to do this now.
            if (deleteWindow)
                EventManager::addToDeleteQueue( w );
            break;
        }
}
bool Slider::processMouseDown(const InputEvent& event) {
	static int zoominc = XMLSupport::parse_int (vs_config->getVariable("general","wheel_increment_lines","3"));
    if(event.code == LEFT_MOUSE_BUTTON && m_thumbLength != NO_THUMB_LENGTH && hitTest(event.loc)) {
        if(m_vertical) {
            if(event.loc.y < m_thumbRect.origin.y) {
                m_mouseState = MOUSE_PAGE_DOWN;
            } else if(event.loc.y > m_thumbRect.top()) {
                m_mouseState = MOUSE_PAGE_UP;
            } else {
                m_mouseState = MOUSE_THUMB_DRAG;
                m_buttonDownMouse = event.loc.y;
                m_buttonDownPosition = m_position;
            }
        } else {
            if(event.loc.x < m_thumbRect.origin.x) {
                m_mouseState = MOUSE_PAGE_UP;
            } else if(event.loc.x > m_thumbRect.right()) {
                m_mouseState = MOUSE_PAGE_DOWN;
            } else {
                m_mouseState = MOUSE_THUMB_DRAG;
                m_buttonDownMouse = event.loc.x;
                m_buttonDownPosition = m_position;
            }
        }

        setModal(true);                   // Make sure we don't miss anything.
        // Make sure we see mouse events *first* until we get a mouse-up.
        globalEventManager().pushResponder(this);
        return true;
    } else if (event.code == WHEELUP_MOUSE_BUTTON) {
		if(hitTest(event.loc)) {
			setPosition(position()-zoominc);
		}
	} else if (event.code == WHEELDOWN_MOUSE_BUTTON) {
		if(hitTest(event.loc)) {
			setPosition(position()+zoominc);
		}
	}

    return Control::processMouseDown(event);
}
Esempio n. 10
0
// Mouse button up.
bool Picker::processMouseUp(const InputEvent& event) {
    if(m_cellPressed && event.code == LEFT_MOUSE_BUTTON) {
        // Select if the mouse goes up inside the pressed cell.
        //  If not, consider the action cancelled.
        const bool newSelection = ( cellForMouse(event.loc) == m_cellPressed );

        // Make sure we get off the event chain.
        globalEventManager().removeResponder(this, true);
        setModal(false);

        // Select a new cell, after we've cleaned up the event handling.
        if(newSelection) {
            selectCell(m_cellPressed);
        }
        m_cellPressed = NULL;

        return true;
    }

    return Control::processMouseUp(event);
}
Esempio n. 11
0
// Mouse clicked down.
bool Picker::processMouseDown(const InputEvent& event) {
	static int zoominc = XMLSupport::parse_int (vs_config->getVariable("general","wheel_increment_lines","3"));
    if(event.code == LEFT_MOUSE_BUTTON) {
        PickerCell* cell = cellForMouse(event.loc);
        if(cell != NULL) {
            // We found the cell that was clicked.
            m_cellPressed = cell;
            setModal(true);                   // Make sure we don't miss anything.
            // Make sure we see mouse events *first* until we get a mouse-up.
            globalEventManager().pushResponder(this);
            return true;
        }
    } else if (event.code == WHEELUP_MOUSE_BUTTON) {
		if(hitTest(event.loc)) {
			m_scroller->setScrollPosition(m_scroller->scrollPosition()-zoominc);
		}
	} else if (event.code == WHEELDOWN_MOUSE_BUTTON) {
		if(hitTest(event.loc)) {
			m_scroller->setScrollPosition(m_scroller->scrollPosition()+zoominc);
		}
	}

    return Control::processMouseDown(event);
}
Esempio n. 12
0
//A new window has been created and is ready to be drawn.
void WindowManager::openWindow( Window *w )
{
    m_windows.push_back( w );
    globalEventManager().pushResponder( w );
}