Commit 5c1f7a0c2d690feae3e475e5c04cbfab3adf8389

Authored by György Straub
2 parents 717e77e8 3293b5b2

[dali_1.4.27] Merge branch 'devel/master'

Change-Id: I21ee39fad3565c19c15077a1aabb8adac151a041
examples/scripting/launcher.cpp deleted
1 -/*  
2 - * Copyright (c) 2015 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 "launcher.h"  
20 -  
21 -// EXTERNAL INCLUDES  
22 -#include <fstream>  
23 -#include <sys/stat.h>  
24 -#include <dali/integration-api/debug.h>  
25 -  
26 -// INTERNAL INCLUDES  
27 -#include "shared/view.h"  
28 -  
29 -  
30 -using namespace Dali;  
31 -using namespace Dali::Toolkit;  
32 -  
33 -#define TOKEN_STRING(x) #x  
34 -  
35 -namespace  
36 -{  
37 -std::string GetFileContents(const std::string& filename)  
38 -{  
39 - std::ifstream t(filename.c_str());  
40 - return std::string((std::istreambuf_iterator<char>(t)),  
41 - std::istreambuf_iterator<char>());  
42 -};  
43 -  
44 -} // unnamed namespace  
45 -  
46 -Launcher::Launcher( Dali::Application application, std::string layoutFileName, std::string scriptFileName )  
47 -: mApplication( application ),  
48 - mJSONFileName(layoutFileName ),  
49 - mJavaScriptFileName( scriptFileName )  
50 -{  
51 - mApplication.InitSignal().Connect( this, &Launcher::Create );  
52 -}  
53 -  
54 -Launcher::~Launcher()  
55 -{  
56 -}  
57 -  
58 -void Launcher::Create( Dali::Application& application )  
59 -{  
60 - TextLabel textActor = TextLabel::New( "JSON & JavaScript Launcher..." );  
61 -  
62 - // Reposition the actor  
63 - textActor.SetParentOrigin( ParentOrigin::TOP_LEFT );  
64 - textActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );  
65 - textActor.SetPosition( 20, 0 );  
66 -  
67 - // Get a handle to the stage  
68 - Stage stage = Stage::GetCurrent();  
69 -  
70 - // Display the actor on the stage  
71 - stage.Add( textActor );  
72 -  
73 - // change the background color to purple  
74 - Stage::GetCurrent().SetBackgroundColor( Vector4(0.2,0.2,0.4,1.0) );  
75 -  
76 - // Try loading a JSON file  
77 - if( !mJSONFileName.empty() )  
78 - {  
79 - mBuilder = Toolkit::Builder::New();  
80 -  
81 - Property::Map defaultDirs;  
82 - defaultDirs[ TOKEN_STRING(DEMO_IMAGE_DIR) ] = DEMO_IMAGE_DIR;  
83 - defaultDirs[ TOKEN_STRING(DEMO_MODEL_DIR) ] = DEMO_MODEL_DIR;  
84 - defaultDirs[ TOKEN_STRING(DEMO_SCRIPT_DIR) ] = DEMO_SCRIPT_DIR;  
85 - mBuilder.AddConstants( defaultDirs );  
86 -  
87 - std::string json_data(GetFileContents( mJSONFileName ));  
88 - mBuilder.LoadFromString(json_data);  
89 - mBuilder.AddActors( stage.GetRootLayer() );  
90 - }  
91 -  
92 - // Try load a JavaScript file  
93 - if( !mJavaScriptFileName.empty() )  
94 - {  
95 - // execute the script  
96 - mScript = Toolkit::Script::New();  
97 -  
98 - mScript.ExecuteFile( mJavaScriptFileName);  
99 - }  
100 -}  
101 -  
102 -void Launcher::MainLoop()  
103 -{  
104 - mApplication.MainLoop();  
105 -}  
examples/scripting/launcher.h deleted
1 -#ifndef DALI_APP_H  
2 -#define DALI_APP_H  
3 -  
4 -/*  
5 - * Copyright (c) 2015 Samsung Electronics Co., Ltd.  
6 - *  
7 - * Licensed under the Apache License, Version 2.0 (the "License");  
8 - * you may not use this file except in compliance with the License.  
9 - * You may obtain a copy of the License at  
10 - *  
11 - * http://www.apache.org/licenses/LICENSE-2.0  
12 - *  
13 - * Unless required by applicable law or agreed to in writing, software  
14 - * distributed under the License is distributed on an "AS IS" BASIS,  
15 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
16 - * See the License for the specific language governing permissions and  
17 - * limitations under the License.  
18 - *  
19 - */  
20 -  
21 -// EXTERNAL INCLUDES  
22 -#include <dali/dali.h>  
23 -#include <dali-toolkit/dali-toolkit.h>  
24 -#include <dali-toolkit/devel-api/scripting/script.h>  
25 -#include <dali-toolkit/devel-api/builder/builder.h>  
26 -  
27 -/**  
28 - * Example app that can load both JSON and JavaScript files from command line  
29 - * E.g. scripting.example my-first.js my-first.json  
30 - * See dali-demo/resources/scripts for example JSON and JavaScript files  
31 - */  
32 -class Launcher: public Dali::ConnectionTracker  
33 -{  
34 -public:  
35 -  
36 - /**  
37 - * @brief Construcctor  
38 - * @param application application  
39 - * @param layoutFileName JSON file to run  
40 - * @param scriptFileName JavaScript file to run  
41 - */  
42 - Launcher( Dali::Application application, std::string layoutFileName, std::string scriptFileName );  
43 -  
44 - /**  
45 - * @brief destructor  
46 - */  
47 - ~Launcher();  
48 -  
49 - /**  
50 - * @brief create app  
51 - */  
52 - void Create( Dali::Application& application );  
53 -  
54 - /**  
55 - * @brief run application MainLoop  
56 - */  
57 - void MainLoop();  
58 -  
59 -private:  
60 -  
61 - Dali::Toolkit::Script mScript; ///< Used to load and execute JavaScript  
62 - Dali::Toolkit::Builder mBuilder; ///< Used to parse JSON  
63 - Dali::Application mApplication; ///< application  
64 - std::string mJSONFileName; ///< JSON filename  
65 - std::string mJavaScriptFileName; ///< JavaScript filename  
66 -};  
67 -  
68 -#endif // header  
examples/scripting/scripting-example.cpp deleted
1 -/*  
2 - * Copyright (c) 2015 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 -// EXTERNAL INCLUDES  
19 -#include <string>  
20 -#include <stdio.h>  
21 -#include <sys/stat.h>  
22 -#include <dali/integration-api/debug.h>  
23 -  
24 -// INTERNAL INCLUDES  
25 -#include "launcher.h"  
26 -  
27 -namespace  
28 -{  
29 -bool CheckIfFileExists( const std::string& filename )  
30 -{  
31 - struct stat buf;  
32 - // fstat returns -1 on error  
33 - if (stat( filename.c_str(), &buf) != -1)  
34 - {  
35 - return true;  
36 - }  
37 - return false;  
38 -}  
39 -  
40 -}  
41 -int DALI_EXPORT_API main( int argc, char* argv[] )  
42 -{  
43 - // pull out the JSON file and JavaScript file from the command line arguments  
44 - std::string javaScriptFileName;  
45 - std::string jSONFileName;  
46 -  
47 - for( int i = 1 ; i < argc ; ++i )  
48 - {  
49 - std::string arg( argv[i] );  
50 -  
51 - size_t idx = arg.find( ".json" );  
52 - if( idx != std::string::npos )  
53 - {  
54 - jSONFileName = arg;  
55 - }  
56 - else  
57 - {  
58 - idx = arg.find( ".js" );  
59 - if( idx != std::string::npos )  
60 - {  
61 - javaScriptFileName = arg;  
62 - }  
63 - }  
64 - }  
65 -  
66 - if( !jSONFileName.empty() )  
67 - {  
68 - bool exists = CheckIfFileExists( jSONFileName );  
69 - if( !exists )  
70 - {  
71 - DALI_ASSERT_ALWAYS( 0 && "JSON file not found ")  
72 - }  
73 - }  
74 - if( !javaScriptFileName.empty() )  
75 - {  
76 - bool exists = CheckIfFileExists( javaScriptFileName );  
77 - if( !exists )  
78 - {  
79 - DALI_ASSERT_ALWAYS( 0 && "JavaScript file not found ")  
80 - }  
81 - }  
82 - if( jSONFileName.empty() && javaScriptFileName.empty() )  
83 - {  
84 - printf("Please specify a JSON and/or JavaScript file to load, e.g. scripting.example mylayout.json my-test.js\n");  
85 - return -1;  
86 - }  
87 -  
88 -  
89 - Launcher daliApplication( Dali::Application::New( &argc, &argv, DEMO_THEME_PATH ), jSONFileName, javaScriptFileName );  
90 -  
91 - daliApplication.MainLoop();  
92 -  
93 - return 0;  
94 -}  
packaging/com.samsung.dali-demo.spec
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 2
3 Name: com.samsung.dali-demo 3 Name: com.samsung.dali-demo
4 Summary: The OpenGLES Canvas Core Demo 4 Summary: The OpenGLES Canvas Core Demo
5 -Version: 1.4.26 5 +Version: 1.4.27
6 Release: 1 6 Release: 1
7 Group: System/Libraries 7 Group: System/Libraries
8 License: Apache-2.0 8 License: Apache-2.0