YSTest  PreAlpha_b500_20140530
The YSLib Test Project
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
shlds.cpp
浏览该文件的文档.
1 /*
2  © 2010-2014 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 int
47 {
48  // TODO: Implementation.
49  return 0;
50 }
51 
52 
53 } // namespace Shells;
54 
55 
56 namespace DS
57 {
58 
59 void
61 {
62  auto& app(FetchGlobalInstance<DSApplication>());
63 
64  ResetDesktop(dsk_m, app.GetScreenUp()),
65  ResetDesktop(dsk_s, app.GetScreenDown());
66 }
67 
68 
69 ShlDS::ShlDS(const shared_ptr<Desktop>& h_main,
70  const shared_ptr<Desktop>& h_sub)
71  : GUIShell(),
72  main_desktop_ptr(h_main ? h_main : make_shared<Desktop>(
73  FetchGlobalInstance<DSApplication>().GetScreenUp())),
74  sub_desktop_ptr(h_sub ? h_sub : make_shared<Desktop>(
75  FetchGlobalInstance<DSApplication>().GetScreenDown())),
76  cursor_desktop_ptr(sub_desktop_ptr),
77  bUpdateUp(), bUpdateDown()
78 {
80 }
81 
82 void
83 ShlDS::OnGotMessage(const Message& msg)
84 {
85  switch(msg.GetMessageID())
86  {
87  case SM_Paint:
89  return;
90  case SM_Input:
91 #if YF_Hosted
92  if(const auto p_wgt = imMain.Update())
93  imMain.DispatchInput(*p_wgt);
94  else
96 #else
97  imMain.Update();
99 #endif
100  OnInput();
101  return;
102  default:
103  break;
104  }
105  GUIShell::OnGotMessage(msg);
106 }
107 
108 void
110 {
111  using Drawing::Rect;
112 
113  yunseq(bUpdateUp = bool(main_desktop_ptr->Validate()),
114  bUpdateDown = bool(sub_desktop_ptr->Validate()));
115  GUIShell::OnInput();
116  if(bUpdateUp)
117  main_desktop_ptr->Update();
118  if(bUpdateDown)
119  sub_desktop_ptr->Update();
120 }
121 
122 void
124 {
126 }
127 
128 void
130 {
131  auto& app(FetchGlobalInstance<DSApplication>());
132 
133  app.SwapScreens();
134  cursor_desktop_ptr = app.IsLCDMainOnTop() ? sub_desktop_ptr
136 }
137 
138 void
139 ShlDS::WrapForSwapScreens(YSLib::UI::IWidget& wgt, KeyInput& mask)
140 {
141  using namespace YSLib::UI;
142 
143  FetchEvent<KeyDown>(wgt).Add([&, this](KeyEventArgs&& e){
144  if(e.Strategy != RoutedEventArgs::Bubble && mask.any()
145  && (platform_ex::FetchKeyState() & mask) == mask)
146  {
147  SwapScreens();
148  e.Handled = true;
149  }
150  }, 0xE0);
151 }
152 
153 } // namespace DS;
154 
155 } // namespace YSLib;
156 
YF_API const platform::KeyInput & FetchKeyState()
取按键状态。
Definition: Input.cpp:123
Desktop *cursor_desktop_ptr Desktop *main_desktop_ptr Desktop *sub_desktop_ptr void OnGotMessage(const Message &) override
消息处理函数。
Definition: shlds.cpp:83
void DispatchInput(UI::IWidget &)
向指定部件分发响应输入状态。
按键输入事件参数类。
Definition: ywgtevt.h:167
#define SM_Paint
Definition: ymsgdef.h:66
std::shared_ptr< _type > make_shared(_tParams &&...args)
使用 new 和指定参数构造指定类型的 std::shared_ptr 实例。
Definition: memory.hpp:239
Devices::InputManager imMain
输入管理器。
Definition: GUIShell.h:52
shared_ptr< Desktop > main_desktop_ptr
共享桌面指针:正常状态下应总是指向可用的桌面对象。
Definition: shlds.h:93
int ExecuteCommand(const String &s)
执行命令行。
Definition: shlds.h:62
_tApp & FetchGlobalInstance() ynothrow
void SwapScreens()
交换屏幕。
Definition: shlds.cpp:129
void swap(any &x, any &y)
交换对象。
Definition: any.h:729
#define yunseq
无序列依赖表达式组求值。
Definition: ydef.h:748
void SwapDesktops()
交换桌面。
Definition: shlds.cpp:123
_tWidget & wgt
Definition: ywgtevt.h:596
#define SM_Input
Definition: ymsgdef.h:67
UI::IWidget * Update()
更新输入状态。
屏幕标准矩形:表示屏幕矩形区域。
Definition: ygdibase.h:416
桌面。
Definition: ydesktop.h:46
void OnInput() override
处理输入消息:发送绘制消息。
Definition: shlds.cpp:109
#define YAssertNonnull(_expr)
Definition: cassert.h:81
bool bUpdateUp
指定当前桌面是否需要更新。
Definition: shlds.h:107
char16_t ucs2_t
UCS-2 字符类型。
Definition: chrdef.h:44
YF_API void ResetDSDesktops(Desktop &, Desktop &)
以默认屏幕复位两个桌面。
Definition: shlds.cpp:60
shared_ptr< Desktop > cursor_desktop_ptr
指针设备响应的桌面指针:总是指向下屏对应的桌面。
Definition: shlds.h:98
气泡事件:向上遍历视图树时触发。
Definition: ywgtevt.h:102
void WrapForSwapScreens(UI::IWidget &, KeyInput &)
包装指定的部件处理满足指定按键掩码的 KeyDown 事件:交换屏幕。
Definition: shlds.cpp:139
bool bUpdateDown
Definition: shlds.h:107
shared_ptr< Desktop > sub_desktop_ptr
Definition: shlds.h:93
std::bitset< KeyBitsetWidth > KeyInput
按键并行位宽。
Definition: Keys.h:68
void ResetDesktop(Desktop &dsk, Devices::Screen &scr)
复位桌面。
Definition: ShellHelper.h:279