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"
40 #define WINDOW_ID_MASK 0xffff
46 class CGUIWindowManager
49 CGUIWindowManager(void);
50 virtual ~CGUIWindowManager(void);
51 bool SendMessage(CGUIMessage& message);
52 bool SendMessage(int message, int senderID, int destID, int param1 = 0, int param2 = 0);
53 bool SendMessage(CGUIMessage& message, int window);
55 void Add(CGUIWindow* pWindow);
56 void AddUniqueInstance(CGUIWindow *window);
57 void AddCustomWindow(CGUIWindow* pWindow);
60 void ActivateWindow(int iWindowID, const CStdString &strPath = "");
61 void ChangeActiveWindow(int iNewID, const CStdString &strPath = "");
62 void ActivateWindow(int iWindowID, const std::vector<CStdString>& params, bool swappingWindows = false);
63 void PreviousWindow();
65 void CloseDialogs(bool forceClose = false);
67 // OnAction() runs through our active dialogs and windows and sends the message
68 // off to the callbacks (application, python, playlist player) and to the
69 // currently focused window(s). Returns true only if the message is handled.
70 bool OnAction(const CAction &action);
72 /*! \brief Process active controls allowing them to animate before rendering.
74 void Process(unsigned int currentTime);
76 /*! \brief Mark the screen as dirty, forcing a redraw at the next Render()
80 /*! \brief Mark a region as dirty, forcing a redraw at the next Render()
82 void MarkDirty(const CRect& rect);
84 /*! \brief Get the current dirty region
86 CDirtyRegionList GetDirty() { return m_tracker.GetDirtyRegions(); }
88 /*! \brief Rendering of the current window and any dialogs
89 Render is called every frame to draw the current window and any dialogs.
90 It should only be called from the application thread.
91 Returns true only if it has rendered something.
95 /*! \brief Do any post render activities.
99 /*! \brief Per-frame updating of the current window and any dialogs
100 FrameMove is called every frame to update the current window and any dialogs
101 on screen. It should only be called from the application thread.
105 /*! \brief Return whether the window manager is initialized.
106 The window manager is initialized on skin load - if the skin isn't yet loaded,
107 no windows should be able to be initialized.
108 \return true if the window manager is initialized, false otherwise.
110 bool Initialized() const { return m_initialized; };
112 CGUIWindow* GetWindow(int id) const;
113 void ProcessRenderLoop(bool renderOnly = false);
114 void SetCallback(IWindowManagerCallback& callback);
117 void RouteToWindow(CGUIWindow* dialog);
118 void AddModeless(CGUIWindow* dialog);
119 void RemoveDialog(int id);
120 int GetTopMostModalDialogID(bool ignoreClosing = false) const;
122 void SendThreadMessage(CGUIMessage& message, int window = 0);
123 void DispatchThreadMessages();
124 // method to removed queued messages with message id in the requested message id list.
125 // pMessageIDList: point to first integer of a 0 ends integer array.
126 int RemoveThreadMessageByMessageIds(int *pMessageIDList);
127 void AddMsgTarget( IMsgTargetCallback* pMsgTarget );
128 int GetActiveWindow() const;
129 int GetFocusedWindow() const;
130 bool HasModalDialog() const;
131 bool HasDialogOnScreen() const;
132 bool IsWindowActive(int id, bool ignoreClosing = true) const;
133 bool IsWindowVisible(int id) const;
134 bool IsWindowTopMost(int id) const;
135 bool IsWindowActive(const CStdString &xmlFile, bool ignoreClosing = true) const;
136 bool IsWindowVisible(const CStdString &xmlFile) const;
137 bool IsWindowTopMost(const CStdString &xmlFile) const;
138 bool IsOverlayAllowed() const;
139 void ShowOverlay(CGUIWindow::OVERLAY_STATE state);
140 void GetActiveModelessWindows(std::vector<int> &ids);
142 void DumpTextureUse();
147 void LoadNotOnDemandWindows();
148 void UnloadNotOnDemandWindows();
149 void HideOverlay(CGUIWindow::OVERLAY_STATE state);
150 void AddToWindowHistory(int newWindowID);
151 void ClearWindowHistory();
152 void CloseWindowSync(CGUIWindow *window, int nextWindowID = 0);
153 CGUIWindow *GetTopMostDialog() const;
155 friend class CApplicationMessenger;
156 void ActivateWindow_Internal(int windowID, const std::vector<CStdString> ¶ms, bool swappingWindows);
158 typedef std::map<int, CGUIWindow *> WindowMap;
159 WindowMap m_mapWindows;
160 std::vector <CGUIWindow*> m_vecCustomWindows;
161 std::vector <CGUIWindow*> m_activeDialogs;
162 std::vector <CGUIWindow*> m_deleteWindows;
163 typedef std::vector<CGUIWindow*>::iterator iDialog;
164 typedef std::vector<CGUIWindow*>::const_iterator ciDialog;
165 typedef std::vector<CGUIWindow*>::reverse_iterator rDialog;
166 typedef std::vector<CGUIWindow*>::const_reverse_iterator crDialog;
168 std::stack<int> m_windowHistory;
170 IWindowManagerCallback* m_pCallback;
171 std::list < std::pair<CGUIMessage*,int> > m_vecThreadMessages;
172 CCriticalSection m_critSection;
173 std::vector <IMsgTargetCallback*> m_vecMsgTargets;
179 CDirtyRegionTracker m_tracker;
186 XBMC_GLOBAL_REF(CGUIWindowManager,g_windowManager);
187 #define g_windowManager XBMC_GLOBAL_USE(CGUIWindowManager)