8a35ee98af52fab4dfe8e8f327edf3b341d0025f
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / controls / control-wrapper-impl.h
1 #ifndef DALI_TOOLKIT_INTERNAL_CONTROL_WRAPPER_H
2 #define DALI_TOOLKIT_INTERNAL_CONTROL_WRAPPER_H
3
4 /*
5  * Copyright (c) 2017 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 // INTERNAL INCLUDES
22 #include <dali-toolkit/public-api/controls/control-impl.h>
23 #include <dali-toolkit/devel-api/controls/control-wrapper.h>
24
25 namespace Dali
26 {
27
28 namespace Toolkit
29 {
30
31 class TransitionData;
32
33 namespace Visual
34 {
35 class Base;
36 }
37
38 namespace Internal
39 {
40
41 class ControlWrapper;
42
43 typedef IntrusivePtr< ControlWrapper > ControlWrapperPtr;
44
45 /**
46  * @copydoc Toolkit::ControlWrapper
47  */
48 class DALI_IMPORT_API ControlWrapper : public Control
49 {
50 public:
51
52   // Flags for the constructor
53   enum CustomControlBehaviour
54   {
55     CONTROL_BEHAVIOUR_DEFAULT            = Control::CONTROL_BEHAVIOUR_DEFAULT,
56     DISABLE_SIZE_NEGOTIATION             = CustomActorImpl::DISABLE_SIZE_NEGOTIATION,
57     REQUIRES_KEYBOARD_NAVIGATION_SUPPORT = Control::REQUIRES_KEYBOARD_NAVIGATION_SUPPORT,
58     DISABLE_STYLE_CHANGE_SIGNALS         = Control::DISABLE_STYLE_CHANGE_SIGNALS,
59
60     LAST_CONTROL_BEHAVIOUR_FLAG
61   };
62
63   static const int CONTROL_BEHAVIOUR_FLAG_COUNT = Log< LAST_CONTROL_BEHAVIOUR_FLAG - 1 >::value + 1;      ///< Total count of flags
64
65   /**
66    * @brief Control constructor
67    *
68    * @param[in] behaviourFlags Behavioural flags from CustomControlBehaviour enum
69    */
70   ControlWrapper( CustomControlBehaviour behaviourFlags );
71
72   /**
73    * Create a new ControlWrapper.
74    *
75    * @param[in] typeName The name of the type that is registered with this control
76    * @param[in] controlWrapper The implementation of this control
77    *
78    * @return A public handle to the newly allocated ControlWrapper.
79    */
80   static Dali::Toolkit::ControlWrapper New( const std::string& typeName, ControlWrapper* controlWrapper );
81
82 public: // From CustomActorImpl
83
84   // Size negotiation helpers
85
86   /**
87    * @copydoc Dali::CustomActorImpl::RelayoutRequest()
88    */
89   void RelayoutRequest();
90
91   /**
92    * @copydoc Dali::CustomActorImpl::GetHeightForWidthBase()
93    */
94   float GetHeightForWidthBase( float width );
95
96   /**
97    * @copydoc Dali::CustomActorImpl::GetWidthForHeightBase()
98    */
99   float GetWidthForHeightBase( float height );
100
101   /**
102    * @copydoc Dali::CustomActorImpl::CalculateChildSizeBase()
103    */
104   float CalculateChildSizeBase( const Dali::Actor& child, Dimension::Type dimension );
105
106   /**
107    * @copydoc Dali::CustomActorImpl::RelayoutDependentOnChildrenBase()
108    */
109   bool RelayoutDependentOnChildrenBase( Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
110
111 public: // From Control
112
113   /**
114    * @ref Dali::Toolkit::DevelControl::RegisterVisual()
115    */
116   void RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual );
117
118   /**
119    * @ref Dali::Toolkit::DevelControl::RegisterVisual()
120    */
121   void RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, float depthIndex );
122
123   /**
124    * @ref Dali::Toolkit::DevelControl::RegisterVisual()
125    */
126   void RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, bool enabled );
127
128   /**
129    * @ref Dali::Toolkit::DevelControl::RegisterVisual()
130    */
131   void RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, bool enabled, float depthIndex );
132
133   /**
134    * @ref Dali::Toolkit::DevelControl::UnregisterVisual()
135    */
136   void UnregisterVisual( Property::Index index );
137
138   /**
139    * @ref Dali::Toolkit::DevelControl::GetVisual()
140    */
141   Toolkit::Visual::Base GetVisual( Property::Index index ) const;
142
143   /**
144    * @ref Dali::Toolkit::DevelControl::EnableVisual()
145    */
146   void EnableVisual( Property::Index index, bool enable );
147
148   /**
149    * @ref Dali::Toolkit::DevelControl::IsVisualEnabled()
150    */
151   bool IsVisualEnabled( Property::Index index ) const;
152
153   /**
154    * @ref Dali::Toolkit::DevelControl::CreateTransition()
155    */
156   Dali::Animation CreateTransition( const Toolkit::TransitionData& transitionData );
157
158   /**
159    * @copydoc Dali::Toolkit::Internal::Control::EmitKeyInputFocusSignal()
160    */
161   void EmitKeyInputFocusSignal( bool focusGained );
162
163   /**
164    * @brief Apply the current style
165    *
166    * This method is called after the Control has been initialized.
167    *
168    */
169   void ApplyThemeStyle();
170
171 protected:
172
173   /**
174    * Protected Destructor
175    * A reference counted object may only be deleted by calling Unreference()
176    */
177   virtual ~ControlWrapper();
178
179 private:
180
181   /// @cond internal
182   /// Undefined.
183   DALI_INTERNAL ControlWrapper( const ControlWrapper& );
184
185   /// Undefined.
186   DALI_INTERNAL ControlWrapper& operator=( const ControlWrapper& rhs );
187   /// @endcond
188 };
189
190 } // namespace Internal
191
192 // Helpers for public-api forwarding methods
193
194 inline Toolkit::Internal::ControlWrapper& GetControlWrapperImpl( Toolkit::ControlWrapper& publicObject )
195 {
196   DALI_ASSERT_ALWAYS( publicObject );
197
198   Dali::RefObject& handle = publicObject.GetImplementation();
199
200   return static_cast<Toolkit::Internal::ControlWrapper&>( handle );
201 }
202
203 inline const Toolkit::Internal::ControlWrapper& GetControlWrapperImpl( const Toolkit::ControlWrapper& publicObject )
204 {
205   DALI_ASSERT_ALWAYS( publicObject );
206
207   const Dali::RefObject& handle = publicObject.GetImplementation();
208
209   return static_cast<const Toolkit::Internal::ControlWrapper&>( handle );
210 }
211
212 } // namespace Toolkit
213
214 } // namespace Dali
215
216 #endif // DALI_TOOLKIT_INTERNAL_CONTROL_WRAPPER_H