示例#1
0
void CGUIBaseContainer::UpdateVisibility(const CGUIListItem *item)
{
  CGUIControl::UpdateVisibility(item);

  if (!IsVisible() && !CGUIControl::CanFocus())
    return; // no need to update the content if we're not visible and we can't focus

  // check whether we need to update our layouts
  if ((m_layout && !m_layout->CheckCondition()) ||
      (m_focusedLayout && !m_focusedLayout->CheckCondition()))
  {
    // and do it
    int item = GetSelectedItem();
    UpdateLayout(true); // true to refresh all items
    SelectItem(item);
  }

  if (m_staticContent)
  { // update our item list with our new content, but only add those items that should
    // be visible.  Save the previous item and keep it if we are adding that one.
    CGUIListItem *lastItem = m_lastItem;
    Reset();
    bool updateItems = false;
    if (!m_staticUpdateTime)
      m_staticUpdateTime = CTimeUtils::GetFrameTime();
    if (CTimeUtils::GetFrameTime() - m_staticUpdateTime > 1000)
    {
      m_staticUpdateTime = CTimeUtils::GetFrameTime();
      updateItems = true;
    }
    for (unsigned int i = 0; i < m_staticItems.size(); ++i)
    {
      CGUIStaticItemPtr item = boost::static_pointer_cast<CGUIStaticItem>(m_staticItems[i]);
      if (item->UpdateVisibility(GetParentID()))
        MarkDirtyRegion();
      if (item->IsVisible())
      {
        m_items.push_back(item);
        if (item.get() == lastItem)
          m_lastItem = lastItem;
      }
      // update any properties
      if (updateItems)
        item->UpdateProperties(GetParentID());
    }
    UpdateScrollByLetter();
  }
}
示例#2
0
void CGUIBaseContainer::UpdateStaticItems(bool refreshItems)
{
    if (m_staticContent)
    {   // update our item list with our new content, but only add those items that should
        // be visible.  Save the previous item and keep it if we are adding that one.
        std::vector<CGUIListItemPtr> items;
        int reselect = -1;
        int selected = GetSelectedItem();
        CGUIListItem* selectedItem = (selected >= 0 && (unsigned int)selected < m_items.size()) ? m_items[selected].get() : NULL;
        bool updateItemsProperties = false;
        if (!m_staticUpdateTime)
            m_staticUpdateTime = CTimeUtils::GetFrameTime();
        if (CTimeUtils::GetFrameTime() - m_staticUpdateTime > 1000)
        {
            m_staticUpdateTime = CTimeUtils::GetFrameTime();
            updateItemsProperties = true;
        }
        for (unsigned int i = 0; i < m_staticItems.size(); ++i)
        {
            CGUIStaticItemPtr staticItem = boost::static_pointer_cast<CGUIStaticItem>(m_staticItems[i]);
            if (staticItem->UpdateVisibility(GetParentID()))
                refreshItems = true;
            if (staticItem->IsVisible())
            {
                items.push_back(staticItem);
                // if item is selected and it changed position, re-select it
                if (staticItem.get() == selectedItem && selected != (int)items.size() - 1)
                    reselect = items.size() - 1;
            }
            // update any properties
            if (updateItemsProperties)
                staticItem->UpdateProperties(GetParentID());
        }
        if (refreshItems)
        {
            Reset();
            m_items = items;
            SetPageControlRange();
            if (reselect >= 0 && reselect < (int)m_items.size())
                SelectItem(reselect);
            MarkDirtyRegion();
        }
        UpdateScrollByLetter();
    }
}
示例#3
0
 std::shared_ptr<CThumbLoader> getThumbLoader(CGUIStaticItemPtr &item)
 {
   if (item->IsVideo())
   {
     initThumbLoader<CVideoThumbLoader>(VIDEO);
     return m_thumbloaders[VIDEO];
   }
   if (item->IsAudio())
   {
     initThumbLoader<CMusicThumbLoader>(AUDIO);
     return m_thumbloaders[AUDIO];
   }
   if (item->IsPicture())
   {
     initThumbLoader<CPictureThumbLoader>(PICTURE);
     return m_thumbloaders[PICTURE];
   }
   initThumbLoader<CProgramThumbLoader>(PROGRAM);
   return m_thumbloaders[PROGRAM];
 }
示例#4
0
bool CGUIBaseContainer::OnClick(int actionID)
{
    int subItem = 0;
    if (actionID == ACTION_SELECT_ITEM || actionID == ACTION_MOUSE_LEFT_CLICK)
    {
        if (m_staticContent)
        {   // "select" action
            int selected = GetSelectedItem();
            if (selected >= 0 && selected < (int)m_items.size())
            {
                CGUIStaticItemPtr item = boost::static_pointer_cast<CGUIStaticItem>(m_items[selected]);
                item->GetClickActions().Execute(GetID(), GetParentID());
            }
            return true;
        }
        // grab the currently focused subitem (if applicable)
        CGUIListItemLayout *focusedLayout = GetFocusedLayout();
        if (focusedLayout)
            subItem = focusedLayout->GetFocusedItem();
    }
    // Don't know what to do, so send to our parent window.
    CGUIMessage msg(GUI_MSG_CLICKED, GetID(), GetParentID(), actionID, subItem);
    return SendWindowMessage(msg);
}
示例#5
0
bool CStaticListProvider::OnClick(const CGUIListItemPtr &item)
{
  CGUIStaticItemPtr staticItem = boost::static_pointer_cast<CGUIStaticItem>(item);
  return staticItem->GetClickActions().ExecuteActions(0, m_parentID);
}