YSTest: Shell_DS.cpp 源文件

YSTest PreAlpha_b700_20160611 The YSLib Test Project

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

- 文件列表
- 文件成员

Shell_DS.cpp
浏览该文件的文档.
1 /*
2 © 2010-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
29 #include "Helper/YModules.h"
30 #include YFM_DS_Helper_Shell_DS
31 #include YFM_DS_Helper_DSMain
32 #include YFM_Helper_ShellHelper
33 #include YFM_YSLib_UI_YDesktop
34 #include YFM_YSLib_UI_YGUI
35 #include YFM_YCLib_Input
36
37 namespace YSLib
38 {
39
40 namespace Shells
41 {
42
43 using namespace Messaging;
44
45 } // namespace Shells;
46
47
48 namespace DS
49 {
50
51 void
52 ResetDSDesktops(Desktop& dsk_m, Desktop& dsk_s)
53 {
54 auto& app(FetchGlobalInstance<DSApplication>());
55
56 ResetDesktop(dsk_m, app.GetScreenUp()),
57 ResetDesktop(dsk_s, app.GetScreenDown());
58 }
59
60
61 ShlDS::ShlDS(const shared_ptr<Desktop>& h_main,
62 const shared_ptr<Desktop>& h_sub)
63 : GUIShell(),
64 main_desktop_ptr(Nonnull(h_main ? h_main : make_shared<Desktop>(
65 FetchGlobalInstance<DSApplication>().GetScreenUp()))),
66 sub_desktop_ptr(Nonnull(h_sub ? h_sub : make_shared<Desktop>(
67 FetchGlobalInstance<DSApplication>().GetScreenDown()))),
68 cursor_desktop_ptr(sub_desktop_ptr),
69 bUpdateUp(), bUpdateDown()
70 {}
71
72 void
73 ShlDS::OnGotMessage(const Message& msg)
74 {
75 switch(msg.GetMessageID())
76 {
77 case SM_Paint:
78 ShlDS::OnInput();
79 return;
80 case SM_Input:
81 #if YF_Hosted && !YCL_Android
82 imMain.DispatchInput(ystdex::value_or<YSLib::UI::IWidget&>(imMain.Update(),
83 *cursor_desktop_ptr));
84 #else
85 imMain.Update();
86 imMain.DispatchInput(*cursor_desktop_ptr);
87 #endif
88 OnInput();
89 return;
90 default:
91 break;
92 }
93 GUIShell::OnGotMessage(msg);
94 }
95
96 void
97 ShlDS::OnInput()
98 {
99 using Drawing::Rect;
100
101 yunseq(bUpdateUp = bool(main_desktop_ptr->Validate()),
102 bUpdateDown = bool(sub_desktop_ptr->Validate()));
103 GUIShell::OnInput();
104 if(bUpdateUp)
105 main_desktop_ptr->Update();
106 if(bUpdateDown)
107 sub_desktop_ptr->Update();
108 }
109
110 void
111 ShlDS::SwapDesktops()
112 {
113 std::swap(main_desktop_ptr, sub_desktop_ptr);
114 }
115
116 void
117 ShlDS::SwapScreens()
118 {
119 auto& app(FetchGlobalInstance<DSApplication>());
120
121 app.SwapScreens();
122 cursor_desktop_ptr = app.IsLCDMainOnTop() ? sub_desktop_ptr
123 : main_desktop_ptr;
124 }
125
126 void
127 ShlDS::WrapForSwapScreens(YSLib::UI::IWidget& wgt, KeyInput& mask)
128 {
129 using namespace YSLib::UI;
130
131 FetchEvent<KeyDown>(wgt).Add([&, this](KeyEventArgs&& e){
132 if(e.Strategy != RoutedEventArgs::Bubble && mask.any()
133 && (platform_ex::FetchKeyState() & mask) == mask)
134 {
135 SwapScreens();
136 e.Handled = true;
137 }
138 }, 0xE0);
139 }
140
141 } // namespace DS;
142
143 } // namespace YSLib;
144
YSLib::Devices::InputManager::Update
observer_ptr< UI::IWidget > Update()
更新输入状态。
Definition: InputManager.cpp:153
YSLib::DS::ShlDS::WrapForSwapScreens
void WrapForSwapScreens(UI::IWidget &, KeyInput &)
包装指定的部件处理满足指定按键掩码的 KeyDown 事件：交换屏幕。
Definition: Shell_DS.cpp:127
YSLib::Shells::GUIShell::imMain
Devices::InputManager imMain
输入管理器。
Definition: GUIShell.h:52
platform::Nonnull
_type && Nonnull(_type &&p) ynothrow
断言并返回非空指针。
Definition: Debug.h:411
ystdex::swap
void swap(container_adaptor< _tSeqCon > &x, container_adaptor< _tSeqCon > &y)
Definition: container.hpp:179
Shells
YSLib
YSLib 命名空间。
Definition: AndroidHost.h:45
CHRLib::e
const char const char * e
Definition: CharacterProcessing.h:109
YSLib::DS::ShlDS::SwapDesktops
void SwapDesktops()
交换桌面。
Definition: Shell_DS.cpp:111
YSLib::DS::ShlDS::main_desktop_ptr
shared_ptr< Desktop > main_desktop_ptr
共享桌面指针：正常状态下应总是指向可用的桌面对象。
Definition: Shell_DS.h:79
YSLib::UI::RoutedEventArgs::Bubble
气泡事件：向上遍历视图树时触发。
Definition: YWidgetEvent.h:107
platform_ex::FetchKeyState
YF_API const platform::KeyInput & FetchKeyState()
取按键状态。
Definition: Input.cpp:127
YSLib::DS::ResetDSDesktops
YF_API void ResetDSDesktops(Desktop &, Desktop &)
以默认屏幕复位两个桌面。
Definition: Shell_DS.cpp:52
SM_Input
#define SM_Input
Definition: ymsgdef.h:67
DS
yunseq
#define yunseq
无序列依赖表达式组求值。
Definition: ydef.h:996
YSLib::UI::wgt
IWidget & wgt
Definition: YControl.h:112
YSLib::Devices::InputManager::DispatchInput
void DispatchInput(UI::IWidget &)
向指定部件分发响应输入状态。
Definition: InputManager.cpp:60
YSLib::Drawing::Rect
屏幕标准矩形：表示屏幕矩形区域。
Definition: YGDIBase.h:540
YSLib::DS::ShlDS::cursor_desktop_ptr
shared_ptr< Desktop > cursor_desktop_ptr
指针设备响应的桌面指针：总是指向下屏对应的桌面。
Definition: Shell_DS.h:84
YSLib::UI
Definition: ShellHelper.h:267
YSLib::DS::ShlDS::SwapScreens
void SwapScreens()
交换屏幕。
Definition: Shell_DS.cpp:117
platform::KeyInput
std::bitset< KeyBitsetWidth > KeyInput
按键并行位宽。
Definition: Keys.h:67
YSLib::UI::Desktop
桌面。
Definition: YDesktop.h:46
SM_Paint
#define SM_Paint
Definition: ymsgdef.h:66
YSLib::DS::ShlDS::bUpdateDown
bool bUpdateDown
Definition: Shell_DS.h:93
YModules.h
YSLib::FetchGlobalInstance
_tApp & FetchGlobalInstance()
Definition: GUIApplication.h:274
YSLib::DS::ShlDS::bUpdateUp
bool bUpdateUp
指定当前桌面是否需要更新。
Definition: Shell_DS.h:93
ystdex::make_shared
std::shared_ptr< _type > make_shared(std::initializer_list< _tValue > il)
使用指定类型的初始化列表构造指定类型的 std::shared_ptr 对象。
Definition: memory.hpp:819
YSLib::DS::ShlDS::OnGotMessage
Desktop *cursor_desktop_ptr Desktop *main_desktop_ptr Desktop *sub_desktop_ptr void OnGotMessage(const Message &) override
消息处理函数。
Definition: Shell_DS.cpp:73
YSLib::DS::ShlDS::OnInput
void OnInput() override
处理输入消息：发送绘制消息。
Definition: Shell_DS.cpp:97
YSLib::UI::KeyEventArgs
按键输入事件参数类。
Definition: YWidgetEvent.h:186
YSLib::DS::ShlDS::sub_desktop_ptr
shared_ptr< Desktop > sub_desktop_ptr
Definition: Shell_DS.h:79