Add handling for context loss and regain behaviour
[platform/core/uifw/dali-adaptor.git] / adaptors / public-api / adaptor-framework / application.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 // CLASS HEADER
19 #include "application.h"
20
21 // EXTERNAL INCLUDES
22 #include <orientation.h>
23 #include <dali/integration-api/debug.h>
24
25 // INTERNAL INCLUDES
26 #include <application-impl.h>
27 #include <orientation-impl.h>
28
29 namespace Dali
30 {
31
32 Application Application::New()
33 {
34   return New( NULL, NULL );
35 }
36
37 Application Application::New( int* argc, char **argv[] )
38 {
39   Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::New( argc, argv, "Dali Application", DeviceLayout::DEFAULT_BASE_LAYOUT, OPAQUE );
40   return Application(internal.Get());
41 }
42
43 Application Application::New( int* argc, char **argv[], const std::string& name )
44 {
45   Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::New( argc, argv, name, DeviceLayout::DEFAULT_BASE_LAYOUT, OPAQUE );
46   return Application(internal.Get());
47 }
48
49 Application Application::New( int* argc, char **argv[], const std::string& name, WINDOW_MODE windowMode )
50 {
51   Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::New( argc, argv, name, DeviceLayout::DEFAULT_BASE_LAYOUT, windowMode );
52   return Application(internal.Get());
53 }
54
55 Application Application::New(int* argc, char **argv[], const DeviceLayout& baseLayout)
56 {
57   Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::New( argc, argv, "Dali Application", baseLayout, OPAQUE );
58   return Application(internal.Get());
59 }
60
61 Application Application::New(int* argc, char **argv[], const std::string& name, const DeviceLayout& baseLayout)
62 {
63   Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::New( argc, argv, name, baseLayout, OPAQUE );
64   return Application(internal.Get());
65 }
66
67 Application::~Application()
68 {
69 }
70
71 Application::Application()
72 {
73 }
74
75 Application::Application(const Application& application)
76 : BaseHandle(application)
77 {
78 }
79
80 Application& Application::operator=(const Application& application)
81 {
82   if( *this != application )
83   {
84     BaseHandle::operator=( application );
85   }
86   return *this;
87 }
88
89 void Application::MainLoop()
90 {
91   Internal::Adaptor::GetImplementation(*this).MainLoop(Configuration::APPLICATION_HANDLES_CONTEXT_LOSS);
92 }
93
94 void Application::MainLoop(Configuration::ContextLoss configuration)
95 {
96   Internal::Adaptor::GetImplementation(*this).MainLoop(configuration);
97 }
98
99 void Application::Lower()
100 {
101   Internal::Adaptor::GetImplementation(*this).Lower();
102 }
103
104 void Application::Quit()
105 {
106   Internal::Adaptor::GetImplementation(*this).Quit();
107 }
108
109 Orientation Application::GetOrientation()
110 {
111   Window window = GetWindow();
112   if( window )
113   {
114     return window.GetOrientation();
115   }
116   return Orientation();
117 }
118
119 bool Application::AddIdle(boost::function<void(void)> callBack)
120 {
121   return Internal::Adaptor::GetImplementation(*this).AddIdle(callBack);
122 }
123
124 Window Application::GetWindow()
125 {
126   return Internal::Adaptor::GetImplementation(*this).GetWindow();
127 }
128
129 void Application::ReplaceWindow(PositionSize windowPosition, const std::string& name)
130 {
131   Internal::Adaptor::GetImplementation(*this).ReplaceWindow(windowPosition, name);
132 }
133
134 void Application::SetViewMode( ViewMode viewMode )
135 {
136   Internal::Adaptor::GetImplementation(*this).SetViewMode( viewMode );
137 }
138
139 ViewMode Application::GetViewMode() const
140 {
141   return Internal::Adaptor::GetImplementation(*this).GetViewMode();
142 }
143
144 void Application::SetStereoBase( float stereoBase )
145 {
146   Internal::Adaptor::GetImplementation(*this).SetStereoBase( stereoBase );
147 }
148
149 float Application::GetStereoBase() const
150 {
151   return Internal::Adaptor::GetImplementation(*this).GetStereoBase();
152 }
153
154 Application::AppSignalV2& Application::InitSignal()
155 {
156   return Internal::Adaptor::GetImplementation(*this).InitSignal();
157 }
158
159 Application::AppSignalV2& Application::TerminateSignal()
160 {
161   return Internal::Adaptor::GetImplementation(*this).TerminateSignal();
162 }
163
164 Application::AppSignalV2& Application::PauseSignal()
165 {
166   return Internal::Adaptor::GetImplementation(*this).PauseSignal();
167 }
168
169 Application::AppSignalV2& Application::ResumeSignal()
170 {
171   return Internal::Adaptor::GetImplementation(*this).ResumeSignal();
172 }
173
174 Application::AppSignalV2& Application::ResetSignal()
175 {
176   return Internal::Adaptor::GetImplementation(*this).ResetSignal();
177 }
178
179 Application::AppSignalV2& Application::ResizeSignal()
180 {
181   return Internal::Adaptor::GetImplementation(*this).ResizeSignal();
182 }
183
184 Application::AppSignalV2& Application::LanguageChangedSignal()
185 {
186   return Internal::Adaptor::GetImplementation(*this).LanguageChangedSignal();
187 }
188
189 Application::Application(Internal::Adaptor::Application* application)
190 : BaseHandle(application)
191 {
192 }
193
194
195 } // namespace Dali