2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include "dummy-control.h"
20 #include <dali-toolkit/dali-toolkit.h>
21 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
29 DummyControl::DummyControl()
33 DummyControl::DummyControl(const DummyControl& control)
38 DummyControl::~DummyControl()
42 DummyControl DummyControl::DownCast( BaseHandle handle )
44 return Control::DownCast<DummyControl, DummyControlImpl>(handle);
47 DummyControl& DummyControl::operator=(const DummyControl& control)
49 Control::operator=( control );
53 // Used to test signal connections
54 void DummyControlImpl::CustomSlot1( Actor actor )
56 mCustomSlot1Called = true;
63 return DummyControlImpl::New();
66 DALI_TYPE_REGISTRATION_BEGIN( Toolkit::DummyControl, Toolkit::Control, Create );
67 DALI_TYPE_REGISTRATION_END()
70 DummyControl DummyControlImpl::New()
72 IntrusivePtr< DummyControlImpl > impl = new DummyControlImpl;
73 DummyControl control( *impl );
78 DummyControlImpl::DummyControlImpl()
79 : Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_HOVER_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS ) ),
80 mCustomSlot1Called(false)
84 DummyControlImpl::~DummyControlImpl()
88 void DummyControlImpl::RegisterVisual( Property::Index index, Toolkit::Visual::Base visual )
90 Control::RegisterVisual( index, visual );
93 void DummyControlImpl::RegisterVisual( Property::Index index, Toolkit::Visual::Base visual, bool enabled )
95 Control::RegisterVisual( index, visual, enabled );
98 void DummyControlImpl::UnregisterVisual( Property::Index index )
100 Control::UnregisterVisual( index );
103 Toolkit::Visual::Base DummyControlImpl::GetVisual( Property::Index index )
105 return Control::GetVisual( index );
108 void DummyControlImpl::EnableVisual( Property::Index index, bool enabled )
110 Control::EnableVisual( index, enabled );
113 bool DummyControlImpl::IsVisualEnabled( Property::Index index )
115 return Control::IsVisualEnabled( index );
118 Animation DummyControlImpl::CreateTransition( const Toolkit::TransitionData& transition )
120 return Control::CreateTransition( transition );
123 DummyControl DummyControlImplOverride::New()
125 IntrusivePtr< DummyControlImplOverride > impl = new DummyControlImplOverride;
126 DummyControl control( *impl );
132 DummyControlImplOverride::DummyControlImplOverride()
133 : DummyControlImpl(),
134 initializeCalled(false),
135 activatedCalled(false),
136 onAccTouchedCalled(false),
137 onAccValueChangeCalled(false),
138 themeChangeCalled(false),
139 fontChangeCalled(false),
143 longPressCalled(false),
144 stageConnectionCalled(false),
145 stageDisconnectionCalled(false),
146 childAddCalled(false),
147 childRemoveCalled(false),
148 sizeSetCalled(false),
149 sizeAnimationCalled(false),
150 touchEventCalled(false),
151 hoverEventCalled(false),
152 wheelEventCalled(false),
153 keyEventCalled(false),
154 keyInputFocusGained(false),
155 keyInputFocusLost(false)
159 DummyControlImplOverride::~DummyControlImplOverride() { }
162 void DummyControlImplOverride::OnInitialize() { initializeCalled = true; }
163 bool DummyControlImplOverride::OnAccessibilityActivated() { activatedCalled = true; return true; }
164 bool DummyControlImplOverride::OnAccessibilityTouch(const TouchEvent& touchEvent) { onAccTouchedCalled = true; return true; }
165 bool DummyControlImplOverride::OnAccessibilityValueChange( bool isIncrease )
167 onAccValueChangeCalled = true; return true;
170 void DummyControlImplOverride::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change )
172 themeChangeCalled = change == StyleChange::THEME_CHANGE;
173 fontChangeCalled = change == StyleChange::DEFAULT_FONT_SIZE_CHANGE;
175 void DummyControlImplOverride::OnPinch(const PinchGesture& pinch) { pinchCalled = true; }
176 void DummyControlImplOverride::OnPan(const PanGesture& pan) { panCalled = true; }
177 void DummyControlImplOverride::OnTap(const TapGesture& tap) { tapCalled = true; }
178 void DummyControlImplOverride::OnLongPress(const LongPressGesture& longPress) { longPressCalled = true; }
179 void DummyControlImplOverride::OnStageConnection( int depth ) { Control::OnStageConnection( depth ); stageConnectionCalled = true; }
180 void DummyControlImplOverride::OnStageDisconnection() { stageDisconnectionCalled = true; Control::OnStageDisconnection(); }
181 void DummyControlImplOverride::OnChildAdd(Actor& child) { childAddCalled = true; }
182 void DummyControlImplOverride::OnChildRemove(Actor& child) { childRemoveCalled = true; }
183 void DummyControlImplOverride::OnSizeSet(const Vector3& targetSize) { Control::OnSizeSet( targetSize ); sizeSetCalled = true; }
184 void DummyControlImplOverride::OnSizeAnimation(Animation& animation, const Vector3& targetSize) { Control::OnSizeAnimation( animation, targetSize ); sizeAnimationCalled = true; }
185 bool DummyControlImplOverride::OnTouchEvent(const TouchEvent& event) { touchEventCalled = true; return false; }
186 bool DummyControlImplOverride::OnHoverEvent(const HoverEvent& event) { hoverEventCalled = true; return false; }
187 bool DummyControlImplOverride::OnWheelEvent(const WheelEvent& event) { wheelEventCalled = true; return false; }
188 bool DummyControlImplOverride::OnKeyEvent(const KeyEvent& event) { keyEventCalled = true; return false;}
189 void DummyControlImplOverride::OnKeyInputFocusGained() { keyInputFocusGained = true; }
190 void DummyControlImplOverride::OnKeyInputFocusLost() { keyInputFocusLost = true; }
192 DummyControl DummyControl::New( bool override )
194 DummyControl control;
198 control = DummyControlImplOverride::New();
202 control = DummyControlImpl::New();
208 DummyControl::DummyControl( DummyControlImpl& implementation )
209 : Control( implementation )
213 DummyControl::DummyControl( Dali::Internal::CustomActor* internal )
214 : Control( internal )
216 VerifyCustomActorPointer<DummyControlImpl>(internal);
219 } // namespace Toolkit