CGUIDialog* CGUIWindowManager::GetDialog(int id) const { CGUIWindow *window = GetWindow(id); if (window->IsDialog()) return dynamic_cast<CGUIDialog*>(window); return nullptr; }
void CGUIWindowManager::Process(unsigned int currentTime) { assert(g_application.IsCurrentThread()); CSingleLock lock(g_graphicsContext); CDirtyRegionList dirtyregions; CGUIWindow* pWindow = GetWindow(GetActiveWindow()); if (pWindow) pWindow->DoProcess(currentTime, dirtyregions); // process all dialogs - visibility may change etc. for (WindowMap::iterator it = m_mapWindows.begin(); it != m_mapWindows.end(); it++) { CGUIWindow *pWindow = (*it).second; if (pWindow && pWindow->IsDialog()) pWindow->DoProcess(currentTime, dirtyregions); } if (g_application.m_AppActive) { for (CDirtyRegionList::iterator itr = dirtyregions.begin(); itr != dirtyregions.end(); itr++) m_tracker.MarkDirtyRegion(*itr); } }
// Shows and hides modeless dialogs as necessary. void CGUIWindowManager::UpdateModelessVisibility() { CSingleLock lock(g_graphicsContext); for (WindowMap::iterator it = m_mapWindows.begin(); it != m_mapWindows.end(); it++) { CGUIWindow *pWindow = (*it).second; if (pWindow && pWindow->IsDialog() && pWindow->GetVisibleCondition()) { if (g_infoManager.GetBool(pWindow->GetVisibleCondition(), GetActiveWindow())) ((CGUIDialog *)pWindow)->Show(); else ((CGUIDialog *)pWindow)->Close(); } } }
/*! \brief Close a dialog. * \param params The parameters. * \details params[0] = "all" to close all dialogs, or dialog name. * params[1] = "true" to force close (skip animations) (optional). */ static int CloseDialog(const std::vector<std::string>& params) { bool bForce = false; if (params.size() > 1 && StringUtils::EqualsNoCase(params[1], "true")) bForce = true; if (StringUtils::EqualsNoCase(params[0], "all")) { CServiceBroker::GetGUI()->GetWindowManager().CloseDialogs(bForce); } else { int id = CWindowTranslator::TranslateWindow(params[0]); CGUIWindow *window = CServiceBroker::GetGUI()->GetWindowManager().GetWindow(id); if (window && window->IsDialog()) static_cast<CGUIDialog*>(window)->Close(bForce); } return 0; }
/*! \brief Close a dialog. * \param params The parameters. * \details params[0] = "all" to close all dialogs, or dialog name. * params[1] = "true" to force close (skip animations) (optional). */ static int CloseDialog(const std::vector<std::string>& params) { bool bForce = false; if (params.size() > 1 && StringUtils::EqualsNoCase(params[1], "true")) bForce = true; if (StringUtils::EqualsNoCase(params[0], "all")) { g_windowManager.CloseDialogs(bForce); } else { int id = CButtonTranslator::TranslateWindow(params[0]); CGUIWindow *window = (CGUIWindow *)g_windowManager.GetWindow(id); if (window && window->IsDialog()) ((CGUIDialog *)window)->Close(bForce); } return 0; }
void CGUIWindowManager::ActivateWindow_Internal(int iWindowID, const vector<CStdString>& params, bool swappingWindows) { // translate virtual windows // virtual music window which returns the last open music window (aka the music start window) if (iWindowID == WINDOW_MUSIC) { iWindowID = g_settings.m_iMyMusicStartWindow; // ensure the music virtual window only returns music files and music library windows if (iWindowID != WINDOW_MUSIC_NAV) iWindowID = WINDOW_MUSIC_FILES; } // virtual video window which returns the last open video window (aka the video start window) if (iWindowID == WINDOW_VIDEOS || iWindowID == WINDOW_VIDEO_FILES) { // backward compatibility for pre-Eden iWindowID = WINDOW_VIDEO_NAV; } if (iWindowID == WINDOW_SCRIPTS) { // backward compatibility for pre-Dharma iWindowID = WINDOW_PROGRAMS; } if (iWindowID == WINDOW_START) { // virtual start window iWindowID = g_SkinInfo->GetStartWindow(); } // debug CLog::Log(LOGDEBUG, "Activating window ID: %i", iWindowID); if (!g_passwordManager.CheckMenuLock(iWindowID)) { CLog::Log(LOGERROR, "MasterCode is Wrong: Window with id %d will not be loaded! Enter a correct MasterCode!", iWindowID); if (GetActiveWindow() == WINDOW_INVALID && iWindowID != WINDOW_HOME) ActivateWindow(WINDOW_HOME); return; } // first check existence of the window we wish to activate. CGUIWindow *pNewWindow = GetWindow(iWindowID); if (!pNewWindow) { // nothing to see here - move along CLog::Log(LOGERROR, "Unable to locate window with id %d. Check skin files", iWindowID - WINDOW_HOME); return ; } else if (pNewWindow->IsDialog()) { // if we have a dialog, we do a DoModal() rather than activate the window if (!pNewWindow->IsDialogRunning()) { CSingleExit exitit(g_graphicsContext); ((CGUIDialog *)pNewWindow)->DoModal(iWindowID, params.size() ? params[0] : ""); } return; } g_infoManager.SetNextWindow(iWindowID); // set our overlay state HideOverlay(pNewWindow->GetOverlayState()); // deactivate any window int currentWindow = GetActiveWindow(); CGUIWindow *pWindow = GetWindow(currentWindow); if (pWindow) CloseWindowSync(pWindow, iWindowID); g_infoManager.SetNextWindow(WINDOW_INVALID); // Add window to the history list (we must do this before we activate it, // as all messages done in WINDOW_INIT will want to be sent to the new // topmost window). If we are swapping windows, we pop the old window // off the history stack if (swappingWindows && m_windowHistory.size()) m_windowHistory.pop(); AddToWindowHistory(iWindowID); g_infoManager.SetPreviousWindow(currentWindow); // Send the init message CGUIMessage msg(GUI_MSG_WINDOW_INIT, 0, 0, currentWindow, iWindowID); msg.SetStringParams(params); pNewWindow->OnMessage(msg); // g_infoManager.SetPreviousWindow(WINDOW_INVALID); }
void CGUIWindowManager::ActivateWindow_Internal(int iWindowID, const std::vector<std::string>& params, bool swappingWindows, bool force /* = false */) { // translate virtual windows // virtual music window which returns the last open music window (aka the music start window) if (iWindowID == WINDOW_MUSIC || iWindowID == WINDOW_MUSIC_FILES) { // backward compatibility for pre-something iWindowID = WINDOW_MUSIC_NAV; } // virtual video window which returns the last open video window (aka the video start window) if (iWindowID == WINDOW_VIDEOS || iWindowID == WINDOW_VIDEO_FILES) { // backward compatibility for pre-Eden iWindowID = WINDOW_VIDEO_NAV; } if (iWindowID == WINDOW_SCRIPTS) { // backward compatibility for pre-Dharma iWindowID = WINDOW_PROGRAMS; } if (iWindowID == WINDOW_START) { // virtual start window iWindowID = g_SkinInfo->GetStartWindow(); } // debug CLog::Log(LOGDEBUG, "Activating window ID: %i", iWindowID); if (!g_passwordManager.CheckMenuLock(iWindowID)) { CLog::Log(LOGERROR, "MasterCode is Wrong: Window with id %d will not be loaded! Enter a correct MasterCode!", iWindowID); if (GetActiveWindow() == WINDOW_INVALID && iWindowID != WINDOW_HOME) ActivateWindow(WINDOW_HOME); return; } // first check existence of the window we wish to activate. CGUIWindow *pNewWindow = GetWindow(iWindowID); if (!pNewWindow) { // nothing to see here - move along CLog::Log(LOGERROR, "Unable to locate window with id %d. Check skin files", iWindowID - WINDOW_HOME); return ; } else if (!pNewWindow->CanBeActivated()) { return; } else if (pNewWindow->IsDialog()) { // if we have a dialog, we do a DoModal() rather than activate the window if (!pNewWindow->IsDialogRunning()) { CSingleExit exitit(g_graphicsContext); ((CGUIDialog *)pNewWindow)->Open(params.size() > 0 ? params[0] : ""); } return; } // don't activate a window if there are active modal dialogs of type NORMAL if (!force && HasModalDialog({ DialogModalityType::MODAL })) { CLog::Log(LOGINFO, "Activate of window '%i' refused because there are active modal dialogs", iWindowID); g_audioManager.PlayActionSound(CAction(ACTION_ERROR)); return; } g_infoManager.SetNextWindow(iWindowID); // deactivate any window int currentWindow = GetActiveWindow(); CGUIWindow *pWindow = GetWindow(currentWindow); if (pWindow) CloseWindowSync(pWindow, iWindowID); g_infoManager.SetNextWindow(WINDOW_INVALID); // Add window to the history list (we must do this before we activate it, // as all messages done in WINDOW_INIT will want to be sent to the new // topmost window). If we are swapping windows, we pop the old window // off the history stack if (swappingWindows && !m_windowHistory.empty()) m_windowHistory.pop(); AddToWindowHistory(iWindowID); g_infoManager.SetPreviousWindow(currentWindow); // Send the init message CGUIMessage msg(GUI_MSG_WINDOW_INIT, 0, 0, currentWindow, iWindowID); msg.SetStringParams(params); pNewWindow->OnMessage(msg); // g_infoManager.SetPreviousWindow(WINDOW_INVALID); }
void CGUIWindowManager::ActivateWindow_Internal(int iWindowID, const vector<CStdString>& params, bool swappingWindows) { /* 参数: 1、iWindowID : 要激活的窗体id 号 2、params : 传递给窗体的参数 3、swappingWindows : 是否交换激活窗体( 见下面对此参数的说明) 返回: 1、 说明: 1、激活窗体的原则: A、根据传入的窗体id 找到要激活的窗体指针 1) 没找到 a、直接出错返回 2) 找到了 a、如果是一个对话框,则调用对话框的DoModal 方法将对话框显示,然后返回 b、执行下面的B 步骤 B、 C、 2、参数swappingWindows 的作用: 假设: AAA : 原来激活的窗体,即当前激活窗体 BBB : 要激活的窗体 true : 将BBB 窗体激活,将AAA 窗体从窗体操作栈出栈,将BBB 窗体添加到窗体操作栈 false : 将BBB 窗体激活,不将AAA 窗体从窗体操作栈出栈,将BBB 窗体添加到窗体操作栈 */ // translate virtual windows // virtual music window which returns the last open music window (aka the music start window) if (iWindowID == WINDOW_MUSIC) { iWindowID = g_settings.m_iMyMusicStartWindow; // ensure the music virtual window only returns music files and music library windows if (iWindowID != WINDOW_MUSIC_NAV) iWindowID = WINDOW_MUSIC_FILES; } // virtual video window which returns the last open video window (aka the video start window) if (iWindowID == WINDOW_VIDEOS || iWindowID == WINDOW_VIDEO_FILES) { // backward compatibility for pre-Eden iWindowID = WINDOW_VIDEO_NAV; } if (iWindowID == WINDOW_SCRIPTS) { // backward compatibility for pre-Dharma iWindowID = WINDOW_PROGRAMS; } if (iWindowID == WINDOW_START) { // virtual start window iWindowID = g_SkinInfo->GetStartWindow(); } // debug CLog::Log(LOGDEBUG, "Activating window ID: %i", iWindowID); if (!g_passwordManager.CheckMenuLock(iWindowID)) { CLog::Log(LOGERROR, "MasterCode is Wrong: Window with id %d will not be loaded! Enter a correct MasterCode!", iWindowID); if (GetActiveWindow() == WINDOW_INVALID && iWindowID != WINDOW_HOME) ActivateWindow(WINDOW_HOME); return; } // first check existence of the window we wish to activate. CGUIWindow *pNewWindow = GetWindow(iWindowID);/* 获取要激活的窗体*/ if (!pNewWindow)/* 没得到*/ { // nothing to see here - move along CLog::Log(LOGERROR, "Unable to locate window with id %d. Check skin files", iWindowID - WINDOW_HOME); return ; } else if (pNewWindow->IsDialog()) /* 如果要激活的窗体是个对话框*/ { // if we have a dialog, we do a DoModal() rather than activate the window if (!pNewWindow->IsDialogRunning())/* 对话框没有在运行状态,则将其模态显示出来*/ { CSingleExit exitit(g_graphicsContext); ((CGUIDialog *)pNewWindow)->DoModal(iWindowID, params.size() ? params[0] : ""); } return; } //-------------------------------------------------------->>> 调用SetNextWindow 开始 g_infoManager.SetNextWindow(iWindowID); /* 设定要激活的窗体的id 为下一个窗体id ,即相当于全局变量保存这个值*/ // set our overlay state HideOverlay(pNewWindow->GetOverlayState()); // deactivate any window int currentWindow = GetActiveWindow(); CGUIWindow *pWindow = GetWindow(currentWindow); if (pWindow) CloseWindowSync(pWindow, iWindowID); //-------------------------------------------------------->>> 调用SetNextWindow 结束 g_infoManager.SetNextWindow(WINDOW_INVALID); /* 设定下一个窗体id 为无效的*/ // Add window to the history list (we must do this before we activate it, // as all messages done in WINDOW_INIT will want to be sent to the new // topmost window). If we are swapping windows, we pop the old window // off the history stack if (swappingWindows && m_windowHistory.size()) m_windowHistory.pop(); /* 将当前激活的窗体从窗体操作栈中出栈*/ AddToWindowHistory(iWindowID); /* 将要激活的窗体id 号添加入窗体操作栈*/ g_infoManager.SetPreviousWindow(currentWindow); /* 向要激活的窗体发送init 消息,即直接调用要激活窗体的OnMessage 方法*/ // Send the init message CGUIMessage msg(GUI_MSG_WINDOW_INIT, 0, 0, currentWindow, iWindowID); msg.SetStringParams(params); pNewWindow->OnMessage(msg); // g_infoManager.SetPreviousWindow(WINDOW_INVALID); }
void CGUIWindowManager::ActivateWindow_Internal(int iWindowID, const vector<CStdString>& params, bool swappingWindows) { bool passParams = true; // translate virtual windows // virtual music window which returns the last open music window (aka the music start window) if (iWindowID == WINDOW_MUSIC) { iWindowID = g_stSettings.m_iMyMusicStartWindow; // ensure the music virtual window only returns music files and music library windows if (iWindowID != WINDOW_MUSIC_NAV) iWindowID = WINDOW_MUSIC_FILES; // destination path cannot be used with virtual window passParams = false; } // virtual video window which returns the last open video window (aka the video start window) if (iWindowID == WINDOW_VIDEOS) { iWindowID = g_stSettings.m_iVideoStartWindow; // ensure the virtual video window only returns video windows if (iWindowID != WINDOW_VIDEO_NAV) iWindowID = WINDOW_VIDEO_FILES; // destination path cannot be used with virtual window passParams = false; } // stop video player when entering home screen if(iWindowID == WINDOW_HOME && g_application.IsPlayingVideo()) { CLog::Log(LOGDEBUG,"CGUIWindowManager::ActivateWindow_Internal - [iWindowID=%d=WINDOW_HOME][IsPlayingVideo=TRUE] - Going to stop the video (ev)",iWindowID); g_application.StopPlaying(); } // debug CLog::Log(LOGDEBUG, "Activating window ID: %i", iWindowID); if(!g_passwordManager.CheckMenuLock(iWindowID)) { CLog::Log(LOGERROR, "MasterCode is Wrong: Window with id %d will not be loaded! Enter a correct MasterCode!", iWindowID); return; } // first check existence of the window we wish to activate. CGUIWindow *pNewWindow = GetWindow(iWindowID); if (!pNewWindow) { // nothing to see here - move along CLog::Log(LOGERROR, "Unable to locate window with id %d. Check skin files", iWindowID - WINDOW_HOME); return ; } else if (pNewWindow->IsDialog()) { // if we have a dialog, we do a DoModal() rather than activate the window if (!pNewWindow->IsDialogRunning()) ((CGUIDialog *)pNewWindow)->DoModal(iWindowID, (passParams && params.size()) ? params[0] : ""); return; } g_infoManager.SetNextWindow(iWindowID); // set our overlay state HideOverlay(pNewWindow->GetOverlayState()); // deactivate any window int currentWindow = GetActiveWindow(); CGUIWindow *pWindow = GetWindow(currentWindow); if (pWindow) { // If we got here from the screen saver, don't close the dialogs as we want to see // them when we come back if (!g_application.GetInSlideshowScreensaver()) CloseDialogs(); // Play the window specific deinit sound g_audioManager.PlayWindowSound(pWindow->GetID(), SOUND_DEINIT); CGUIMessage msg(GUI_MSG_WINDOW_DEINIT, 0, 0, iWindowID); pWindow->OnMessage(msg); } g_infoManager.SetNextWindow(WINDOW_INVALID); // Add window to the history list (we must do this before we activate it, // as all messages done in WINDOW_INIT will want to be sent to the new // topmost window). If we are swapping windows, we pop the old window // off the history stack if (swappingWindows && m_windowHistory.size()) m_windowHistory.pop(); AddToWindowHistory(iWindowID); g_infoManager.SetPreviousWindow(currentWindow); g_audioManager.PlayWindowSound(pNewWindow->GetID(), SOUND_INIT); // Send the init message CGUIMessage msg(GUI_MSG_WINDOW_INIT, 0, 0, currentWindow, iWindowID); if (passParams) msg.SetStringParams(params); pNewWindow->OnMessage(msg); // g_infoManager.SetPreviousWindow(WINDOW_INVALID); }