X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=builder%2Fdali-builder.cpp;h=ba5a1014f96039b400430f20f822d6d12811fb3b;hb=1b19fd140ff139b5854a1a62447faf31b175d8f6;hp=5445fd1953aa8ad5826ab7ef003c83b21b75f24d;hpb=888de069f8cb0dd95e90994474c488cfd8f5bbb0;p=platform%2Fcore%2Fuifw%2Fdali-demo.git diff --git a/builder/dali-builder.cpp b/builder/dali-builder.cpp index 5445fd1..ba5a101 100644 --- a/builder/dali-builder.cpp +++ b/builder/dali-builder.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,19 +26,19 @@ // //------------------------------------------------------------------------------ -#include -#include #include #include #include +#include +#include +#include #include #include -#include -#include #include +#include -#include "sys/stat.h" #include +#include "sys/stat.h" #include @@ -49,8 +49,8 @@ using namespace Dali::Toolkit; namespace { - -std::string JSON_BROKEN(" \ +std::string JSON_BROKEN( + " \ { \ 'stage': \ [ \ @@ -64,7 +64,7 @@ std::string JSON_BROKEN(" \ } \ "); -std::string ReplaceQuotes(const std::string &single_quoted) +std::string ReplaceQuotes(const std::string& single_quoted) { std::string s(single_quoted); @@ -74,8 +74,7 @@ std::string ReplaceQuotes(const std::string &single_quoted) return s; } -} // anon namespace - +} // namespace //------------------------------------------------------------------------------ // @@ -87,13 +86,20 @@ class FileWatcher public: FileWatcher(void); ~FileWatcher(void); - explicit FileWatcher(const std::string &fn): mLastTime(0) { SetFilename(fn) ; }; + explicit FileWatcher(const std::string& fn) + : mLastTime(0) + { + SetFilename(fn); + }; - void SetFilename(const std::string &fn); + void SetFilename(const std::string& fn); std::string GetFilename(); - bool FileHasChanged(void); - std::string GetFileContents(void) { return GetFileContents(mstringPath) ; }; + bool FileHasChanged(void); + std::string GetFileContents(void) + { + return GetFileContents(mstringPath); + }; private: // compiler does @@ -103,20 +109,21 @@ private: std::time_t mLastTime; std::string mstringPath; - std::string GetFileContents(const std::string &filename) + std::string GetFileContents(const std::string& filename) { - std::streampos bufferSize = 0; + std::streampos bufferSize = 0; Dali::Vector fileBuffer; - if( !Dali::FileLoader::ReadFile( filename, bufferSize, fileBuffer, FileLoader::FileType::BINARY ) ) + if(!Dali::FileLoader::ReadFile(filename, bufferSize, fileBuffer, FileLoader::FileType::BINARY)) { return std::string(); } - return std::string( &fileBuffer[0], bufferSize ); + return std::string(&fileBuffer[0], bufferSize); }; }; -FileWatcher::FileWatcher(void) : mLastTime(0) +FileWatcher::FileWatcher(void) +: mLastTime(0) { } @@ -150,7 +157,7 @@ FileWatcher::~FileWatcher() { } -void FileWatcher::SetFilename(const std::string &fn) +void FileWatcher::SetFilename(const std::string& fn) { mstringPath = fn; } @@ -160,7 +167,6 @@ std::string FileWatcher::GetFilename(void) return mstringPath; } - //------------------------------------------------------------------------------ // // @@ -169,68 +175,73 @@ std::string FileWatcher::GetFilename(void) class ExampleApp : public ConnectionTracker { public: - ExampleApp(Application &app) : mApp(app) + ExampleApp(Application& app) + : mApp(app) { app.InitSignal().Connect(this, &ExampleApp::Create); - } - ~ExampleApp() {} + ~ExampleApp() + { + } public: - void SetJSONFilename(std::string const &fn) { fw.SetFilename(fn) ; }; + void SetJSONFilename(std::string const& fn) + { + fw.SetFilename(fn); + }; void Create(Application& app) { - mTimer = Timer::New( 500 ); // ms - mTimer.TickSignal().Connect( this, &ExampleApp::OnTimer); + mTimer = Timer::New(500); // ms + mTimer.TickSignal().Connect(this, &ExampleApp::OnTimer); mTimer.Start(); // Connect to key events in order to exit - Stage::GetCurrent().KeyEventSignal().Connect(this, &ExampleApp::OnKeyEvent); + app.GetWindow().KeyEventSignal().Connect(this, &ExampleApp::OnKeyEvent); } private: Application& mApp; - Layer mRootLayer; + Layer mRootLayer; FileWatcher fw; - Timer mTimer; + Timer mTimer; void ReloadJsonFile(Builder& builder, Layer& layer) { - Stage stage = Stage::GetCurrent(); - stage.SetBackgroundColor( Color::WHITE ); + Window window = mApp.GetWindow(); + window.SetBackgroundColor(Color::WHITE); builder = Builder::New(); - builder.QuitSignal().Connect( this, &ExampleApp::OnBuilderQuit ); + builder.QuitSignal().Connect(this, &ExampleApp::OnBuilderQuit); Property::Map defaultDirs; - defaultDirs[ TOKEN_STRING(DEMO_IMAGE_DIR) ] = DEMO_IMAGE_DIR; - defaultDirs[ TOKEN_STRING(DEMO_MODEL_DIR) ] = DEMO_MODEL_DIR; - defaultDirs[ TOKEN_STRING(DEMO_SCRIPT_DIR) ] = DEMO_SCRIPT_DIR; + defaultDirs[TOKEN_STRING(DEMO_IMAGE_DIR)] = DEMO_IMAGE_DIR; + defaultDirs[TOKEN_STRING(DEMO_MODEL_DIR)] = DEMO_MODEL_DIR; + defaultDirs[TOKEN_STRING(DEMO_SCRIPT_DIR)] = DEMO_SCRIPT_DIR; - builder.AddConstants( defaultDirs ); + builder.AddConstants(defaultDirs); if(!layer) { layer = Layer::New(); - layer.SetParentOrigin(ParentOrigin::CENTER); - layer.SetAnchorPoint(AnchorPoint::CENTER); - layer.SetSize( stage.GetRootLayer().GetCurrentSize() ); - stage.GetRootLayer().Add(layer); + layer.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + layer.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); + layer.SetProperty(Actor::Property::SIZE, window.GetRootLayer().GetCurrentProperty(Actor::Property::SIZE)); + window.GetRootLayer().Add(layer); // render tasks may have been setup last load so remove them - RenderTaskList taskList = stage.GetRenderTaskList(); - if( taskList.GetTaskCount() > 1 ) + RenderTaskList taskList = window.GetRenderTaskList(); + if(taskList.GetTaskCount() > 1) { typedef std::vector Collection; - typedef Collection::iterator ColIter; - Collection tasks; + typedef Collection::iterator ColIter; + Collection tasks; for(unsigned int i = 1; i < taskList.GetTaskCount(); ++i) { - tasks.push_back( taskList.GetTask(i) ); + tasks.push_back(taskList.GetTask(i)); } for(ColIter iter = tasks.begin(); iter != tasks.end(); ++iter) @@ -239,16 +250,16 @@ private: } RenderTask defaultTask = taskList.GetTask(0); - defaultTask.SetSourceActor( stage.GetRootLayer() ); - defaultTask.SetTargetFrameBuffer( FrameBufferImage() ); + defaultTask.SetSourceActor(window.GetRootLayer()); + defaultTask.SetFrameBuffer(FrameBuffer()); } } unsigned int numChildren = layer.GetChildCount(); - for(unsigned int i=0; i 1) {