1 #ifndef DALI_TOOLKIT_TEST_DUMMY_CONTROL_H
2 #define DALI_TOOLKIT_TEST_DUMMY_CONTROL_H
5 * Copyright (c) 2020 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-toolkit/dali-toolkit.h>
33 class DummyControlImpl;
42 * Control does not have a New method so use this dummy class for the handle.
44 class DummyControl : public Control
49 PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1, ///< @SINCE_1_0.0
50 PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000 ///< Reserve property index
57 TEST_VISUAL = PROPERTY_START_INDEX,
66 DummyControl(const DummyControl& control);
69 static DummyControl New( bool override = false );
71 static DummyControl DownCast( BaseHandle handle );
74 DummyControl& operator=(const DummyControl& control);
76 public: // Not intended for application developers
78 DummyControl( DummyControlImpl& implementation );
79 DummyControl( Dali::Internal::CustomActor* internal );
83 * Cannot create an instance of Internal::Control, so use this dummy class for the implementation.
84 * This class does not override any of Internal::Control's behaviour.
86 class DummyControlImpl : public Toolkit::Internal::Control
90 static DummyControl New();
93 inline void EnableGestureDetection(Gesture::Type type) { Internal::Control::EnableGestureDetection(type); }
94 inline void DisableGestureDetection(Gesture::Type type) { Internal::Control::DisableGestureDetection(type); }
95 inline PinchGestureDetector GetPinchGestureDetector() const { return Internal::Control::GetPinchGestureDetector(); }
96 inline PanGestureDetector GetPanGestureDetector() const { return Internal::Control::GetPanGestureDetector(); }
97 inline TapGestureDetector GetTapGestureDetector() const { return Internal::Control::GetTapGestureDetector(); }
98 inline LongPressGestureDetector GetLongPressGestureDetector() const { return Internal::Control::GetLongPressGestureDetector(); }
100 void RegisterVisual( Property::Index index, Toolkit::Visual::Base visual);
101 void RegisterVisual( Property::Index index, Toolkit::Visual::Base visual, bool enabled );
102 void UnregisterVisual( Property::Index index );
103 void EnableVisual( Property::Index index, bool enabled );
104 bool IsVisualEnabled( Property::Index index );
105 int GetVisualCount();
106 Toolkit::Visual::Base GetVisual( Property::Index index );
107 Animation CreateTransition( const Toolkit::TransitionData& transition );
108 void DoAction( Dali::Property::Index index, Dali::Property::Index action, const Dali::Property::Value attributes );
110 static void SetProperty( BaseObject* object, Dali::Property::Index index, const Dali::Property::Value& value );
112 static Property::Value GetProperty( BaseObject* object, Dali::Property::Index propertyIndex );
114 // Used to test signal connections
115 void CustomSlot1( Actor actor );
117 bool mCustomSlot1Called;
118 typedef std::vector<Property::Index> VisualIndices;
119 VisualIndices mRegisteredVisualIndices;
125 virtual ~DummyControlImpl();
132 * Cannot create an instance of Internal::Control, so use this dummy class for the implementation.
133 * This class DOES override Internal::Control's behaviour.
135 class DummyControl : public Toolkit::DummyControlImpl
139 typedef std::function<void( Size )> RelayoutCallbackFunc;
141 static Toolkit::DummyControl New();
143 void SetLayout( Property::Index visualIndex, Property::Map& map );
145 void SetRelayoutCallback( RelayoutCallbackFunc callback );
151 virtual ~DummyControl();
153 private: // From Internal::Control
155 virtual void OnInitialize();
156 virtual bool OnAccessibilityActivated();
157 virtual bool OnAccessibilityValueChange( bool isIncrease );
159 virtual void OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change );
160 virtual void OnPinch(const PinchGesture& pinch);
161 virtual void OnPan(const PanGesture& pan);
162 virtual void OnTap(const TapGesture& tap);
163 virtual void OnLongPress(const LongPressGesture& longPress);
164 virtual Vector3 GetNaturalSize();
166 private: // From CustomActorImpl
168 virtual void OnSceneConnection( int depth );
169 virtual void OnSceneDisconnection();
170 virtual void OnChildAdd(Actor& child);
171 virtual void OnChildRemove(Actor& child);
172 virtual void OnSizeSet(const Vector3& targetSize);
173 virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize);
174 virtual bool OnHoverEvent(const HoverEvent& event);
175 virtual bool OnWheelEvent(const WheelEvent& event);
176 virtual bool OnKeyEvent(const KeyEvent& event);
177 virtual void OnKeyInputFocusGained();
178 virtual void OnKeyInputFocusLost();
179 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
181 DALI_INTERNAL DummyControl( const DummyControl& );
182 DALI_INTERNAL DummyControl& operator=( const DummyControl& );
186 bool initializeCalled;
187 bool activatedCalled;
188 bool onAccValueChangeCalled;
189 bool themeChangeCalled;
190 bool fontChangeCalled;
194 bool longPressCalled;
195 bool stageConnectionCalled;
196 bool stageDisconnectionCalled;
198 bool childRemoveCalled;
200 bool sizeAnimationCalled;
201 bool hoverEventCalled;
202 bool wheelEventCalled;
204 bool keyInputFocusGained;
205 bool keyInputFocusLost;
206 static int constructorCount;
207 static int destructorCount;
209 Property::Map mLayouts;
210 RelayoutCallbackFunc mRelayoutCallback;
216 } // namespace Toolkit
220 #endif // DALI_TOOLKIT_TEST_DUMMY_CONTROL_H