コード例 #1
0
ファイル: ScrollBar.cpp プロジェクト: priyananda/projects
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
bool
ScrollBarSlider::moved(MouseMessage& message)
{
    if(_oldMousePos.x() >= 0.0f)
    {
        if(state() == Button::down)
        {
            int value = _scrollBar.value();
            switch(_scrollBar.justification())
            {
            case ScrollBar::horizontal:
                {
                    const float delta = message.x() - _oldMousePos.x();
                    if(delta != 0) moveHorizontally(delta);
                }
                break;
            case ScrollBar::vertical:
                {
                    const float delta = message.y() - _oldMousePos.y();
                    if(delta != 0) moveVertically(delta);
                }
                break;
            }
            if(value != _scrollBar.value()) _scrollBar.sliderMoved(_scrollBar.value());
        }
    }
    _oldMousePos.setX(message.x());
    _oldMousePos.setY(message.y());
    return true;
}
コード例 #2
0
ファイル: FrameWindow.cpp プロジェクト: priyananda/projects
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
bool
FrameWindowMouseListener::moved(MouseMessage& message)
{
    bool isHandled = false;
    if(frameWindow_.isMovable())
    {
        if(WindowManager::instance().captureWindow() == &frameWindow_)
        {
            Core::Vector2 delta(message.x() - _oldMousePos.x(), message.y() - _oldMousePos.y());
            frameWindow_.setPosition(frameWindow_.position() + delta);
        }
        _oldMousePos.setX(message.x());
        _oldMousePos.setY(message.y());
        isHandled = true;
    }

    return isHandled;
}