Beispiel #1
0
bool CGUIBaseContainer::OnClick(int actionID)
{
  int subItem = 0;
  if (actionID == ACTION_SELECT_ITEM || actionID == ACTION_MOUSE_LEFT_CLICK)
  {
    if (m_listProvider)
    { // "select" action
      int selected = GetSelectedItem();
      if (selected >= 0 && selected < (int)m_items.size())
      {
        if (m_clickActions.HasActionsMeetingCondition())
          m_clickActions.ExecuteActions(0, GetParentID(), m_items[selected]);
        else
          m_listProvider->OnClick(m_items[selected]);
      }
      return true;
    }
    // grab the currently focused subitem (if applicable)
    CGUIListItemLayout *focusedLayout = GetFocusedLayout();
    if (focusedLayout)
      subItem = focusedLayout->GetFocusedItem();
  }
  else if (actionID == ACTION_MOUSE_RIGHT_CLICK)
  {
    if (OnContextMenu())
      return true;
  }
  // Don't know what to do, so send to our parent window.
  CGUIMessage msg(GUI_MSG_CLICKED, GetID(), GetParentID(), actionID, subItem);
  return SendWindowMessage(msg);
}
Beispiel #2
0
bool CGUIBaseContainer::GetCondition(int condition, int data) const
{
  switch (condition)
  {
  case CONTAINER_ROW:
    return (m_orientation == VERTICAL) ? (GetCursor() == data) : true;
  case CONTAINER_COLUMN:
    return (m_orientation == HORIZONTAL) ? (GetCursor() == data) : true;
  case CONTAINER_POSITION:
    return (GetCursor() == data);
  case CONTAINER_HAS_NEXT:
    return (HasNextPage());
  case CONTAINER_HAS_PREVIOUS:
    return (HasPreviousPage());
  case CONTAINER_HAS_PARENT_ITEM:
    return (m_items.size() && m_items[0]->IsFileItem() && (std::static_pointer_cast<CFileItem>(m_items[0]))->IsParentFolder());
  case CONTAINER_SUBITEM:
    {
      CGUIListItemLayout *layout = GetFocusedLayout();
      return layout ? (layout->GetFocusedItem() == (unsigned int)data) : false;
    }
  case CONTAINER_SCROLLING:
    return ((m_scrollTimer.IsRunning() && m_scrollTimer.GetElapsedMilliseconds() > std::max(m_scroller.GetDuration(), SCROLLING_THRESHOLD)) || m_pageChangeTimer.IsRunning());
  case CONTAINER_ISUPDATING:
    return (m_listProvider) ? m_listProvider->IsUpdating() : false;
  default:
    return false;
  }
}
//#ifdef PRE_SKIN_VERSION_2_1_COMPATIBILITY
CGUIPanelContainer::CGUIPanelContainer(DWORD dwParentID, DWORD dwControlId, float posX, float posY, float width, float height,
                                       const CImage& imageNoFocus, const CImage& imageFocus,
                                       float itemWidth, float itemHeight,
                                       float textureWidth, float textureHeight,
                                       float thumbPosX, float thumbPosY, float thumbWidth, float thumbHeight, DWORD thumbAlign, const CGUIImage::CAspectRatio &thumbAspect,
                                       const CLabelInfo& labelInfo, bool hideLabels,
                                       CGUIControl *pSpin, CGUIControl *pPanel)
    : CGUIBaseContainer(dwParentID, dwControlId, posX, posY, width, height, VERTICAL, 200)
{
    CGUIListItemLayout layout;
    layout.CreateThumbnailPanelLayouts(itemWidth, itemHeight, false, imageNoFocus, textureWidth, textureHeight, thumbPosX, thumbPosY, thumbWidth, thumbHeight, thumbAlign, thumbAspect, labelInfo, hideLabels);
    m_layouts.push_back(layout);
    CGUIListItemLayout focusedLayout;
    focusedLayout.CreateThumbnailPanelLayouts(itemWidth, itemHeight, true, imageFocus, textureWidth, textureHeight, thumbPosX, thumbPosY, thumbWidth, thumbHeight, thumbAlign, thumbAspect, labelInfo, hideLabels);
    m_focusedLayouts.push_back(focusedLayout);
    m_height -= 5;
    m_itemsPerPage = (int)(m_height / itemHeight);
    if (m_itemsPerPage < 1) m_itemsPerPage = 1;
    m_itemsPerRow = (int)(m_width / itemWidth);
    if (m_itemsPerRow < 1) m_itemsPerRow = 1;
    m_height = m_itemsPerPage * itemHeight;
    m_spinControl = pSpin;
    m_largePanel = pPanel;
    ControlType = GUICONTAINER_PANEL;
}
Beispiel #4
0
bool CGUIBaseContainer::GetCondition(int condition, int data) const
{
    switch (condition)
    {
    case CONTAINER_ROW:
        return (m_orientation == VERTICAL) ? (GetCursor() == data) : true;
    case CONTAINER_COLUMN:
        return (m_orientation == HORIZONTAL) ? (GetCursor() == data) : true;
    case CONTAINER_POSITION:
        return (GetCursor() == data);
    case CONTAINER_HAS_NEXT:
        return (HasNextPage());
    case CONTAINER_HAS_PREVIOUS:
        return (HasPreviousPage());
    case CONTAINER_SUBITEM:
    {
        CGUIListItemLayout *layout = GetFocusedLayout();
        return layout ? (layout->GetFocusedItem() == (unsigned int)data) : false;
    }
    case CONTAINER_SCROLLING:
        return (m_scrollTimer.GetElapsedMilliseconds() > std::max(m_scroller.GetDuration(), SCROLLING_THRESHOLD) || m_pageChangeTimer.IsRunning());
    default:
        return false;
    }
}
bool CGUIBaseContainer::OnClick(DWORD 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())
            {
                CFileItem *item = (CFileItem *)m_items[selected];
                // multiple action strings are concat'd together, separated with " , "
                vector<CStdString> actions;
                StringUtils::SplitString(item->m_strPath, " , ", actions);
                for (unsigned int i = 0; i < actions.size(); i++)
                {
                    CStdString action = actions[i];
                    action.Replace(",,", ",");
                    CGUIMessage message(GUI_MSG_EXECUTE, GetID(), GetParentID());
                    message.SetStringParam(action);
                    g_graphicsContext.SendMessage(message);
                }
            }
            return true;
        }
        // grab the currently focused subitem (if applicable)
        CGUIListItemLayout *focusedLayout = GetFocusedLayout();
        if (focusedLayout)
            subItem = focusedLayout->GetFocus();
    }
    // Don't know what to do, so send to our parent window.
    CGUIMessage msg(GUI_MSG_CLICKED, GetID(), GetParentID(), actionID, subItem);
    return SendWindowMessage(msg);
}
bool CGUIBaseContainer::SelectItemFromPoint(const CPoint &point)
{
    if (!m_focusedLayout || !m_layout)
        return false;

    int row = 0;
    float pos = (m_orientation == VERTICAL) ? point.y : point.x;
    while (row < m_itemsPerPage)
    {
        const CGUIListItemLayout *layout = (row == m_cursor) ? m_focusedLayout : m_layout;
        if (pos < layout->Size(m_orientation) && row + m_offset < (int)m_items.size())
        {   // found correct "row" -> check horizontal
            if (!InsideLayout(layout, point))
                return false;

            MoveToItem(row);
            CGUIListItemLayout *focusedLayout = GetFocusedLayout();
            if (focusedLayout)
            {
                CPoint pt(point);
                if (m_orientation == VERTICAL)
                    pt.y = pos;
                else
                    pt.x = pos;
                focusedLayout->SelectItemFromPoint(pt);
            }
            return true;
        }
        row++;
        pos -= layout->Size(m_orientation);
    }
    return false;
}
Beispiel #7
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();
}
Beispiel #8
0
bool CGUIListContainer::SelectItemFromPoint(const CPoint &point)
{
  CPoint itemPoint;
  int row = GetCursorFromPoint(point, &itemPoint);
  if (row < 0)
    return false;

  SetCursor(row);
  CGUIListItemLayout *focusedLayout = GetFocusedLayout();
  if (focusedLayout)
    focusedLayout->SelectItemFromPoint(itemPoint);
  return true;
}
Beispiel #9
0
void CGUIBaseContainer::OnRight()
{
    bool wrapAround = m_actionRight.GetNavigation() == GetID() || !m_actionRight.HasActionsMeetingCondition();
    if (m_orientation == HORIZONTAL && MoveDown(wrapAround))
        return;
    else if (m_orientation == VERTICAL)
    {
        CGUIListItemLayout *focusedLayout = GetFocusedLayout();
        if (focusedLayout && focusedLayout->MoveRight())
            return;
    }
    CGUIControl::OnRight();
}
Beispiel #10
0
void CGUIBaseContainer::OnLeft()
{
    bool wrapAround = m_dwControlLeft == GetID() || !(m_dwControlLeft || m_leftActions.size());
    if (m_orientation == HORIZONTAL && MoveUp(wrapAround))
        return;
    else if (m_orientation == VERTICAL)
    {
        CGUIListItemLayout *focusedLayout = GetFocusedLayout();
        if (focusedLayout && focusedLayout->MoveLeft())
            return;
    }
    CGUIControl::OnLeft();
}
Beispiel #11
0
void CGUIBaseContainer::OnRight()
{
  bool wrapAround = m_controlRight == GetID() || !(m_controlRight || m_rightActions.size());
  if (m_orientation == HORIZONTAL && MoveDown(wrapAround))
    return;
  else if (m_orientation == VERTICAL)
  {
    CGUIListItemLayout *focusedLayout = GetFocusedLayout();
    if (focusedLayout && focusedLayout->MoveRight())
      return;
  }
  CGUIControl::OnRight();
}
void CGUIBaseContainer::OnLeft()
{
  CGUIAction action = GetNavigateAction(ACTION_MOVE_LEFT);
  bool wrapAround = action.GetNavigation() == GetID() || !action.HasActionsMeetingCondition();
  if (m_orientation == HORIZONTAL && MoveUp(wrapAround))
    return;
  else if (m_orientation == VERTICAL)
  {
    CGUIListItemLayout *focusedLayout = GetFocusedLayout();
    if (focusedLayout && focusedLayout->MoveLeft())
      return;
  }
  CGUIControl::OnLeft();
}
Beispiel #13
0
//#ifdef GUILIB_PYTHON_COMPATIBILITY
CGUIListContainer::CGUIListContainer(int parentID, int controlID, float posX, float posY, float width, float height,
                                 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)
{
  CGUIListItemLayout layout;
  layout.CreateListControlLayouts(width, textureHeight + spaceBetweenItems, false, labelInfo, labelInfo2, textureButton, textureButtonFocus, textureHeight, itemWidth, itemHeight, "", "");
  m_layouts.push_back(layout);
  std::string condition = StringUtils::Format("control.hasfocus(%i)", controlID);
  std::string condition2 = "!" + condition;
  CGUIListItemLayout focusLayout;
  focusLayout.CreateListControlLayouts(width, textureHeight + spaceBetweenItems, true, labelInfo, labelInfo2, textureButton, textureButtonFocus, textureHeight, itemWidth, itemHeight, condition2, condition);
  m_focusedLayouts.push_back(focusLayout);
  m_height = floor(m_height / (textureHeight + spaceBetweenItems)) * (textureHeight + spaceBetweenItems);
  ControlType = GUICONTAINER_LIST;
}
//#ifdef PRE_SKIN_VERSION_9_10_COMPATIBILITY
CGUIListContainer::CGUIListContainer(DWORD dwParentID, DWORD dwControlId, float posX, float posY, float width, float height,
                                 const CLabelInfo& labelInfo, const CLabelInfo& labelInfo2,
                                 const CTextureInfo& textureButton, const CTextureInfo& textureButtonFocus,
                                 float textureHeight, float itemWidth, float itemHeight, float spaceBetweenItems)
