diff options
author | pieh <misiek.piechowiak@gmail.com> | 2011-07-26 20:30:50 +0200 |
---|---|---|
committer | pieh <misiek.piechowiak@gmail.com> | 2011-08-02 07:44:29 +0200 |
commit | 6e1a053071380b33dd7beb121228bc50cc0110d9 (patch) | |
tree | 2e9a8d9f21684da7b429e9e38cf4afb869522939 | |
parent | 74a5b6d801eac48eeb65d5a0e74cef9bbdc77ad6 (diff) |
use CGUIWindow::Close_Internal to trigger WindowClose animation and play deinit sound
addded CGUIWindowManager::CloseWindowSync that call CGUIWindow::Close and block context until animation finish
-rw-r--r-- | xbmc/ApplicationMessenger.cpp | 8 | ||||
-rw-r--r-- | xbmc/ApplicationMessenger.h | 2 | ||||
-rw-r--r-- | xbmc/guilib/GUIDialog.cpp | 27 | ||||
-rw-r--r-- | xbmc/guilib/GUIDialog.h | 1 | ||||
-rw-r--r-- | xbmc/guilib/GUIWindow.cpp | 44 | ||||
-rw-r--r-- | xbmc/guilib/GUIWindow.h | 5 | ||||
-rw-r--r-- | xbmc/guilib/GUIWindowManager.cpp | 21 | ||||
-rw-r--r-- | xbmc/guilib/GUIWindowManager.h | 1 |
8 files changed, 41 insertions, 68 deletions
diff --git a/xbmc/ApplicationMessenger.cpp b/xbmc/ApplicationMessenger.cpp index f97cf72604..6edf4756b5 100644 --- a/xbmc/ApplicationMessenger.cpp +++ b/xbmc/ApplicationMessenger.cpp @@ -638,7 +638,7 @@ case TMSG_POWERDOWN: { CGUIWindow *window = (CGUIWindow *)pMsg->lpVoid; if (window) - window->Close(pMsg->dwParam1 > 0); + window->Close(pMsg->dwParam2 & 0x1 ? true : false, pMsg->dwParam1, pMsg->dwParam2 & 0x2 ? true : false); } break; @@ -1091,10 +1091,10 @@ void CApplicationMessenger::Show(CGUIDialog *pDialog) SendMessage(tMsg, true); } -void CApplicationMessenger::Close(CGUIWindow *window, bool forceClose, - bool waitResult) +void CApplicationMessenger::Close(CGUIWindow *window, bool forceClose, bool waitResult /*= true*/, int nextWindowID /*= 0*/, bool enableSound /*= true*/) { - ThreadMessage tMsg = {TMSG_GUI_WINDOW_CLOSE, forceClose ? 1 : 0}; + ThreadMessage tMsg = {TMSG_GUI_WINDOW_CLOSE, nextWindowID}; + tMsg.dwParam2 = (DWORD)(forceClose ? 0x01 : 0 | enableSound ? 0x02 : 0); tMsg.lpVoid = window; SendMessage(tMsg, waitResult); } diff --git a/xbmc/ApplicationMessenger.h b/xbmc/ApplicationMessenger.h index 7272ccd2f0..f716477e80 100644 --- a/xbmc/ApplicationMessenger.h +++ b/xbmc/ApplicationMessenger.h @@ -186,7 +186,7 @@ public: void DoModal(CGUIDialog *pDialog, int iWindowID, const CStdString ¶m = ""); void Show(CGUIDialog *pDialog); - void Close(CGUIWindow *window, bool forceClose, bool waitResult=true); + void Close(CGUIWindow *window, bool forceClose, bool waitResult = true, int nextWindowID = 0, bool enableSound = true); void ActivateWindow(int windowID, const std::vector<CStdString> ¶ms, bool swappingWindows); void SendAction(const CAction &action, int windowID = WINDOW_INVALID, bool waitResult=true); std::vector<CStdString> GetInfoLabels(const std::vector<CStdString> &properties); diff --git a/xbmc/guilib/GUIDialog.cpp b/xbmc/guilib/GUIDialog.cpp index 5d024052cb..fec383ee1f 100644 --- a/xbmc/guilib/GUIDialog.cpp +++ b/xbmc/guilib/GUIDialog.cpp @@ -138,33 +138,6 @@ void CGUIDialog::UpdateVisibility() } } -void CGUIDialog::Close_Internal(bool forceClose /*= false*/) -{ - //Lock graphic context here as it is sometimes called from non rendering threads - //maybe we should have a critical section per window instead?? - CSingleLock lock(g_graphicsContext); - - if (!m_bRunning) return; - - // Play the window specific deinit sound - if(!m_closing && m_enableSound) - g_audioManager.PlayWindowSound(GetID(), SOUND_DEINIT); - - // don't close if we should be animating - if (!forceClose && HasAnimation(ANIM_TYPE_WINDOW_CLOSE)) - { - if (!m_closing && !IsAnimating(ANIM_TYPE_WINDOW_CLOSE)) - { - QueueAnimation(ANIM_TYPE_WINDOW_CLOSE); - m_closing = true; - } - return; - } - - CGUIMessage msg(GUI_MSG_WINDOW_DEINIT, 0, 0); - OnMessage(msg); -} - void CGUIDialog::DoModal_Internal(int iWindowID /*= WINDOW_INVALID */, const CStdString ¶m /* = "" */) { //Lock graphic context here as it is sometimes called from non rendering threads diff --git a/xbmc/guilib/GUIDialog.h b/xbmc/guilib/GUIDialog.h index 3a977a3212..3ed65e9eff 100644 --- a/xbmc/guilib/GUIDialog.h +++ b/xbmc/guilib/GUIDialog.h @@ -64,7 +64,6 @@ protected: virtual void DoModal_Internal(int iWindowID = WINDOW_INVALID, const CStdString ¶m = ""); // modal virtual void Show_Internal(); // modeless - virtual void Close_Internal(bool forceClose = false); bool m_bRunning; bool m_wasRunning; ///< \brief true if we were running during the last DoProcess() diff --git a/xbmc/guilib/GUIWindow.cpp b/xbmc/guilib/GUIWindow.cpp index af3edb8791..ef6c22bb72 100644 --- a/xbmc/guilib/GUIWindow.cpp +++ b/xbmc/guilib/GUIWindow.cpp @@ -39,6 +39,7 @@ #include "utils/TimeUtils.h" #include "input/ButtonTranslator.h" #include "utils/XMLUtils.h" +#include "GUIAudioManager.h" #include "Application.h" #ifdef HAS_PERFORMANCE_SAMPLE @@ -327,21 +328,38 @@ void CGUIWindow::Render() Close(true); } -void CGUIWindow::Close_Internal(bool forceClose) +void CGUIWindow::Close_Internal(bool forceClose /*= false*/, int nextWindowID /*= 0*/, bool enableSound /*= true*/) { - CLog::Log(LOGERROR,"%s - should never be called on the base class!", __FUNCTION__); + CSingleLock lock(g_graphicsContext); + if (!g_windowManager.IsWindowActive(GetID(), false)) return; + forceClose |= (nextWindowID == WINDOW_FULLSCREEN_VIDEO); + if (forceClose) + { + CGUIMessage msg(GUI_MSG_WINDOW_DEINIT, 0, 0); + OnMessage(msg); + m_closing = false; + } + else if (!m_closing) + { + if (enableSound && IsSoundEnabled()) + g_audioManager.PlayWindowSound(GetID(), SOUND_DEINIT); + + // Perform the window out effect + QueueAnimation(ANIM_TYPE_WINDOW_CLOSE); + m_closing = true; + } } -void CGUIWindow::Close(bool forceClose /* = false */) +void CGUIWindow::Close(bool forceClose /*= false*/, int nextWindowID /*= 0*/, bool enableSound /*= true*/) { if (!g_application.IsCurrentThread()) { // make sure graphics lock is not held CSingleExit leaveIt(g_graphicsContext); - g_application.getApplicationMessenger().Close(this, forceClose); + g_application.getApplicationMessenger().Close(this, forceClose, true, nextWindowID, enableSound); } else - Close_Internal(forceClose); + Close_Internal(forceClose, nextWindowID, enableSound); } bool CGUIWindow::OnAction(const CAction &action) @@ -462,22 +480,6 @@ void CGUIWindow::OnDeinitWindow(int nextWindowID) RunUnloadActions(); } - if (nextWindowID != WINDOW_FULLSCREEN_VIDEO) - { - // Dialog animations are handled in Close() rather than here - if (HasAnimation(ANIM_TYPE_WINDOW_CLOSE) && !IsDialog() && IsActive()) - { - // Perform the window out effect - QueueAnimation(ANIM_TYPE_WINDOW_CLOSE); - while (IsAnimating(ANIM_TYPE_WINDOW_CLOSE)) - { - // TODO This shouldn't be handled like this - // The processing should be done from WindowManager and deinit - // should probably be called from there. - g_windowManager.ProcessRenderLoop(true); - } - } - } SaveControlStates(); } diff --git a/xbmc/guilib/GUIWindow.h b/xbmc/guilib/GUIWindow.h index 5dd66b67a6..21f1711960 100644 --- a/xbmc/guilib/GUIWindow.h +++ b/xbmc/guilib/GUIWindow.h @@ -105,8 +105,7 @@ public: */ virtual void FrameMove() {}; - // Close should never be called on this base class (only on derivatives) - its here so that window-manager can use a general close - void Close(bool forceClose = false); + void Close(bool forceClose = false, int nextWindowID = 0, bool enableSound = true); // OnAction() is called by our window manager. We should process any messages // that should be handled at the window level in the derived classes, and any @@ -226,7 +225,7 @@ protected: virtual void OnWindowLoaded(); virtual void OnInitWindow(); virtual void OnDeinitWindow(int nextWindowID); - virtual void Close_Internal(bool forceClose = false); + void Close_Internal(bool forceClose = false, int nextWindowID = 0, bool enableSound = true); EVENT_RESULT OnMouseAction(const CAction &action); virtual bool Animate(unsigned int currentTime); virtual bool CheckAnimation(ANIMATION_TYPE animType); diff --git a/xbmc/guilib/GUIWindowManager.cpp b/xbmc/guilib/GUIWindowManager.cpp index 95a2fd0753..d871a8ee35 100644 --- a/xbmc/guilib/GUIWindowManager.cpp +++ b/xbmc/guilib/GUIWindowManager.cpp @@ -302,9 +302,7 @@ void CGUIWindowManager::PreviousWindow() HideOverlay(pNewWindow->GetOverlayState()); // deinitialize our window - g_audioManager.PlayWindowSound(pCurrentWindow->GetID(), SOUND_DEINIT); - CGUIMessage msg(GUI_MSG_WINDOW_DEINIT, 0, 0); - pCurrentWindow->OnMessage(msg); + CloseWindowSync(pCurrentWindow); g_infoManager.SetNextWindow(WINDOW_INVALID); g_infoManager.SetPreviousWindow(currentWindow); @@ -415,12 +413,7 @@ void CGUIWindowManager::ActivateWindow_Internal(int iWindowID, const vector<CStd int currentWindow = GetActiveWindow(); CGUIWindow *pWindow = GetWindow(currentWindow); if (pWindow) - { - // 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); - } + CloseWindowSync(pWindow, iWindowID); g_infoManager.SetNextWindow(WINDOW_INVALID); // Add window to the history list (we must do this before we activate it, @@ -656,8 +649,7 @@ void CGUIWindowManager::DeInitialize() if (IsWindowActive(it->first)) { pWindow->DisableAnimations(); - CGUIMessage msg(GUI_MSG_WINDOW_DEINIT, 0, 0); - pWindow->OnMessage(msg); + pWindow->Close(true); } pWindow->ResetControlStates(); pWindow->FreeResources(true); @@ -964,6 +956,13 @@ void CGUIWindowManager::ClearWindowHistory() m_windowHistory.pop(); } +void CGUIWindowManager::CloseWindowSync(CGUIWindow *window, int nextWindowID /*= 0*/) +{ + window->Close(false, nextWindowID); + while (window->IsAnimating(ANIM_TYPE_WINDOW_CLOSE)) + g_windowManager.ProcessRenderLoop(true); +} + #ifdef _DEBUG void CGUIWindowManager::DumpTextureUse() { diff --git a/xbmc/guilib/GUIWindowManager.h b/xbmc/guilib/GUIWindowManager.h index 83a6bed95f..0ad20e666f 100644 --- a/xbmc/guilib/GUIWindowManager.h +++ b/xbmc/guilib/GUIWindowManager.h @@ -138,6 +138,7 @@ private: void HideOverlay(CGUIWindow::OVERLAY_STATE state); void AddToWindowHistory(int newWindowID); void ClearWindowHistory(); + void CloseWindowSync(CGUIWindow *window, int nextWindowID = 0); CGUIWindow *GetTopMostDialog() const; friend class CApplicationMessenger; |