Пример #1
0
EVENT_RESULT CGUIBaseContainer::OnMouseEvent(const CPoint &point, const CMouseEvent &event)
{
    if (event.m_id >= ACTION_MOUSE_LEFT_CLICK && event.m_id <= ACTION_MOUSE_DOUBLE_CLICK)
    {
        if (SelectItemFromPoint(point - CPoint(m_posX, m_posY)))
        {
            OnClick(event.m_id);
            return EVENT_RESULT_HANDLED;
        }
    }
    else if (event.m_id == ACTION_MOUSE_WHEEL_UP)
    {
        Scroll(-1);
        return EVENT_RESULT_HANDLED;
    }
    else if (event.m_id == ACTION_MOUSE_WHEEL_DOWN)
    {
        Scroll(1);
        return EVENT_RESULT_HANDLED;
    }
    else if (event.m_id == ACTION_GESTURE_NOTIFY)
    {
        return (m_orientation == HORIZONTAL) ? EVENT_RESULT_PAN_HORIZONTAL : EVENT_RESULT_PAN_VERTICAL;
    }
    else if (event.m_id == ACTION_GESTURE_BEGIN)
    {   // grab exclusive access
        CGUIMessage msg(GUI_MSG_EXCLUSIVE_MOUSE, GetID(), GetParentID());
        SendWindowMessage(msg);
        return EVENT_RESULT_HANDLED;
    }
    else if (event.m_id == ACTION_GESTURE_PAN)
    {   // do the drag and validate our offset (corrects for end of scroll)
        m_scroller.SetValue(m_scroller.GetValue() - ((m_orientation == HORIZONTAL) ? event.m_offsetX : event.m_offsetY));
        float size = (m_layout) ? m_layout->Size(m_orientation) : 10.0f;
        int offset = (int)MathUtils::round_int(m_scroller.GetValue() / size);
        m_lastScrollStartTimer.Stop();
        m_scrollTimer.Start();
        SetOffset(offset);
        ValidateOffset();
        return EVENT_RESULT_HANDLED;
    }
    else if (event.m_id == ACTION_GESTURE_END)
    {   // release exclusive access
        CGUIMessage msg(GUI_MSG_EXCLUSIVE_MOUSE, 0, GetParentID());
        SendWindowMessage(msg);
        m_scrollTimer.Stop();
        // and compute the nearest offset from this and scroll there
        float size = (m_layout) ? m_layout->Size(m_orientation) : 10.0f;
        float offset = m_scroller.GetValue() / size;
        int toOffset = (int)MathUtils::round_int(offset);
        if (toOffset < offset)
            SetOffset(toOffset+1);
        else
            SetOffset(toOffset-1);
        ScrollToOffset(toOffset);
        return EVENT_RESULT_HANDLED;
    }
    return EVENT_RESULT_UNHANDLED;
}
Пример #2
0
bool CGUIBaseContainer::OnMouseOver(const CPoint &point)
{
  // select the item under the pointer
  SelectItemFromPoint(point - CPoint(m_posX, m_posY));
  return CGUIControl::OnMouseOver(point);
}