diff --git a/xbmc/guilib/GUIBaseContainer.cpp b/xbmc/guilib/GUIBaseContainer.cpp index 0708b7b3443..ecb50eda556 100644 --- a/xbmc/guilib/GUIBaseContainer.cpp +++ b/xbmc/guilib/GUIBaseContainer.cpp @@ -40,7 +40,7 @@ using namespace KODI; #define SCROLLING_GAP 200U #define SCROLLING_THRESHOLD 300U -CGUIBaseContainer::CGUIBaseContainer(int parentID, int controlID, float posX, float posY, float width, float height, ORIENTATION orientation, const CScroller& scroller, int preloadItems) +CGUIBaseContainer::CGUIBaseContainer(int parentID, int controlID, float posX, float posY, float width, float height, ORIENTATION orientation, const CScroller& scroller, int preloadItems, bool unloadDelayed) : IGUIContainer(parentID, controlID, posX, posY, width, height) , m_scroller(scroller) { @@ -55,6 +55,7 @@ CGUIBaseContainer::CGUIBaseContainer(int parentID, int controlID, float posX, fl m_layout = nullptr; m_focusedLayout = nullptr; m_cacheItems = preloadItems; + m_unloadDelayed = unloadDelayed; m_scrollItemsPerFrame = 0.0f; m_type = VIEW_TYPE_NONE; m_autoScrollMoveTime = 0; @@ -85,6 +86,7 @@ CGUIBaseContainer::CGUIBaseContainer(const CGUIBaseContainer& other) m_cursor(other.m_cursor), m_offset(other.m_offset), m_cacheItems(other.m_cacheItems), + m_unloadDelayed(other.m_unloadDelayed), m_scrollTimer(other.m_scrollTimer), m_lastScrollStartTimer(other.m_lastScrollStartTimer), m_pageChangeTimer(other.m_pageChangeTimer), @@ -1480,18 +1482,18 @@ void CGUIBaseContainer::GetCacheOffsets(int &cacheBefore, int &cacheAfter) const { if (m_scroller.IsScrollingDown()) { - cacheBefore = 0; - cacheAfter = m_cacheItems; + cacheBefore = !m_unloadDelayed ? 0 : 1; + cacheAfter = m_cacheItems > 0 ? 1 : 0; } else if (m_scroller.IsScrollingUp()) { - cacheBefore = m_cacheItems; + cacheBefore = !m_unloadDelayed && m_cacheItems == 0 ? 0 : 1; cacheAfter = 0; } else { - cacheBefore = m_cacheItems / 2; - cacheAfter = m_cacheItems / 2; + cacheBefore = m_unloadDelayed && m_cacheItems == 0 ? 1 : m_cacheItems; + cacheAfter = m_cacheItems; } } diff --git a/xbmc/guilib/GUIBaseContainer.h b/xbmc/guilib/GUIBaseContainer.h index e8a5fc78860..e8d3cb3ddc3 100644 --- a/xbmc/guilib/GUIBaseContainer.h +++ b/xbmc/guilib/GUIBaseContainer.h @@ -35,7 +35,7 @@ class CGUIListItemLayout; class CGUIBaseContainer : public IGUIContainer { public: - CGUIBaseContainer(int parentID, int controlID, float posX, float posY, float width, float height, ORIENTATION orientation, const CScroller& scroller, int preloadItems); + CGUIBaseContainer(int parentID, int controlID, float posX, float posY, float width, float height, ORIENTATION orientation, const CScroller& scroller, int preloadItems, bool unloadDelayed); explicit CGUIBaseContainer(const CGUIBaseContainer& other); ~CGUIBaseContainer(void) override; @@ -233,6 +233,7 @@ class CGUIBaseContainer : public IGUIContainer int m_cursor; int m_offset; int m_cacheItems; + bool m_unloadDelayed; CStopWatch m_scrollTimer; CStopWatch m_lastScrollStartTimer; CStopWatch m_pageChangeTimer; diff --git a/xbmc/guilib/GUIControlFactory.cpp b/xbmc/guilib/GUIControlFactory.cpp index b191a6a9615..8dd74749cb4 100644 --- a/xbmc/guilib/GUIControlFactory.cpp +++ b/xbmc/guilib/GUIControlFactory.cpp @@ -881,6 +881,7 @@ CGUIControl* CGUIControlFactory::Create(int parentID, bool showOnePage = true; bool scrollOut = true; int preloadItems = 0; + bool unloadDelayed = false; CLabelInfo labelInfo, labelInfoMono; @@ -1165,7 +1166,8 @@ CGUIControl* CGUIControlFactory::Create(int parentID, XMLUtils::GetBoolean(pControlNode, "showonepage", showOnePage); XMLUtils::GetInt(pControlNode, "focusposition", focusPosition); XMLUtils::GetInt(pControlNode, "scrolltime", scrollTime); - XMLUtils::GetInt(pControlNode, "preloaditems", preloadItems, 0, 2); + XMLUtils::GetInt(pControlNode, "preloaditems", preloadItems, 0, 1); + XMLUtils::GetBoolean(pControlNode, "unloaddelayed", unloadDelayed); XMLUtils::GetBoolean(pControlNode, "usecontrolcoords", useControlCoords); XMLUtils::GetBoolean(pControlNode, "renderfocusedlast", renderFocusedLast); @@ -1591,7 +1593,7 @@ CGUIControl* CGUIControlFactory::Create(int parentID, GetScroller(pControlNode, "scrolltime", scroller); control = new CGUIPanelContainer(parentID, id, posX, posY, width, height, orientation, - scroller, preloadItems); + scroller, preloadItems, unloadDelayed); auto pcontrol = static_cast(control); pcontrol->LoadLayout(pControlNode); pcontrol->LoadListProvider(pControlNode, defaultControl, defaultAlways); diff --git a/xbmc/guilib/GUIFixedListContainer.cpp b/xbmc/guilib/GUIFixedListContainer.cpp index ab24f5cf583..2d8483fce9b 100644 --- a/xbmc/guilib/GUIFixedListContainer.cpp +++ b/xbmc/guilib/GUIFixedListContainer.cpp @@ -13,7 +13,7 @@ #include "input/actions/ActionIDs.h" CGUIFixedListContainer::CGUIFixedListContainer(int parentID, int controlID, float posX, float posY, float width, float height, ORIENTATION orientation, const CScroller& scroller, int preloadItems, int fixedPosition, int cursorRange) - : CGUIBaseContainer(parentID, controlID, posX, posY, width, height, orientation, scroller, preloadItems) + : CGUIBaseContainer(parentID, controlID, posX, posY, width, height, orientation, scroller, preloadItems, false) { ControlType = GUICONTAINER_FIXEDLIST; m_type = VIEW_TYPE_LIST; diff --git a/xbmc/guilib/GUIListContainer.cpp b/xbmc/guilib/GUIListContainer.cpp index 15612a9b49f..777416f3280 100644 --- a/xbmc/guilib/GUIListContainer.cpp +++ b/xbmc/guilib/GUIListContainer.cpp @@ -15,7 +15,7 @@ #include "utils/StringUtils.h" CGUIListContainer::CGUIListContainer(int parentID, int controlID, float posX, float posY, float width, float height, ORIENTATION orientation, const CScroller& scroller, int preloadItems) - : CGUIBaseContainer(parentID, controlID, posX, posY, width, height, orientation, scroller, preloadItems) + : CGUIBaseContainer(parentID, controlID, posX, posY, width, height, orientation, scroller, preloadItems, false) { ControlType = GUICONTAINER_LIST; m_type = VIEW_TYPE_LIST; @@ -276,7 +276,7 @@ CGUIListContainer::CGUIListContainer(int parentID, int controlID, float posX, fl const CLabelInfo& labelInfo, const CLabelInfo& labelInfo2, const CTextureInfo& textureButton, const CTextureInfo& textureButtonFocus, float textureHeight, float itemWidth, float itemHeight, float spaceBetweenItems) -: CGUIBaseContainer(parentID, controlID, posX, posY, width, height, VERTICAL, 200, 0) +: CGUIBaseContainer(parentID, controlID, posX, posY, width, height, VERTICAL, 200, 0, false) { m_layouts.emplace_back(); m_layouts.back().CreateListControlLayouts(width, textureHeight + spaceBetweenItems, false, labelInfo, labelInfo2, textureButton, textureButtonFocus, textureHeight, itemWidth, itemHeight, "", ""); diff --git a/xbmc/guilib/GUIPanelContainer.cpp b/xbmc/guilib/GUIPanelContainer.cpp index 415f5914882..527f2437075 100644 --- a/xbmc/guilib/GUIPanelContainer.cpp +++ b/xbmc/guilib/GUIPanelContainer.cpp @@ -18,8 +18,8 @@ #include -CGUIPanelContainer::CGUIPanelContainer(int parentID, int controlID, float posX, float posY, float width, float height, ORIENTATION orientation, const CScroller& scroller, int preloadItems) - : CGUIBaseContainer(parentID, controlID, posX, posY, width, height, orientation, scroller, preloadItems) +CGUIPanelContainer::CGUIPanelContainer(int parentID, int controlID, float posX, float posY, float width, float height, ORIENTATION orientation, const CScroller& scroller, int preloadItems, bool unloadDelayed) + : CGUIBaseContainer(parentID, controlID, posX, posY, width, height, orientation, scroller, preloadItems, unloadDelayed) { ControlType = GUICONTAINER_PANEL; m_type = VIEW_TYPE_ICON; diff --git a/xbmc/guilib/GUIPanelContainer.h b/xbmc/guilib/GUIPanelContainer.h index 3087156f5c3..578a53b5f05 100644 --- a/xbmc/guilib/GUIPanelContainer.h +++ b/xbmc/guilib/GUIPanelContainer.h @@ -22,7 +22,7 @@ class CGUIPanelContainer : public CGUIBaseContainer { public: - CGUIPanelContainer(int parentID, int controlID, float posX, float posY, float width, float height, ORIENTATION orientation, const CScroller& scroller, int preloadItems); + CGUIPanelContainer(int parentID, int controlID, float posX, float posY, float width, float height, ORIENTATION orientation, const CScroller& scroller, int preloadItems, bool unloadDelayed); ~CGUIPanelContainer(void) override; CGUIPanelContainer* Clone() const override { return new CGUIPanelContainer(*this); } diff --git a/xbmc/guilib/GUIWrappingListContainer.cpp b/xbmc/guilib/GUIWrappingListContainer.cpp index 2ac2d179b14..08704323ea5 100644 --- a/xbmc/guilib/GUIWrappingListContainer.cpp +++ b/xbmc/guilib/GUIWrappingListContainer.cpp @@ -15,7 +15,7 @@ #include "input/actions/ActionIDs.h" CGUIWrappingListContainer::CGUIWrappingListContainer(int parentID, int controlID, float posX, float posY, float width, float height, ORIENTATION orientation, const CScroller& scroller, int preloadItems, int fixedPosition) - : CGUIBaseContainer(parentID, controlID, posX, posY, width, height, orientation, scroller, preloadItems) + : CGUIBaseContainer(parentID, controlID, posX, posY, width, height, orientation, scroller, preloadItems, false) { SetCursor(fixedPosition); ControlType = GUICONTAINER_WRAPLIST;