2 \file GUIWindowManager.h
6 #ifndef GUILIB_CGUIWindowManager_H
7 #define GUILIB_CGUIWindowManager_H
12 * Copyright (C) 2005-2013 Team XBMC
15 * This Program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2, or (at your option)
20 * This Program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with XBMC; see the file COPYING. If not, see
27 * <http://www.gnu.org/licenses/>.
31 #include "GUIWindow.h"
32 #include "IWindowManagerCallback.h"
33 #include "IMsgTargetCallback.h"
34 #include "DirtyRegionTracker.h"
35 #include "utils/GlobalsHandling.h"
39 #define WINDOW_ID_MASK 0xffff
45 class CGUIWindowManager
48 CGUIWindowManager(void);
49 virtual ~CGUIWindowManager(void);
50 bool SendMessage(CGUIMessage& message);
51 bool SendMessage(int message, int senderID, int destID, int param1 = 0, int param2 = 0);
52 bool SendMessage(CGUIMessage& message, int window);
54 void Add(CGUIWindow* pWindow);
55 void AddUniqueInstance(CGUIWindow *window);
56 void AddCustomWindow(CGUIWindow* pWindow);
59 void ActivateWindow(int iWindowID, const CStdString &strPath = "");
60 void ChangeActiveWindow(int iNewID, const CStdString &strPath = "");
61 void ActivateWindow(int iWindowID, const std::vector<CStdString>& params, bool swappingWindows = false);
62 void PreviousWindow();
64 void CloseDialogs(bool forceClose = false);
66 // OnAction() runs through our active dialogs and windows and sends the message
67 // off to the callbacks (application, python, playlist player) and to the
68 // currently focused window(s). Returns true only if the message is handled.
69 bool OnAction(const CAction &action);
71 /*! \brief Process active controls allowing them to animate before rendering.
73 void Process(unsigned int currentTime);
75 /*! \brief Mark the screen as dirty, forcing a redraw at the next Render()
79 /*! \brief Mark a region as dirty, forcing a redraw at the next Render()
81 void MarkDirty(const CRect& rect);
83 /*! \brief Get the current dirty region
85 CDirtyRegionList GetDirty() { return m_tracker.GetDirtyRegions(); }
87 /*! \brief Rendering of the current window and any dialogs
88 Render is called every frame to draw the current window and any dialogs.
89 It should only be called from the application thread.
90 Returns true only if it has rendered something.
94 /*! \brief Do any post render activities.
98 /*! \brief Per-frame updating of the current window and any dialogs
99 FrameMove is called every frame to update the current window and any dialogs
100 on screen. It should only be called from the application thread.
104 /*! \brief Return whether the window manager is initialized.
105 The window manager is initialized on skin load - if the skin isn't yet loaded,
106 no windows should be able to be initialized.
107 \return true if the window manager is initialized, false otherwise.
109 bool Initialized() const { return m_initialized; };
111 CGUIWindow* GetWindow(int id) const;
112 void ProcessRenderLoop(bool renderOnly = false);
113 void SetCallback(IWindowManagerCallback& callback);
116 void RouteToWindow(CGUIWindow* dialog);
117 void AddModeless(CGUIWindow* dialog);
118 void RemoveDialog(int id);
119 int GetTopMostModalDialogID(bool ignoreClosing = false) const;
121 void SendThreadMessage(CGUIMessage& message);
122 void SendThreadMessage(CGUIMessage& message, int window);
123 void DispatchThreadMessages();
124 void AddMsgTarget( IMsgTargetCallback* pMsgTarget );
125 int GetActiveWindow() const;
126 int GetFocusedWindow() const;
127 bool HasModalDialog() const;
128 bool HasDialogOnScreen() const;
129 bool IsWindowActive(int id, bool ignoreClosing = true) const;
130 bool IsWindowVisible(int id) const;
131 bool IsWindowTopMost(int id) const;
132 bool IsWindowActive(const CStdString &xmlFile, bool ignoreClosing = true) const;
133 bool IsWindowVisible(const CStdString &xmlFile) const;
134 bool IsWindowTopMost(const CStdString &xmlFile) const;
135 bool IsOverlayAllowed() const;
136 void ShowOverlay(CGUIWindow::OVERLAY_STATE state);
137 void GetActiveModelessWindows(std::vector<int> &ids);
139 void DumpTextureUse();
144 void LoadNotOnDemandWindows();
145 void UnloadNotOnDemandWindows();
146 void HideOverlay(CGUIWindow::OVERLAY_STATE state);
147 void AddToWindowHistory(int newWindowID);
148 void ClearWindowHistory();
149 void CloseWindowSync(CGUIWindow *window, int nextWindowID = 0);
150 CGUIWindow *GetTopMostDialog() const;
152 friend class CApplicationMessenger;
153 void ActivateWindow_Internal(int windowID, const std::vector<CStdString> ¶ms, bool swappingWindows);
155 typedef std::map<int, CGUIWindow *> WindowMap;
156 WindowMap m_mapWindows;
157 std::vector <CGUIWindow*> m_vecCustomWindows;
158 std::vector <CGUIWindow*> m_activeDialogs;
159 std::vector <CGUIWindow*> m_deleteWindows;
160 typedef std::vector<CGUIWindow*>::iterator iDialog;
161 typedef std::vector<CGUIWindow*>::const_iterator ciDialog;
162 typedef std::vector<CGUIWindow*>::reverse_iterator rDialog;
163 typedef std::vector<CGUIWindow*>::const_reverse_iterator crDialog;
165 std::stack<int> m_windowHistory;
167 IWindowManagerCallback* m_pCallback;
168 std::vector < std::pair<CGUIMessage*,int> > m_vecThreadMessages;
169 CCriticalSection m_critSection;
170 std::vector <IMsgTargetCallback*> m_vecMsgTargets;
176 CDirtyRegionTracker m_tracker;
183 XBMC_GLOBAL_REF(CGUIWindowManager,g_windowManager);
184 #define g_windowManager XBMC_GLOBAL_USE(CGUIWindowManager)