Ejemplo n.º 1
0
void CGUIViewControl::SetCurrentView(int viewMode, bool focusToCurrentView)
{
  // grab the previous control
  CGUIControl *previousView = NULL;
  if (m_currentView >= 0 && m_currentView < (int)m_visibleViews.size())
    previousView = m_visibleViews[m_currentView];

  UpdateViewVisibility();

  // viewMode is of the form TYPE << 16 | ID
  VIEW_TYPE type = (VIEW_TYPE)(viewMode >> 16);
  int id = viewMode & 0xffff;

  // first find a view that matches this view, if possible...
  int newView = GetView(type, id);
  if (newView < 0) // no suitable view that matches both id and type, so try just type
    newView = GetView(type, 0);
  if (newView < 0 && type == VIEW_TYPE_BIG_ICON) // try icon view if they want big icon
    newView = GetView(VIEW_TYPE_ICON, 0);
  if (newView < 0) // try a list view
    newView = GetView(VIEW_TYPE_LIST, 0);
  if (newView < 0) // try anything!
    newView = GetView(VIEW_TYPE_NONE, 0);

  if (newView < 0)
    return;

  SelectVisibleView(newView, previousView, focusToCurrentView);
}
Ejemplo n.º 2
0
// Sets view by control id only
void CGUIViewControl::SetCurrentViewByID(int viewId, bool focusToCurrentView)
{
  // grab the previous control
  CGUIControl *previousView = NULL;
  if (m_currentView >= 0 && m_currentView < (int)m_visibleViews.size())
    previousView = m_visibleViews[m_currentView];

  UpdateViewVisibility();

  // first find a view that matches this view, if possible...
  int newView = GetView(VIEW_TYPE_NONE, viewId);

  if (newView < 0)
    return;

  SelectVisibleView(newView, previousView, focusToCurrentView);
}
Ejemplo n.º 3
0
void CGUIViewControl::SetCurrentView(int viewMode, bool bRefresh /* = false */)
{
    // grab the previous control
    CGUIControl *previousView = NULL;
    if (m_currentView >= 0 && m_currentView < (int)m_visibleViews.size())
        previousView = m_visibleViews[m_currentView];

    UpdateViewVisibility();

    // viewMode is of the form TYPE << 16 | ID
    VIEW_TYPE type = (VIEW_TYPE)(viewMode >> 16);
    int id = viewMode & 0xffff;

    // first find a view that matches this view, if possible...
    int newView = GetView(type, id);
    if (newView < 0) // no suitable view that matches both id and type, so try just type
        newView = GetView(type, 0);
    if (newView < 0 && type == VIEW_TYPE_BIG_ICON) // try icon view if they want big icon
        newView = GetView(VIEW_TYPE_ICON, 0);
    if (newView < 0 && type == VIEW_TYPE_BIG_INFO)
        newView = GetView(VIEW_TYPE_INFO, 0);
    if (newView < 0) // try a list view
        newView = GetView(VIEW_TYPE_LIST, 0);
    if (newView < 0) // try anything!
        newView = GetView(VIEW_TYPE_NONE, 0);

    if (newView < 0)
        return;

    m_currentView = newView;
    CGUIControl *pNewView = m_visibleViews[m_currentView];

    // make only current control visible...
    for (ciViews view = m_allViews.begin(); view != m_allViews.end(); ++view)
        (*view)->SetVisible(false);
    pNewView->SetVisible(true);

    if (!bRefresh && pNewView == previousView)
        return; // no need to actually update anything (other than visibility above)

//  CLog::Log(LOGDEBUG,"SetCurrentView: Oldview: %i, Newview :%i", m_currentView, viewMode);

    bool hasFocus(false);
    int item = -1;
    if (previousView)
    {   // have an old view - let's clear it out and hide it.
        hasFocus = previousView->HasFocus();
        item = GetSelectedItem(previousView);
        CGUIMessage msg(GUI_MSG_LABEL_RESET, m_parentWindow, previousView->GetID());
        previousView->OnMessage(msg);
    }

    // Update it with the contents
    UpdateContents(pNewView, item);

    // and focus if necessary
    if (hasFocus)
    {
        CGUIMessage msg(GUI_MSG_SETFOCUS, m_parentWindow, pNewView->GetID(), 0);
        g_windowManager.SendMessage(msg, m_parentWindow);
    }

    UpdateViewAsControl(((IGUIContainer *)pNewView)->GetLabel());
}