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 #define __DALI_ADAPTOR_H__
19 #define __DALI_ACCESSIBILITY_MANAGER_H__
20 #define __DALI_TIMER_H__
21 #define __DALI_CLIPBOARD_H__
22 #define __DALI_IMF_MANAGER_H__
24 #include "toolkit-adaptor.h"
26 #include <dali/public-api/common/dali-common.h>
27 #include <dali/public-api/signals/dali-signal-v2.h>
32 ////////////////////////////////////////////////////////////////////////////////////////////////////
34 class TestRenderSurface : public RenderSurface
38 virtual ~TestRenderSurface(){}
39 virtual SurfaceType GetType() { return RenderSurface::WINDOW; }
40 virtual Dali::Any GetSurface() { return Dali::Any(); }
41 virtual Dali::Any GetDisplay() { return Dali::Any(); }
42 virtual PositionSize GetPositionSize() const { return PositionSize(0, 0, 640, 480);}
43 virtual void SetRenderMode(RenderMode mode){}
44 virtual RenderMode GetRenderMode() const { return RenderSurface::RENDER_60FPS; }
47 typedef Dali::Rect<int> PositionSize;
50 * Stub for the Adaptor
56 typedef SignalV2< void ( Adaptor& ) > AdaptorSignalV2;
60 Adaptor(ToolkitAdaptor& toolkitAdaptor);
69 bool AddIdle(boost::function<void(void)> callBack);
70 void FeedEvent(TouchPoint& point, int timeStamp);
71 bool MoveResize(const PositionSize& positionSize);
72 void SurfaceResized(const PositionSize& positionSize);
73 void ReplaceSurface(RenderSurface& surface);
75 RenderSurface& GetSurface();
77 public: // static methods
78 static Adaptor& Get();
79 static bool IsAvailable();
83 AdaptorSignalV2& SignalResize();
85 void EmitSignalResize()
87 mResizeSignal.Emit( *this );
93 Adaptor(const Adaptor&);
94 Adaptor& operator=(Adaptor&);
96 AdaptorSignalV2 mResizeSignal;
97 TestRenderSurface mRenderSurface;
98 ToolkitAdaptor& mToolkitAdaptor;
103 Adaptor* gAdaptor = NULL;
107 Adaptor::Adaptor(ToolkitAdaptor& toolkitAdaptor)
108 : mToolkitAdaptor(toolkitAdaptor)
117 void Adaptor::Start()
119 mToolkitAdaptor.mFunctionsCalled.Start = true;
122 void Adaptor::Pause()
124 mToolkitAdaptor.mFunctionsCalled.Pause = true;
127 void Adaptor::Resume()
129 mToolkitAdaptor.mFunctionsCalled.Resume = true;
134 mToolkitAdaptor.mFunctionsCalled.Stop = true;
137 bool Adaptor::AddIdle(boost::function<void(void)> callBack)
139 mToolkitAdaptor.mFunctionsCalled.AddIdle = true;
140 mToolkitAdaptor.mLastIdleAdded = callBack;
144 void Adaptor::FeedEvent(TouchPoint& point, int timeStamp)
146 mToolkitAdaptor.mFunctionsCalled.FeedEvent = true;
147 mToolkitAdaptor.mLastTouchPointFed = point;
148 mToolkitAdaptor.mLastTimeStampFed = timeStamp;
151 bool Adaptor::MoveResize(const PositionSize& positionSize)
153 mToolkitAdaptor.mFunctionsCalled.MoveResize = true;
154 mToolkitAdaptor.mLastSizeSet = positionSize;
158 void Adaptor::SurfaceResized(const PositionSize& positionSize)
160 mToolkitAdaptor.mFunctionsCalled.SurfaceResized = true;
161 mToolkitAdaptor.mLastSizeSet = positionSize;
164 void Adaptor::ReplaceSurface(RenderSurface& surface)
166 mToolkitAdaptor.mFunctionsCalled.ReplaceSurface = true;
169 void Adaptor::RenderSync()
171 mToolkitAdaptor.mFunctionsCalled.RenderSync = true;
174 RenderSurface& Adaptor::GetSurface()
176 mToolkitAdaptor.mFunctionsCalled.GetSurface = true;
177 return mRenderSurface;
180 Adaptor& Adaptor::Get()
182 DALI_ASSERT_ALWAYS(gAdaptor);
183 gAdaptor->mToolkitAdaptor.mFunctionsCalled.Get = true;
187 bool Adaptor::IsAvailable()
189 bool available(false);
193 gAdaptor->mToolkitAdaptor.mFunctionsCalled.IsAvailable = true;
200 Adaptor::AdaptorSignalV2& Adaptor::SignalResize()
202 mToolkitAdaptor.mFunctionsCalled.SignalResize = true;
203 return mResizeSignal;
206 ////////////////////////////////////////////////////////////////////////////////////////////////////
208 ToolkitAdaptor::ToolkitAdaptor()
209 : mLastTouchPointFed(0, TouchPoint::Down, 0.0f, 0.0f),
210 mLastTimeStampFed(0),
211 mStyleMonitor(StyleMonitor::Get()),
212 mAccessibilityManager(AccessibilityManager::Get()),
213 mImfManager(ImfManager::Get()),
214 mAdaptorStub(new Adaptor(*this))
216 gAdaptor = mAdaptorStub;
219 ToolkitAdaptor::~ToolkitAdaptor()
225 void ToolkitAdaptor::EmitSignalResize()
227 mAdaptorStub->EmitSignalResize();