You.i Engine
YiDecoratedView.h
Go to the documentation of this file.
1 // © You i Labs Inc. 2000-2020. All rights reserved.
2 #ifndef _YI_DECORATED_VIEW_H_
3 #define _YI_DECORATED_VIEW_H_
4 
5 #include "utility/YiColor.h"
6 #include "view/YiSceneView.h"
7 
8 #include <functional>
9 
10 class CYINVGContext;
11 
35 {
36 public:
37  enum class OverflowMode
38  {
39  Hidden,
40  Visible
41  };
42 
44  virtual ~CYIDecoratedView();
45 
46  virtual bool Init() override;
47 
48  void SetBackgroundColor(const CYIColor &color);
49  const CYIColor &GetBackgroundColor() const;
50 
51  void SetBorderThickness(float thickness);
52  float GetBorderThickness() const;
53 
54  void SetBorderColor(const CYIColor &color);
55  const CYIColor &GetBorderColor() const;
56 
57  void SetCornerRadius(float radius);
58  void SetCornerRadiuses(float topLeftRadius, float topRightRadius, float bottomLeftRadius, float bottomRightRadius);
59  float GetTopLeftCornerRadius() const;
60  float GetTopRightCornerRadius() const;
61  float GetBottomLeftCornerRadius() const;
62  float GetBottomRightCornerRadius() const;
63 
64  void SetOverflowMode(OverflowMode mode);
66 
67 protected:
68  virtual void UpdateBegin() override;
69  virtual void TransformUpdated() override;
70 
71 private:
72  friend class CYIOverdrawCalculator; //For overflow method
73 
74  enum class OverflowMethod
75  {
76  Clipping,
77  Stencil
78  };
79 
80  struct CornerRadius
81  {
82  CornerRadius(float radius = 0.0f);
83 
84  float topLeft;
85  float topRight;
86  float bottomLeft;
87  float bottomRight;
88  };
89 
90  virtual void BuildDrawList(std::vector<IYIRenderer::Command> &drawList, CYIAbstractCameraSceneNode *pCameraToDrawWith) override;
91  void DoPreDrawActions();
92  void DoPostDrawActions();
93 
94  void UpdateOverflowMethod();
95  OverflowMethod GetOverflowMethod() const;
96 
97  void ParseProperties();
98  void SetCornerRadius(const CornerRadius &radiuses);
99  void DirtyRendering();
100  virtual void SizeChanged() override;
101 
102  CYIColor m_backgroundColor; // Defaults to transparent
103 
104  float m_borderThickness; // Defaults to 0.0 (no border)
105  CYIColor m_borderColor; // Defaults to black
106  CornerRadius m_cornerRadius; // Defaults to 0.0 (square corners)
107 
108  OverflowMode m_overflowMode;
109  OverflowMethod m_overflowMethod;
110 
111  std::function<void()> m_preDrawFunction;
112  std::function<void()> m_postDrawFunction;
113  bool m_needsClipBoxUpdate;
114  bool m_canReuseLastFrameDataPreDraw;
115  bool m_canReuseLastFrameDataPostDraw;
116 
117  mutable std::unique_ptr<CYINVGContext> m_pPreDrawContext;
118  mutable std::unique_ptr<CYINVGContext> m_pPostDrawContext;
119 
121 };
122 
125 #endif // _YI_DECORATED_VIEW_H_
float GetBottomLeftCornerRadius() const
float GetTopRightCornerRadius() const
The base class for all view types. Views are containers of renderable elements that often define inte...
Definition: YiSceneView.h:47
Provides a base for the definition of camera objects.
Definition: YiAbstractCameraSceneNode.h:31
A class used to add a background and a border to its content. This view supports clipping the content...
Definition: YiDecoratedView.h:34
virtual bool Init() override
float GetBorderThickness() const
virtual ~CYIDecoratedView()
float GetBottomRightCornerRadius() const
OverflowMode
Definition: YiDecoratedView.h:37
void SetBorderThickness(float thickness)
void SetCornerRadiuses(float topLeftRadius, float topRightRadius, float bottomLeftRadius, float bottomRightRadius)
const CYIColor & GetBorderColor() const
void SetBackgroundColor(const CYIColor &color)
void SetOverflowMode(OverflowMode mode)
OverflowMode GetOverflowMode() const
void SetCornerRadius(float radius)
#define YI_TYPE_BASES(CLASS, BASES...)
Definition: YiRtti.h:257
const CYIColor & GetBackgroundColor() const
float GetTopLeftCornerRadius() const
A class used to represent a color value.
Definition: YiColor.h:31
virtual void TransformUpdated() override
void SetBorderColor(const CYIColor &color)
friend class CYIOverdrawCalculator
Definition: YiDecoratedView.h:72
virtual void UpdateBegin() override