1 #ifndef DALI_TOOLKIT_CONTROL_DATA_IMPL_H
2 #define DALI_TOOLKIT_CONTROL_DATA_IMPL_H
5 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/public-api/object/type-registry.h>
23 #include <dali-toolkit/devel-api/controls/control-devel.h>
27 #include <dali-toolkit/internal/visuals/visual-resource-observer.h>
28 #include <dali-toolkit/public-api/controls/control-impl.h>
29 #include <dali/devel-api/common/owner-container.h>
30 #include <dali-toolkit/devel-api/visual-factory/visual-base.h>
42 * Struct used to store Visual within the control, index is a unique key for each visual.
44 struct RegisteredVisual
46 Property::Index index;
47 Toolkit::Visual::Base visual;
50 RegisteredVisual( Property::Index aIndex, Toolkit::Visual::Base &aVisual, bool aEnabled)
51 : index(aIndex), visual(aVisual), enabled(aEnabled)
56 typedef Dali::OwnerContainer< RegisteredVisual* > RegisteredVisualContainer;
60 * @brief Holds the Implementation for the internal control class
62 class Control::Impl : public ConnectionTracker, public Visual::ResourceObserver
68 * @brief Retrieves the implementation of the internal control class.
69 * @param[in] internalControl A ref to the control whose internal implementation is required
70 * @return The internal implementation
72 static Control::Impl& Get( Internal::Control& internalControl );
75 * @copydoc Get( Internal::Control& )
77 static const Control::Impl& Get( const Internal::Control& internalControl );
81 * @param[in] controlImpl The control which own this implementation
83 Impl( Control& controlImpl );
91 * @brief Called when a pinch is detected.
92 * @param[in] actor The actor the pinch occurred on
93 * @param[in] pinch The pinch gesture details
95 void PinchDetected(Actor actor, const PinchGesture& pinch);
98 * @brief Called when a pan is detected.
99 * @param[in] actor The actor the pan occurred on
100 * @param[in] pan The pan gesture details
102 void PanDetected(Actor actor, const PanGesture& pan);
105 * @brief Called when a tap is detected.
106 * @param[in] actor The actor the tap occurred on
107 * @param[in] tap The tap gesture details
109 void TapDetected(Actor actor, const TapGesture& tap);
112 * @brief Called when a long-press is detected.
113 * @param[in] actor The actor the long-press occurred on
114 * @param[in] longPress The long-press gesture details
116 void LongPressDetected(Actor actor, const LongPressGesture& longPress);
119 * @brief Called when a resource is ready.
120 * @param[in] object The visual whose resources are ready
121 * @note Overriding method in Visual::ResourceObserver.
123 virtual void ResourceReady( Visual::Base& object );
126 * @copydoc Dali::Toolkit::DevelControl::RegisterVisual()
128 void RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual );
131 * @copydoc Dali::Toolkit::DevelControl::RegisterVisual()
133 void RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, bool enabled );
136 * @copydoc Dali::Toolkit::DevelControl::UnregisterVisual()
138 void UnregisterVisual( Property::Index index );
141 * @copydoc Dali::Toolkit::DevelControl::GetVisual()
143 Toolkit::Visual::Base GetVisual( Property::Index index ) const;
146 * @copydoc Dali::Toolkit::DevelControl::EnableVisual()
148 void EnableVisual( Property::Index index, bool enable );
151 * @copydoc Dali::Toolkit::DevelControl::IsVisualEnabled()
153 bool IsVisualEnabled( Property::Index index ) const;
156 * @brief Stops observing the given visual.
157 * @param[in] visual The visual to stop observing
159 void StopObservingVisual( Toolkit::Visual::Base& visual );
162 * @brief Starts observing the given visual.
163 * @param[in] visual The visual to start observing
165 void StartObservingVisual( Toolkit::Visual::Base& visual);
168 * @brief Function used to set control properties.
169 * @param[in] object The object whose property to set
170 * @param[in] index The index of the property to set
171 * @param[in] value The value of the property to set
173 static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
176 * @brief Function used to retrieve the value of control properties.
177 * @param[in] object The object whose property to get
178 * @param[in] index The index of the property to get
179 * @return The value of the property
181 static Property::Value GetProperty( BaseObject* object, Property::Index index );
184 * @brief Removes a visual from the control's container.
185 * @param[in] visuals The container of visuals
186 * @param[in] visualName The name of the visual to remove
188 void RemoveVisual( RegisteredVisualContainer& visuals, const std::string& visualName );
191 * @brief Whether the resource is ready
192 * @return True if the resource is read.
194 bool IsResourceReady() const;
196 Control& mControlImpl;
198 RegisteredVisualContainer mVisuals; ///< Stores visuals needed by the control, non trivial type so std::vector used.
199 std::string mStyleName;
200 Vector4 mBackgroundColor; ///< The color of the background visual
201 Vector3* mStartingPinchScale; ///< The scale when a pinch gesture starts, TODO: consider removing this
202 Toolkit::Control::KeyEventSignalType mKeyEventSignal;
203 Toolkit::Control::KeyInputFocusSignalType mKeyInputFocusGainedSignal;
204 Toolkit::Control::KeyInputFocusSignalType mKeyInputFocusLostSignal;
206 Toolkit::DevelControl::ResourceReadySignalType mResourceReadySignal;
209 PinchGestureDetector mPinchGestureDetector;
210 PanGestureDetector mPanGestureDetector;
211 TapGestureDetector mTapGestureDetector;
212 LongPressGestureDetector mLongPressGestureDetector;
214 ControlBehaviour mFlags : CONTROL_BEHAVIOUR_FLAG_COUNT; ///< Flags passed in from constructor.
215 bool mIsKeyboardNavigationSupported :1; ///< Stores whether keyboard navigation is supported by the control.
216 bool mIsKeyboardFocusGroup :1; ///< Stores whether the control is a focus group.
218 // Properties - these need to be members of Internal::Control::Impl as they access private methods/data of Internal::Control and Internal::Control::Impl.
219 static const PropertyRegistration PROPERTY_1;
220 static const PropertyRegistration PROPERTY_2;
221 static const PropertyRegistration PROPERTY_3;
222 static const PropertyRegistration PROPERTY_4;
223 static const PropertyRegistration PROPERTY_5;
228 } // namespace Internal
230 } // namespace Toolkit
234 #endif // DALI_TOOLKIT_CONTROL_DATA_IMPL_H