[dali_2.3.19] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / wireframe / wireframe-visual.h
1 #ifndef DALI_TOOLKIT_INTERNAL_WIREFRAME_VISUAL_H
2 #define DALI_TOOLKIT_INTERNAL_WIREFRAME_VISUAL_H
3
4 /*
5  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/common/intrusive-ptr.h>
23
24 // INTERNAL INCLUDES
25 #include <dali-toolkit/internal/visuals/visual-base-impl.h>
26
27 namespace Dali
28 {
29 namespace Toolkit
30 {
31 namespace Internal
32 {
33 class WireframeVisual;
34 typedef IntrusivePtr<WireframeVisual> WireframeVisualPtr;
35
36 /**
37  * @brief Renders a wireframe outline to the control's quad.
38  */
39 class WireframeVisual : public Visual::Base
40 {
41 public:
42   /**
43    * @brief Create a new wireframe visual.
44    *
45    * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
46    * @param[in] properties A Property::Map containing settings for this visual
47    * @return A smart-pointer to the newly allocated visual.
48    */
49   static WireframeVisualPtr New(VisualFactoryCache& factoryCache, const Property::Map& properties);
50
51   /**
52    * @brief Create a new wireframe visual with an encapsulated actual visual.
53    *
54    * For debugging purpose, the rendering of the encapsulated visual is replaced with wireframe
55    *
56    * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
57    * @param[in] actualVisual The encapsulated actual visual.
58    * @return A smart-pointer to the newly allocated visual.
59    */
60   static WireframeVisualPtr New(VisualFactoryCache& factoryCache, Visual::BasePtr actualVisual);
61
62   /**
63    * @brief Create a new wireframe visual with an encapsulated actual visual.
64    *
65    * For debugging purpose, the rendering of the encapsulated visual is replaced with wireframe
66    *
67    * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
68    * @param[in] actualVisual The encapsulated actual visual.
69    * @param[in] properties A Property::Map containing settings for this visual
70    * @return A smart-pointer to the newly allocated visual.
71    */
72   static WireframeVisualPtr New(VisualFactoryCache& factoryCache, Visual::BasePtr actualVisual, const Property::Map& properties);
73
74 protected:
75   /**
76    * @brief Constructor.
77    *
78    * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
79    * @param[in] actualVisual The encapsulated actual visual.
80    */
81   WireframeVisual(VisualFactoryCache& factoryCache, Visual::BasePtr actualVisual);
82
83   /**
84    * @brief A reference counted object may only be deleted by calling Unreference().
85    */
86   virtual ~WireframeVisual();
87
88 protected: // from Visual::Base
89   /**
90    * @copydoc Visual::Base::OnInitialize
91    */
92   void OnInitialize() override;
93
94   /**
95    * @copydoc Visual::Base::GetHeightForWidth()
96    */
97   float GetHeightForWidth(float width) override;
98
99   /**
100    * @copydoc Visual::Base::GetNaturalSize()
101    */
102   void GetNaturalSize(Vector2& naturalSize) override;
103
104   /**
105    * @copydoc Visual::Base::CreatePropertyMap()
106    */
107   void DoCreatePropertyMap(Property::Map& map) const override;
108
109   /**
110    * @copydoc Visual::Base::CreateInstancePropertyMap
111    */
112   void DoCreateInstancePropertyMap(Property::Map& map) const override;
113
114   /**
115    * @copydoc Visual::Base::DoSetProperties()
116    */
117   void DoSetProperties(const Property::Map& propertyMap) override;
118
119   /**
120    * @copydoc Visual::Base::DoSetOnScene
121    */
122   void DoSetOnScene(Actor& actor) override;
123
124   /**
125    * @copydoc Visual::Base::OnSetTransform
126    */
127   void OnSetTransform() override;
128
129   /**
130    * @copydoc Visual::Base::GetVisualObject
131    *
132    * Overriding as this visual can sometimes act as a proxy to the actual visual, i.e. when using debug rendering.
133    */
134   Base& GetVisualObject() override;
135
136 private:
137   /**
138    * Create the geometry which presents the quad wireframe.
139    * @return The border geometry
140    */
141   Geometry CreateQuadWireframeGeometry();
142
143   // Undefined
144   WireframeVisual(const WireframeVisual& visual);
145
146   // Undefined
147   WireframeVisual& operator=(const WireframeVisual& visual);
148
149 private:
150   Visual::BasePtr mActualVisual;
151 };
152
153 } // namespace Internal
154
155 } // namespace Toolkit
156
157 } // namespace Dali
158
159 #endif // DALI_TOOLKIT_INTERNAL_WIREFRAME_VISUAL_H