Merge branch 'devel/master' into devel/graphics
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / arc / arc-visual.h
1 #ifndef DALI_TOOLKIT_INTERNAL_ARC_VISUAL_H
2 #define DALI_TOOLKIT_INTERNAL_ARC_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 #include <dali-toolkit/devel-api/visuals/arc-visual-properties-devel.h>
27
28 namespace Dali
29 {
30
31 namespace Toolkit
32 {
33
34 namespace Internal
35 {
36
37 class ArcVisual;
38 typedef IntrusivePtr< ArcVisual > ArcVisualPtr;
39
40 /**
41  * The visual which renders an arc to the control's quad
42  *
43  * The following properties are required for create an ArcVisual
44  *
45  * | %Property Name  | Type        |
46  * |-----------------|-------------|
47  * | THICKNESS       | FLOAT       |
48  * | START_ANGLE     | FLOAT       |
49  * | SWEEP_ANGLE     | FLOAT       |
50  * | CAP             | INTEGER     |
51  */
52 class ArcVisual: public Visual::Base
53 {
54 public:
55
56   /**
57    * @brief Create a new arc visual.
58    *
59    * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
60    * @param[in] properties A Property::Map containing settings for this visual
61    * @return A smart-pointer to the newly allocated visual.
62    */
63   static ArcVisualPtr New( VisualFactoryCache& factoryCache, const Property::Map& properties );
64
65 public:  // from Visual
66
67   /**
68    * @copydoc Visual::Base::CreatePropertyMap
69    */
70   void DoCreatePropertyMap( Property::Map& map ) const override;
71
72   /**
73    * @copydoc Visual::Base::CreateInstancePropertyMap
74    */
75   void DoCreateInstancePropertyMap( Property::Map& map ) const override;
76
77 protected:
78
79   /**
80    * @brief Constructor.
81    *
82    * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
83    */
84   ArcVisual( VisualFactoryCache& factoryCache );
85
86   /**
87    * @brief A reference counted object may only be deleted by calling Unreference().
88    */
89   virtual ~ArcVisual();
90
91   /**
92    * @copydoc Visual::Base::OnInitialize
93    */
94   void OnInitialize() override;
95
96   /**
97    * @copydoc Visual::Base::DoSetProperties
98    */
99   void DoSetProperties( const Property::Map& propertyMap ) override;
100
101   /**
102    * @copydoc Visual::Base::DoSetOnScene
103    */
104   void DoSetOnScene( Actor& actor ) override;
105
106   /**
107    * @copydoc Visual::Base::DoSetOffScene
108    */
109   void DoSetOffScene(Actor& actor) override;
110
111   /**
112    * @copydoc Visual::Base::OnSetTransform
113    */
114   void OnSetTransform() override;
115
116   /**
117    * @copydoc Visual::Base::OnDoAction
118    */
119   void OnDoAction( const Property::Index actionId, const Property::Value& attributes ) override;
120
121 private:
122
123   // Undefined
124   ArcVisual( const ArcVisual& arcVisual ) = delete;
125
126   // Undefined
127   ArcVisual& operator=( const ArcVisual& arcVisual ) = delete;
128
129 private:
130
131   float mThickness;                    ///< The thickness of the arc.
132   float mRadius;                       ///< The radius of the arc.
133   float mStartAngle;                   ///< The start angle of the arc.
134   float mSweepAngle;                   ///< The sweep angle of the arc.
135   Property::Index mRadiusIndex;        ///< The index of the radius property.
136   Property::Index mThicknessIndex;     ///< The index of the thickness property.
137   Property::Index mStartAngleIndex;    ///< The index of the start angle property.
138   Property::Index mSweepAngleIndex;    ///< The index of the sweep angle property.
139   DevelArcVisual::Cap::Type mCapType;  ///< The cap type.
140 };
141
142 } // namespace Internal
143
144 } // namespace Toolkit
145
146 } // namespace Dali
147
148 #endif /* DALI_TOOLKIT_INTERNAL_ARC_VISUAL_H */