2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
8 // http://floralicense.org/license/
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.
17 #define __DALI_ADAPTOR_H__
18 #define __DALI_ACCESSIBILITY_MANAGER_H__
19 #define __DALI_TIMER_H__
20 #define __DALI_CLIPBOARD_H__
23 #include "toolkit-adaptor.h"
25 #include <dali/public-api/common/dali-common.h>
26 #include <dali/public-api/signals/dali-signal-v2.h>
31 ////////////////////////////////////////////////////////////////////////////////////////////////////
33 class TestRenderSurface : public RenderSurface
37 virtual ~TestRenderSurface(){}
38 virtual SurfaceType GetType() { return RenderSurface::WINDOW; }
39 virtual Dali::Any GetSurface() { return Dali::Any(); }
40 virtual Dali::Any GetDisplay() { return Dali::Any(); }
41 virtual PositionSize GetPositionSize() const { return PositionSize(0, 0, 640, 480);}
42 virtual void SetRenderMode(RenderMode mode){}
43 virtual RenderMode GetRenderMode() const { return RenderSurface::RENDER_60FPS; }
46 typedef Dali::Rect<int> PositionSize;
49 * Stub for the Adaptor
55 typedef SignalV2< void ( Adaptor& ) > AdaptorSignalV2;
57 typedef std::pair<std::string, Dali::BaseHandle> SingletonPair;
58 typedef std::map<std::string, Dali::BaseHandle> SingletonContainer;
59 typedef SingletonContainer::const_iterator SingletonConstIter;
63 Adaptor(ToolkitAdaptor& toolkitAdaptor);
72 bool AddIdle(boost::function<void(void)> callBack);
73 void FeedEvent(TouchPoint& point, int timeStamp);
74 bool MoveResize(const PositionSize& positionSize);
75 void SurfaceResized(const PositionSize& positionSize);
76 void ReplaceSurface(RenderSurface& surface);
78 RenderSurface& GetSurface();
80 void RegisterSingleton(const std::type_info& info, Dali::BaseHandle singleton);
81 Dali::BaseHandle GetSingleton(const std::type_info& info) const;
83 public: // static methods
84 static Adaptor& Get();
85 static bool IsAvailable();
89 AdaptorSignalV2& SignalResize();
91 void EmitSignalResize()
93 mResizeSignal.Emit( *this );
99 Adaptor(const Adaptor&);
100 Adaptor& operator=(Adaptor&);
102 AdaptorSignalV2 mResizeSignal;
103 TestRenderSurface mRenderSurface;
104 ToolkitAdaptor& mToolkitAdaptor;
106 SingletonContainer mSingletonContainer;
111 Adaptor* gAdaptor = NULL;
115 Adaptor::Adaptor(ToolkitAdaptor& toolkitAdaptor)
116 : mToolkitAdaptor(toolkitAdaptor)
125 void Adaptor::Start()
127 mToolkitAdaptor.mFunctionsCalled.Start = true;
130 void Adaptor::Pause()
132 mToolkitAdaptor.mFunctionsCalled.Pause = true;
135 void Adaptor::Resume()
137 mToolkitAdaptor.mFunctionsCalled.Resume = true;
142 mToolkitAdaptor.mFunctionsCalled.Stop = true;
145 bool Adaptor::AddIdle(boost::function<void(void)> callBack)
147 mToolkitAdaptor.mFunctionsCalled.AddIdle = true;
148 mToolkitAdaptor.mLastIdleAdded = callBack;
152 void Adaptor::FeedEvent(TouchPoint& point, int timeStamp)
154 mToolkitAdaptor.mFunctionsCalled.FeedEvent = true;
155 mToolkitAdaptor.mLastTouchPointFed = point;
156 mToolkitAdaptor.mLastTimeStampFed = timeStamp;
159 bool Adaptor::MoveResize(const PositionSize& positionSize)
161 mToolkitAdaptor.mFunctionsCalled.MoveResize = true;
162 mToolkitAdaptor.mLastSizeSet = positionSize;
166 void Adaptor::SurfaceResized(const PositionSize& positionSize)
168 mToolkitAdaptor.mFunctionsCalled.SurfaceResized = true;
169 mToolkitAdaptor.mLastSizeSet = positionSize;
172 void Adaptor::ReplaceSurface(RenderSurface& surface)
174 mToolkitAdaptor.mFunctionsCalled.ReplaceSurface = true;
177 void Adaptor::RenderSync()
179 mToolkitAdaptor.mFunctionsCalled.RenderSync = true;
182 RenderSurface& Adaptor::GetSurface()
184 mToolkitAdaptor.mFunctionsCalled.GetSurface = true;
185 return mRenderSurface;
188 Adaptor& Adaptor::Get()
190 DALI_ASSERT_ALWAYS(gAdaptor);
191 gAdaptor->mToolkitAdaptor.mFunctionsCalled.Get = true;
195 bool Adaptor::IsAvailable()
197 bool available(false);
201 gAdaptor->mToolkitAdaptor.mFunctionsCalled.IsAvailable = true;
208 void Adaptor::RegisterSingleton(const std::type_info& info, Dali::BaseHandle singleton)
210 mToolkitAdaptor.mFunctionsCalled.RegisterSingleton = true;
214 mSingletonContainer.insert(SingletonPair(info.name(), singleton));
218 Dali::BaseHandle Adaptor::GetSingleton(const std::type_info& info) const
220 mToolkitAdaptor.mFunctionsCalled.GetSingleton = true;
222 Dali::BaseHandle object = Dali::BaseHandle();
224 SingletonConstIter iter = mSingletonContainer.find(info.name());
225 if(iter != mSingletonContainer.end())
227 object = (*iter).second;
233 Adaptor::AdaptorSignalV2& Adaptor::SignalResize()
235 mToolkitAdaptor.mFunctionsCalled.SignalResize = true;
236 return mResizeSignal;
239 ////////////////////////////////////////////////////////////////////////////////////////////////////
241 ToolkitAdaptor::ToolkitAdaptor()
242 : mLastTouchPointFed(0, TouchPoint::Down, 0.0f, 0.0f),
243 mLastTimeStampFed(0),
244 mStyleMonitor(StyleMonitor::Get()),
245 mAccessibilityManager(AccessibilityManager::Get()),
246 mImfManager(ImfManager::Get()),
247 mAdaptorStub(new Adaptor(*this))
249 gAdaptor = mAdaptorStub;
252 ToolkitAdaptor::~ToolkitAdaptor()
258 void ToolkitAdaptor::EmitSignalResize()
260 mAdaptorStub->EmitSignalResize();