1 #ifndef DALI_TOOLKIT_CONTROL_DATA_IMPL_H
2 #define DALI_TOOLKIT_CONTROL_DATA_IMPL_H
5 * Copyright (c) 2016 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>
31 #include <dali-toolkit/internal/controls/tooltip/tooltip.h>
32 #include <dali-toolkit/internal/builder/style.h>
33 #include <dali-toolkit/internal/builder/dictionary.h>
45 * Struct used to store Visual within the control, index is a unique key for each visual.
47 struct RegisteredVisual
49 Property::Index index;
50 Toolkit::Visual::Base visual;
53 RegisteredVisual( Property::Index aIndex, Toolkit::Visual::Base &aVisual, bool aEnabled)
54 : index(aIndex), visual(aVisual), enabled(aEnabled)
59 typedef Dali::OwnerContainer< RegisteredVisual* > RegisteredVisualContainer;
63 * Holds the Implementation for the internal control class
65 class Control::Impl : public ConnectionTracker, public Visual::ResourceObserver
70 static Control::Impl& Get( Internal::Control& internalControl );
72 static const Control::Impl& Get( const Internal::Control& internalControl );
75 Impl( Control& controlImpl );
79 void PinchDetected(Actor actor, const PinchGesture& pinch);
81 void PanDetected(Actor actor, const PanGesture& pan);
83 void TapDetected(Actor actor, const TapGesture& tap);
85 void LongPressDetected(Actor actor, const LongPressGesture& longPress);
87 void ResourceReady( Visual::Base& object);
89 void StopObservingVisual( Toolkit::Visual::Base& visual );
91 void StartObservingVisual( Toolkit::Visual::Base& visual);
93 static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
95 static Property::Value GetProperty( BaseObject* object, Property::Index index );
97 void SetState( DevelControl::State newState, bool withTransitions=true );
99 void SetSubState( const std::string& subStateName, bool withTransitions=true );
101 void ReplaceStateVisualsAndProperties( const StylePtr oldState, const StylePtr newState, const std::string& subState );
103 void RemoveVisual( RegisteredVisualContainer& visuals, const std::string& visualName );
105 void RemoveVisuals( RegisteredVisualContainer& visuals, DictionaryKeys& removeVisuals );
107 void CopyInstancedProperties( RegisteredVisualContainer& visuals, Dictionary<Property::Map>& instancedProperties );
109 void RecreateChangedVisuals( Dictionary<Property::Map>& stateVisualsToChange, Dictionary<Property::Map>& instancedProperties );
111 Toolkit::Visual::Base GetVisualByName( RegisteredVisualContainer& visuals, const std::string& visualName );
113 bool IsResourceReady() const;
115 Control& mControlImpl;
116 DevelControl::State mState;
117 std::string mSubStateName;
119 int mLeftFocusableActorId; ///< Actor ID of Left focusable control.
120 int mRightFocusableActorId; ///< Actor ID of Right focusable control.
121 int mUpFocusableActorId; ///< Actor ID of Up focusable control.
122 int mDownFocusableActorId; ///< Actor ID of Down focusable control.
125 RegisteredVisualContainer mVisuals; ///< Stores visuals needed by the control, non trivial type so std::vector used.
126 std::string mStyleName;
127 Vector4 mBackgroundColor; ///< The color of the background visual
128 Vector3* mStartingPinchScale; ///< The scale when a pinch gesture starts, TODO: consider removing this
129 Toolkit::Control::KeyEventSignalType mKeyEventSignal;
130 Toolkit::Control::KeyInputFocusSignalType mKeyInputFocusGainedSignal;
131 Toolkit::Control::KeyInputFocusSignalType mKeyInputFocusLostSignal;
133 Toolkit::DevelControl::ResourceReadySignalType mResourceReadySignal;
136 PinchGestureDetector mPinchGestureDetector;
137 PanGestureDetector mPanGestureDetector;
138 TapGestureDetector mTapGestureDetector;
139 LongPressGestureDetector mLongPressGestureDetector;
144 ControlBehaviour mFlags : CONTROL_BEHAVIOUR_FLAG_COUNT; ///< Flags passed in from constructor.
145 bool mIsKeyboardNavigationSupported :1; ///< Stores whether keyboard navigation is supported by the control.
146 bool mIsKeyboardFocusGroup :1; ///< Stores whether the control is a focus group.
148 // Properties - these need to be members of Internal::Control::Impl as they access private methods/data of Internal::Control and Internal::Control::Impl.
149 static const PropertyRegistration PROPERTY_1;
150 static const PropertyRegistration PROPERTY_2;
151 static const PropertyRegistration PROPERTY_3;
152 static const PropertyRegistration PROPERTY_4;
153 static const PropertyRegistration PROPERTY_5;
154 static const PropertyRegistration PROPERTY_6;
155 static const PropertyRegistration PROPERTY_7;
156 static const PropertyRegistration PROPERTY_8;
157 static const PropertyRegistration PROPERTY_9;
158 static const PropertyRegistration PROPERTY_10;
159 static const PropertyRegistration PROPERTY_11;
160 static const PropertyRegistration PROPERTY_12;
165 } // namespace Internal
167 } // namespace Toolkit
171 #endif // DALI_TOOLKIT_CONTROL_DATA_IMPL_H