2 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/public-api/adaptor-framework/application.h>
22 #include <dali/integration-api/debug.h>
23 #include <dali/public-api/object/object-registry.h>
26 #include <dali/internal/adaptor/common/application-impl.h>
30 Application Application::New()
32 return New(NULL, NULL);
35 Application Application::New(int* argc, char** argv[])
37 Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::GetPreInitializedApplication();
40 // pre-initialized application
41 internal->SetCommandLineOptions(argc, argv);
42 if(argc && (*argc > 0))
44 internal->GetWindow().SetClass((*argv)[0], "");
49 internal = Internal::Adaptor::Application::New(argc, argv, "", OPAQUE, PositionSize(), Internal::Adaptor::Framework::NORMAL, WindowType::NORMAL);
51 return Application(internal.Get());
54 Application Application::New(int* argc, char** argv[], const std::string& stylesheet)
56 Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::GetPreInitializedApplication();
59 // pre-initialized application
60 internal->SetCommandLineOptions(argc, argv);
61 if(argc && (*argc > 0))
63 internal->GetWindow().SetClass((*argv)[0], "");
65 internal->SetStyleSheet(stylesheet);
69 internal = Internal::Adaptor::Application::New(argc, argv, stylesheet, OPAQUE, PositionSize(), Internal::Adaptor::Framework::NORMAL, WindowType::NORMAL);
71 return Application(internal.Get());
74 Application Application::New(int* argc, char** argv[], const std::string& stylesheet, WINDOW_MODE windowMode)
76 Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::GetPreInitializedApplication();
79 // pre-initialized application
80 internal->SetCommandLineOptions(argc, argv);
81 if(argc && (*argc > 0))
83 internal->GetWindow().SetClass((*argv)[0], "");
85 internal->SetStyleSheet(stylesheet);
87 internal->GetWindow().SetTransparency((windowMode == Application::OPAQUE ? false : true));
91 internal = Internal::Adaptor::Application::New(argc, argv, stylesheet, windowMode, PositionSize(), Internal::Adaptor::Framework::NORMAL, WindowType::NORMAL);
93 return Application(internal.Get());
96 Application Application::New(int* argc, char** argv[], const std::string& stylesheet, Application::WINDOW_MODE windowMode, PositionSize positionSize)
98 Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::GetPreInitializedApplication();
101 // pre-initialized application
102 internal->SetCommandLineOptions(argc, argv);
103 if(argc && (*argc > 0))
105 internal->GetWindow().SetClass((*argv)[0], "");
107 internal->SetStyleSheet(stylesheet);
109 internal->GetWindow().SetTransparency((windowMode == Application::OPAQUE ? false : true));
111 //Store only the value before adaptor is created
112 internal->StoreWindowPositionSize(positionSize);
116 internal = Internal::Adaptor::Application::New(argc, argv, stylesheet, windowMode, positionSize, Internal::Adaptor::Framework::NORMAL, WindowType::NORMAL);
118 return Application(internal.Get());
121 Application::~Application()
125 Application::Application()
129 Application::Application(const Application& copy) = default;
131 Application& Application::operator=(const Application& rhs) = default;
133 Application::Application(Application&& rhs) = default;
135 Application& Application::operator=(Application&& rhs) = default;
137 void Application::MainLoop()
139 Internal::Adaptor::GetImplementation(*this).MainLoop();
142 void Application::Lower()
144 Internal::Adaptor::GetImplementation(*this).Lower();
147 void Application::Quit()
149 Internal::Adaptor::GetImplementation(*this).Quit();
152 bool Application::AddIdle(CallbackBase* callback)
154 return Internal::Adaptor::GetImplementation(*this).AddIdle(callback, false);
157 Window Application::GetWindow()
159 return Internal::Adaptor::GetImplementation(*this).GetWindow();
162 std::string Application::GetResourcePath()
164 return Internal::Adaptor::Application::GetResourcePath();
167 std::string Application::GetRegion() const
169 return Internal::Adaptor::GetImplementation(*this).GetRegion();
172 std::string Application::GetLanguage() const
174 return Internal::Adaptor::GetImplementation(*this).GetLanguage();
177 ObjectRegistry Application::GetObjectRegistry() const
179 return Internal::Adaptor::GetImplementation(*this).GetObjectRegistry();
182 Application::AppSignalType& Application::InitSignal()
184 return Internal::Adaptor::GetImplementation(*this).InitSignal();
187 Application::AppSignalType& Application::TerminateSignal()
189 return Internal::Adaptor::GetImplementation(*this).TerminateSignal();
192 Application::AppSignalType& Application::PauseSignal()
194 return Internal::Adaptor::GetImplementation(*this).PauseSignal();
197 Application::AppSignalType& Application::ResumeSignal()
199 return Internal::Adaptor::GetImplementation(*this).ResumeSignal();
202 Application::AppSignalType& Application::ResetSignal()
204 return Internal::Adaptor::GetImplementation(*this).ResetSignal();
207 Application::AppControlSignalType& Application::AppControlSignal()
209 return Internal::Adaptor::GetImplementation(*this).AppControlSignal();
212 Application::AppSignalType& Application::LanguageChangedSignal()
214 return Internal::Adaptor::GetImplementation(*this).LanguageChangedSignal();
217 Application::AppSignalType& Application::RegionChangedSignal()
219 return Internal::Adaptor::GetImplementation(*this).RegionChangedSignal();
222 Application::LowBatterySignalType& Application::LowBatterySignal()
224 return Internal::Adaptor::GetImplementation(*this).LowBatterySignal();
227 Application::LowMemorySignalType& Application::LowMemorySignal()
229 return Internal::Adaptor::GetImplementation(*this).LowMemorySignal();
232 Application::Application(Internal::Adaptor::Application* application)
233 : BaseHandle(application)