void CGUIPanelContainer::Process(unsigned int currentTime, CDirtyRegionList &dirtyregions) { ValidateOffset(); if (m_bInvalidated) UpdateLayout(); if (!m_layout || !m_focusedLayout) return; UpdateScrollOffset(currentTime); int offset = (int)(m_scroller.GetValue() / m_layout->Size(m_orientation)); int cacheBefore, cacheAfter; GetCacheOffsets(cacheBefore, cacheAfter); // Free memory not used on screen if ((int)m_items.size() > m_itemsPerPage + cacheBefore + cacheAfter) FreeMemory(CorrectOffset(offset - cacheBefore, 0), CorrectOffset(offset + m_itemsPerPage + 1 + cacheAfter, 0)); CPoint origin = CPoint(m_posX, m_posY) + m_renderOffset; float pos = (m_orientation == VERTICAL) ? origin.y : origin.x; float end = (m_orientation == VERTICAL) ? m_posY + m_height : m_posX + m_width; pos += (offset - cacheBefore) * m_layout->Size(m_orientation) - m_scroller.GetValue(); end += cacheAfter * m_layout->Size(m_orientation); int current = (offset - cacheBefore) * m_itemsPerRow; int col = 0; while (pos < end && m_items.size()) { if (current >= (int)m_items.size()) break; if (current >= 0) { CGUIListItemPtr item = m_items[current]; bool focused = (current == GetOffset() * m_itemsPerRow + GetCursor()) && m_bHasFocus; if (m_orientation == VERTICAL) ProcessItem(origin.x + col * m_layout->Size(HORIZONTAL), pos, item, focused, currentTime, dirtyregions); else ProcessItem(pos, origin.y + col * m_layout->Size(VERTICAL), item, focused, currentTime, dirtyregions); } // increment our position if (col < m_itemsPerRow - 1) col++; else { pos += m_layout->Size(m_orientation); col = 0; } current++; } // when we are scrolling up, offset will become lower (integer division, see offset calc) // to have same behaviour when scrolling down, we need to set page control to offset+1 UpdatePageControl(offset + (m_scroller.IsScrollingDown() ? 1 : 0)); CGUIControl::Process(currentTime, dirtyregions); }
void CGUIBaseContainer::Process(unsigned int currentTime, CDirtyRegionList &dirtyregions) { // update our auto-scrolling as necessary UpdateAutoScrolling(currentTime); ValidateOffset(); if (m_bInvalidated) UpdateLayout(); if (!m_layout || !m_focusedLayout) return; UpdateScrollOffset(currentTime); int offset = (int)floorf(m_scroller.GetValue() / m_layout->Size(m_orientation)); int cacheBefore, cacheAfter; GetCacheOffsets(cacheBefore, cacheAfter); // Free memory not used on screen if ((int)m_items.size() > m_itemsPerPage + cacheBefore + cacheAfter) FreeMemory(CorrectOffset(offset - cacheBefore, 0), CorrectOffset(offset + m_itemsPerPage + 1 + cacheAfter, 0)); CPoint origin = CPoint(m_posX, m_posY) + m_renderOffset; float pos = (m_orientation == VERTICAL) ? origin.y : origin.x; float end = (m_orientation == VERTICAL) ? m_posY + m_height : m_posX + m_width; // we offset our draw position to take into account scrolling and whether or not our focused // item is offscreen "above" the list. float drawOffset = (offset - cacheBefore) * m_layout->Size(m_orientation) - m_scroller.GetValue(); if (GetOffset() + GetCursor() < offset) drawOffset += m_focusedLayout->Size(m_orientation) - m_layout->Size(m_orientation); pos += drawOffset; end += cacheAfter * m_layout->Size(m_orientation); int current = offset - cacheBefore; while (pos < end && m_items.size()) { int itemNo = CorrectOffset(current, 0); if (itemNo >= (int)m_items.size()) break; bool focused = (current == GetOffset() + GetCursor()); if (itemNo >= 0) { CGUIListItemPtr item = m_items[itemNo]; // render our item if (m_orientation == VERTICAL) ProcessItem(origin.x, pos, item, focused, currentTime, dirtyregions); else ProcessItem(pos, origin.y, item, focused, currentTime, dirtyregions); } // increment our position pos += focused ? m_focusedLayout->Size(m_orientation) : m_layout->Size(m_orientation); current++; } // when we are scrolling up, offset will become lower (integer division, see offset calc) // to have same behaviour when scrolling down, we need to set page control to offset+1 UpdatePageControl(offset + (m_scroller.IsScrollingDown() ? 1 : 0)); m_lastRenderTime = currentTime; CGUIControl::Process(currentTime, dirtyregions); }
void CGUIWrappingListContainer::Render() { if (!IsVisible()) return; ValidateOffset(); if (m_bInvalidated) UpdateLayout(); if (!m_layout || !m_focusedLayout) return; UpdateScrollOffset(); int offset = (int)floorf(m_scrollOffset / m_layout->Size(m_orientation)); // Free memory not used on scre if (m_scrollSpeed) if ((int)m_items.size() > m_itemsPerPage) FreeMemory(CorrectOffset(offset, 0), CorrectOffset(offset, m_itemsPerPage + 1)); g_graphicsContext.SetClipRegion(m_posX, m_posY, m_width, m_height); float posX = m_posX; float posY = m_posY; if (m_orientation == VERTICAL) posY += (offset * m_layout->Size(m_orientation) - m_scrollOffset); else posX += (offset * m_layout->Size(m_orientation) - m_scrollOffset);; float focusedPosX = 0; float focusedPosY = 0; CGUIListItemPtr focusedItem; int current = offset; while (posX < m_posX + m_width && posY < m_posY + m_height && m_items.size()) { CGUIListItemPtr item = m_items[CorrectOffset(current, 0)]; bool focused = (current == m_offset + m_cursor) && m_bHasFocus; // render our item if (focused) { focusedPosX = posX; focusedPosY = posY; focusedItem = item; } else RenderItem(posX, posY, item.get(), focused); // increment our position if (m_orientation == VERTICAL) posY += focused ? m_focusedLayout->Size(m_orientation) : m_layout->Size(m_orientation); else posX += focused ? m_focusedLayout->Size(m_orientation) : m_layout->Size(m_orientation); current++; } // render focused item last so it can overlap other items if (focusedItem) RenderItem(focusedPosX, focusedPosY, focusedItem.get(), true); g_graphicsContext.RestoreClipRegion(); if (m_pageControl) { // tell our pagecontrol (scrollbar or whatever) to update CGUIMessage msg(GUI_MSG_ITEM_SELECT, GetID(), m_pageControl, CorrectOffset(offset, 0)); SendWindowMessage(msg); } CGUIBaseContainer::Render(); }
void CGUIFixedListContainer::Render() { ValidateOffset(); if (m_bInvalidated) UpdateLayout(); if (!m_focusedLayout || !m_layout) return; UpdateScrollOffset(); int offset = (int)(m_scrollOffset / m_layout->Size(m_orientation)); // Free memory not used on screen at the moment, do this first so there's more memory for the new items. FreeMemory(CorrectOffset(offset, 0), CorrectOffset(offset, m_itemsPerPage + 1)); g_graphicsContext.SetClipRegion(m_posX, m_posY, m_width, m_height); float posX = m_posX; float posY = m_posY; if (m_orientation == VERTICAL) posY += (offset * m_layout->Size(m_orientation) - m_scrollOffset); else posX += (offset * m_layout->Size(m_orientation) - m_scrollOffset);; float focusedPosX = 0; float focusedPosY = 0; CGUIListItemPtr focusedItem; int current = offset; while (posX < m_posX + m_width && posY < m_posY + m_height && m_items.size()) { if (current >= (int)m_items.size()) break; bool focused = (current == m_offset + m_cursor); if (current >= 0) { CGUIListItemPtr item = m_items[current]; // render our item if (focused) { focusedPosX = posX; focusedPosY = posY; focusedItem = item; } else RenderItem(posX, posY, item.get(), focused); } // increment our position if (m_orientation == VERTICAL) posY += focused ? m_focusedLayout->Size(m_orientation) : m_layout->Size(m_orientation); else posX += focused ? m_focusedLayout->Size(m_orientation) : m_layout->Size(m_orientation); current++; } // and render the focused item last (for overlapping purposes) if (focusedItem) RenderItem(focusedPosX, focusedPosY, focusedItem.get(), true); g_graphicsContext.RestoreClipRegion(); if (m_pageControl) { // tell our pagecontrol (scrollbar or whatever) to update CGUIMessage msg(GUI_MSG_ITEM_SELECT, GetID(), m_pageControl, offset); SendWindowMessage(msg); } CGUIBaseContainer::Render(); }