YSTest: ShlExplorer.cpp 源文件

YSTest PreAlpha_b700_20160611 The YSLib Test Project

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

- 文件列表
- 文件成员

ShlExplorer.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
28 #include "ShlExplorer.h"
29 #include "ShlReader.h"
30 #include YFM_YSLib_UI_ExStyle
31 #include <ystdex/functional.hpp> // for ystdex::bind1;
32
33 namespace YReader
34 {
35
36 using ystdex::polymorphic_downcast;
37
38 namespace
39 {
40
42
43 using namespace IO;
44
45 enum class FileCategory
46 {
47 Empty = yimpl(int)(NodeCategory::Empty),
48 Unknown = yimpl(int)(NodeCategory::Regular),
49 Binary,
50 Text
51 };
52
53 bool
54 CheckTextFileExtensions(string ext)
55 {
56 for(auto& c : ext)
57 c = std::tolower(c);
58 try
59 {
60 const auto& m(FetchMIMEBiMapping().GetExtensionMap());
61 const auto i(m.find(ext));
62
63 // TODO: Compare for multiple values.
64 if(i != m.end())
65 {
66 const auto& pth(i->second);
67
68 return !pth.empty() && (pth.front() == "text"
69 || ystdex::ends_with(pth.back(), "xml"));
70 }
71 }
72 CatchIgnore(std::out_of_range&)
73 return {};
74 }
75
76 FileCategory
77 ClassifyFile(const Path& pth)
78 {
79 switch(ClassifyNode(pth))
80 {
81 case NodeCategory::Regular:
82 return CheckTextFileExtensions(GetExtensionOf(pth).GetMBCS())
83 ? FileCategory::Text : FileCategory::Binary;
84 case NodeCategory::Unknown:
85 break;
86 default:
87 return FileCategory::Empty;
88 }
89 // TODO: Verifying.
90 // TODO: Implementation for other categories.
91 return FileCategory::Unknown;
92 }
94
96 bool
97 CheckReaderEnability(FileBox& fb, RadioBox& hex)
98 {
99 if(fb.IsSelected())
100 {
101 switch(ClassifyFile(fb.GetPath()))
102 {
103 case FileCategory::Text:
104 return true;
105 case FileCategory::Binary:
106 return hex.GetState().get() == &hex;
107 default:
108 ;
109 }
110 }
111 return {};
112 }
113
114
116 inline bool
117 CheckMenuKey(const KeyInput& k)
118 {
119 #if YCL_Win32
120 auto ke(k);
121
122 unseq_apply([&](int vk) ynothrow{
123 ke.set(size_t(vk), {});
124 }, VK_CONTROL, VK_LCONTROL, VK_RCONTROL);
125 return ke.none() && k[VK_CONTROL];
126 #else
127 return k.count() == 1 && k[YCL_KEY_Start];
128 #endif
129 }
130
131
133
134 yconstexpr const auto PI = 3.141592F;
135 yconstexpr const auto PI_2 = PI * 2;
136
138 void
139 DrawStar(Graphics& g, const Rect& bounds, Color c, const Point& pt, SDst r,
140 float a, size_t n = 5)
141 {
142 static yconstexpr const auto PI_4 = PI * 4;
143 vector<Point> pts(n);
144
145 for(size_t i = 0; i < n; ++i)
146 pts[i] = {int(-std::cos(PI_4 / n * i + a) * r + pt.X),
147 int(std::sin(PI_4 / n * i + a) * r + pt.Y)};
148 DrawPolygon(g, bounds, pts.cbegin(), pts.cend(), c);
149 }
151
153 const char TU_Explorer_Main[]{u8R"NPL(root
154 ($type "Panel")($bounds "0 0 256 192")
155 (lblTitle
156 ($type "Label")($bounds "16 20 220 22"))
157 (lblPath
158 ($type "Label")($bounds "8 48 240 48"))
159 (lblInfo
160 ($type "Label")($bounds "8 100 240 64"))
161 )NPL"};
163 const char TU_Explorer_Sub[]{u8R"NPL(root
164 ($type "Panel")($bounds "0 0 256 192")
165 (fbMain
166 ($type "FileBox")($bounds "0 0 256 170"))
167 (btnOK
168 ($type "Button")($bounds "170 170 64 22"))
169 (btnMenu
170 ($type "Button")($bounds "0 170 72 22"))
171 (pnlSetting
172 ($type "Panel")($bounds "10 40 224 100")($z 128)
173 (ddlStyle
174 ($type "DropDownList")($bounds "10 24 80 22"))
175 (rbTxt
176 ($type "RadioButton")($bounds "120 18 100 18"))
177 (rbHex
178 ($type "RadioButton")($bounds "120 36 100 18"))
179 (cbFPS
180 ($type "CheckButton")($bounds "10 60 72 18"))
181 (btnPrevBackground
182 ($type "Button")($bounds "120 60 30 22"))
183 (btnNextBackground
184 ($type "Button")($bounds "164 60 30 22"))
185 )
186 (pnlTest1
187 ($type "Panel")($bounds "10 20 224 144")($z 128)
188 (tcTest1
189 ($type "TabControl")
190 ($bounds "3 3 218 138")
191 (pnlPage1
192 ($type "Panel")
193 (btnEnterTest
194 ($type "Button")($bounds "8 32 104 22"))
195 (lblDragTest
196 ($type "Label")($bounds "4 4 104 22"))
197 )
198 (pnlPage2
199 ($type "Panel")
200 (btnTestAni
201 ($type "Button")($bounds "8 32 104 22"))
202 )
203 (pnlPage3
204 ($type "Panel")
205 (tbTest
206 ($type "TextBox")($bounds "8 4 104 22"))
207 (btnTestEx
208 ($type "Button")($bounds "8 32 104 22"))
209 (cbDisableSetting
210 ($type "CheckButton")($bounds "8 64 104 22"))
211 (cbShowTextBoxContent
212 ($type "CheckButton")($bounds "8 88 104 22"))
213 )
214 )
215 )
216 )NPL"};
217
218 } // unnamed namespace;
219
220
221 IO::Path
222 FetchDefaultShellDirectory()
223 {
224 #if YCL_Android
225 return
226 Path(AccessChild<string>(FetchRoot()["YFramework"], "DataDirectory"));
227 #else
228 return Path(IO::FetchCurrentWorkingDirectory());
229 #endif
230 }
231
232 SwitchScreensButton::SwitchScreensButton(ShlDS& shl, const Point& pt)
233 : Button({pt, {22, 22}}, 60),
234 shell(shl)
235 {
236 yunseq(
237 Text = u"％",
238 FetchEvent<Click>(*this) += [this]{
239 shell.get().SwapScreens();
240 }
241 );
242 }
243 ImplDeDtor(SwitchScreensButton)
244
245
246 ShlExplorer::ShlExplorer(const IO::Path& pth,
247 const shared_ptr<Desktop>& h_dsk_up, const shared_ptr<Desktop>& h_dsk_dn)
248 : ShlDS(h_dsk_up, h_dsk_dn),
249 dynWgts_Main(FetchWidgetLoader(), TU_Explorer_Main),
250 dynWgts_Sub(FetchWidgetLoader(), TU_Explorer_Sub),
251 fpsCounter(std::chrono::milliseconds(500)),
252 btnSwitchMain(*this, {234, 170}), btnSwitchSub(*this, {234, 170})
253 {
254 using namespace std;
255 using namespace placeholders;
256 using ystdex::bind1;
257 static struct Init
258 {
259 Init()
260 {
261 YTraceDe(Debug, "First time to load extra styles.");
262 Styles::InitExStyles();
263 }
264 } init;
265 static int up_i(1);
266 auto& dsk_m(GetMainDesktop());
267 auto& dsk_s(GetSubDesktop());
268 auto& node(dynWgts_Main.WidgetNode);
269 DeclDynWidget(Panel, root, node)
270 DeclDynWidgetNode(Label, lblTitle)
271 DeclDynWidgetNode(Label, lblPath)
272 DeclDynWidgetNode(Label, lblInfo)
273 auto& node_sub(dynWgts_Sub.WidgetNode);
274 DeclDynWidget(Panel, root_sub, node_sub)
275 DeclDynWidgetN(FileBox, fbMain, node_sub)
276 DeclDynWidgetN(Button, btnOK, node_sub)
277 DeclDynWidgetN(Button, btnMenu, node_sub)
278 auto& node_pnlSetting(AccessWidgetNode(node_sub, "pnlSetting"));
279 DeclDynWidget(Panel, pnlSetting, node_pnlSetting)
280 DeclDynWidgetN(DropDownList, ddlStyle, node_pnlSetting)
281 DeclDynWidgetN(RadioButton, rbTxt, node_pnlSetting)
282 DeclDynWidgetN(RadioButton, rbHex, node_pnlSetting)
283 DeclDynWidgetN(CheckButton, cbFPS, node_pnlSetting)
284 DeclDynWidgetN(Button, btnPrevBackground, node_pnlSetting)
285 DeclDynWidgetN(Button, btnNextBackground, node_pnlSetting)
286 auto& node_pnlTest1(AccessWidgetNode(node_sub, "pnlTest1"));
287 auto& node_tcTest1(AccessWidgetNode(node_pnlTest1, "tcTest1"));
288 DeclDynWidget(Panel, pnlTest1, node_pnlTest1)
289 DeclDynWidgetN(TabControl, tcTest1, node_pnlTest1)
290 auto& node_pnlPage1(AccessWidgetNode(node_tcTest1, "pnlPage1"));
291 auto& node_pnlPage2(AccessWidgetNode(node_tcTest1, "pnlPage2"));
292 auto& node_pnlPage3(AccessWidgetNode(node_tcTest1, "pnlPage3"));
293 DeclDynWidget(Panel, pnlPage2, node_pnlPage2)
294 DeclDynWidgetN(Label, lblDragTest, node_pnlPage1)
295 DeclDynWidgetN(Button, btnEnterTest, node_pnlPage1)
296 DeclDynWidgetN(Button, btnTestAni, node_pnlPage2)
297 DeclDynWidgetN(TextBox, tbTest, node_pnlPage3)
298 DeclDynWidgetN(Button, btnTestEx, node_pnlPage3)
299 DeclDynWidgetN(CheckButton, cbDisableSetting, node_pnlPage3)
300 DeclDynWidgetN(CheckButton, cbShowTextBoxContent, node_pnlPage3)
301 const auto f_refresh_current([&]{
302 lblPath.Text = fbMain.GetPath().Verify(),
303 Invalidate(lblPath),
304 Enable(btnOK, CheckReaderEnability(fbMain, rbHex));
305 });
306
307 YTraceDe(Debug, "Initialization of ShlExplorer began.");
308 AddButtonToTabBar(tcTest1, node_pnlTest1, "btnTab1", u"基本测试");
309 AddButtonToTabBar(tcTest1, node_pnlTest1, "btnTab2", u"动画测试");
310 AddButtonToTabBar(tcTest1, node_pnlTest1, "btnTab3", u"附加测试");
311 tcTest1.UpdateTabPages();
312 p_border.reset(new BorderResizer(pnlTest1, 4)),
313 p_ChkFPS = &cbFPS,
314 tpDefault.Text = u"请输入文本",
315 tpDefault.BindByFocus(tbTest, bind(&TextPlaceholder::SwapTextBox<TextBox>,
316 _1, _2)),
317 tpDefault.Font.SetStyle(FontStyle::Italic),
318 pnlAbout.OnCommand += [this]{
319 YTraceDe(Informative, "System information panel request received.");
320 pnlSysInfo.UpdateContents();
321 Show(pnlSysInfo);
322 };
323 dsk_m += root,
324 dsk_m.Add(btnSwitchMain, 96),
325 dsk_s += root_sub,
326 // XXX: NPL script should be used to describe Z-order variable.
327 dsk_s.Add(btnSwitchSub, 96),
328 AddWidgetsZ(root_sub, DefaultWindowZOrder, pnlAbout, pnlSysInfo);
329 fbMain.SetRenderer(make_unique<BufferedRenderer>(true)),
330 pnlSetting.SetRenderer(make_unique<BufferedRenderer>()),
331 pnlTest1.SetRenderer(make_unique<BufferedRenderer>()),
332 unseq_apply(bind1(SetVisibleOf, false), pnlSetting, pnlTest1, pnlAbout,
333 pnlSysInfo),
334 unseq_apply(bind(&ShlDS::WrapForSwapScreens, this, _1, ref(SwapMask)),
335 dsk_m, dsk_s),
336 ani.Reset(make_observer(&pnlTest1)),
337 ddlStyle.SetList(FetchVisualStyleNames()),
338 rbTxt.ShareTo(rbHex),
339 rbTxt.Select(),
340 unseq_apply(bind1(Enable, false), btnOK, btnPrevBackground),
341 yunseq(
342 dsk_m.Background = ImageBrush(FetchImage(0)),
343 dsk_s.Background
344 = SolidBrush(FetchGUIConfiguration().Colors[Styles::Panel]),
345 root.Background = nullptr,
346 root_sub.Background = nullptr,
347 lblTitle.Text = G_APP_NAME,
348 lblPath.AutoWrapLine = true, lblPath.Text = pth.Verify(),
349 lblInfo.AutoWrapLine = true, lblInfo.Text = u"文件列表：请选择一个文件。",
350 // TODO: Show current working directory properly.
351 btnOK.Text = u"确定(A)",
352 #if YCL_Win32
353 btnMenu.Text = u"菜单(Ctrl)",
354 #else
355 btnMenu.Text = u"菜单(Start)",
356 #endif
357 tbTest.Text = u"测试文本框输入字符串",
358 tbTest.MaskChar = u'●',
359 tbTest.MaxLength = 8,
360 ddlStyle.Text = [](const TextList::ListType& lst){
361 const auto& name(FetchGUIConfiguration().Styles.GetCurrent()->first);
362
363 YAssert(!lst.empty(), "Invalid list found.");
364 return name.empty() ? lst[0] : String(name);
365 }(ddlStyle.GetList()),
366 rbTxt.Text = u"文本阅读",
367 rbHex.Text = u"十六进制浏览",
368 cbFPS.Text = u"显示 FPS",
369 pnlSetting.Background = SolidBrush({160, 252, 160}),
370 pnlTest1.Background = SolidBrush({248, 248, 120}),
371 lblDragTest.HorizontalAlignment = TextAlignment::Left,
372 // btnTestEx.Enabled = {},
373 btnTestEx.Font.SetStyle(FontStyle::Bold | FontStyle::Italic),
374 btnTestEx.Text = u"附加测试",
375 btnTestEx.HorizontalAlignment = TextAlignment::Left,
376 btnTestEx.VerticalAlignment = TextAlignment::Down,
377 btnTestAni.Text = u"开始动画",
378 cbDisableSetting.Text = u"禁用设置选择框",
379 cbShowTextBoxContent.Text = u"显示文本框内容",
380 lblDragTest.Text = u"移动设置面板位置",
381 btnEnterTest.Font.SetStyle(FontStyle::Italic),
382 btnEnterTest.Text = u"边界测试",
383 btnEnterTest.HorizontalAlignment = TextAlignment::Right,
384 btnEnterTest.VerticalAlignment = TextAlignment::Up,
385 btnPrevBackground.Font.SetStyle(FontStyle::Bold),
386 btnPrevBackground.Text = u"<<",
387 btnNextBackground.Font.SetStyle(FontStyle::Bold),
388 btnNextBackground.Text = u">>",
389 fbMain.SetPath(pth),
390 dsk_s.BoundControlPtr
391 = [&, this](const KeyInput& k) -> observer_ptr<IWidget>{
392 if(k.count() == 1)
393 {
394 if(k[YCL_KEY(A)])
395 return make_observer(&btnOK);
396 }
397 else if(CheckMenuKey(k))
398 return make_observer(&btnMenu);
399 return {};
400 },
401 FetchEvent<KeyUp>(dsk_s) += OnKey_Bound_TouchUp,
402 FetchEvent<KeyDown>(dsk_s) += OnKey_Bound_TouchDown,
403 FetchEvent<KeyDown>(dsk_s) += [&](KeyEventArgs&& e){
404 if(e.Strategy != RoutedEventArgs::Bubble && e.GetKeys()[YCL_KEY(X)])
405 {
406 SwitchVisibleToFront(pnlSetting);
407 RequestFocusCascade(pnlSetting);
408 }
409 },
410 // TODO: Improve UI action when %ViewChanged being called?
411 fbMain.GetSelected() += f_refresh_current,
412 fbMain.GetViewChanged() += f_refresh_current,
413 FetchEvent<Click>(btnOK) += [&]{
414 if(fbMain.IsSelected())
415 {
416 const auto& fb_path(fbMain.GetPath());
417 // const string s(fb_path);
418 const auto category(ClassifyFile(fb_path));
419
420 if(category == FileCategory::Text
421 || category == FileCategory::Binary)
422 {
423 const auto h_up(GetMainDesktopHandle());
424 const auto h_dn(GetSubDesktopHandle());
425 const bool b(category == FileCategory::Text
426 && rbTxt.IsSelected());
427
428 PostTask([=]{
429 ResetDSDesktops(*h_up, *h_dn);
430 NowShellTo(b ? shared_ptr<Shell>(make_shared<ShlTextReader>(
431 fb_path, h_up, h_dn)) : shared_ptr<Shell>(
432 make_shared<ShlHexBrowser>(fb_path, h_up, h_dn)));
433 }, 0xF8);
434 }
435 }
436 },
437 FetchEvent<Click>(cbFPS) += [this]{
438 SetInvalidationOf(GetSubDesktop());
439 },
440 FetchEvent<Click>(rbHex) += [&]{
441 Enable(btnOK, CheckReaderEnability(fbMain, rbHex));
442 SetInvalidationOf(GetSubDesktop());
443 },
444 FetchEvent<Move>(pnlSetting) += [&]{
445 lblDragTest.Text = to_string(GetLocationOf(pnlSetting)) + ';';
446 Invalidate(lblDragTest);
447 },
448 FetchEvent<TouchHeld>(pnlSetting) += OnTouchHeld_Dragging,
449 #if YCL_DS
450 FetchEvent<TouchDown>(pnlSetting) += [&]{
451 struct ::mallinfo t(::mallinfo());
452
453 lblInfo.Text = sfmt("%d,%d,%d,%d,%d;", t.arena, t.ordblks, t.uordblks,
454 t.fordblks, t.keepcost);
455 Invalidate(lblInfo);
456 },
457 #endif
458 FetchEvent<Click>(pnlSetting) += [&]{
459 yunseq(
460 lblDragTest.ForeColor = GenerateRandomColor(),
461 lblTitle.ForeColor = GenerateRandomColor()
462 );
463 Invalidate(pnlSetting);
464 },
465 FetchEvent<TouchHeld>(pnlTest1) += OnTouchHeld_Dragging,
466 FetchEvent<Paint>(pnlPage2) += [&, this](PaintEventArgs&& e){
467 auto& g(e.Target);
468 const auto& pt(GetLocationOf(pnlTest1));
469 auto& bounds(e.ClipArea);
470
471 DrawStar(g, bounds, ColorSpace::Red, pt + Point{96, 96}, 48, rad);
472 DrawStar(g, bounds, ColorSpace::Green, pt + Point{96, 96}, 48,
473 rad + PI);
474 if(ani.GetConnectionRef().Ready)
475 {
476 rad += 0.02F;
477 if(rad > PI_2)
478 rad -= PI_2;
479 }
480 UpdateClipArea(e, {{}, GetSizeOf(e.GetSender())});
481 },
482 FetchEvent<Click>(btnTestEx) += [&](CursorEventArgs&& e){
483 const auto& k(e.GetKeys());
484 auto& btn(polymorphic_downcast<Button&>(e.GetSender()));
485
486 if(lblTitle.Background)
487 lblTitle.Background = nullptr;
488 else
489 lblTitle.Background = SolidBrush(GenerateRandomColor());
490 lblInfo.Text = btn.Text + u", " + String(to_string(
491 FetchImageLoadTime())) + u";\n" + String(k.to_string());
492 InvalidateWidgets(lblTitle, lblInfo);
493 },
494 FetchEvent<Click>(btnTestAni) += [&]{
495 auto& conn(ani.GetConnectionRef());
496
497 if(conn.Ready)
498 yunseq(btnTestAni.Text = u"开始动画", conn.Ready = {});
499 else
500 {
501 yunseq(btnTestAni.Text = u"停止动画", conn.Ready = true),
502 ani.Start();
503 }
504 Invalidate(btnTestAni);
505 },
506 FetchEvent<Enter>(btnEnterTest) += [](CursorEventArgs&& e){
507 auto& btn(ystdex::polymorphic_downcast<Button&>(e.GetSender()));
508
509 btn.Text = u"Enter: " + String(to_string(e.Position));
510 Invalidate(btn);
511 },
512 FetchEvent<Leave>(btnEnterTest) += [&](CursorEventArgs&& e){
513 btnEnterTest.Text = u"Leave: " + String(to_string(e.Position));
514 Invalidate(btnEnterTest);
515 },
516 FetchEvent<Click>(btnMenu) += [this]{
517 auto& mnu(*p_m0);
518
519 if(mhMain.IsShowing(mnu))
520 {
521 mhMain.HideAll();
522 mnu.ClearSelected();
523 }
524 else
525 mhMain.Show(mnu);
526 Invalidate(mnu);
527 },
528 FetchEvent<Click>(btnPrevBackground) += [&]{
529 if(up_i > 0)
530 {
531 --up_i;
532 Enable(btnNextBackground);
533 }
534 if(up_i == 0)
535 Enable(btnPrevBackground, false);
536 GetMainDesktop().Background = ImageBrush(FetchImage(size_t(up_i)));
537 unseq_apply(SetInvalidationOf, GetMainDesktop(), GetSubDesktop());
538 },
539 FetchEvent<Click>(btnNextBackground) += [&]{
540 if(size_t(up_i + 1) < Image_N)
541 {
542 ++up_i;
543 Enable(btnPrevBackground);
544 }
545 if(size_t(up_i + 1) == Image_N)
546 Enable(btnNextBackground, false);
547 GetMainDesktop().Background = ImageBrush(FetchImage(size_t(up_i)));
548 SetInvalidationOf(GetMainDesktop()),
549 SetInvalidationOf(GetSubDesktop());
550 },
551 cbDisableSetting.Ticked += [&](CheckBox::TickedArgs&& e){
552 unseq_apply(bind1(SetEnabledOf, !e), cbFPS, rbTxt, rbHex);
553 InvalidateWidgets(cbFPS, rbTxt, rbHex);
554 },
555 cbShowTextBoxContent.Ticked += [&](CheckBox::TickedArgs&& e){
556 (tpDefault.GetCapturedPtr().get() == &tbTest ? tpDefault.MaskChar
557 : tbTest.MaskChar) = e ? char32_t() : u'●';
558 Invalidate(tbTest);
559 },
560 ddlStyle.GetConfirmed() += [&, this]{
561 FetchGUIConfiguration().Styles.Switch(ddlStyle.Text.GetMBCS());
562 InvalidateWidgets(dsk_m, dsk_s);
563 }
564 );
565 RequestFocusCascade(fbMain),
566 unseq_apply(SetInvalidationOf, dsk_m, dsk_s);
567
568 {
569 p_m0.reset(new Menu({}, make_shared<Menu::ListType, String>(
570 {u"测试", u"关于", u"设置(X)", u"退出"})));
571 p_m1.reset(new Menu({},
572 make_shared<Menu::ListType, String>({u"项目1", u"项目2"})));
573 auto& m0(*p_m0);
574 auto& m1(*p_m1);
575
576 m0.Confirmed += [&](IndexEventArgs&& e){
577 switch(e.Value)
578 {
579 case 1U:
580 Show(pnlAbout);
581 break;
582 case 2U:
583 SwitchVisibleToFront(pnlSetting);
584 break;
585 case 3U:
586 YSLib::PostQuitMessage(0);
587 }
588 },
589 m1.Confirmed += [&](IndexEventArgs&& e){
590 #if YCL_Win32
591 Windows::TestFramework(e.Value);
592 #endif
593 if(e.Value == 0)
594 SwitchVisibleToFront(pnlTest1);
595 },
596 AddWidgetsZ(GetSubDesktop(), DefaultMenuZOrder, m0, m1),
597 mhMain += m0, mhMain += m1,
598 m0 += {0u, make_observer(&m1)};
599 mhMain.Roots[btnMenu] = make_observer(&m0);
600 unseq_apply(ResizeForContent, m0, m1),
601 // XXX: Conversion to 'SPos' might be implementation-defined.
602 SetLocationOf(m0,
603 Point(btnMenu.GetX(), btnMenu.GetY() - SPos(m0.GetHeight())));
604 //m0.SetWidth(btnMenu.GetWidth() + 20);
605 }
606 YTraceDe(Debug, "Initialization of ShlExplorer ended.");
607 }
608
609 void
610 ShlExplorer::OnPaint()
611 {
612 // NOTE: Hack for performance.
613 // DeclDynWidgetN(CheckButton, cbFPS, dynWgts_Sub.WidgetNode, "pnlSetting")
614 auto& cbFPS(*p_ChkFPS);
615
616 // NOTE: Overriding member function %OnInput using %SM_TASK is also valid
617 // because the %SM_Input message is sent continuously, but less efficient.
618 if(cbFPS.IsTicked())
619 {
620 using namespace ColorSpace;
621 const auto t(fpsCounter.Refresh());
622
623 if(t != 0)
624 {
625 const auto g(ystdex::polymorphic_downcast<BufferedRenderer&>(
626 GetMainDesktop().GetRenderer()).GetContext());
627 static yconstexpr const Rect r(176, 0, 80, 20);
628 char strt[20];
629
630 std::sprintf(strt, "FPS: %u.%03u", unsigned(t / 1000),
631 unsigned(t % 1000));
632 FillRect(g, r, Blue);
633 DrawText(g, r, strt, DefaultMargin, White, false);
634 bUpdateUp = true;
635 }
636 }
637 }
638
639 } // namespace YReader;
640
YSLib::UI::DefaultMenuZOrder
yconstexpr const ZOrder DefaultMenuZOrder(224)
默认菜单 Z 顺序值。
YSLib::UI::RequestFocusCascade
YF_API void RequestFocusCascade(IWidget &)
级联请求部件及上层容器焦点。
Definition: YFocus.cpp:137
ystdex::lref::get
_type & get() const
Definition: ref.hpp:107
ystdex::to_string
std::string to_string(const std::thread::id &)
转换 thread::id 为字符串表示。
ystdex::sfmt
auto sfmt(const _tChar *fmt,...) -> decltype(vsfmt(fmt, std::declval< std::va_list >()))
以 C 标准输出格式的输出 std::basic_string 实例的对象。
Definition: string.hpp:1140
YSLib::Consoles::Blue
Definition: YConsole.h:62
yconstexpr
#define yconstexpr
指定编译时常量表达式。
Definition: ydef.h:653
ynothrow
#define ynothrow
YSLib 无异常抛出保证：若支持 noexcept 关键字， 指定特定的 noexcept 异常规范。
Definition: ydef.h:740
YSLib::Consoles::Green
Definition: YConsole.h:63
platform::Descriptions::Informative
Definition: YCommon.h:159
placeholders
YSLib::shared_ptr< Shell >
shared_ptr< Shell >
Definition: GUIApplication.h:311
YSLib::IO::FetchCurrentWorkingDirectory
PDefH(String, GetExtensionOf, const Path &pth) ImplRet(pth.empty()?String() YF_API String FetchCurrentWorkingDirectory(size_t=MaxPathLength)
默认目录路径长度。
Definition: YSLib/Service/FileSystem.h:343
YSLib::UI::TextAlignment::Right
ystdex::unseq_apply
void unseq_apply(_func &&f, _tParams &&...args)
无序调用。
Definition: functional.hpp:241
G_APP_NAME
#define G_APP_NAME
Definition: Shells.h:56
YSLib::UI::MCheckBox::TickedArgs
MSelector::SelectedArgs TickedArgs
选择框选中状态参数类型。
Definition: Selector.h:105
YReader::Image_N
yconstexpr const size_t Image_N(3)
NPL::A1::name
ctx const string & name
Definition: NPLA1.h:248
YSLib::PostQuitMessage
YF_API void PostQuitMessage(int=0, Messaging::Priority p=DefaultQuitPriority)
以指定错误码和优先级发起 Shell 终止请求。
Definition: YApplication.cpp:85
YSLib::UI::MTextList::ListType
vector< ItemType > ListType
列表类型。
Definition: ListControl.h:142
YSLib::Drawing::bounds
The boundary is out of the const Rect & bounds
Definition: YDraw.h:127
YSLib::FetchMIMEBiMapping
YF_API MIMEBiMapping & FetchMIMEBiMapping()
取 MIME 类型名和文件扩展名双向映射对象。
Definition: Initialization.cpp:518
CHRLib::e
const char const char * e
Definition: CharacterProcessing.h:109
YReader::FetchImage
shared_ptr< Image > & FetchImage(size_t)
Definition: Shells.cpp:89
YSLib::UI::Button
按钮。
Definition: Button.h:127
YSLib::UI::FetchGUIConfiguration
GUIConfiguration & FetchGUIConfiguration()
Definition: YGUI.cpp:519
YReader
Definition: About.h:33
YReader::ShlExplorer::OnPaint
void OnPaint() override
处理绘制消息：更新到屏幕并刷新 FPS 。
Definition: ShlExplorer.cpp:610
YSLib::UI::OnTouchHeld_Dragging
YF_API void OnTouchHeld_Dragging(CursorEventArgs &&)
处理屏幕接触移动事件：拖放按下部件。
Definition: YControl.cpp:145
NPL::SXML::ParseOption::String
YSLib::UI::OnKey_Bound_TouchUp
YF_API void OnKey_Bound_TouchUp(KeyEventArgs &&)
处理按键事件：按键-指针设备接触结束。
Definition: YControl.cpp:160
YAssert
#define YAssert(_expr, _msg)
Definition: cassert.h:105
YSLib::Drawing::char32_t
tr TextRegion &tr char32_t
Definition: TextLayout.h:92
YReader::AddButtonToTabBar
void AddButtonToTabBar(TabControl &, ValueNode &, const string &, const String &, SDst=64)
向标签栏和节点添加按钮。
Definition: Shells.cpp:156
Color
Pixel Color
Definition: CharRenderer.cpp:58
DeclDynWidgetN
#define DeclDynWidgetN(_t, _n,...)
声明指定节点下的按相同名称访问的动态部件。
Definition: Loader.h:307
YSLib::UI::SwitchVisibleToFront
YF_API void SwitchVisibleToFront(IWidget &)
切换部件显示状态并请求提升至前端。
Definition: ShellHelper.cpp:152
YSLib::Drawing::DrawPolygon
void DrawPolygon(Graphics &g, const Rect &bounds, _tIn first, _tIn last, Color c)
描画多边形。
Definition: YDraw.h:214
CHRLib::c
c
Definition: CharacterProcessing.h:81
YSLib::UI::SetEnabledOf
SetEnabledOf
Definition: YControl.h:112
YSLib::UI::TextAlignment::Up
YSLib::UI::Invalidate
YF_API void Invalidate(IWidget &, const Rect &)
无效化：使相对部件的指定区域在直接和间接的窗口缓冲区中无效。
Definition: YWidget.cpp:108
yimpl
#define yimpl(...)
实现标签。
Definition: ydef.h:256
YSLib::UI::RoutedEventArgs::Bubble
气泡事件：向上遍历视图树时触发。
Definition: YWidgetEvent.h:107
YTraceDe
#define YTraceDe(...)
YCLib 默认调试跟踪。
Definition: Debug.h:305
CatchIgnore
#define CatchIgnore(_ex)
指定异常处理器忽略指定异常。
Definition: YBaseMacro.h:133
YSLib::UI::FetchVisualStyleNames
YF_API shared_ptr< TextList::ListType > FetchVisualStyleNames(String=u"<Default>")
取视觉样式名称。
Definition: ShellHelper.cpp:160
YSLib::UI::TextAlignment::Left
YReader::ImplDeDtor
ImplDeDtor(AboutPanel) SystemInformationPanel
Definition: About.cpp:103
YSLib::DS::ResetDSDesktops
YF_API void ResetDSDesktops(Desktop &, Desktop &)
以默认屏幕复位两个桌面。
Definition: Shell_DS.cpp:52
ystdex::polymorphic_downcast
_pDst polymorphic_downcast(_tSrc *v)
多态类指针向派生类指针转换。
Definition: cast.hpp:100
ystdex::path_category::node
functional.hpp
函数和可调用对象。
std
Definition: memory.hpp:1100
platform::SPos
std::int16_t SPos
屏幕坐标度量。
Definition: Video.h:42
YReader::SwitchScreensButton::SwitchScreensButton
SwitchScreensButton(ShlDS &, const Point &)
Definition: ShlExplorer.cpp:232
YSLib::UI::Enable
bool Enable(IWidget &wgt, bool b)
Definition: YControl.cpp:91
platform::KeyCodes::Win32::Empty
Definition: Keys.h:279
YCL_KEY
#define YCL_KEY(X)
Definition: Input.h:45
DeclDynWidget
#define DeclDynWidget(_t, _n,...)
声明动态部件。
Definition: Loader.h:300
YSLib::Drawing::FontStyle::Italic
斜体。
YCL_DS
#define YCL_DS
Definition: Platform.h:325
ShlReader.h
Shell 阅读器框架。
YSLib::UI::Styles::InitExStyles
YF_API void InitExStyles()
初始化扩展样式。
Definition: ExStyle.cpp:236
YSLib::UI::SetInvalidationOf
void SetInvalidationOf(IWidget &wgt)
Definition: YWidget.cpp:63
YSLib::UI::ResizeForContent
void ResizeForContent(TextList &tl)
Definition: ListControl.cpp:414
yunseq
#define yunseq
无序列依赖表达式组求值。
Definition: ydef.h:996
IO
ystdex::bind1
auto bind1(_func &&f, _tParams &&...args) -> decltype(std::bind(std::forward< decltype(f)>(f), std::placeholders::_1, std::forward< decltype(args)>(args)...))
复合调用 std::bind 和 std::placeholders::_1 。
Definition: functional.hpp:583
YSLib::Drawing::Rect
屏幕标准矩形：表示屏幕矩形区域。
Definition: YGDIBase.h:540
YSLib::UI::SetLocationOf
YF_API void SetLocationOf(IWidget &, const Point &)
设置部件左上角所在位置（相对容器的偏移坐标）。
Definition: YWidget.cpp:76
YSLib::UI::TextAlignment::Down
YSLib::UI::AddWidgetsZ
void AddWidgetsZ(_tCon &con, ZOrder z, _tWidgets &...wgts)
向部件容器添加指定 Z 顺序的子部件。
Definition: YUIContainer.h:457
YSLib::IO::ClassifyNode
const Path &pth const string &pth vector< String > &YF_API NodeCategory ClassifyNode(const Path &)
按文件系统节点类别对路径分类。
Definition: YSLib/Service/FileSystem.cpp:233
YSLib::Drawing::r
The boundary is out of the const Graphics const Rect const Point const Point Color c const Rect const Rect & r
Definition: YDraw.h:174
YSLib::Consoles::White
Definition: YConsole.h:68
YSLib::UI::Show
YF_API void Show(IWidget &)
显示部件。
Definition: YWidget.cpp:202
ShlExplorer.h
文件浏览器。
YSLib::UI::OnKey_Bound_TouchDown
YF_API void OnKey_Bound_TouchDown(KeyEventArgs &&)
处理按键事件：按键-指针设备接触开始。
Definition: YControl.cpp:166
YSLib::FetchRoot
YF_API ValueNode & FetchRoot() ynothrow
取值类型根节点。
Definition: Initialization.cpp:487
YSLib::IO::int
YF_API int
Definition: File.h:49
YReader::FetchWidgetLoader
WidgetLoader & FetchWidgetLoader()
Definition: Shells.cpp:127
platform::KeyInput
std::bitset< KeyBitsetWidth > KeyInput
按键并行位宽。
Definition: Keys.h:67
YSLib::i
return i
Definition: YCoreUtilities.h:176
platform::KeyCodes::DS::A
Definition: Keys.h:215
YReader::SwitchScreensButton::shell
lref< ShlDS > shell
Definition: ShlExplorer.h:49
YCL_KEY_Start
#define YCL_KEY_Start
Definition: Input.h:46
YSLib::UI::Desktop
桌面。
Definition: YDesktop.h:46
YSLib::Drawing::DefaultMargin
yconstexpr const Padding DefaultMargin(2, 2, 2, 2)
默认边距。
platform::Descriptions::Debug
Definition: YCommon.h:160
YSLib::UI::DefaultWindowZOrder
const ZOrder DefaultWindowZOrder(128)
默认窗口 Z 顺序值。
YReader::FetchDefaultShellDirectory
IO::Path FetchDefaultShellDirectory()
取默认 Shell 起始路径。
Definition: ShlExplorer.cpp:222
Text
YSLib::Drawing::Point
GBinaryGroup< SPos > Point
屏幕二维点（直角坐标表示）。
Definition: YGDIBase.h:278
ColorSpace
YSLib::a
YB_PURE const _type * a
Definition: YCoreUtilities.h:167
YReader::ShlExplorer
Definition: ShlExplorer.h:62
YSLib::Drawing::FillRect
c YF_API void FillRect(const Graphics &g, const Rect &r, Color c)
填充标准矩形。
Definition: YDraw.cpp:150
platform::KeyCodes::DS::X
Definition: Keys.h:228
YSLib::UI::GetSizeOf
pt pt Y const IWidget &wgt const IWidget &wgt GetSizeOf
无效化：使相对部件的子部件的指定区域在直接和间接的窗口缓冲区中无效。
Definition: YWidget.h:161
ystdex::make_observer
observer_ptr< _type > make_observer(_type *p)
Definition: memory.hpp:1042
YSLib::IO::Path
路径。
Definition: YSLib/Service/FileSystem.h:109
ystdex::ends_with
bool ends_with(const _tRange1 &input, const _tRange2 &test, _fPred comp)
判断第一个参数指定的串是否以第二个参数结束。
Definition: string.hpp:362
YReader::SwitchScreensButton
Definition: ShlExplorer.h:45
YReader::FetchImageLoadTime
double FetchImageLoadTime()
Definition: Shells.cpp:120
YSLib::UI::GetLocationOf
pt pt Y const IWidget &wgt GetLocationOf
Definition: YWidget.h:153
YSLib::Drawing::g
The boundary is out of the const Graphics & g
Definition: YDraw.h:161
YSLib::PostTask
void PostTask(_fCallable &&f, Messaging::Priority prior=Messaging::NormalPriority)
通过消息队列部署后任务。
Definition: Task.h:43
ystdex::tolower
_tChar tolower(_tChar c)
转换大小写字符。
Definition: cctype.h:137
platform::KeyCategory::Menu
表示菜单键（如 Menu 和 Win ）。
Definition: Keys.h:131
DeclDynWidgetNode
#define DeclDynWidgetNode(_t, _n)
声明名称为 node 的节点下的按相同名称访问的动态部件。
Definition: Loader.h:313
YSLib::UI::Styles::Panel
面板背景。
Definition: YStyle.h:312
YSLib::UI::IndexEventArgs
GValueEventArgs< size_t > IndexEventArgs
索引事件。
Definition: ListControl.h:47
platform::n
size_t n
Definition: YCLib/FileSystem.cpp:321
platform::SDst
std::uint16_t SDst
屏幕坐标距离。
Definition: Video.h:43
YSLib::Drawing::DrawText
YF_API void DrawText(const Graphics &g, TextState &ts, const String &str, bool line_wrap)
绘制文本。
Definition: TextRenderer.cpp:247
YSLib::Consoles::Red
Definition: YConsole.h:65
ystdex::ref
lref< _type > ref(_type &t)
构造引用包装。
Definition: ref.hpp:120
YSLib::Drawing::Graphics
GGraphics< BitmapPtr > Graphics
Definition: YGraphics.h:163