YSTest: GUIApplication.h 源文件

YSTest PreAlpha_b700_20160611 The YSLib Test Project

- 首页
- 相关页面
- 模块
- 命名空间
- 类
- 文件

- 文件列表
- 文件成员

GUIApplication.h
浏览该文件的文档.
1 /*
2 © 2012-2016 FrankHB.
3
4 This file is part of the YSLib project, and may only be used,
5 modified, and distributed under the terms of the YSLib project
6 license, LICENSE.TXT. By continuing to use, modify, or distribute
7 this file you indicate that you have read the license and
8 understand and accept it fully.
9 */
10
28 #ifndef INC_Helper_GUIApplication_h_
29 #define INC_Helper_GUIApplication_h_ 1
30
31 #include "YModules.h"
32 #include YFM_Helper_YGlobal // for Environment;
33 #include YFM_Helper_HostWindow // for Host::Window;
34 #include YFM_YCLib_NativeAPI
35 #include YFM_YSLib_Core_YApplication // for Application;
36 #include <ystdex/cast.hpp> // for ystdex::polymorphic_downcast;
37 #include YFM_Helper_GUIShell
38 #include YFM_YCLib_HostedGUI
39 #if YF_Multithread == 1
40 # include <atomic>
41 # include <mutex> // for std::once_flag;
42 #endif
43 #include <ystdex/utility.hpp> // for ystdex::call_once_init;
44 #if YCL_Win32
45 # include YFM_YSLib_UI_YPanel
46 #elif YCL_Android
47 # include YFM_YSLib_UI_YDesktop
48 #endif
49
50 namespace YSLib
51 {
52
57 class YF_API GUIHost
58 {
59 private:
60 #if YF_Hosted
61
68 map<Host::NativeWindowHandle, observer_ptr<Host::Window>> wnd_map;
70 mutable mutex wmap_mtx;
71 # if YF_Multithread == 1
72
76 std::atomic<size_t> wnd_thrd_count{0};
77
78 public:
83 std::atomic<bool> ExitOnAllWindowThreadCompleted{true};
84 # endif
85
86 public:
87 # if YCL_Win32
88
92 std::function<pair<observer_ptr<Host::Window>, Drawing::Point>(
93 const Drawing::Point&)> MapPoint{};
95 UI::Panel Desktop{};
96
97 private:
98 Host::WindowClass window_class;
99 # elif YCL_Android
100
104 ystdex::id_func_clr_t<Drawing::Point>* MapPoint = {};
109 UI::Desktop Desktop;
110 # endif
111 #endif
112
113 public:
114 GUIHost();
115 ~GUIHost();
116
117 #if YF_Hosted
118
123 observer_ptr<Host::Window>
124 GetForegroundWindow() const ynothrow;
125 #endif
126
127 #if YF_Hosted
128
132 void
133 AddMappedItem(Host::NativeWindowHandle, observer_ptr<Host::Window>);
134
135 # if YF_Multithread == 1
136
141 void
142 EnterWindowThread();
143 # endif
144
149 observer_ptr<Host::Window>
150 FindWindow(Host::NativeWindowHandle) const ynothrow;
151
152 # if YF_Multithread == 1
153
158 void
159 LeaveWindowThread();
160 # endif
161
170 pair<observer_ptr<Host::Window>, Drawing::Point>
171 MapCursor() const;
172
173 # if YCL_Win32
174
180 pair<observer_ptr<Host::Window>, Drawing::Point>
181 MapTopLevelWindowPoint(const Drawing::Point&) const;
182 # endif
183
187 void
188 RemoveMappedItem(Host::NativeWindowHandle) ynothrow;
189
191 void
192 UpdateRenderWindows();
193 #endif
194 };
195
196
202 class YF_API GUIApplication : public Application
203 {
204 private:
206 struct InitBlock final
207 {
209 unique_ptr<Environment> p_env;
211 mutable GUIHost host{};
212
214 InitBlock(Application&);
215 };
216
218 ystdex::call_once_init<InitBlock, once_flag> init;
219
220 public:
227 Messaging::Priority UIResponseLimit = 0x40;
228
233 GUIApplication();
237 ~GUIApplication() override;
238
240 Environment&
241 GetEnvironmentRef() const ynothrow;
243 GUIHost&
244 GetGUIHostRef() const ynothrow;
245
258 bool
259 DealMessage();
260 };
261
262
270 YF_API yimpl(GUIApplication&)
271 FetchGlobalInstance();
272 template<class _tApp>
273 inline _tApp&
274 FetchGlobalInstance()
275 {
276 return ystdex::polymorphic_downcast<_tApp&>(FetchGlobalInstance());
277 }
279
285 YF_API locked_ptr<yimpl(GUIApplication), recursive_mutex>
286 LockInstance();
287
288
293 inline PDefH(Environment&, FetchEnvironment, )
294 ImplRet(FetchGlobalInstance().GetEnvironmentRef())
295
300 inline PDefH(GUIHost&, FetchGUIHost, )
301 ImplRet(FetchGlobalInstance().GetGUIHostRef())
302
303
310 YF_API void
311 Execute(GUIApplication&, shared_ptr<Shell> = make_shared<Shells::GUIShell>());
312
313 } // namespace YSLib;
314
315 #endif
316
YSLib::GUIHost
GUI 宿主。
Definition: GUIApplication.h:57
YSLib::GUIApplication::InitBlock::p_env
unique_ptr< Environment > p_env
环境状态。
Definition: GUIApplication.h:209
Shells
YSLib::yimpl
YF_API yimpl(GUIApplication &) FetchGlobalInstance()
取全局应用程序实例。
YSLib::Execute
void Execute(GUIApplication &app, shared_ptr< Shell > p_shl)
Definition: GUIApplication.cpp:308
utility.hpp
实用设施。
YSLib
YSLib 命名空间。
Definition: AndroidHost.h:45
YSLib::PDefH
PDefH(Environment &, FetchEnvironment,) ImplRet(FetchGlobalInstance().GetEnvironmentRef()) inline PDefH(GUIHost &
取单一环境对象引用。
YSLib::GUIApplication::InitBlock
Definition: GUIApplication.h:206
YSLib::Environment
应用程序环境。
Definition: Environment.h:62
YSLib::FetchGUIHost
FetchGUIHost
Definition: GUIApplication.h:300
YSLib::ynothrow
YB_PURE const _type size_t n ynothrow
Definition: YCoreUtilities.h:168
ystdex::id_func_clr_t
id_func_t< _type, _vN, const _type & > id_func_clr_t
取指定维数和 const 左值引用参数类型的多元映射扩展恒等函数类型。
Definition: functional.hpp:567
YSLib::Application
程序实例。
Definition: YApplication.h:46
YSLib::LockInstance
YF_API locked_ptr< yimpl(GUIApplication), recursive_mutex > LockInstance()
锁定实例。
Definition: GUIApplication.cpp:301
cast.hpp
C++ 转换模板。
YSLib::GUIApplication
平台相关的应用程序类。
Definition: GUIApplication.h:202
YSLib::UI::Styles::Desktop
桌面背景。
Definition: YStyle.h:310
ystdex::call_once_init
使用 call_once 的静态初始化管理器。
Definition: utility.hpp:370
YSLib::UI::Desktop
桌面。
Definition: YDesktop.h:46
YSLib::Messaging::Priority
std::uint8_t Priority
消息优先级。
Definition: YMessage.h:51
YSLib::UI::Panel
面板。
Definition: ypanel.h:45
ystdex::single_thread::mutex
Definition: pseudo_mutex.h:63
YModules.h
YSLib::FetchGlobalInstance
_tApp & FetchGlobalInstance()
Definition: GUIApplication.h:274
ystdex::make_shared
std::shared_ptr< _type > make_shared(std::initializer_list< _tValue > il)
使用指定类型的初始化列表构造指定类型的 std::shared_ptr 对象。
Definition: memory.hpp:819
YF_API
#define YF_API
Definition: Platform.h:56
YSLib::ImplRet
ImplRet(FetchGlobalInstance().GetGUIHostRef()) YF_API void Execute(GUIApplication &
执行程序主消息循环。
YSLib::GUIApplication::init
ystdex::call_once_init< InitBlock, once_flag > init
Definition: GUIApplication.h:218
YSLib::Drawing::GBinaryGroup< SPos >