: CGUIBaseContainer(dwParentID, dwControlId, posX, posY, width, height, VERTICAL, 200)
{
  CGUIListItemLayout layout;
  layout.CreateListControlLayouts(width, textureHeight + spaceBetweenItems, false, labelInfo, labelInfo2, textureButton, textureButtonFocus, textureHeight, itemWidth, itemHeight, 0, 0);
  m_layouts.push_back(layout);
  CStdString condition;
  condition.Format("control.hasfocus(%i)", dwControlId);
  CStdString condition2 = "!" + condition;
  CGUIListItemLayout focusLayout;
  focusLayout.CreateListControlLayouts(width, textureHeight + spaceBetweenItems, true, labelInfo, labelInfo2, textureButton, textureButtonFocus, textureHeight, itemWidth, itemHeight, g_infoManager.TranslateString(condition2), g_infoManager.TranslateString(condition));
  m_focusedLayouts.push_back(focusLayout);
  m_height = floor(m_height / (textureHeight + spaceBetweenItems)) * (textureHeight + spaceBetweenItems);
  ControlType = GUICONTAINER_LIST;
}
Beispiel #15
0
void CGUIBaseContainer::LoadLayout(TiXmlElement *layout)
{
    TiXmlElement *itemElement = layout->FirstChildElement("itemlayout");
    while (itemElement)
    {   // we have a new item layout
        CGUIListItemLayout itemLayout;
        itemLayout.LoadLayout(itemElement, GetParentID(), false);
        m_layouts.push_back(itemLayout);
        itemElement = itemElement->NextSiblingElement("itemlayout");
    }
    itemElement = layout->FirstChildElement("focusedlayout");
    while (itemElement)
    {   // we have a new item layout
        CGUIListItemLayout itemLayout;
        itemLayout.LoadLayout(itemElement, GetParentID(), true);
        m_focusedLayouts.push_back(itemLayout);
        itemElement = itemElement->NextSiblingElement("focusedlayout");
    }
}
Beispiel #16
0
bool CGUIBaseContainer::GetCondition(int condition, int data) const
{
    switch (condition)
    {
    case CONTAINER_ROW:
        return (m_orientation == VERTICAL) ? (m_cursor == data) : true;
    case CONTAINER_COLUMN:
        return (m_orientation == HORIZONTAL) ? (m_cursor == data) : true;
    case CONTAINER_POSITION:
        return (m_cursor == data);
    case CONTAINER_HAS_NEXT:
        return (HasNextPage());
    case CONTAINER_HAS_PREVIOUS:
        return (HasPreviousPage());
    case CONTAINER_SUBITEM:
    {
        CGUIListItemLayout *layout = GetFocusedLayout();
        return layout ? (layout->GetFocus() == (unsigned int)data) : false;
    }
    default:
        return false;
    }
}
Beispiel #17
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);
}