1 /* Copyright (c) 2015 Samsung Electronics Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
19 #include <public-api/dali-core.h>
20 #include <dali-toolkit/dali-toolkit.h>
21 #include <integration-api/core.h>
22 #include <integration-api/adaptors/adaptor.h>
23 #include <public-api/adaptor-framework/window.h>
24 #include <devel-api/adaptor-framework/singleton-service.h>
27 #include <dali-wrapper.h>
28 #include "javascript-application-options.h"
32 namespace DaliNodeAddon
40 : mInitialized( false),
41 mSingletonService(SingletonService::New()),
48 mSingletonService.UnregisterAll();
53 bool Initialized() const
58 void Initialize( ApplicationOptions options )
65 // 1. Create the window ( adaptor requires a window)
66 const WindowOptions& window( options.window);
68 mWindow = Window::New( window.positionSize, window.name, window.transparent );
70 // 2. create the adaptor
71 Adaptor* adaptor = &Adaptor::New( mWindow );
73 // 3. start the adaptor
76 // fire the scene create signal
77 adaptor->NotifySceneCreated();
84 SingletonService mSingletonService;
92 void CreateDali(const v8::FunctionCallbackInfo<v8::Value>& args)
94 v8::Isolate* isolate = args.GetIsolate();
95 v8::HandleScope scope(isolate);
97 ApplicationOptions options;
99 bool ok = GetApplicationOptions( args, options);
102 isolate->ThrowException( v8::Exception::TypeError( v8::String::NewFromUtf8(isolate, "Please check arguments passed to DALi require") ) );
106 app.Initialize( options );
108 // the return value from calling the function require('dali.js)( options )
109 // is the dali object
110 args.GetReturnValue().Set( V8Plugin::DaliWrapper::CreateWrapperForNodeJS( isolate ) );
115 * We make module.exports a function so that the developer can pass to
116 * parameters to DALi when it's 'required'
125 * transparent: false,
126 * name:'my-first-dali-app'
130 * 'stereoscopic-mode':'stereo-vertical', // mono, stereo-horizontal, stereo-vertical, stereo-interlaced,
131 * 'stereo-base': 65 // Distance in millimeters between left/right cameras typically between (50-70mm)
136 * 'view-mode': viewMode,
137 * 'style-sheet': 'my-theme.json'
140 * var dali = require('dali.js')( options )
144 void ExportDaliModule(v8::Handle<v8::Object> exports, v8::Handle<v8::Object> module)
146 NODE_SET_METHOD(module, "exports", CreateDali);
149 } // namespace DaliNodeAddon
151 NODE_MODULE(dali, DaliNodeAddon::ExportDaliModule)