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