(StyleManager) Add style monitor signal into StyleManager
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / dummy-control.cpp
1 //
2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.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
7 //
8 //     http://floralicense.org/license/
9 //
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.
15 //
16
17 #include "dummy-control.h"
18
19 #include <dali-toolkit/public-api/styling/style-manager.h>
20
21 namespace Dali
22 {
23
24 namespace Toolkit
25 {
26
27 DummyControl::DummyControl()
28 : mCustomSlot1Called(false)
29 {
30 }
31
32 DummyControl::DummyControl(const DummyControl& control)
33 : Control( control ),
34   mCustomSlot1Called(false),
35   mCustomSlot1Value(Vector3::ZERO)
36 {
37 }
38
39 DummyControl::~DummyControl()
40 {
41 }
42
43 DummyControl DummyControl::DownCast( BaseHandle handle )
44 {
45   return Control::DownCast<DummyControl, DummyControlImpl>(handle);
46 }
47
48 DummyControl& DummyControl::operator=(const DummyControl& control)
49 {
50   Control::operator=( control );
51   return *this;
52 }
53
54 // Used to test signal connections
55 void DummyControl::CustomSlot1( Actor actor, const Vector3& value )
56 {
57   mCustomSlot1Called = true;
58   mCustomSlot1Value = value;
59 }
60
61 DummyControl DummyControlImpl::New()
62 {
63   IntrusivePtr< DummyControlImpl > impl = new DummyControlImpl;
64   DummyControl control( *impl );
65   impl->Initialize();
66   return control;
67 }
68
69 DummyControlImpl::DummyControlImpl()
70 : Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS ) )
71 {
72 }
73
74 DummyControlImpl::~DummyControlImpl()
75 {
76 }
77
78 DummyControl DummyControlImplOverride::New()
79 {
80   IntrusivePtr< DummyControlImplOverride > impl = new DummyControlImplOverride;
81   DummyControl control( *impl );
82   impl->Initialize();
83   return control;
84 }
85
86
87 DummyControlImplOverride::DummyControlImplOverride()
88 : DummyControlImpl(),
89   initializeCalled(false),
90   themeChangeCalled( false ),
91   fontChangeCalled( false ),
92   pinchCalled(false),
93   panCalled(false),
94   tapCalled(false),
95   longPressCalled(false),
96   stageConnectionCalled(false),
97   stageDisconnectionCalled(false),
98   childAddCalled(false),
99   childRemoveCalled(false),
100   sizeSetCalled(false),
101   sizeAnimationCalled(false),
102   touchEventCalled(false),
103   mouseWheelEventCalled(false),
104   keyEventCalled(false),
105   keyInputFocusGained(false),
106   keyInputFocusLost(false)
107 {
108 }
109
110 DummyControlImplOverride::~DummyControlImplOverride() { }
111
112
113 void DummyControlImplOverride::OnInitialize() { initializeCalled = true; }
114 void DummyControlImplOverride::OnThemeChange(StyleManager change) { themeChangeCalled = true;}
115 void DummyControlImplOverride::OnFontChange(bool defaultFontChange, bool defaultFontSizeChange) { fontChangeCalled = true; }
116 void DummyControlImplOverride::OnPinch(PinchGesture pinch) { pinchCalled = true; }
117 void DummyControlImplOverride::OnPan(PanGesture pan) { panCalled = true; }
118 void DummyControlImplOverride::OnTap(TapGesture tap) { tapCalled = true; }
119 void DummyControlImplOverride::OnLongPress(LongPressGesture longPress) { longPressCalled = true; }
120 void DummyControlImplOverride::OnStageConnection() { stageConnectionCalled = true; }
121 void DummyControlImplOverride::OnStageDisconnection() { stageDisconnectionCalled = true; }
122 void DummyControlImplOverride::OnChildAdd(Actor& child) { childAddCalled = true; }
123 void DummyControlImplOverride::OnChildRemove(Actor& child) { childRemoveCalled = true; }
124 void DummyControlImplOverride::OnSizeSet(const Vector3& targetSize) { sizeSetCalled = true; }
125 void DummyControlImplOverride::OnSizeAnimation(Animation& animation, const Vector3& targetSize) { sizeAnimationCalled = true; }
126 bool DummyControlImplOverride::OnTouchEvent(const TouchEvent& event) { touchEventCalled = true; return false; }
127 bool DummyControlImplOverride::OnMouseWheelEvent(const MouseWheelEvent& event) { mouseWheelEventCalled = true; return false; }
128 bool DummyControlImplOverride::OnKeyEvent(const KeyEvent& event) { keyEventCalled = true; return false;}
129 void DummyControlImplOverride::OnKeyInputFocusGained() { keyInputFocusGained = true; }
130 void DummyControlImplOverride::OnKeyInputFocusLost() { keyInputFocusLost = true; }
131
132 DummyControl DummyControl::New( bool override )
133 {
134   DummyControl control;
135
136   if (override)
137   {
138     control = DummyControlImplOverride::New();
139   }
140   else
141   {
142     control = DummyControlImpl::New();
143   }
144
145   return control;
146 }
147
148 DummyControl::DummyControl( DummyControlImpl& implementation )
149 : Control( implementation ),
150   mCustomSlot1Called(false),
151   mCustomSlot1Value(Vector3::ZERO)
152 {
153 }
154
155 DummyControl::DummyControl( Dali::Internal::CustomActor* internal )
156 : Control( internal ),
157   mCustomSlot1Called(false),
158   mCustomSlot1Value(Vector3::ZERO)
159 {
160   VerifyCustomActorPointer<DummyControlImpl>(internal);
161 }
162
163 } // namespace Toolkit
164
165 } // namespace Dali