YSTest: YBrush.h 源文件

YSTest PreAlpha_b500_20140530 The YSLib Test Project

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

- 文件列表
- 文件成员

全部 类 命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义 组 页
YBrush.h
浏览该文件的文档.
1 /*
2 © 2012-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 #ifndef YSL_INC_UI_YBrush_h_
29 #define YSL_INC_UI_YBrush_h_ 1
30
31 #include "YModules.h"
32 #include YFM_YSLib_UI_YWidgetEvent
33 #include YFM_YSLib_Service_YResource
34 #include YFM_YSLib_Service_YBlit // for Drawing::BlitPixels;
35
36 namespace YSLib
37 {
38
39 namespace UI
40 {
41
46 class YF_API SolidBrush
47 {
48 public:
49 Drawing::Color Color;
50
51 SolidBrush(Drawing::Color c)
52 : Color(c)
53 {}
54
55 void
56 operator()(PaintEventArgs&&);
57 };
58
59
68 template<typename _type>
69 using GBrushUpdater = std::function<void(const PaintContext&, _type,
70 const Point&, const Point&)>;
71
72
77 class YF_API ImageBrush
78 {
79 public:
84 GBrushUpdater<const Drawing::Image&> Update{DefaultUpdate};
85
87 mutable shared_ptr<Drawing::Image> ImagePtr;
89 Point DstOffset{};
91 Point SrcOffset{};
92
93 yconstfn DefDeCtor(ImageBrush)
94 ImageBrush(const shared_ptr<Drawing::Image>& h)
95 : ImagePtr(h)
96 {}
97 ImageBrush(shared_ptr<Drawing::Image>&& h)
98 : ImagePtr(std::move(h))
99 {}
100 DefDeCopyCtor(ImageBrush)
101 DefDeMoveCtor(ImageBrush)
102
103 DefDeCopyAssignment(ImageBrush)
104 DefDeMoveAssignment(ImageBrush)
105
110 void
111 operator()(PaintEventArgs&&);
112
117 static void
118 DefaultUpdate(const PaintContext&, const Drawing::Image&, const Point&,
119 const Point&);
120
125 static void
126 UpdateComposite(const PaintContext&, const Drawing::Image&, const Point&,
127 const Point&);
128 };
129
130
136 template<typename _fPixelShader, bool _bSwapLR = false, bool _bSwapUD = false>
137 void
138 UpdatePixels(_fPixelShader shader, const PaintContext& pc,
139 const Drawing::Image& img, const Point& dst_offset, const Point& src_offset)
140 {
141 const auto& g(pc.Target);
142 const Rect& r(pc.ClipArea);
143 const auto& src(img.GetContext());
144
145 Drawing::BlitPixels<_bSwapLR, _bSwapUD>(shader, g.GetBufferPtr(),
146 src.GetBufferPtr(), g.GetSize(), src.GetSize(), r.GetPoint(),
147 r.GetPoint() + src_offset - dst_offset, r.GetSize());
148 }
149
150 } // namespace UI;
151
152 } // namespace YSLib;
153
154 #endif
155
YSLib::UI::SolidBrush::Color
Drawing::Color Color
Definition: YBrush.h:49
YModules.h
YSLib::UI::ImageBrush::DefDeCtor
yconstfn DefDeCtor(ImageBrush) ImageBrush(const shared_ptr< Drawing
Definition: YBrush.h:93
DefDeCopyCtor
#define DefDeCopyCtor(_t)
Definition: YBaseMacro.h:136
YSLib::UI::SolidBrush::SolidBrush
SolidBrush(Drawing::Color c)
Definition: YBrush.h:51
YSLib::UI::PaintEventArgs
部件绘制参数。
Definition: ywgtevt.h:276
YF_API
#define YF_API
Definition: Platform.h:64
YSLib::UI::UpdatePixels
void UpdatePixels(_fPixelShader shader, const PaintContext &pc, const Drawing::Image &img, const Point &dst_offset, const Point &src_offset)
更新：逐像素操作。
Definition: YBrush.h:138
YSLib::UI::ImageBrush::ImagePtr
shared_ptr< Drawing::Image > ImagePtr
Definition: YBrush.h:87
YSLib::Drawing::Rect
屏幕标准矩形：表示屏幕矩形区域。
Definition: ygdibase.h:416
YSLib::Drawing::GBinaryGroup< SPos >
YSLib::UI::GBrushUpdater
std::function< void(const PaintContext &, _type, const Point &, const Point &)> GBrushUpdater
画刷更新器类型。
Definition: YBrush.h:70
yconstfn
#define yconstfn
指定编译时常量函数。
Definition: ydef.h:463
DefDeMoveAssignment
#define DefDeMoveAssignment(_t)
Definition: YBaseMacro.h:159
YSLib::UI::DefDeMoveCtor
Selected const shared_ptr< ListType > const pair< Color, Color > & DefDeMoveCtor(TextList) DefPredMem(const ynothrow
YSLib::UI::SolidBrush
单色画刷。
Definition: YBrush.h:46
YSLib::UI::ImageBrush
图像画刷。
Definition: YBrush.h:77
YSLib::Drawing::r
bounds & r
Definition: ydraw.h:220
YSLib::Drawing::g
c yconstfn g
Definition: ystyle.h:104
CHRLib::c
c
Definition: chrproc.h:76
YSLib::UI::ImageBrush::ImageBrush
ImageBrush(shared_ptr< Drawing::Image > &&h)
Definition: YBrush.h:97
platform::Color
颜色。
Definition: Video.h:339
DefDeCopyAssignment
#define DefDeCopyAssignment(_t)
Definition: YBaseMacro.h:154