Remove usage of deprecated APIs
[platform/core/uifw/dali-demo.git] / builder / dali-builder.cpp
index 1ce2ec4..5445fd1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
 //------------------------------------------------------------------------------
 
 #include <dali/dali.h>
+#include <dali/devel-api/adaptor-framework/file-loader.h>
 #include <dali-toolkit/dali-toolkit.h>
-#include <dali-toolkit/public-api/builder/builder.h>
-#include <dali-toolkit/public-api/builder/tree-node.h>
+#include <dali-toolkit/devel-api/builder/builder.h>
+#include <dali-toolkit/devel-api/builder/tree-node.h>
 #include <iostream>
 #include <map>
 #include <string>
@@ -56,7 +57,7 @@ std::string JSON_BROKEN("                                      \
     {                                                          \
       'type':'TextActor',                                      \
       'size': [50,50,1],                                       \
-      'parent-origin': 'CENTER',                               \
+      'parentOrigin': 'CENTER',                                \
       'text':'COULD NOT LOAD JSON FILE'                        \
     }                                                          \
   ]                                                            \
@@ -102,10 +103,16 @@ private:
   std::time_t mLastTime;
   std::string mstringPath;
 
-  std::string GetFileContents(const std::string &fn)
+  std::string GetFileContents(const std::string &filename)
   {
-    std::ifstream t(fn.c_str());
-    return std::string((std::istreambuf_iterator<char>(t)), std::istreambuf_iterator<char>());
+    std::streampos bufferSize = 0;
+    Dali::Vector<char> fileBuffer;
+    if( !Dali::FileLoader::ReadFile( filename, bufferSize, fileBuffer, FileLoader::FileType::BINARY ) )
+    {
+      return std::string();
+    }
+
+    return std::string( &fileBuffer[0], bufferSize );
   };
 };
 
@@ -193,14 +200,15 @@ private:
   void ReloadJsonFile(Builder& builder, Layer& layer)
   {
     Stage stage = Stage::GetCurrent();
+    stage.SetBackgroundColor( Color::WHITE );
 
     builder = Builder::New();
     builder.QuitSignal().Connect( this, &ExampleApp::OnBuilderQuit );
 
     Property::Map defaultDirs;
-    defaultDirs[ TOKEN_STRING(DALI_IMAGE_DIR) ]  = DALI_IMAGE_DIR;
-    defaultDirs[ TOKEN_STRING(DALI_MODEL_DIR) ]  = DALI_MODEL_DIR;
-    defaultDirs[ TOKEN_STRING(DALI_SCRIPT_DIR) ] = DALI_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 );
 
@@ -294,13 +302,12 @@ private:
 //
 //
 //------------------------------------------------------------------------------
-int main(int argc, char **argv)
+int DALI_EXPORT_API main(int argc, char **argv)
 {
-  Application dali_app = Application::New(&argc, &argv);
 
+  Application dali_app = Application::New(&argc, &argv, DEMO_THEME_PATH);
   ExampleApp app(dali_app);
 
-
   if(argc > 1)
   {
     std::cout << "Loading file:" << argc << " " << argv[1] << std::endl;