X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=adaptors%2Fcommon%2Fapplication-impl.cpp;h=9e1efddca9435c434e3b1b97eb425e02f28f3937;hb=7f3341b2da0e085639752b68e41a4230428ac737;hp=894607fddcb290cd68022771c6a01000f20d6cd7;hpb=eab81035044cc7398ed941f5e92bdef45ed0f58c;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/adaptors/common/application-impl.cpp b/adaptors/common/application-impl.cpp index 894607f..9e1efdd 100644 --- a/adaptors/common/application-impl.cpp +++ b/adaptors/common/application-impl.cpp @@ -20,9 +20,9 @@ // EXTERNAL INCLUDES #include -#include // INTERNAL INCLUDES +#include #include #include #include @@ -31,9 +31,9 @@ namespace Dali { -namespace SlpPlatform +namespace TizenPlatform { -class SlpPlatformAbstraction; +class TizenPlatformAbstraction; } namespace Integration @@ -47,49 +47,53 @@ namespace Internal namespace Adaptor { -namespace -{ -// Defaults taken from H2 device -const unsigned int DEFAULT_WINDOW_WIDTH = 480; -const unsigned int DEFAULT_WINDOW_HEIGHT = 800; -const float DEFAULT_HORIZONTAL_DPI = 220; -const float DEFAULT_VERTICAL_DPI = 217; -} - ApplicationPtr Application::New( int* argc, char **argv[], - const std::string& name, - const DeviceLayout& baseLayout, + const std::string& stylesheet, Dali::Application::WINDOW_MODE windowMode) { - ApplicationPtr application ( new Application (argc, argv, name, baseLayout, windowMode ) ); + ApplicationPtr application ( new Application (argc, argv, stylesheet, windowMode ) ); return application; } -Application::Application( int* argc, char** argv[], const std::string& name, const DeviceLayout& baseLayout, Dali::Application::WINDOW_MODE windowMode) +Application::Application( int* argc, char** argv[], const std::string& stylesheet, Dali::Application::WINDOW_MODE windowMode ) : mInitSignal(), mTerminateSignal(), mPauseSignal(), mResumeSignal(), mResetSignal(), mResizeSignal(), + mAppControlSignal(), mLanguageChangedSignal(), + mRegionChangedSignal(), + mBatteryLowSignal(), + mMemoryLowSignal(), mEventLoop( NULL ), mFramework( NULL ), + mContextLossConfiguration( Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS ), mCommandLineOptions( NULL ), mSingletonService( SingletonService::New() ), mAdaptor( NULL ), mWindow(), mWindowMode( windowMode ), - mName( name ), + mName(), + mStylesheet( stylesheet ), + mEnvironmentOptions(), mInitialized( false ), - mBaseLayout( baseLayout ), mSlotDelegate( this ) { + // Get mName from environment options + mName = mEnvironmentOptions.GetWindowName(); + if( mName.empty() && argc && ( *argc > 0 ) ) + { + // Set mName from command-line args if environment option not set + mName = (*argv)[0]; + } + mCommandLineOptions = new CommandLineOptions(argc, argv); - mFramework = new Framework(*this, argc, argv, name); + mFramework = new Framework( *this, argc, argv ); } Application::~Application() @@ -104,36 +108,31 @@ Application::~Application() void Application::CreateWindow() { -#ifndef __arm__ - PositionSize windowPosition(0, 0, DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT); -#else - PositionSize windowPosition(0, 0, 0, 0); // this will use full screen -#endif - if (mCommandLineOptions->stageWidth > 0 && mCommandLineOptions->stageHeight > 0) + PositionSize windowPosition(0, 0, 0, 0); // this will use full screen + + if( mCommandLineOptions->stageWidth > 0 && mCommandLineOptions->stageHeight > 0 ) + { + // Command line options override environment options and full screen + windowPosition = PositionSize( 0, 0, mCommandLineOptions->stageWidth, mCommandLineOptions->stageHeight ); + } + else if( mEnvironmentOptions.GetWindowWidth() && mEnvironmentOptions.GetWindowHeight() ) { - // let the command line options over ride - windowPosition = PositionSize(0,0,mCommandLineOptions->stageWidth,mCommandLineOptions->stageHeight); + // Environment options override full screen functionality if command line arguments not provided + windowPosition = PositionSize( 0, 0, mEnvironmentOptions.GetWindowWidth(), mEnvironmentOptions.GetWindowHeight() ); } - mWindow = Dali::Window::New( windowPosition, mName, mWindowMode == Dali::Application::TRANSPARENT ); + const std::string& windowClassName = mEnvironmentOptions.GetWindowClassName(); + mWindow = Dali::Window::New( windowPosition, mName, windowClassName, mWindowMode == Dali::Application::TRANSPARENT ); + + // Quit the application when the window is closed + GetImplementation( mWindow ).DeleteRequestSignal().Connect( mSlotDelegate, &Application::Quit ); } void Application::CreateAdaptor() { DALI_ASSERT_ALWAYS( mWindow && "Window required to create adaptor" ); - mAdaptor = &Dali::Adaptor::New( mWindow, mBaseLayout, mContextLossConfiguration ); - - // Allow DPI to be overridden from command line. - unsigned int hDPI=DEFAULT_HORIZONTAL_DPI; - unsigned int vDPI=DEFAULT_VERTICAL_DPI; - - std::string dpiStr = mCommandLineOptions->stageDPI; - if(!dpiStr.empty()) - { - sscanf(dpiStr.c_str(), "%ux%u", &hDPI, &vDPI); - } - Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).SetDpi(hDPI, vDPI); + mAdaptor = Dali::Internal::Adaptor::Adaptor::New( mWindow, mContextLossConfiguration, &mEnvironmentOptions ); mAdaptor->ResizedSignal().Connect( mSlotDelegate, &Application::OnResize ); } @@ -155,7 +154,7 @@ void Application::Lower() void Application::Quit() { // Actually quit the application. - AddIdle(boost::bind(&Application::QuitFromMainLoop, this)); + AddIdle( MakeCallback( this, &Application::QuitFromMainLoop ) ); } void Application::QuitFromMainLoop() @@ -172,7 +171,7 @@ void Application::QuitFromMainLoop() void Application::OnInit() { - mFramework->AddAbortCallback(boost::bind(&Application::QuitFromMainLoop, this)); + mFramework->AddAbortCallback( MakeCallback( this, &Application::QuitFromMainLoop ) ); CreateWindow(); CreateAdaptor(); @@ -197,6 +196,11 @@ void Application::OnInit() Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).SetViewMode( viewMode ); } + if( ! mStylesheet.empty() ) + { + Dali::StyleMonitor::Get().SetTheme( mStylesheet ); + } + mInitialized = true; // Wire up the LifecycleController @@ -213,7 +217,7 @@ void Application::OnInit() Dali::Application application(this); mInitSignal.Emit( application ); - Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).GetCore().SceneCreated(); + mAdaptor->NotifySceneCreated(); } void Application::OnTerminate() @@ -251,40 +255,56 @@ void Application::OnReset() mWindow.Raise(); } +void Application::OnAppControl(void *data) +{ + Dali::Application application(this); + mAppControlSignal.Emit( application , data ); +} + void Application::OnLanguageChanged() { mAdaptor->NotifyLanguageChanged(); + Dali::Application application(this); + mLanguageChangedSignal.Emit( application ); } -void Application::OnResize(Dali::Adaptor& adaptor) +void Application::OnRegionChanged() { Dali::Application application(this); - mResizeSignal.Emit( application ); + mRegionChangedSignal.Emit( application ); } -bool Application::AddIdle(boost::function callBack) +void Application::OnBatteryLow() { - return mAdaptor->AddIdle(callBack); + Dali::Application application(this); + mBatteryLowSignal.Emit( application ); } -Dali::Adaptor& Application::GetAdaptor() +void Application::OnMemoryLow() { - return *mAdaptor; + Dali::Application application(this); + mMemoryLowSignal.Emit( application ); } -Dali::Window Application::GetWindow() +void Application::OnResize(Dali::Adaptor& adaptor) { - return mWindow; + Dali::Application application(this); + mResizeSignal.Emit( application ); +} + +bool Application::AddIdle( CallbackBase* callback ) +{ + return mAdaptor->AddIdle( callback ); } -const std::string& Application::GetTheme() +Dali::Adaptor& Application::GetAdaptor() { - return Dali::StyleMonitor::Get().GetTheme(); + return *mAdaptor; } -void Application::SetTheme(const std::string& themeFilePath) +Dali::Window Application::GetWindow() { - return Dali::StyleMonitor::Get().SetTheme(themeFilePath); + return mWindow; } // Stereoscopy @@ -317,7 +337,9 @@ void Application::ReplaceWindow(PositionSize windowPosition, const std::string& windowImpl.SetAdaptor(*mAdaptor); newWindow.ShowIndicator(Dali::Window::INVISIBLE); Dali::RenderSurface* renderSurface = windowImpl.GetSurface(); - Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).ReplaceSurface(*renderSurface); + + Any nativeWindow = newWindow.GetNativeHandle(); + Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).ReplaceSurface(nativeWindow, *renderSurface); mWindow = newWindow; }