b30f36aba887fe4af1cd05e4edbda561030cf775
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / border / border-visual.h
1 #ifndef DALI_TOOLKIT_INTERNAL_BORDER_VISUAL_H
2 #define DALI_TOOLKIT_INTERNAL_BORDER_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/rendering/geometry.h>
23
24 // INTERNAL INCLUDES
25 #include <dali-toolkit/internal/visuals/visual-impl.h>
26
27 namespace Dali
28 {
29
30 namespace Toolkit
31 {
32
33 namespace Internal
34 {
35
36 /**
37  * The renderer which renders a solid color to the control's quad border fixed to a specified size.
38  *
39  * The following properties are required for create a BorderRender
40  *
41  * | %Property Name  | Type        |
42  * |-----------------|-------------|
43  * | borderColor     | VECTOR4     |
44  * | borderSize      | FLOAT       |
45  * | antiAliasing    | BOOLEAN     |
46  */
47
48 class BorderVisual : public Visual
49 {
50 public:
51
52   /**
53    * @brief Constructor.
54    *
55    * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
56    */
57   BorderVisual( VisualFactoryCache& factoryCache );
58
59   /**
60    * @brief A reference counted object may only be deleted by calling Unreference().
61    */
62   virtual ~BorderVisual();
63
64 public:  // from Visual
65
66   /**
67    * @copydoc Visual::SetClipRect
68    */
69   virtual void SetClipRect( const Rect<int>& clipRect );
70
71 protected:
72
73   /**
74    * @copydoc Visual::DoInitialize
75    */
76   virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
77
78   /**
79    * @copydoc Visual::DoSetOnStage
80    */
81   virtual void DoSetOnStage( Actor& actor );
82
83   /**
84    * @copydoc Visual::CreatePropertyMap
85    */
86   virtual void DoCreatePropertyMap( Property::Map& map ) const;
87
88 public:
89
90   /**
91    * Set the color of the border.
92    * @param[in] color The border color.
93    */
94   void SetBorderColor( const Vector4& color);
95
96   /**
97    * Set the size of the border.
98    * @param[in] size The border size.
99    */
100   void SetBorderSize( float size );
101
102   /**
103    * Enable/Disable the anti-aliasing.
104    * @param[in] enable Whether the anti-aliasing be enabled or not.
105    */
106   void RequireAntiAliasing( bool antiAliasing );
107
108 private:
109
110   /**
111    * @brief Initialize the renderer with the geometry and shader from the cache, if not available, create and save to the cache for sharing.
112    */
113   void InitializeRenderer();
114
115   /**
116    * Request the border shader from the factory cache. If fail, create tha shader and add it to cache.
117    * @return The border shader.
118    */
119   Shader GetBorderShader();
120
121   /**
122    * Create the geometry which presents the border.
123    * @return The border geometry
124    */
125   Geometry CreateBorderGeometry();
126
127   // Undefined
128   BorderVisual( const BorderVisual& borderRenderer );
129
130   // Undefined
131   BorderVisual& operator=( const BorderVisual& borderRenderer );
132
133 private:
134
135   Vector4 mBorderColor;
136   float   mBorderSize;
137
138   Property::Index mBorderColorIndex;
139   Property::Index mBorderSizeIndex;
140
141   bool mAntiAliasing;
142 };
143
144 } // namespace Internal
145
146 } // namespace Toolkit
147
148 } // namespace Dali
149
150 #endif // DALI_TOOLKIT_INTERNAL_BORDER_VISUAL_H