[Tizen] Add Keyboard repeat setting changed signal to Window
[platform/core/uifw/dali-adaptor.git] / dali / internal / offscreen / common / offscreen-application-impl.h
1 #ifndef DALI_INTERNAL_OFFSCREEN_APPLICATION_IMPL_H
2 #define DALI_INTERNAL_OFFSCREEN_APPLICATION_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 // EXTERNAL INCLUDES
22 #include <memory>
23
24 #include <dali/integration-api/adaptor-framework/scene-holder-impl.h>
25 #include <dali/public-api/common/intrusive-ptr.h>
26 #include <dali/public-api/object/base-object.h>
27 #include <dali/public-api/signals/connection-tracker.h>
28
29 // INTERNAL INCLUDES
30 #include <dali/devel-api/adaptor-framework/offscreen-application.h>
31 #include <dali/devel-api/adaptor-framework/offscreen-window.h>
32
33
34 namespace Dali
35 {
36 class Adaptor;
37
38 namespace Internal
39 {
40
41 /**
42  * Implementation of the OffscreenApplication class.
43  */
44 class OffscreenApplication : public BaseObject,
45                    public ConnectionTracker
46 {
47 public:
48
49   typedef Dali::OffscreenApplication::OffscreenApplicationSignalType OffscreenApplicationSignalType;
50
51   /**
52    * @brief Create a new OffscreenApplication
53    * @param[in] width The width of the default OffscreenWindow
54    * @param[in] height The height of the default OffscreenWindow
55    * @param[in] surface The native surface handle to create the default OffscreenWindow
56    * @param[in] isTranslucent Whether the OffscreenWindow is translucent or not
57    */
58   static IntrusivePtr<OffscreenApplication> New( uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent);
59
60 public:
61
62   /**
63    * @copydoc Dali::OffscreenApplication::Start()
64    */
65   void Run();
66
67   /**
68    * @copydoc Dali::OffscreenApplication::Stop()
69    */
70   void Stop();
71
72   /**
73    * @copydoc Dali::OffscreenApplication::GetDefaultWindow()
74    */
75   Dali::OffscreenWindow GetWindow();
76
77   /**
78    * @copydoc Dali::OffscreenApplication::InitSignal()
79    */
80   OffscreenApplicationSignalType& InitSignal()
81   {
82     return mInitSignal;
83   }
84
85   /**
86    * @copydoc Dali::OffscreenApplication::TerminateSignal()
87    */
88   OffscreenApplicationSignalType& TerminateSignal()
89   {
90     return mTerminateSignal;
91   }
92
93 public:
94   /**
95    * All methods here are for the internal use
96    */
97   enum State
98   {
99     READY,
100     RUNNING,
101     STOPPED,
102   };
103
104   /**
105    * @brief This is for internal use to get notified before InitSignal() emits
106    */
107   OffscreenApplicationSignalType& PreInitSignal()
108   {
109     return mPreInitSignal;
110   }
111
112   /**
113    * @brief Get OffscreenApplication's current state
114    *
115    * @return The state
116    */
117   const State GetState() const
118   {
119     return mState;
120   }
121
122   /*
123    * @bried Get currently working Adaptor. It can be null.
124    */
125   Dali::Adaptor* GetAdaptor();
126
127 private:
128   /**
129    * Private constructor
130    * @param[in] width The width of the OffscreenWindow
131    * @param[in] height The height of the OffscreenApplication
132    * @param[in] surface The native surface handle to create the default OffscreenWindow
133    * @param[in] isTranslucent Whether the OffscreenWindow is translucent or not
134    */
135   OffscreenApplication( uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent );
136
137
138   /**
139    * Destructor
140    */
141   virtual ~OffscreenApplication();
142
143   // Undefined
144   OffscreenApplication( const OffscreenApplication& );
145   OffscreenApplication& operator=( OffscreenApplication& );
146
147 private:
148   Dali::Adaptor*                           mAdaptor;
149   Dali::OffscreenWindow                     mDefaultWindow;
150
151   OffscreenApplicationSignalType              mPreInitSignal;
152   OffscreenApplicationSignalType              mInitSignal;
153   OffscreenApplicationSignalType              mTerminateSignal;
154
155   State                                    mState;
156 };
157
158 inline OffscreenApplication& GetImplementation( Dali::OffscreenApplication& offscreenApplication )
159 {
160   DALI_ASSERT_ALWAYS( offscreenApplication && "OffscreenApplication handle is empty" );
161
162   BaseObject& handle = offscreenApplication.GetBaseObject();
163
164   return static_cast<OffscreenApplication&>( handle );
165 }
166
167 inline const OffscreenApplication& GetImplementation( const Dali::OffscreenApplication& offscreenApplication )
168 {
169   DALI_ASSERT_ALWAYS( offscreenApplication && "OffscreenApplication handle is empty" );
170
171   const BaseObject& handle = offscreenApplication.GetBaseObject();
172
173   return static_cast<const OffscreenApplication&>( handle );
174 }
175
176 } // namespace Internal
177
178 } // namespace Dali
179
180 #endif // DALI_INTERNAL_OFFSCREEN_APPLICATION_IMPL_H