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
78 if( options.stereo.viewMode > Dali::MONO )
80 adaptor->SetStereoBase( options.stereo.stereoBase );
81 adaptor->SetViewMode( options.stereo.viewMode );
84 // fire the scene create signal
85 adaptor->NotifySceneCreated();
92 SingletonService mSingletonService;
100 void CreateDali(const v8::FunctionCallbackInfo<v8::Value>& args)
102 v8::Isolate* isolate = args.GetIsolate();
103 v8::HandleScope scope(isolate);
105 ApplicationOptions options;
107 bool ok = GetApplicationOptions( args, options);
110 isolate->ThrowException( v8::Exception::TypeError( v8::String::NewFromUtf8(isolate, "Please check arguments passed to DALi require") ) );
114 app.Initialize( options );
116 // the return value from calling the function require('dali.js)( options )
117 // is the dali object
118 args.GetReturnValue().Set( V8Plugin::DaliWrapper::CreateWrapperForNodeJS( isolate ) );
123 * We make module.exports a function so that the developer can pass to
124 * parameters to DALi when it's 'required'
133 * transparent: false,
134 * name:'my-first-dali-app'
138 * 'stereoscopic-mode':'stereo-vertical', // mono, stereo-horizontal, stereo-vertical, stereo-interlaced,
139 * 'stereo-base': 65 // Distance in millimeters between left/right cameras typically between (50-70mm)
144 * 'view-mode': viewMode,
145 * 'style-sheet': 'my-theme.json'
148 * var dali = require('dali.js')( options )
152 void ExportDaliModule(v8::Handle<v8::Object> exports, v8::Handle<v8::Object> module)
154 NODE_SET_METHOD(module, "exports", CreateDali);
157 } // namespace DaliNodeAddon
159 NODE_MODULE(dali, DaliNodeAddon::ExportDaliModule)