For custom wheel events, event propagation starts from the focused actor.
[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) 2021 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 ) : mPositionSize(positionSize) {};
35
36   PositionSize GetPositionSize() const override { return mPositionSize; };
37
38   virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) { dpiHorizontal = dpiVertical = 96; }
39
40   void InitializeGraphics() override {};
41
42   void CreateSurface() override {};
43
44   void DestroySurface() override {};
45
46   bool ReplaceGraphicsSurface() override { return false; };
47
48   void MoveResize( Dali::PositionSize positionSize ) override { mPositionSize = positionSize; };
49
50   void StartRender() override {};
51
52   bool PreRender( bool resizingSurface, const std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect  ) override { return false; };
53
54   void PostRender()
55   {
56   }
57
58   //void PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface, const std::vector<Rect<int>>& damagedRects ) override {};
59
60   void StopRender() override {};
61
62   void ReleaseLock() override {};
63
64   void SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization ) override {};
65
66   RenderSurfaceInterface::Type GetSurfaceType() override { return RenderSurfaceInterface::WINDOW_RENDER_SURFACE; };
67
68   void MakeContextCurrent() override {};
69
70   Integration::DepthBufferAvailable GetDepthBufferRequired() override { return Integration::DepthBufferAvailable::FALSE; };
71
72   Integration::StencilBufferAvailable GetStencilBufferRequired() override { return Integration::StencilBufferAvailable::FALSE; };
73
74   int GetOrientation() const override {return 0;};
75
76   void SetBackgroundColor( Vector4 color ) {};
77
78   Vector4 GetBackgroundColor() { return Color::WHITE; };
79
80 private:
81   PositionSize mPositionSize;
82 };
83
84 namespace Internal
85 {
86
87 namespace Adaptor
88 {
89
90 class SceneHolder : public Dali::BaseObject
91 {
92 public:
93
94   SceneHolder( const Dali::Rect<int>& positionSize );
95
96   virtual ~SceneHolder();
97
98   void Add( Dali::Actor actor );
99
100   void Remove( Dali::Actor actor );
101
102   Dali::Layer GetRootLayer() const;
103
104   void SetBackgroundColor( Vector4 color );
105
106   Vector4 GetBackgroundColor() const;
107
108   void FeedTouchPoint( Dali::TouchPoint& point, int timeStamp );
109
110   void FeedWheelEvent( Dali::WheelEvent& wheelEvent );
111
112   void FeedKeyEvent( Dali::KeyEvent& keyEvent );
113
114   Dali::Integration::SceneHolder::KeyEventSignalType& KeyEventSignal();
115
116   Dali::Integration::SceneHolder::KeyEventGeneratedSignalType& KeyEventGeneratedSignal();
117
118   Dali::Integration::SceneHolder::TouchEventSignalType& TouchedSignal();
119
120   Dali::Integration::SceneHolder::WheelEventSignalType& WheelEventSignal();
121
122   Dali::Integration::SceneHolder::WheelEventGeneratedSignalType& WheelEventGeneratedSignal();
123
124   Integration::Scene GetScene();
125
126   Dali::RenderSurfaceInterface& GetRenderSurface();
127
128 protected:
129
130   TestRenderSurface mRenderSurface;
131   Integration::Scene mScene;
132 };
133
134 } // namespace Adaptor
135
136 } // namespace Internal
137
138 inline Internal::Adaptor::SceneHolder& GetImplementation( Dali::Integration::SceneHolder& sceneHolder )
139 {
140   DALI_ASSERT_ALWAYS( sceneHolder && "SceneHolder handle is empty" );
141   BaseObject& object = sceneHolder.GetBaseObject();
142   return static_cast<Internal::Adaptor::SceneHolder&>( object );
143 }
144
145 inline const Internal::Adaptor::SceneHolder& GetImplementation( const Dali::Integration::SceneHolder& sceneHolder )
146 {
147   DALI_ASSERT_ALWAYS( sceneHolder && "SceneHolder handle is empty" );
148   const BaseObject& object = sceneHolder.GetBaseObject();
149   return static_cast<const Internal::Adaptor::SceneHolder&>( object );
150 }
151
152 } // namespace Dali
153
154 #endif // DALI_TOOLKIT_SCENE_HOLDER_IMPL_H