Changes after TouchedSignal changes
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / toolkit-scene-holder-impl.h
1 #ifndef DALI_TOOLKIT_SCENE_HOLDER_IMPL_H
2 #define DALI_TOOLKIT_SCENE_HOLDER_IMPL_H
3
4 /*
5  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 #include <dali/integration-api/adaptor-framework/render-surface-interface.h>
22
23 #include <dali/integration-api/scene.h>
24 #include <dali/public-api/actors/layer.h>
25 #include <dali/public-api/object/base-object.h>
26
27 namespace Dali
28 {
29
30 class TestRenderSurface : public Dali::RenderSurfaceInterface
31 {
32 public:
33
34   TestRenderSurface( PositionSize positionSize ) {};
35
36   virtual PositionSize GetPositionSize() const { PositionSize size; return size; };
37
38   virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) { dpiHorizontal = dpiVertical = 96; }
39
40   virtual void InitializeGraphics() {};
41
42   virtual void CreateSurface() {};
43
44   virtual void DestroySurface() {};
45
46   virtual bool ReplaceGraphicsSurface() { return false; };
47
48   virtual void MoveResize( Dali::PositionSize positionSize ) {};
49
50   virtual void StartRender() {};
51
52   virtual bool PreRender( bool resizingSurface, const std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect  ) { return false; };
53
54   virtual void PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface, const std::vector<Rect<int>>& damagedRects ) {};
55
56   virtual void StopRender() {};
57
58   virtual void ReleaseLock() {};
59
60   virtual void SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization ) {};
61
62   virtual RenderSurfaceInterface::Type GetSurfaceType() { return RenderSurfaceInterface::WINDOW_RENDER_SURFACE; };
63
64   virtual void MakeContextCurrent() {};
65
66   virtual Integration::DepthBufferAvailable GetDepthBufferRequired() { return Integration::DepthBufferAvailable::FALSE; };
67
68   virtual Integration::StencilBufferAvailable GetStencilBufferRequired() { return Integration::StencilBufferAvailable::FALSE; };
69
70   virtual void SetBackgroundColor( Vector4 color ) {};
71
72   virtual Vector4 GetBackgroundColor() { return Color::WHITE; };
73 };
74
75 namespace Internal
76 {
77
78 namespace Adaptor
79 {
80
81 class SceneHolder : public Dali::BaseObject
82 {
83 public:
84
85   SceneHolder( const Dali::Rect<int>& positionSize );
86
87   virtual ~SceneHolder();
88
89   void Add( Dali::Actor actor );
90
91   void Remove( Dali::Actor actor );
92
93   Dali::Layer GetRootLayer() const;
94
95   void SetBackgroundColor( Vector4 color );
96
97   Vector4 GetBackgroundColor() const;
98
99   void FeedTouchPoint( Dali::TouchPoint& point, int timeStamp );
100
101   void FeedWheelEvent( Dali::WheelEvent& wheelEvent );
102
103   void FeedKeyEvent( Dali::KeyEvent& keyEvent );
104
105   Dali::Integration::SceneHolder::KeyEventSignalType& KeyEventSignal();
106
107   Dali::Integration::SceneHolder::KeyEventGeneratedSignalType& KeyEventGeneratedSignal();
108
109   Dali::Integration::SceneHolder::TouchEventSignalType& TouchedSignal();
110
111   Dali::Integration::SceneHolder::WheelEventSignalType& WheelEventSignal();
112
113   Integration::Scene GetScene();
114
115   Dali::RenderSurfaceInterface& GetRenderSurface();
116
117 private:
118
119   TestRenderSurface mRenderSurface;
120   Integration::Scene mScene;
121 };
122
123 } // namespace Adaptor
124
125 } // namespace Internal
126
127 inline Internal::Adaptor::SceneHolder& GetImplementation( Dali::Integration::SceneHolder& sceneHolder )
128 {
129   DALI_ASSERT_ALWAYS( sceneHolder && "SceneHolder handle is empty" );
130   BaseObject& object = sceneHolder.GetBaseObject();
131   return static_cast<Internal::Adaptor::SceneHolder&>( object );
132 }
133
134 inline const Internal::Adaptor::SceneHolder& GetImplementation( const Dali::Integration::SceneHolder& sceneHolder )
135 {
136   DALI_ASSERT_ALWAYS( sceneHolder && "SceneHolder handle is empty" );
137   const BaseObject& object = sceneHolder.GetBaseObject();
138   return static_cast<const Internal::Adaptor::SceneHolder&>( object );
139 }
140
141 } // namespace Dali
142
143 #endif // DALI_TOOLKIT_SCENE_HOLDER_IMPL_H