Merge "Support animation of Visual transform properties" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / visual-base-data-impl.h
1 #ifndef DALI_TOOLKIT_INTERNAL_VISUAL_BASE_DATA_IMPL_H
2 #define DALI_TOOLKIT_INTERNAL_VISUAL_BASE_DATA_IMPL_H
3
4 /*
5  * Copyright (c) 2018 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/math/vector2.h>
23 #include <dali/public-api/rendering/renderer.h>
24
25 // INTERNAL INCLUDES
26 #include <dali-toolkit/internal/visuals/visual-base-impl.h>
27 #include <dali-toolkit/internal/visuals/visual-event-observer.h>
28 #include <dali-toolkit/public-api/align-enumerations.h>
29 #include <dali-toolkit/public-api/visuals/visual-properties.h>
30 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
31
32 namespace Dali
33 {
34
35 namespace Toolkit
36 {
37
38 namespace Internal
39 {
40
41 namespace Visual
42 {
43
44 struct Base::Impl
45 {
46   /**
47    * Constructor
48    * @param [in] fittingMode that the derived class prefers
49    * @param [in] type The type of the this visual
50    */
51   Impl( FittingMode fittingMode, Toolkit::Visual::Type type );
52
53   /**
54    * Destructor
55    */
56   ~Impl();
57
58   enum Flags
59   {
60     IS_ON_SCENE = 1,
61     IS_ATLASING_APPLIED = 1<<1,
62     IS_PREMULTIPLIED_ALPHA = 1 << 2,
63     IS_SYNCHRONOUS_RESOURCE_LOADING = 1 << 3
64   };
65
66   struct CustomShader
67   {
68     CustomShader( const Property::Map& map );
69     void SetPropertyMap( const Property::Map& map );
70     void CreatePropertyMap( Property::Map& map ) const;
71
72     std::string mVertexShader;
73     std::string mFragmentShader;
74     Dali::ImageDimensions mGridSize;
75     Dali::Shader::Hint::Value mHints; //(bitfield) values from enum Shader::Hint
76   };
77
78   struct Transform
79   {
80     /**
81      * Default constructor ensures the visual fills the control
82      */
83     Transform();
84
85     /**
86      * Use the property map to set zero or more of the transform
87      * attributes, and sets the remaining attributes to their default
88      * values.
89      */
90     void SetPropertyMap( const Property::Map& map );
91
92     /**
93      * Add the transform attributes to the map (using integer keys)
94      */
95     void GetPropertyMap( Property::Map& map ) const;
96
97     /**
98      * Update zero or more attributes from the property map.
99      */
100     void UpdatePropertyMap( const Property::Map& map );
101
102     /**
103      * Register or set the uniform properties onto the renderer
104      */
105     void RegisterUniforms( Renderer renderer, Toolkit::Direction::Type direction );
106
107     /**
108      * Convert the control size and the transform attributes into the actual
109      * size of the visual.
110      */
111     Vector2 GetVisualSize( const Vector2& controlSize );
112
113     Vector2 mOffset;
114     Vector2 mSize;
115     Vector2 mExtraSize;
116     Vector4 mOffsetSizeMode;
117     Toolkit::Align::Type mOrigin;
118     Toolkit::Align::Type mAnchorPoint;
119     Property::Index      mOffsetIndex;
120     Property::Index      mSizeIndex;
121   };
122
123   Renderer        mRenderer;
124   CustomShader*   mCustomShader;
125   EventObserver*  mEventObserver;  ///< Allows controls to observe when the visual has events to notify
126   std::string     mName;
127   Transform       mTransform;
128   Vector4         mMixColor;
129   Size            mControlSize;
130   float           mCornerRadius;
131   float           mCornerRadiusPolicy;
132   int             mDepthIndex;
133   Property::Index mMixColorIndex;
134   Property::Index mCornerRadiusIndex;
135   FittingMode     mFittingMode;  //< How the contents should fit the view
136   int             mFlags;
137   Toolkit::Visual::ResourceStatus  mResourceStatus;
138   const Toolkit::Visual::Type      mType;
139   bool                             mNeedCornerRadius;
140 };
141
142 } // namespace Visual
143
144 } // namespace Internal
145
146 } // namespace Toolkit
147
148 } // namespace Dali
149
150 #endif // DALI_TOOLKIT_INTERNAL_VISUAL_BASE_DATA_IMPL_H