Kiwano Engine v1.2.x
Layer.h
1// Copyright (c) 2016-2019 Kiwano - Nomango
2//
3// Permission is hereby granted, free of charge, to any person obtaining a copy
4// of this software and associated documentation files (the "Software"), to deal
5// in the Software without restriction, including without limitation the rights
6// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7// copies of the Software, and to permit persons to whom the Software is
8// furnished to do so, subject to the following conditions:
9//
10// The above copyright notice and this permission notice shall be included in
11// all copies or substantial portions of the Software.
12//
13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19// THE SOFTWARE.
20
21#pragma once
22#include <kiwano/render/Shape.h>
23
24namespace kiwano
25{
26
27KGE_DECLARE_SMART_PTR(Layer);
28
38class KGE_API Layer : public NativeObject
39{
40public:
41 Layer();
42
45 const Rect& GetClipRect() const;
46
49 float GetOpacity() const;
50
53 ShapePtr GetMaskShape() const;
54
57 const Matrix3x2& GetMaskTransform() const;
58
61 void SetClipRect(const Rect& rect);
62
65 void SetOpacity(float opacity);
66
69 void SetMaskShape(ShapePtr mask);
70
73 void SetMaskTransform(const Matrix3x2& matrix);
74
75private:
76 Rect clip_rect_;
77 float opacity_;
78 ShapePtr mask_;
79 Matrix3x2 mask_transform_;
80};
81
84inline const Rect& Layer::GetClipRect() const
85{
86 return clip_rect_;
87}
88
89inline float Layer::GetOpacity() const
90{
91 return opacity_;
92}
93
94inline ShapePtr Layer::GetMaskShape() const
95{
96 return mask_;
97}
98
100{
101 return mask_transform_;
102}
103
104inline void Layer::SetClipRect(const Rect& rect)
105{
106 clip_rect_ = rect;
107}
108
109inline void Layer::SetOpacity(float opacity)
110{
111 opacity_ = opacity;
112}
113
114inline void Layer::SetMaskShape(ShapePtr mask)
115{
116 mask_ = mask;
117}
118
119inline void Layer::SetMaskTransform(const Matrix3x2& matrix)
120{
121 mask_transform_ = matrix;
122}
123
124} // namespace kiwano
图层
Definition: Layer.h:39
const Matrix3x2 & GetMaskTransform() const
获取几何蒙层变换
Definition: Layer.h:99
void SetMaskTransform(const Matrix3x2 &matrix)
设置几何蒙层变换
Definition: Layer.h:119
void SetMaskShape(ShapePtr mask)
设置几何蒙层
Definition: Layer.h:114
float GetOpacity() const
获取图层透明度
Definition: Layer.h:89
ShapePtr GetMaskShape() const
获取几何蒙层
Definition: Layer.h:94
void SetClipRect(const Rect &rect)
设置图层裁剪区域
Definition: Layer.h:104
const Rect & GetClipRect() const
获取图层裁剪区域
Definition: Layer.h:84
void SetOpacity(float opacity)
设置图层透明度
Definition: Layer.h:109
含有本地指针的对象
Definition: NativeObject.hpp:34