示例#1
0
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();
}
示例#2
0
CGUIListItemLayout *CGUIBaseContainer::GetFocusedLayout() const
{
  CGUIListItemPtr item = GetListItem(0);
  if (item.get()) return item->GetFocusedLayout();
  return NULL;
}
示例#3
0
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 (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_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);
    }

    g_graphicsContext.RestoreClipRegion();
  }
  CGUIControl::Render();
}
示例#4
0
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();
}
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();
}
示例#6
0
bool CGUIDialogBoxeeShare::OnMessage(CGUIMessage &message)
{
  if (message.GetMessage() == GUI_MSG_WINDOW_INIT)
  {
    //if (!LoadSocialServices(true))
    int retCode;
    if (BoxeeUtils::GetShareServicesJson(m_jsonServiceList,retCode,true) != JOB_SUCCEEDED)
    {
      Close();
      return true;
    }
  }
  else if (message.GetMessage() == GUI_MSG_WINDOW_DEINIT)
  {
    m_item.Reset();
  }
  else if (message.GetMessage() == GUI_MSG_CLICKED)
  {
    switch(message.GetSenderId())
    {
    case EDIT_CONTROL:
    {
      CGUIEditControl* editControl = (CGUIEditControl*)GetControl(EDIT_CONTROL);
      CGUIWindow* activeWindow = g_windowManager.GetWindow(g_windowManager.GetActiveWindow());
      if (editControl && activeWindow)
      {
        CStdString leftToInput = BOXEE::BXUtils::IntToString(editControl->GetMaxInputSize() - (int)editControl->GetLabel2().size());
        activeWindow->SetProperty(LEFT_TO_INPUT_SIZE,leftToInput);
      }
    }
    break;
    case SHARE_BTN:
    {
      CGUIEditControl* editControl = (CGUIEditControl*)GetControl(EDIT_CONTROL);
      if (!editControl)
      {
        CGUIDialogOK2::ShowAndGetInput(257, 55195);
        return true;
      }

      m_strText = editControl->GetLabel2();

      if (m_strText.IsEmpty())
      {
        CGUIDialogOK2::ShowAndGetInput(54000, 54001);
        return true;
      }

      std::vector<BOXEE::BXFriend> recommendTo; // always empty at the moment - which means - "to all the world".

      BoxeeUtils::Share(&m_item, recommendTo, m_servicesList, false, m_strText);
      Close();
      g_application.m_guiDialogKaiToast.QueueNotification(CGUIDialogKaiToast::ICON_HEART, "", g_localizeStrings.Get(51033), 3000, KAI_RED_COLOR, KAI_GREY_COLOR);
    }
    break;
    case SERVICE_LIST:
    {
      CGUIBaseContainer* serviceList = (CGUIBaseContainer*) GetControl(SERVICE_LIST);
      CGUIListItemPtr itemUI = serviceList->GetSelectedItemPtr();

      int iItem = serviceList->GetSelectedItem();
      if (iItem < m_servicesList.Size() && iItem >= 0 )
      {
        CFileItemPtr fileItem = m_servicesList.Get(iItem);
        CFileItem* fItem = fileItem.get();

        //fItem->Dump();

        if (!fileItem->GetPropertyBOOL("enable"))
        {
          //open up the browser dialog with the link we got from the server
#ifdef CANMORE
          if (!g_application.IsPlaying() || g_application.GetCurrentPlayer() != PCID_FLASHLAYER)
          {
            //browser reported success
            int retCode;
            if (CGUIWebDialog::ShowAndGetInput(fileItem->GetProperty("connect")) && BoxeeUtils::GetShareServicesJson(m_jsonServiceList,retCode,true) == JOB_SUCCEEDED)
            {
              UpdateShareDialog();
            }
          }
          else
#endif
          {
            CStdString text = g_localizeStrings.Get(80001);
            text += " " + fileItem->GetProperty("link");
            CGUIDialogOK2::ShowAndGetInput(g_localizeStrings.Get(10014),text);
          }
          return true;
        }

        bool bSelection = itemUI->GetPropertyBOOL("isSelected");
        fItem->SetProperty("isSelected", !bSelection);
        itemUI->SetProperty("isSelected", !bSelection);
      }
    }
    break;
    }
	}

  return CGUIDialog::OnMessage(message);
}
示例#7
0
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();
}
示例#8
0
void CGUIPanelContainer::Render()
{
  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);

  // 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 == m_offset * m_itemsPerRow + m_cursor) && 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();

  UpdatePageControl(offset);

  CGUIControl::Render();
}
示例#9
0
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();
}