void CGUIBaseContainer::Process(unsigned int currentTime, CDirtyRegionList &dirtyregions) { 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.get(), focused, currentTime, dirtyregions); else ProcessItem(pos, origin.y, item.get(), focused, currentTime, dirtyregions); } // increment our position pos += focused ? m_focusedLayout->Size(m_orientation) : m_layout->Size(m_orientation); current++; } UpdatePageControl(offset); CGUIControl::Process(currentTime, dirtyregions); }
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_scrollOffset / m_layout->Size(m_orientation)); int cacheBefore, cacheAfter; GetCacheOffsets(cacheBefore, cacheAfter); // Free memory not used on screen at the moment, do this first so there's more memory for the new items. FreeMemory(CorrectOffset(offset - cacheBefore, 0), CorrectOffset(offset + cacheAfter + m_itemsPerPage + 1, 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_scrollOffset; 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.get(), focused, currentTime, dirtyregions); else ProcessItem(pos, origin.y + col * m_layout->Size(VERTICAL), item.get(), focused, currentTime, dirtyregions); } // increment our position if (col < m_itemsPerRow - 1) col++; else { pos += m_layout->Size(m_orientation); col = 0; } current++; } UpdatePageControl(offset); CGUIControl::Process(currentTime, dirtyregions); }
void CGUIBaseContainer::ProcessItem(float posX, float posY, CGUIListItemPtr& item, bool focused, unsigned int currentTime, CDirtyRegionList &dirtyregions) { if (!m_focusedLayout || !m_layout) return; // set the origin g_graphicsContext.SetOrigin(posX, posY); if (m_bInvalidated) item->SetInvalid(); if (focused) { if (!item->GetFocusedLayout()) { CGUIListItemLayout *layout = new CGUIListItemLayout(*m_focusedLayout, this); item->SetFocusedLayout(layout); } if (item->GetFocusedLayout()) { if (item != m_lastItem || !HasFocus()) { item->GetFocusedLayout()->SetFocusedItem(0); } if (item != m_lastItem && HasFocus()) { item->GetFocusedLayout()->ResetAnimation(ANIM_TYPE_UNFOCUS); unsigned int subItem = 1; if (m_lastItem && m_lastItem->GetFocusedLayout()) subItem = m_lastItem->GetFocusedLayout()->GetFocusedItem(); item->GetFocusedLayout()->SetFocusedItem(subItem ? subItem : 1); } item->GetFocusedLayout()->Process(item.get(), m_parentID, currentTime, dirtyregions); } m_lastItem = item; } else { if (item->GetFocusedLayout()) item->GetFocusedLayout()->SetFocusedItem(0); // focus is not set if (!item->GetLayout()) { CGUIListItemLayout *layout = new CGUIListItemLayout(*m_layout); layout->SetParentControl(this); item->SetLayout(layout); } if (item->GetFocusedLayout()) item->GetFocusedLayout()->Process(item.get(), m_parentID, currentTime, dirtyregions); if (item->GetLayout()) item->GetLayout()->Process(item.get(), m_parentID, currentTime, dirtyregions); } g_graphicsContext.RestoreOrigin(); }
CGUIListItemLayout *CGUIBaseContainer::GetFocusedLayout() const { CGUIListItemPtr item = GetListItem(0); if (item.get()) return item->GetFocusedLayout(); return NULL; }
void CGUIBaseContainer::Render() { if (!m_layout || !m_focusedLayout) return; int offset = (int)floorf(m_scroller.GetValue() / m_layout->Size(m_orientation)); int cacheBefore, cacheAfter; GetCacheOffsets(cacheBefore, cacheAfter); if (g_graphicsContext.SetClipRegion(m_posX, m_posY, m_width, m_height)) { 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); float focusedPos = 0; CGUIListItemPtr focusedItem; 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 (focused) { focusedPos = pos; focusedItem = item; } else { if (m_orientation == VERTICAL) RenderItem(origin.x, pos, item.get(), false); else RenderItem(pos, origin.y, item.get(), false); } } // increment our position pos += focused ? m_focusedLayout->Size(m_orientation) : m_layout->Size(m_orientation); current++; } // render focused item last so it can overlap other items if (focusedItem) { if (m_orientation == VERTICAL) RenderItem(origin.x, focusedPos, focusedItem.get(), true); else RenderItem(focusedPos, origin.y, focusedItem.get(), true); } g_graphicsContext.RestoreClipRegion(); } UpdatePageControl(offset); CGUIControl::Render(); }
void CGUIPanelContainer::Render() { if (!m_layout || !m_focusedLayout) return; int offset = (int)(m_scrollOffset / m_layout->Size(m_orientation)); int cacheBefore, cacheAfter; GetCacheOffsets(cacheBefore, cacheAfter); // Free memory not used on screen at the moment, do this first so there's more memory for the new items. FreeMemory(CorrectOffset(offset - cacheBefore, 0), CorrectOffset(offset + cacheAfter + m_itemsPerPage + 1, 0)); g_graphicsContext.SetClipRegion(m_posX, m_posY, m_width, m_height); 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_scrollOffset; end += cacheAfter * m_layout->Size(m_orientation); float focusedPos = 0; int focusedCol = 0; CGUIListItemPtr focusedItem; 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; // render our item if (focused) { focusedPos = pos; focusedCol = col; focusedItem = item; } else { if (m_orientation == VERTICAL) RenderItem(origin.x + col * m_layout->Size(HORIZONTAL), pos, item.get(), false); else RenderItem(pos, origin.y + col * m_layout->Size(VERTICAL), item.get(), false); } } // increment our position if (col < m_itemsPerRow - 1) col++; else { pos += m_layout->Size(m_orientation); col = 0; } current++; } // and render the focused item last (for overlapping purposes) if (focusedItem) { if (m_orientation == VERTICAL) RenderItem(origin.x + focusedCol * m_layout->Size(HORIZONTAL), focusedPos, focusedItem.get(), true); else RenderItem(focusedPos, origin.y + focusedCol * m_layout->Size(VERTICAL), focusedItem.get(), true); } g_graphicsContext.RestoreClipRegion(); CGUIControl::Render(); }
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(); }
void CGUIPanelContainer::Render() { if (!m_layout || !m_focusedLayout) return; int offset = (int)(m_scroller.GetValue() / m_layout->Size(m_orientation)); int cacheBefore, cacheAfter; GetCacheOffsets(cacheBefore, cacheAfter); if (CServiceBroker::GetWinSystem()->GetGfxContext().SetClipRegion(m_posX, m_posY, m_width, m_height)) { 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); float focusedPos = 0; int focusedCol = 0; CGUIListItemPtr focusedItem; 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; // render our item if (focused) { focusedPos = pos; focusedCol = col; focusedItem = item; } else { if (m_orientation == VERTICAL) RenderItem(origin.x + col * m_layout->Size(HORIZONTAL), pos, item.get(), false); else RenderItem(pos, origin.y + col * m_layout->Size(VERTICAL), item.get(), false); } } // increment our position if (col < m_itemsPerRow - 1) col++; else { pos += m_layout->Size(m_orientation); col = 0; } current++; } // and render the focused item last (for overlapping purposes) if (focusedItem) { if (m_orientation == VERTICAL) RenderItem(origin.x + focusedCol * m_layout->Size(HORIZONTAL), focusedPos, focusedItem.get(), true); else RenderItem(focusedPos, origin.y + focusedCol * m_layout->Size(VERTICAL), focusedItem.get(), true); } CServiceBroker::GetWinSystem()->GetGfxContext().RestoreClipRegion(); } CGUIControl::Render(); }
void CGUIPanelContainer::Render() { bool bIsScrolling = IsScrolling(); #ifndef OLD_SCROLLING if (!bIsScrolling && !m_deferredActions.empty()) { { CSingleLock lock(m_actionsLock); if (!m_deferredActions.empty()) { CAction action = m_deferredActions.front(); m_deferredActions.pop(); g_application.DeferAction(action); } } } #endif ValidateOffset(); if (m_bInvalidated) UpdateLayout(); if (!m_layout || !m_focusedLayout) return; UpdateScrollOffset(); int offset = (int)(m_scrollOffset / m_layout->Size(m_orientation) ); int cacheBefore, cacheAfter; GetCacheOffsets(cacheBefore, cacheAfter); // the following is required to avoid releasing the mem from rows that are rendered partially if (cacheBefore < 2) cacheBefore = 2; if (cacheAfter < 2) cacheAfter = 2; // Free memory not used on screen at the moment, do this first so there's more memory for the new items. // Free only if we're not scrolling up/down, if there was a change in the movement and the time since we last freed the memory was above 2 seconds if (m_bShouldFreeMemory && !ScrollingDown() && !ScrollingUp() && m_memoryTimer.GetElapsedSeconds() > 2) { FreeMemory(CorrectOffset(offset - cacheBefore, 0), CorrectOffset(offset + cacheAfter + m_itemsPerPage + 1, 0)); m_bShouldFreeMemory = false; m_memoryTimer.StartZero(); } bool clip = g_graphicsContext.SetClipRegion(m_posX + m_offsetX, m_posY + m_offsetY, m_width, m_height); float pos = (m_orientation == VERTICAL) ? m_posY + m_offsetY : m_posX + m_offsetX; float end = (m_orientation == VERTICAL) ? m_posY + m_height : m_posX + m_width; pos += (offset - cacheBefore) * m_layout->Size(m_orientation) - m_scrollOffset; end += cacheAfter * m_layout->Size(m_orientation); float focusedPos = 0; unsigned int focusedCol = 0; unsigned int focusedRow = 0; CGUIListItemPtr focusedItem; int current = (offset - cacheBefore) * m_itemsPerRow; unsigned int col = 0; unsigned int row = 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 == m_offset * m_itemsPerRow + m_cursor) && m_bHasFocus; // render our item if (focused) { focusedPos = pos; focusedCol = col; focusedRow = row; focusedItem = item; } else { if (m_orientation == VERTICAL) RenderItem(m_posX + m_offsetX + col * m_layout->Size(HORIZONTAL), pos, item.get(), row, col, false); else RenderItem(pos, m_posY + m_offsetY + col * m_layout->Size(VERTICAL), item.get(), row, col, false); } } // increment our position if (col < (size_t) (m_itemsPerRow - 1)) col++; else { pos += m_layout->Size(m_orientation); col = 0; row++; } current++; } // and render the focused item last (for overlapping purposes) if (focusedItem) { if (m_orientation == VERTICAL) RenderItem(m_posX + m_offsetX + focusedCol * m_layout->Size(HORIZONTAL), focusedPos, focusedItem.get(), focusedRow, focusedCol, true); else RenderItem(focusedPos, m_posY + m_offsetY + focusedCol * m_layout->Size(VERTICAL), focusedItem.get(), focusedRow, focusedCol, true); } m_firstRenderAfterLoad = false; if(clip) g_graphicsContext.RestoreClipRegion(); UpdatePageControl(offset); CGUIControl::Render(); }