1 #ifndef DALI_TOOLKIT_TEST_DUMMY_CONTROL_H
2 #define DALI_TOOLKIT_TEST_DUMMY_CONTROL_H
5 * Copyright (c) 2024 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>
31 class DummyControlImpl;
40 * Control does not have a New method so use this dummy class for the handle.
42 class DummyControl : public Control
47 PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1, ///< @SINCE_1_0.0
48 PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000 ///< Reserve property index
55 TEST_VISUAL = PROPERTY_START_INDEX,
64 DummyControl(const DummyControl& control);
67 static DummyControl New(bool override = false);
69 static DummyControl DownCast(BaseHandle handle);
71 DummyControl& operator=(const DummyControl& control);
73 public: // Not intended for application developers
74 DummyControl(DummyControlImpl& implementation);
75 DummyControl(Dali::Internal::CustomActor* internal);
79 * Cannot create an instance of Internal::Control, so use this dummy class for the implementation.
80 * This class does not override any of Internal::Control's behaviour.
82 class DummyControlImpl : public Toolkit::Internal::Control
85 static DummyControl New();
88 inline void EnableGestureDetection(GestureType::Value type)
90 Internal::Control::EnableGestureDetection(type);
92 inline void DisableGestureDetection(GestureType::Value type)
94 Internal::Control::DisableGestureDetection(type);
96 inline PinchGestureDetector GetPinchGestureDetector() const
98 return Internal::Control::GetPinchGestureDetector();
100 inline PanGestureDetector GetPanGestureDetector() const
102 return Internal::Control::GetPanGestureDetector();
104 inline TapGestureDetector GetTapGestureDetector() const
106 return Internal::Control::GetTapGestureDetector();
108 inline LongPressGestureDetector GetLongPressGestureDetector() const
110 return Internal::Control::GetLongPressGestureDetector();
113 void RegisterVisual(Property::Index index, Toolkit::Visual::Base visual);
114 void RegisterVisual(Property::Index index, Toolkit::Visual::Base visual, bool enabled);
115 void RegisterVisual(Property::Index index, Toolkit::Visual::Base visual, int depthIndex);
116 void UnregisterVisual(Property::Index index);
117 void EnableVisual(Property::Index index, bool enabled);
118 bool IsVisualEnabled(Property::Index index);
119 int GetVisualCount();
120 Toolkit::Visual::Base GetVisual(Property::Index index);
121 Animation CreateTransition(const Toolkit::TransitionData& transition);
122 void DoAction(Dali::Property::Index index, Dali::Property::Index action, const Dali::Property::Value attributes);
124 static void SetProperty(BaseObject* object, Dali::Property::Index index, const Dali::Property::Value& value);
126 static Property::Value GetProperty(BaseObject* object, Dali::Property::Index propertyIndex);
128 // Used to test signal connections
129 void CustomSlot1(Actor actor);
131 bool mCustomSlot1Called;
132 typedef std::vector<Property::Index> VisualIndices;
133 VisualIndices mRegisteredVisualIndices;
138 ~DummyControlImpl() override;
144 * Cannot create an instance of Internal::Control, so use this dummy class for the implementation.
145 * This class DOES override Internal::Control's behaviour.
147 class DummyControl : public Toolkit::DummyControlImpl
150 typedef std::function<void(Size)> RelayoutCallbackFunc;
152 static Toolkit::DummyControl New();
154 void SetLayout(Property::Index visualIndex, Property::Map& map);
156 void SetRelayoutCallback(RelayoutCallbackFunc callback);
161 ~DummyControl() override;
163 private: // From Internal::Control
164 void OnInitialize() override;
165 bool OnAccessibilityActivated() override;
166 bool OnAccessibilityValueChange(bool isIncrease) override;
168 void OnStyleChange(Toolkit::StyleManager styleManager, StyleChange::Type change) override;
169 void OnPinch(const PinchGesture& pinch) override;
170 void OnPan(const PanGesture& pan) override;
171 void OnTap(const TapGesture& tap) override;
172 void OnLongPress(const LongPressGesture& longPress) override;
173 Vector3 GetNaturalSize() override;
174 bool OnKeyEvent(const KeyEvent& event) override;
176 private: // From CustomActorImpl
177 void OnSceneConnection(int depth) override;
178 void OnSceneDisconnection() override;
179 void OnChildAdd(Actor& child) override;
180 void OnChildRemove(Actor& child) override;
181 void OnSizeSet(const Vector3& targetSize) override;
182 void OnSizeAnimation(Animation& animation, const Vector3& targetSize) override;
183 void OnKeyInputFocusGained() override;
184 void OnKeyInputFocusLost() override;
185 void OnRelayout(const Vector2& size, RelayoutContainer& container) override;
187 DALI_INTERNAL DummyControl(const DummyControl&);
188 DALI_INTERNAL DummyControl& operator=(const DummyControl&);
191 bool initializeCalled;
192 bool activatedCalled;
193 bool onAccValueChangeCalled;
194 bool themeChangeCalled;
195 bool fontChangeCalled;
199 bool longPressCalled;
200 bool stageConnectionCalled;
201 bool stageDisconnectionCalled;
203 bool childRemoveCalled;
205 bool sizeAnimationCalled;
206 bool hoverEventCalled;
207 bool wheelEventCalled;
209 bool keyInputFocusGained;
210 bool keyInputFocusLost;
211 static int constructorCount;
212 static int destructorCount;
214 Property::Map mLayouts;
215 RelayoutCallbackFunc mRelayoutCallback;
220 } // namespace Toolkit
224 #endif // DALI_TOOLKIT_TEST_DUMMY_CONTROL_H