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