[dali_1.1.9] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / renderers / border / border-renderer.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_BORDER_RENDERER_H__
2 #define __DALI_TOOLKIT_INTERNAL_BORDER_RENDERER_H__
3
4 /*
5  * Copyright (c) 2015 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 // EXTERNAL INCLUDES
21 #include <dali/devel-api/rendering/geometry.h>
22
23 // INTERNAL INCLUDES
24 #include <dali-toolkit/internal/controls/renderers/control-renderer-impl.h>
25
26 namespace Dali
27 {
28
29 namespace Toolkit
30 {
31
32 namespace Internal
33 {
34
35 /**
36  * The renderer which renders a solid color to the control's quad border fixed to a specified size.
37  *
38  * The following properties are required for create a BorderRender
39  *
40  * | %Property Name  | Type        |
41  * |-----------------|-------------|
42  * | borderColor     | VECTOR4     |
43  * | borderSize      | FLOAT       |
44  */
45
46 class BorderRenderer : public ControlRenderer
47 {
48 public:
49
50   /**
51    * @brief Constructor.
52    *
53    * @param[in] factoryCache A pointer pointing to the RendererFactoryCache object
54    */
55   BorderRenderer( RendererFactoryCache& factoryCache );
56
57   /**
58    * @brief A reference counted object may only be deleted by calling Unreference().
59    */
60   virtual ~BorderRenderer();
61
62 public:  // from ControlRenderer
63
64   /**
65    * @copydoc ControlRenderer::SetClipRect
66    */
67   virtual void SetClipRect( const Rect<int>& clipRect );
68
69 protected:
70
71   /**
72    * @copydoc ControlRenderer::DoInitialize
73    */
74   virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
75
76   /**
77    * @copydoc ControlRenderer::DoSetOnStage
78    */
79   virtual void DoSetOnStage( Actor& actor );
80
81   /**
82    * @copydoc ControlRenderer::CreatePropertyMap
83    */
84   virtual void DoCreatePropertyMap( Property::Map& map ) const;
85
86 public:
87
88   /**
89    * Set the color of the border.
90    * @param[in] color The border color.
91    */
92   void SetBorderColor( const Vector4& color);
93
94   /**
95    * Set the size of the border.
96    * @param[in] size The border size.
97    */
98   void SetBorderSize( float size );
99
100 private:
101
102   /**
103    * @brief Initialize the renderer with the geometry and shader from the cache, if not available, create and save to the cache for sharing.
104    */
105   void InitializeRenderer();
106
107   /**
108    * Create the geometry which presents the border.
109    * @return The border geometry
110    */
111   Geometry CreateBorderGeometry();
112
113   // Undefined
114   BorderRenderer( const BorderRenderer& borderRenderer );
115
116   // Undefined
117   BorderRenderer& operator=( const BorderRenderer& borderRenderer );
118
119 private:
120
121   Vector4 mBorderColor;
122   float   mBorderSize;
123
124   Property::Index mBorderColorIndex;
125   Property::Index mBorderSizeIndex;
126 };
127
128 } // namespace Internal
129
130 } // namespace Toolkit
131
132 } // namespace Dali
133
134 #endif /* __DALI_TOOLKIT_INTERNAL_BORDER_RENDERER_H__ */