[make] don't install addon data of disabled addons
[vuplus_xbmc] / xbmc / guilib / GUIWindowManager.h
1 /*!
2 \file GUIWindowManager.h
3 \brief
4 */
5
6 #ifndef GUILIB_CGUIWindowManager_H
7 #define GUILIB_CGUIWindowManager_H
8
9 #pragma once
10
11 /*
12  *      Copyright (C) 2005-2013 Team XBMC
13  *      http://xbmc.org
14  *
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)
18  *  any later version.
19  *
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.
24  *
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/>.
28  *
29  */
30
31 #include "GUIWindow.h"
32 #include "IWindowManagerCallback.h"
33 #include "IMsgTargetCallback.h"
34 #include "DirtyRegionTracker.h"
35 #include "utils/GlobalsHandling.h"
36 #include <list>
37
38 class CGUIDialog;
39
40 #define WINDOW_ID_MASK 0xffff
41
42 /*!
43  \ingroup winman
44  \brief
45  */
46 class CGUIWindowManager
47 {
48 public:
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);
54   void Initialize();
55   void Add(CGUIWindow* pWindow);
56   void AddUniqueInstance(CGUIWindow *window);
57   void AddCustomWindow(CGUIWindow* pWindow);
58   void Remove(int id);
59   void Delete(int id);
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();
64
65   void CloseDialogs(bool forceClose = false);
66
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);
71
72   /*! \brief Process active controls allowing them to animate before rendering.
73    */
74   void Process(unsigned int currentTime);
75
76   /*! \brief Mark the screen as dirty, forcing a redraw at the next Render()
77    */
78   void MarkDirty();
79
80   /*! \brief Mark a region as dirty, forcing a redraw at the next Render()
81    */
82   void MarkDirty(const CRect& rect);
83
84   /*! \brief Get the current dirty region
85    */
86   CDirtyRegionList GetDirty() { return m_tracker.GetDirtyRegions(); }
87
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.
92    */
93   bool Render();
94
95   /*! \brief Do any post render activities.
96    */
97   void AfterRender();
98
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.
102    */
103   void FrameMove();
104
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.
109    */
110   bool Initialized() const { return m_initialized; };
111
112   CGUIWindow* GetWindow(int id) const;
113   void ProcessRenderLoop(bool renderOnly = false);
114   void SetCallback(IWindowManagerCallback& callback);
115   void DeInitialize();
116
117   void RouteToWindow(CGUIWindow* dialog);
118   void AddModeless(CGUIWindow* dialog);
119   void RemoveDialog(int id);
120   int GetTopMostModalDialogID(bool ignoreClosing = false) const;
121
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);
141 #ifdef _DEBUG
142   void DumpTextureUse();
143 #endif
144 private:
145   void RenderPass();
146
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;
154
155   friend class CApplicationMessenger;
156   void ActivateWindow_Internal(int windowID, const std::vector<CStdString> &params, bool swappingWindows);
157
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;
167
168   std::stack<int> m_windowHistory;
169
170   IWindowManagerCallback* m_pCallback;
171   std::list < std::pair<CGUIMessage*,int> > m_vecThreadMessages;
172   CCriticalSection m_critSection;
173   std::vector <IMsgTargetCallback*> m_vecMsgTargets;
174
175   bool m_bShowOverlay;
176   int  m_iNested;
177   bool m_initialized;
178
179   CDirtyRegionTracker m_tracker;
180 };
181
182 /*!
183  \ingroup winman
184  \brief
185  */
186 XBMC_GLOBAL_REF(CGUIWindowManager,g_windowManager);
187 #define g_windowManager XBMC_GLOBAL_USE(CGUIWindowManager)
188 #endif
189