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);}
45 typedef Dali::Rect<int> PositionSize;
48 * Stub for the Adaptor
54 typedef SignalV2< void ( Adaptor& ) > AdaptorSignalV2;
58 Adaptor(ToolkitAdaptor& toolkitAdaptor);
67 bool AddIdle(boost::function<void(void)> callBack);
68 void FeedEvent(TouchPoint& point, int timeStamp);
69 bool MoveResize(const PositionSize& positionSize);
70 void SurfaceResized(const PositionSize& positionSize);
71 void ReplaceSurface(RenderSurface& surface);
73 RenderSurface& GetSurface();
75 public: // static methods
76 static Adaptor& Get();
77 static bool IsAvailable();
81 AdaptorSignalV2& SignalResize();
83 void EmitSignalResize()
85 mResizeSignal.Emit( *this );
91 Adaptor(const Adaptor&);
92 Adaptor& operator=(Adaptor&);
94 AdaptorSignalV2 mResizeSignal;
95 TestRenderSurface mRenderSurface;
96 ToolkitAdaptor& mToolkitAdaptor;
101 Adaptor* gAdaptor = NULL;
105 Adaptor::Adaptor(ToolkitAdaptor& toolkitAdaptor)
106 : mToolkitAdaptor(toolkitAdaptor)
115 void Adaptor::Start()
117 mToolkitAdaptor.mFunctionsCalled.Start = true;
120 void Adaptor::Pause()
122 mToolkitAdaptor.mFunctionsCalled.Pause = true;
125 void Adaptor::Resume()
127 mToolkitAdaptor.mFunctionsCalled.Resume = true;
132 mToolkitAdaptor.mFunctionsCalled.Stop = true;
135 bool Adaptor::AddIdle(boost::function<void(void)> callBack)
137 mToolkitAdaptor.mFunctionsCalled.AddIdle = true;
138 mToolkitAdaptor.mLastIdleAdded = callBack;
142 void Adaptor::FeedEvent(TouchPoint& point, int timeStamp)
144 mToolkitAdaptor.mFunctionsCalled.FeedEvent = true;
145 mToolkitAdaptor.mLastTouchPointFed = point;
146 mToolkitAdaptor.mLastTimeStampFed = timeStamp;
149 bool Adaptor::MoveResize(const PositionSize& positionSize)
151 mToolkitAdaptor.mFunctionsCalled.MoveResize = true;
152 mToolkitAdaptor.mLastSizeSet = positionSize;
156 void Adaptor::SurfaceResized(const PositionSize& positionSize)
158 mToolkitAdaptor.mFunctionsCalled.SurfaceResized = true;
159 mToolkitAdaptor.mLastSizeSet = positionSize;
162 void Adaptor::ReplaceSurface(RenderSurface& surface)
164 mToolkitAdaptor.mFunctionsCalled.ReplaceSurface = true;
167 void Adaptor::RenderSync()
169 mToolkitAdaptor.mFunctionsCalled.RenderSync = true;
172 RenderSurface& Adaptor::GetSurface()
174 mToolkitAdaptor.mFunctionsCalled.GetSurface = true;
175 return mRenderSurface;
178 Adaptor& Adaptor::Get()
180 DALI_ASSERT_ALWAYS(gAdaptor);
181 gAdaptor->mToolkitAdaptor.mFunctionsCalled.Get = true;
185 bool Adaptor::IsAvailable()
187 bool available(false);
191 gAdaptor->mToolkitAdaptor.mFunctionsCalled.IsAvailable = true;
198 Adaptor::AdaptorSignalV2& Adaptor::SignalResize()
200 mToolkitAdaptor.mFunctionsCalled.SignalResize = true;
201 return mResizeSignal;
204 ////////////////////////////////////////////////////////////////////////////////////////////////////
206 ToolkitAdaptor::ToolkitAdaptor()
207 : mLastTouchPointFed(0, TouchPoint::Down, 0.0f, 0.0f),
208 mLastTimeStampFed(0),
209 mStyleMonitor(StyleMonitor::Get()),
210 mAccessibilityManager(AccessibilityManager::Get()),
211 mImfManager(ImfManager::Get()),
212 mAdaptorStub(new Adaptor(*this))
214 gAdaptor = mAdaptorStub;
217 ToolkitAdaptor::~ToolkitAdaptor()
223 void ToolkitAdaptor::EmitSignalResize()
225 mAdaptorStub->EmitSignalResize();