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>
22 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
23 #include <dali-toolkit/devel-api/align-enums.h>
31 DummyControl::DummyControl()
35 DummyControl::DummyControl(const DummyControl& control)
40 DummyControl::~DummyControl()
44 DummyControl DummyControl::DownCast( BaseHandle handle )
46 return Control::DownCast<DummyControl, DummyControlImpl>(handle);
49 DummyControl& DummyControl::operator=(const DummyControl& control)
51 Control::operator=( control );
55 // Used to test signal connections
56 void DummyControlImpl::CustomSlot1( Actor actor )
58 mCustomSlot1Called = true;
65 return DummyControlImpl::New();
68 DALI_TYPE_REGISTRATION_BEGIN( Toolkit::DummyControl, Toolkit::Control, Create );
69 DALI_TYPE_REGISTRATION_END()
72 DummyControl DummyControlImpl::New()
74 IntrusivePtr< DummyControlImpl > impl = new DummyControlImpl;
75 DummyControl control( *impl );
80 DummyControlImpl::DummyControlImpl()
81 : Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_HOVER_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS ) ),
82 mCustomSlot1Called(false)
86 DummyControlImpl::~DummyControlImpl()
90 void DummyControlImpl::RegisterVisual( Property::Index index, Toolkit::Visual::Base visual )
92 Control::RegisterVisual( index, visual );
94 VisualIndices::iterator iter = std::find( mRegisteredVisualIndices.begin(), mRegisteredVisualIndices.end(), index );
95 if( iter == mRegisteredVisualIndices.end() )
97 mRegisteredVisualIndices.push_back(index);
101 void DummyControlImpl::RegisterVisual( Property::Index index, Toolkit::Visual::Base visual, bool enabled )
103 Control::RegisterVisual( index, visual, enabled );
105 VisualIndices::iterator iter = std::find( mRegisteredVisualIndices.begin(), mRegisteredVisualIndices.end(), index );
106 if( iter == mRegisteredVisualIndices.end() )
108 mRegisteredVisualIndices.push_back(index);
112 void DummyControlImpl::UnregisterVisual( Property::Index index )
114 Control::UnregisterVisual( index );
117 Toolkit::Visual::Base DummyControlImpl::GetVisual( Property::Index index )
119 return Control::GetVisual( index );
122 void DummyControlImpl::EnableVisual( Property::Index index, bool enabled )
124 Control::EnableVisual( index, enabled );
127 bool DummyControlImpl::IsVisualEnabled( Property::Index index )
129 return Control::IsVisualEnabled( index );
133 Animation DummyControlImpl::CreateTransition( const Toolkit::TransitionData& transition )
135 return Control::CreateTransition( transition );
138 DummyControl DummyControlImplOverride::New()
140 IntrusivePtr< DummyControlImplOverride > impl = new DummyControlImplOverride;
141 DummyControl control( *impl );
147 DummyControlImplOverride::DummyControlImplOverride()
148 : DummyControlImpl(),
149 initializeCalled(false),
150 activatedCalled(false),
151 onAccTouchedCalled(false),
152 onAccValueChangeCalled(false),
153 themeChangeCalled(false),
154 fontChangeCalled(false),
158 longPressCalled(false),
159 stageConnectionCalled(false),
160 stageDisconnectionCalled(false),
161 childAddCalled(false),
162 childRemoveCalled(false),
163 sizeSetCalled(false),
164 sizeAnimationCalled(false),
165 touchEventCalled(false),
166 hoverEventCalled(false),
167 wheelEventCalled(false),
168 keyEventCalled(false),
169 keyInputFocusGained(false),
170 keyInputFocusLost(false)
174 DummyControlImplOverride::~DummyControlImplOverride() { }
177 void DummyControlImplOverride::OnInitialize() { initializeCalled = true; }
178 bool DummyControlImplOverride::OnAccessibilityActivated() { activatedCalled = true; return true; }
179 bool DummyControlImplOverride::OnAccessibilityTouch(const TouchEvent& touchEvent) { onAccTouchedCalled = true; return true; }
180 bool DummyControlImplOverride::OnAccessibilityValueChange( bool isIncrease )
182 onAccValueChangeCalled = true; return true;
185 void DummyControlImplOverride::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change )
187 themeChangeCalled = change == StyleChange::THEME_CHANGE;
188 fontChangeCalled = change == StyleChange::DEFAULT_FONT_SIZE_CHANGE;
190 void DummyControlImplOverride::OnPinch(const PinchGesture& pinch) { pinchCalled = true; }
191 void DummyControlImplOverride::OnPan(const PanGesture& pan) { panCalled = true; }
192 void DummyControlImplOverride::OnTap(const TapGesture& tap) { tapCalled = true; }
193 void DummyControlImplOverride::OnLongPress(const LongPressGesture& longPress) { longPressCalled = true; }
194 void DummyControlImplOverride::OnStageConnection( int depth ) { Control::OnStageConnection( depth ); stageConnectionCalled = true; }
195 void DummyControlImplOverride::OnStageDisconnection() { stageDisconnectionCalled = true; Control::OnStageDisconnection(); }
196 void DummyControlImplOverride::OnChildAdd(Actor& child) { childAddCalled = true; }
197 void DummyControlImplOverride::OnChildRemove(Actor& child) { childRemoveCalled = true; }
198 void DummyControlImplOverride::OnSizeSet(const Vector3& targetSize) { Control::OnSizeSet( targetSize ); sizeSetCalled = true; }
199 void DummyControlImplOverride::OnSizeAnimation(Animation& animation, const Vector3& targetSize) { Control::OnSizeAnimation( animation, targetSize ); sizeAnimationCalled = true; }
200 bool DummyControlImplOverride::OnTouchEvent(const TouchEvent& event) { touchEventCalled = true; return false; }
201 bool DummyControlImplOverride::OnHoverEvent(const HoverEvent& event) { hoverEventCalled = true; return false; }
202 bool DummyControlImplOverride::OnWheelEvent(const WheelEvent& event) { wheelEventCalled = true; return false; }
203 bool DummyControlImplOverride::OnKeyEvent(const KeyEvent& event) { keyEventCalled = true; return false;}
204 void DummyControlImplOverride::OnKeyInputFocusGained() { keyInputFocusGained = true; }
205 void DummyControlImplOverride::OnKeyInputFocusLost() { keyInputFocusLost = true; }
207 void DummyControlImplOverride::OnRelayout( const Vector2& size, RelayoutContainer& container )
209 Property::Map transformMap;
211 .Add( Toolkit::DevelVisual::Transform::Property::OFFSET, Vector2(0.0f, 0.0f) )
212 .Add( Toolkit::DevelVisual::Transform::Property::SIZE, Vector2(1.0f, 1.0f) )
213 .Add( Toolkit::DevelVisual::Transform::Property::ORIGIN, Toolkit::Align::CENTER )
214 .Add( Toolkit::DevelVisual::Transform::Property::ANCHOR_POINT, Toolkit::Align::CENTER )
215 .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_SIZE_MODE, Vector4::ZERO );
217 for( VisualIndices::iterator iter = mRegisteredVisualIndices.begin(); iter != mRegisteredVisualIndices.end() ; ++iter )
219 Visual::Base visual = GetVisual(*iter);
220 visual.SetTransformAndSize( transformMap, size );
225 DummyControl DummyControl::New( bool override )
227 DummyControl control;
231 control = DummyControlImplOverride::New();
235 control = DummyControlImpl::New();
241 DummyControl::DummyControl( DummyControlImpl& implementation )
242 : Control( implementation )
246 DummyControl::DummyControl( Dali::Internal::CustomActor* internal )
247 : Control( internal )
249 VerifyCustomActorPointer<DummyControlImpl>(internal);
252 } // namespace Toolkit