bool CGUIPanelContainer::SelectItemFromPoint(const CPoint &point) { int cursor = GetCursorFromPoint(point); if (cursor < 0) return false; SetCursor(cursor); return true; }
bool CGUIFixedListContainer::SelectItemFromPoint(const CPoint &point) { if (!m_focusedLayout || !m_layout) return false; MarkDirtyRegion(); const float mouse_scroll_speed = 0.25f; const float mouse_max_amount = 1.5f; float sizeOfItem = m_layout->Size(m_orientation); int minCursor, maxCursor; GetCursorRange(minCursor, maxCursor); // see if the point is either side of our focus range float start = (minCursor + 0.2f) * sizeOfItem; float end = (maxCursor - 0.2f) * sizeOfItem + m_focusedLayout->Size(m_orientation); float pos = (m_orientation == VERTICAL) ? point.y : point.x; if (pos < start && GetOffset() > -minCursor) { // scroll backward if (!InsideLayout(m_layout, point)) return false; float amount = std::min((start - pos) / sizeOfItem, mouse_max_amount); m_analogScrollCount += amount * amount * mouse_scroll_speed; if (m_analogScrollCount > 1) { ScrollToOffset(GetOffset() - 1); m_analogScrollCount = 0; } return true; } else if (pos > end && GetOffset() + maxCursor < (int)m_items.size() - 1) { if (!InsideLayout(m_layout, point)) return false; // scroll forward float amount = std::min((pos - end) / sizeOfItem, mouse_max_amount); m_analogScrollCount += amount * amount * mouse_scroll_speed; if (m_analogScrollCount > 1) { ScrollToOffset(GetOffset() + 1); m_analogScrollCount = 0; } return true; } else { // select the appropriate item int cursor = GetCursorFromPoint(point); if (cursor < 0) return false; // calling SelectItem() here will focus the item and scroll, which isn't really what we're after SetCursor(cursor); return true; } }
bool CGUIListContainer::SelectItemFromPoint(const CPoint &point) { CPoint itemPoint; int row = GetCursorFromPoint(point, &itemPoint); if (row < 0) return false; SetCursor(row); CGUIListItemLayout *focusedLayout = GetFocusedLayout(); if (focusedLayout) focusedLayout->SelectItemFromPoint(itemPoint); return true; }