Example #1
0
void CGUIWindowManager::PreviousWindow()
{
  // deactivate any window
  CSingleLock lock(g_graphicsContext);
  CLog::Log(LOGDEBUG,"CGUIWindowManager::PreviousWindow: Deactivate");
  int currentWindow = GetActiveWindow();
  CGUIWindow *pCurrentWindow = GetWindow(currentWindow);
  if (!pCurrentWindow)
    return;     // no windows or window history yet

  // check to see whether our current window has a <previouswindow> tag
  if (pCurrentWindow->GetPreviousWindow() != WINDOW_INVALID)
  {
    //! @todo we may need to test here for the
    //!       whether our history should be changed

    // don't reactivate the previouswindow if it is ourselves.
    if (currentWindow != pCurrentWindow->GetPreviousWindow())
      ActivateWindow(pCurrentWindow->GetPreviousWindow());
    return;
  }
  // get the previous window in our stack
  if (m_windowHistory.size() < 2)
  {
    // no previous window history yet - check if we should just activate home
    if (GetActiveWindow() != WINDOW_INVALID && GetActiveWindow() != WINDOW_HOME)
    {
      CloseWindowSync(pCurrentWindow);
      ClearWindowHistory();
      ActivateWindow(WINDOW_HOME);
    }
    return;
  }
  m_windowHistory.pop();
  int previousWindow = GetActiveWindow();
  m_windowHistory.push(currentWindow);

  CGUIWindow *pNewWindow = GetWindow(previousWindow);
  if (!pNewWindow)
  {
    CLog::Log(LOGERROR, "Unable to activate the previous window");
    CloseWindowSync(pCurrentWindow);
    ClearWindowHistory();
    ActivateWindow(WINDOW_HOME);
    return;
  }

  // ok to go to the previous window now

  // pause game when leaving fullscreen or resume game when entering fullscreen
  if (g_application.m_pPlayer->IsPlayingGame())
  {
    if (previousWindow == WINDOW_FULLSCREEN_VIDEO && g_application.m_pPlayer->IsPaused())
      g_application.OnAction(ACTION_PAUSE);
    else if (currentWindow == WINDOW_FULLSCREEN_VIDEO && !g_application.m_pPlayer->IsPaused())
      g_application.OnAction(ACTION_PAUSE);
  }

  // tell our info manager which window we are going to
  g_infoManager.SetNextWindow(previousWindow);

  // deinitialize our window
  CloseWindowSync(pCurrentWindow);

  g_infoManager.SetNextWindow(WINDOW_INVALID);
  g_infoManager.SetPreviousWindow(currentWindow);

  // remove the current window off our window stack
  m_windowHistory.pop();

  // ok, initialize the new window
  CLog::Log(LOGDEBUG,"CGUIWindowManager::PreviousWindow: Activate new");
  CGUIMessage msg2(GUI_MSG_WINDOW_INIT, 0, 0, WINDOW_INVALID, GetActiveWindow());
  pNewWindow->OnMessage(msg2);

  g_infoManager.SetPreviousWindow(WINDOW_INVALID);
  return;
}
Example #2
0
void CGUIWindowManager::PreviousWindow()
{
  // deactivate any window
  CSingleLock lock(g_graphicsContext);
  CLog::Log(LOGDEBUG,"CGUIWindowManager::PreviousWindow: Deactivate");
  int currentWindow = GetActiveWindow();
  CGUIWindow *pCurrentWindow = GetWindow(currentWindow);
  if (!pCurrentWindow)
    return;     // no windows or window history yet

  // check to see whether our current window has a <previouswindow> tag
  if (pCurrentWindow->GetPreviousWindow() != WINDOW_INVALID)
  {
    // TODO: we may need to test here for the
    //       whether our history should be changed

    // don't reactivate the previouswindow if it is ourselves.
    if (currentWindow != pCurrentWindow->GetPreviousWindow())
      ActivateWindow(pCurrentWindow->GetPreviousWindow());
    return;
  }
  // get the previous window in our stack
  if (m_windowHistory.size() < 2)
  { // no previous window history yet - check if we should just activate home
    if (GetActiveWindow() != WINDOW_INVALID && GetActiveWindow() != WINDOW_HOME)
    {
      ClearWindowHistory();
      ActivateWindow(WINDOW_HOME);
    }
    return;
  }
  m_windowHistory.pop();
  int previousWindow = GetActiveWindow();
  m_windowHistory.push(currentWindow);

  CGUIWindow *pNewWindow = GetWindow(previousWindow);
  if (!pNewWindow)
  {
    CLog::Log(LOGERROR, "Unable to activate the previous window");
    ClearWindowHistory();
    ActivateWindow(WINDOW_HOME);
    return;
  }

  // ok to go to the previous window now

  // tell our info manager which window we are going to
  g_infoManager.SetNextWindow(previousWindow);

  // set our overlay state (enables out animations on window change)
  HideOverlay(pNewWindow->GetOverlayState());

  // deinitialize our window
  CloseWindowSync(pCurrentWindow);

  g_infoManager.SetNextWindow(WINDOW_INVALID);
  g_infoManager.SetPreviousWindow(currentWindow);

  // remove the current window off our window stack
  m_windowHistory.pop();

  // ok, initialize the new window
  CLog::Log(LOGDEBUG,"CGUIWindowManager::PreviousWindow: Activate new");
  CGUIMessage msg2(GUI_MSG_WINDOW_INIT, 0, 0, WINDOW_INVALID, GetActiveWindow());
  pNewWindow->OnMessage(msg2);

  g_infoManager.SetPreviousWindow(WINDOW_INVALID);
  return;
}
Example #3
0
void CGUIWindowManager::PreviousWindow()
{
/*
	参数:
		1、

	返回:
		1、

	说明:
		1、此函数实现激活上一个窗体的功能
		2、函数执行的原理:

			根据窗体操作栈(m_windowHistory) 来实现的
*/
	// deactivate any window
	CSingleLock lock(g_graphicsContext);
	CLog::Log(LOGDEBUG,"CGUIWindowManager::PreviousWindow: Deactivate");
	
	int currentWindow = GetActiveWindow(); /* 获取当前激活窗体的id 号*/
	CGUIWindow *pCurrentWindow = GetWindow(currentWindow); /* 获取当前激活窗体指针*/
	if (!pCurrentWindow)/* 没有当前被激活的窗体*/
		return;     // no windows or window history yet

	// check to see whether our current window has a <previouswindow> tag
	if (pCurrentWindow->GetPreviousWindow() != WINDOW_INVALID)/* 获取当前窗体是否具有上一个窗体的标记*/
	{
		// TODO: we may need to test here for the
		//       whether our history should be changed

		// don't reactivate the previouswindow if it is ourselves.
		if (currentWindow != pCurrentWindow->GetPreviousWindow())
			ActivateWindow(pCurrentWindow->GetPreviousWindow());/* 激活上一个窗体*/
		
		return;/* 返回*/
	}

	/* 
		执行到此处时只能是从窗体的历史记录中获取上一个窗体进行激活了
	*/
	
	// get the previous window in our stack
	/* 窗体操作记录总数少于2 个,则激活home 窗体*/
	if (m_windowHistory.size() < 2)
	{ // no previous window history yet - check if we should just activate home
		if (GetActiveWindow() != WINDOW_INVALID && GetActiveWindow() != WINDOW_HOME)/* 当前窗体有效,并且不是home 窗体,则激活home 窗体,否则直接返回了*/
		{
			ClearWindowHistory();
			ActivateWindow(WINDOW_HOME);
		}
		return; /* 返回*/
	}

	/*
		执行到此处时窗体操作栈中的数量肯定是大于等于2 个,因此需要从窗体操作栈中获取前一个窗体
	*/

	/* 如下三行代码就是从窗体的操作记录表( 窗体操作栈)  中取出当前窗体前一个窗体的id 号*/
	m_windowHistory.pop(); /* 将当前激活的窗体出栈*/
	int previousWindow = GetActiveWindow(); /* 取出当前窗体的前一个窗体,即当前窗体出栈后栈顶的那个窗体*/
	m_windowHistory.push(currentWindow); /* 再将当前激活的窗体入栈*/

	

	CGUIWindow *pNewWindow = GetWindow(previousWindow);/* 根据前一个窗体的id 号取出窗体的指针*/
	if (!pNewWindow)/* 没得到前一个窗体的指针则清除窗体操作记录栈,将home 窗体激活*/
	{
		CLog::Log(LOGERROR, "Unable to activate the previous window");
		ClearWindowHistory();
		ActivateWindow(WINDOW_HOME);
		return;
	}

	/* 
		执行到此处时获得到了前一个窗体的指针
	*/
	
	// ok to go to the previous window now

	//-------------------------------------------------------->>> 调用SetNextWindow 开始
	// tell our info manager which window we are going to
	g_infoManager.SetNextWindow(previousWindow);

	// set our overlay state (enables out animations on window change)
	HideOverlay(pNewWindow->GetOverlayState());

	// deinitialize our window
	CloseWindowSync(pCurrentWindow);

	//-------------------------------------------------------->>> 调用SetNextWindow 结束
	g_infoManager.SetNextWindow(WINDOW_INVALID);
	g_infoManager.SetPreviousWindow(currentWindow);

	// remove the current window off our window stack
	m_windowHistory.pop();

	// ok, initialize the new window
	CLog::Log(LOGDEBUG,"CGUIWindowManager::PreviousWindow: Activate new");
	CGUIMessage msg2(GUI_MSG_WINDOW_INIT, 0, 0, WINDOW_INVALID, GetActiveWindow());
	pNewWindow->OnMessage(msg2);

	g_infoManager.SetPreviousWindow(WINDOW_INVALID);
	return;
}