YSTest  PreAlpha_b500_20140530
The YSLib Test Project
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
ydesktop.cpp
浏览该文件的文档.
1 /*
2  © 2010-2013 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 "YSLib/UI/YModules.h"
29 #include YFM_YSLib_UI_YDesktop
30 #include YFM_YSLib_UI_YBrush
31 #include <ystdex/cast.hpp> // for ystdex::polymorphic_downcast;
32 
33 namespace YSLib
34 {
35 
36 using namespace Drawing;
37 
38 namespace UI
39 {
40 
41 namespace
42 {
43 
45 BufferedRenderer&
46 GetBufferedRendererOf(const IWidget& wgt) ynothrow
47 {
48  return ystdex::polymorphic_downcast<BufferedRenderer&>(wgt.GetRenderer());
49 }
50 
51 } // unnamed namespace;
52 
53 
54 Desktop::Desktop(Devices::Screen& s, Color c, const shared_ptr<Image>& hImg,
55  unique_ptr<BufferedRenderer> p)
56  : Window(Rect(s.GetSize()), p ? std::move(p) : std::move(
57  make_unique<BufferedRenderer>(true, std::move(s.GetBackBuffer())))),
58  screen(s)
59 {
60  Background = hImg ? HBrush(ImageBrush(hImg)) : HBrush(SolidBrush(c)),
61  GetBufferedRendererOf(*this).IgnoreBackground = true;
62 }
63 
64 void
66 {
67 // if(!GetBufferedRendererOf(*this).RequiresRefresh())
68  screen.Update(GetBufferedRendererOf(*this).GetContext().GetBufferPtr());
69 }
70 
71 Rect
73 {
74  auto& rd(GetBufferedRendererOf(*this));
75 
76  return rd.Validate(*this, *this,
77  {rd.GetContext(), Point(), GetBoundsOf(*this)});
78 }
79 
80 } // namespace UI;
81 
82 } // namespace YSLib;
83 
bool return true
Definition: DSMain.cpp:177
Rect Validate()
验证:绘制缓冲区使之有效。
Definition: ydesktop.cpp:72
Devices::Screen & screen
屏幕对象。
Definition: ydesktop.h:49
窗口。
Definition: ywindow.h:44
C++ 转换模板。
HBrush Background
背景。
Definition: ywidget.h:374
GBinaryGroup< SPos > Point
屏幕二维点(直角坐标表示)。
Definition: ygdibase.h:235
pt pt Y const IWidget &wgt const IWidget &wgt const IWidget &wgt GetBoundsOf
Definition: ywidget.h:163
_tWidget & wgt
Definition: ywgtevt.h:596
#define ynothrow
YSLib 无异常抛出保证:若支持 noexcept 关键字, 指定特定的 noexcept 异常规范。
Definition: ydef.h:514
屏幕标准矩形:表示屏幕矩形区域。
Definition: ygdibase.h:416
void Update()
更新缓冲区至屏幕。
Definition: ydesktop.cpp:65
std::function< void(PaintEventArgs &&)> HBrush
画刷回调函数。
Definition: YComponent.h:104
Desktop(Devices::Screen &, Color=Drawing::ColorSpace::Black, const shared_ptr< Drawing::Image > &={}, unique_ptr< BufferedRenderer >={})
构造:使用指定屏幕对象引用、渲染器指针和背景。
Definition: ydesktop.cpp:54
virtual void Update(Drawing::BitmapPtr) ynothrow
更新。
Definition: ydevice.cpp:47
单色画刷。
Definition: YBrush.h:46
图像画刷。
Definition: YBrush.h:77
带缓冲的部件渲染器。
Definition: yrender.h:94
颜色。
Definition: Video.h:339
enable_if_t<!is_array< _type >::value, std::unique_ptr< _type > > make_unique(_tParams &&...args)
使用 new 和指定参数构造指定类型的 std::unique_ptr 实例。
Definition: memory.hpp:213