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