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__
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;
58 typedef std::pair<std::string, Dali::BaseHandle> SingletonPair;
59 typedef std::map<std::string, Dali::BaseHandle> SingletonContainer;
60 typedef SingletonContainer::const_iterator SingletonConstIter;
64 Adaptor(ToolkitAdaptor& toolkitAdaptor);
73 bool AddIdle(boost::function<void(void)> callBack);
74 void FeedEvent(TouchPoint& point, int timeStamp);
75 bool MoveResize(const PositionSize& positionSize);
76 void SurfaceResized(const PositionSize& positionSize);
77 void ReplaceSurface(RenderSurface& surface);
79 RenderSurface& GetSurface();
81 void RegisterSingleton(const std::type_info& info, Dali::BaseHandle singleton);
82 Dali::BaseHandle GetSingleton(const std::type_info& info) const;
84 public: // static methods
85 static Adaptor& Get();
86 static bool IsAvailable();
90 AdaptorSignalV2& SignalResize();
92 void EmitSignalResize()
94 mResizeSignal.Emit( *this );
100 Adaptor(const Adaptor&);
101 Adaptor& operator=(Adaptor&);
103 AdaptorSignalV2 mResizeSignal;
104 TestRenderSurface mRenderSurface;
105 ToolkitAdaptor& mToolkitAdaptor;
107 SingletonContainer mSingletonContainer;
112 Adaptor* gAdaptor = NULL;
116 Adaptor::Adaptor(ToolkitAdaptor& toolkitAdaptor)
117 : mToolkitAdaptor(toolkitAdaptor)
126 void Adaptor::Start()
128 mToolkitAdaptor.mFunctionsCalled.Start = true;
131 void Adaptor::Pause()
133 mToolkitAdaptor.mFunctionsCalled.Pause = true;
136 void Adaptor::Resume()
138 mToolkitAdaptor.mFunctionsCalled.Resume = true;
143 mToolkitAdaptor.mFunctionsCalled.Stop = true;
146 bool Adaptor::AddIdle(boost::function<void(void)> callBack)
148 mToolkitAdaptor.mFunctionsCalled.AddIdle = true;
149 mToolkitAdaptor.mLastIdleAdded = callBack;
153 void Adaptor::FeedEvent(TouchPoint& point, int timeStamp)
155 mToolkitAdaptor.mFunctionsCalled.FeedEvent = true;
156 mToolkitAdaptor.mLastTouchPointFed = point;
157 mToolkitAdaptor.mLastTimeStampFed = timeStamp;
160 bool Adaptor::MoveResize(const PositionSize& positionSize)
162 mToolkitAdaptor.mFunctionsCalled.MoveResize = true;
163 mToolkitAdaptor.mLastSizeSet = positionSize;
167 void Adaptor::SurfaceResized(const PositionSize& positionSize)
169 mToolkitAdaptor.mFunctionsCalled.SurfaceResized = true;
170 mToolkitAdaptor.mLastSizeSet = positionSize;
173 void Adaptor::ReplaceSurface(RenderSurface& surface)
175 mToolkitAdaptor.mFunctionsCalled.ReplaceSurface = true;
178 void Adaptor::RenderSync()
180 mToolkitAdaptor.mFunctionsCalled.RenderSync = true;
183 RenderSurface& Adaptor::GetSurface()
185 mToolkitAdaptor.mFunctionsCalled.GetSurface = true;
186 return mRenderSurface;
189 Adaptor& Adaptor::Get()
191 DALI_ASSERT_ALWAYS(gAdaptor);
192 gAdaptor->mToolkitAdaptor.mFunctionsCalled.Get = true;
196 bool Adaptor::IsAvailable()
198 bool available(false);
202 gAdaptor->mToolkitAdaptor.mFunctionsCalled.IsAvailable = true;
209 void Adaptor::RegisterSingleton(const std::type_info& info, Dali::BaseHandle singleton)
211 mToolkitAdaptor.mFunctionsCalled.RegisterSingleton = true;
215 mSingletonContainer.insert(SingletonPair(info.name(), singleton));
219 Dali::BaseHandle Adaptor::GetSingleton(const std::type_info& info) const
221 mToolkitAdaptor.mFunctionsCalled.GetSingleton = true;
223 Dali::BaseHandle object = Dali::BaseHandle();
225 SingletonConstIter iter = mSingletonContainer.find(info.name());
226 if(iter != mSingletonContainer.end())
228 object = (*iter).second;
234 Adaptor::AdaptorSignalV2& Adaptor::SignalResize()
236 mToolkitAdaptor.mFunctionsCalled.SignalResize = true;
237 return mResizeSignal;
240 ////////////////////////////////////////////////////////////////////////////////////////////////////
242 ToolkitAdaptor::ToolkitAdaptor()
243 : mLastTouchPointFed(0, TouchPoint::Down, 0.0f, 0.0f),
244 mLastTimeStampFed(0),
245 mStyleMonitor(StyleMonitor::Get()),
246 mAccessibilityManager(AccessibilityManager::Get()),
247 mImfManager(ImfManager::Get()),
248 mAdaptorStub(new Adaptor(*this))
250 gAdaptor = mAdaptorStub;
253 ToolkitAdaptor::~ToolkitAdaptor()
259 void ToolkitAdaptor::EmitSignalResize()
261 mAdaptorStub->EmitSignalResize();