[dali_1.2.13] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / color / color-visual.h
1 #ifndef DALI_TOOLKIT_INTERNAL_COLOR_VISUAL_H
2 #define DALI_TOOLKIT_INTERNAL_COLOR_VISUAL_H
3
4 /*
5  * Copyright (c) 2016 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
30 namespace Toolkit
31 {
32
33 namespace Internal
34 {
35
36 class ColorVisual;
37 typedef IntrusivePtr< ColorVisual > ColorVisualPtr;
38
39 /**
40  * The visual which renders a solid color to the control's quad
41  *
42  * The following properties are required for create a ColorRender
43  *
44  * | %Property Name  | Type        |
45  * |-----------------|-------------|
46  * | mixColor        | VECTOR4     |
47  */
48 class ColorVisual: public Visual::Base
49 {
50 public:
51
52   /**
53    * @brief Create a new color visual.
54    *
55    * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
56    * @return A smart-pointer to the newly allocated visual.
57    */
58   static ColorVisualPtr New( VisualFactoryCache& factoryCache );
59
60 public:  // from Visual
61
62   /**
63    * @copydoc Visual::Base::SetSize
64    */
65   virtual void SetSize( const Vector2& size );
66
67   /**
68    * @copydoc Visual::Base::CreatePropertyMap
69    */
70   virtual void DoCreatePropertyMap( Property::Map& map ) const;
71
72   /**
73    * @copydoc Visual::Base::DoSetProperty
74    */
75   virtual void DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue );
76
77   /**
78    * @copydoc Visual::Base::DoGetProperty
79    */
80   virtual Dali::Property::Value DoGetProperty( Dali::Property::Index index );
81
82 protected:
83
84   /**
85    * @brief Constructor.
86    *
87    * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
88    */
89   ColorVisual( VisualFactoryCache& factoryCache );
90
91   /**
92    * @brief A reference counted object may only be deleted by calling Unreference().
93    */
94   virtual ~ColorVisual();
95
96   /**
97    * @copydoc Visual::Base::DoSetProperties
98    */
99   virtual void DoSetProperties( const Property::Map& propertyMap );
100
101   /**
102    * @copydoc Visual::Base::DoSetOnStage
103    */
104   virtual void DoSetOnStage( Actor& actor );
105
106   /**
107    * @copydoc Visual::Base::OnSetTransform
108    */
109   virtual void OnSetTransform();
110
111 public:
112
113   /**
114    * Set the color for rendering.
115    * @param[in] color The color to be rendered.
116    */
117   void SetColor( const Vector4& color );
118
119 private:
120   /**
121    * @brief Initialize the renderer with the geometry and shader from the cache, if not available, create and save to the cache for sharing.
122    */
123   void InitializeRenderer();
124
125 private:
126
127   // Undefined
128   ColorVisual( const ColorVisual& colorRenderer );
129
130   // Undefined
131   ColorVisual& operator=( const ColorVisual& colorRenderer );
132
133 private:
134
135   Vector4 mMixColor;
136   Property::Index mMixColorIndex;
137
138 };
139
140 } // namespace Internal
141
142 } // namespace Toolkit
143
144 } // namespace Dali
145
146 #endif /* DALI_TOOLKIT_INTERNAL_COLOR_VISUAL_H */