From: Paul Wisbey Date: Fri, 20 Mar 2015 17:04:31 +0000 (+0000) Subject: Merge remote-tracking branch 'origin/tizen' into new_text X-Git-Tag: dali_1.0.38~11^2~39 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=3e17d9f63dedb5d669409301f8d9a3d8c393f979;hp=428bd47c26043ccaabab1a64cbc7cbd7ce3c7427 Merge remote-tracking branch 'origin/tizen' into new_text Conflicts: build/tizen/configure.ac Change-Id: Id18adef88fdd0edca9ccb6a1225ab4def1bedf32 --- diff --git a/build/tizen/configure.ac b/build/tizen/configure.ac index 7a90b2a..006e192 100644 --- a/build/tizen/configure.ac +++ b/build/tizen/configure.ac @@ -45,25 +45,29 @@ AC_ARG_ENABLE([debug], [enable_debug=$enableval], [enable_debug=no]) -# option for JavaScript plugin -AC_ARG_ENABLE(javascript, +# option to build JavaScript plugin +# configure settings and output +# --enable-javascript // enable_javascript = yes +# --enable-javascript=yes // enable_javascript = yes +# --enable-javascript=no // enable_javascript = no +# --disable-javascript // enable_javascript = no +# no setting // enable_javascript = automatic ( enable if v8 present) +AC_ARG_ENABLE([javascript], [AC_HELP_STRING([--enable-javascript], - [Enable JavaScript plugin])] , - [enable_javascript=yes], - [enable_javascript=no]) + [Enable JavaScript plugin])] , + [enable_javascript=$enableval], + [enable_javascript=automatic]) + if test "x$enable_debug" = "xyes"; then DALI_TOOLKIT_CFLAGS="$DALI_TOOLKIT_CFLAGS -DDEBUG_ENABLED" - DALI_SCRIPTV8_CFLAGS="$DALI_TOOLKIT_CFLAGS -DDEBUG_ENABLED" fi if test "x$enable_debug" = "xno" -a "x$enable_exportall" = "xno"; then DALI_TOOLKIT_CFLAGS="$DALI_TOOLKIT_CFLAGS -fvisibility=hidden -DHIDE_DALI_INTERNALS" - DALI_SCRIPTV8_CFLAGS="$DALI_TOOLKIT_CFLAGS -fvisibility=hidden -DHIDE_DALI_INTERNALS" fi -#set a variable for the makefile to conditionally compile the plugin -AM_CONDITIONAL([ENABLE_JAVASCRIPT_PLUGIN], [test x$enable_javascript = xyes]) + # Tizen Profile options @@ -89,11 +93,37 @@ DALI_TOOLKIT_CFLAGS="$DALI_TOOLKIT_CFLAGS -DDALI_PROFILE_${enable_profile}" AM_CONDITIONAL([COMMON_PROFILE], [test x$enable_profile = xCOMMON]) AM_CONDITIONAL([MOBILE_PROFILE], [test x$enable_profile = xMOBILE]) +# v8 version 4+ requires c++11 +PKG_CHECK_MODULES(V8, v8 = 3.32.7, [ pkg_check_v8=yes ], [ pkg_check_v8=no ] ) + +# Rules for building JavaScript plugin +# If enable_javascript=yes and v8 installed = build javascript +# If enable_javascript=automatic and v8 installed = build javascript +# If enable_javascript=yes and v8 not installed = throw an error +build_javascript_plugin=no +if test x$enable_javascript = xyes; then + if test x$pkg_check_v8 = xno; then + [build_javascript_plugin=no] + AC_MSG_ERROR("V8 not found or incorrect version installed") + AC_MSG_NOTICE("To disable building of JavaScript plugin use --disable-javascript") + else + [build_javascript_plugin=yes] + AC_MSG_NOTICE(V8 library found. Building DALi JavaScript plugin) + fi +fi +if test x$enable_javascript = xautomatic && test x$pkg_check_v8 = xyes; then + [build_javascript_plugin=yes] + AC_MSG_NOTICE( V8 library found. Automatic building of JavaScript plugin. Use use --disable-javascript to disable) +fi + + +#set a variable for the makefile to force compile the JAvaSplugin +AM_CONDITIONAL([ENABLE_JAVASCRIPT_PLUGIN], [test x$build_javascript_plugin = xyes]) + AC_SUBST(dataReadWriteDir) AC_SUBST(dataReadOnlyDir) AC_SUBST(DALI_TOOLKIT_CFLAGS) -AC_SUBST(DALI_SCRIPTV8_CFLAGS) -AC_SUBST(DALI_SCRIPTV8_LIBS) + # Specify the include directory for development headers #devincludepath=${includedir}/dali/internal @@ -122,7 +152,7 @@ Configuration ------------- Prefix: $prefix Debug Build: $enable_debug - JavaScript support (V8 required) $enable_javascript + JavaScript support (V8 required) $build_javascript_plugin Profile: $dali_profile Data Dir (Read/Write): $dataReadWriteDir Data Dir (Read Only): $dataReadOnlyDir diff --git a/build/tizen/plugins/Makefile.am b/build/tizen/plugins/Makefile.am index d80dd67..1ca51e4 100644 --- a/build/tizen/plugins/Makefile.am +++ b/build/tizen/plugins/Makefile.am @@ -20,7 +20,6 @@ plugin_src_dir = ../../../plugins include ../../../plugins/dali-script-v8/file.list -DALI_SCRIPTV8_LIBS="-lv8 -lpthread" lib_LTLIBRARIES = libdali-script-plugin-v8.la @@ -46,16 +45,16 @@ libdali_script_plugin_v8_la_CXXFLAGS = -DDALI_COMPILATION \ -DDALI_DATA_READ_ONLY_DIR="\"${dataReadOnlyDir}\"" \ $(DALI_CFLAGS) \ $(DLOG_CFLAGS) \ - $(DALI_SCRIPTV8_CFLAGS) \ -I../../.. \ $(script_plugin_v8_includes) \ + $(V8_CFLAGS) \ -Werror -Wall libdali_script_plugin_v8_la_LIBADD = \ $(DALICORE_LIBS) \ $(DALI_LIBS) \ $(DLOG_LIBS) \ - $(DALI_SCRIPTV8_LIBS) + $(V8_LIBS) libdali_script_plugin_v8_la_LDFLAGS = \ -rdynamic diff --git a/dali-toolkit/public-api/dali-toolkit-version.cpp b/dali-toolkit/public-api/dali-toolkit-version.cpp index 78fc9df..89d0637 100644 --- a/dali-toolkit/public-api/dali-toolkit-version.cpp +++ b/dali-toolkit/public-api/dali-toolkit-version.cpp @@ -31,7 +31,7 @@ namespace Toolkit const unsigned int TOOLKIT_MAJOR_VERSION = 1; const unsigned int TOOLKIT_MINOR_VERSION = 0; -const unsigned int TOOLKIT_MICRO_VERSION = 33; +const unsigned int TOOLKIT_MICRO_VERSION = 34; const char * const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__; #ifdef DEBUG_ENABLED diff --git a/packaging/dali-toolkit.spec b/packaging/dali-toolkit.spec index 921e2dc..fb616da 100644 --- a/packaging/dali-toolkit.spec +++ b/packaging/dali-toolkit.spec @@ -1,6 +1,6 @@ Name: dali-toolkit Summary: The OpenGLES Canvas Core Library Toolkit -Version: 1.0.33 +Version: 1.0.34 Release: 1 Group: System/Libraries License: Apache-2.0 diff --git a/plugins/dali-script-v8/docs/content/actor.js b/plugins/dali-script-v8/docs/content/actor.js index 7bd5b20..b2ea595 100644 --- a/plugins/dali-script-v8/docs/content/actor.js +++ b/plugins/dali-script-v8/docs/content/actor.js @@ -119,7 +119,7 @@ function OnPressed( actor, touchEvent ) var anim = new dali.Animation( 4 ); var rotation = new dali.Rotation( 90, 0, 0 ); // pitch, yaw, roll - anim.animateBy( actor, "rotation", rotation ); + anim.animateBy( actor, "orientation", rotation ); anim.play(); return true; } diff --git a/plugins/dali-script-v8/docs/content/animation.js b/plugins/dali-script-v8/docs/content/animation.js index ec587fe..33c64f8 100644 --- a/plugins/dali-script-v8/docs/content/animation.js +++ b/plugins/dali-script-v8/docs/content/animation.js @@ -68,8 +68,8 @@ myActor2.position=[ 100,0,-2000]; // x = 100, y = 0 , z = -2000 function createAnimation() { var startRotation = new dali.Rotation(180, -180, 0); - myActor1.rotation = startRotation; - myActor2.rotation = startRotation; + myActor1.orientation = startRotation; + myActor2.orientation = startRotation; dali.stage.add( myActor1 ); dali.stage.add( myActor2 ); @@ -90,7 +90,7 @@ function createAnimation() { var endRotation = new dali.Rotation(0,0,0); animOptions.alpha = "easeInOutSine"; - anim.animateTo(myActor1, "rotation", endRotation, animOptions); + anim.animateTo(myActor1, "orientation", endRotation, animOptions); // Delay the myActor2 by a second animOptions.delay = 0.0; @@ -99,7 +99,7 @@ function createAnimation() { // rotate back to correct orientation animOptions.alpha = "easeInOutSine"; - anim.animateTo(myActor2, "rotation", endRotation, animOptions); + anim.animateTo(myActor2, "orientation", endRotation, animOptions); return anim; } @@ -209,7 +209,7 @@ var shaderAnim = createShaderAnimation( shaderEffect, color,zoom, duration, dela // also rotate the imageActor 90 degrees at the same time. var rotation = new dali.Rotation(90,0,0,1); -shaderAnim.animateTo(imageActor, "rotation", rotation, { alpha:"linear", duration:duration, delay:delay }); +shaderAnim.animateTo(imageActor, "orientation", rotation, { alpha:"linear", duration:duration, delay:delay }); shaderAnim.play(); diff --git a/plugins/dali-script-v8/docs/content/shader-effect.js b/plugins/dali-script-v8/docs/content/shader-effect.js index eedfafa..a83df51 100644 --- a/plugins/dali-script-v8/docs/content/shader-effect.js +++ b/plugins/dali-script-v8/docs/content/shader-effect.js @@ -238,7 +238,7 @@ imageActor.setCullFace( dali.CULL_FACE_DISABLE ); // disable face culling so we dali.stage.add( imageActor ); // start it of tilted around the y-axis -imageActor.rotation=new dali.Rotation(90, 0, 1, 0); +imageActor.orientation=new dali.Rotation(90, 0, 1, 0); var twistEffect = createTwistEffect(); imageActor.setShaderEffect( twistEffect ); diff --git a/plugins/dali-script-v8/file.list b/plugins/dali-script-v8/file.list index 13300ef..ef35cf9 100644 --- a/plugins/dali-script-v8/file.list +++ b/plugins/dali-script-v8/file.list @@ -12,14 +12,11 @@ script_v8_plugin_src_files = \ $(v8_plugin_dir)/actors/actor-wrapper.cpp \ $(v8_plugin_dir)/actors/actor-api.cpp \ $(v8_plugin_dir)/actors/layer-api.cpp \ - $(v8_plugin_dir)/actors/text-actor-api.cpp \ $(v8_plugin_dir)/actors/image-actor-api.cpp \ $(v8_plugin_dir)/actors/camera-actor-api.cpp \ $(v8_plugin_dir)/actors/mesh-actor-api.cpp \ $(v8_plugin_dir)/actors/renderable-actor-api.cpp \ $(v8_plugin_dir)/constants/constants-wrapper.cpp \ - $(v8_plugin_dir)/text/font-api.cpp \ - $(v8_plugin_dir)/text/font-wrapper.cpp \ $(v8_plugin_dir)/animation/animation-api.cpp \ $(v8_plugin_dir)/animation/animation-wrapper.cpp \ $(v8_plugin_dir)/animation/path-api.cpp \ diff --git a/plugins/dali-script-v8/src/actors/actor-api.cpp b/plugins/dali-script-v8/src/actors/actor-api.cpp index 4027a1b..c169b2a 100644 --- a/plugins/dali-script-v8/src/actors/actor-api.cpp +++ b/plugins/dali-script-v8/src/actors/actor-api.cpp @@ -19,7 +19,7 @@ #include "actor-api.h" // EXTERNAL INCLUDES -#include +#include // INTERNAL INCLUDES #include @@ -41,11 +41,11 @@ Actor GetActor( v8::Isolate* isolate, const v8::FunctionCallbackInfo& } //unanmed namespace -namespace TextViewApi +namespace TextLabelApi { Actor New( const v8::FunctionCallbackInfo< v8::Value >& args ) { - return Dali::Toolkit::TextView::New(); + return Dali::Toolkit::TextLabel::New(); } } @@ -485,7 +485,7 @@ void ActorApi::IsKeyboardFocusable( const v8::FunctionCallbackInfo& a * * @for Actor * @method getActorType - * @return {String} Actor, ImageActor, TextActor, MeshActor, Layer, CameraActor ... + * @return {String} Actor, ImageActor, MeshActor, Layer, CameraActor ... */ void ActorApi::GetActorType( const v8::FunctionCallbackInfo& args ) { @@ -557,7 +557,7 @@ void ActorApi::RotateBy( const v8::FunctionCallbackInfo& args ) bool found( false ); Property::Value rotation = V8Utils::GetPropertyValueParameter( PARAMETER_0, found, isolate, args ); - if( rotation.GetType() != Property::ORIENTATION ) + if( rotation.GetType() != Property::ROTATION ) { DALI_SCRIPT_EXCEPTION( isolate, "Rotation parameter missing" ); return; diff --git a/plugins/dali-script-v8/src/actors/actor-api.h b/plugins/dali-script-v8/src/actors/actor-api.h index 9d1bb16..8543f11 100644 --- a/plugins/dali-script-v8/src/actors/actor-api.h +++ b/plugins/dali-script-v8/src/actors/actor-api.h @@ -28,7 +28,7 @@ namespace Dali namespace V8Plugin { -namespace TextViewApi +namespace TextLabelApi { /** * Temporary TextView constructor diff --git a/plugins/dali-script-v8/src/actors/actor-wrapper.cpp b/plugins/dali-script-v8/src/actors/actor-wrapper.cpp index 6f2d6f0..5916dd2 100644 --- a/plugins/dali-script-v8/src/actors/actor-wrapper.cpp +++ b/plugins/dali-script-v8/src/actors/actor-wrapper.cpp @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -40,11 +39,10 @@ namespace V8Plugin v8::Persistent ActorWrapper::mActorTemplate; v8::Persistent ActorWrapper::mImageActorTemplate; -v8::Persistent ActorWrapper::mTextActorTemplate; v8::Persistent ActorWrapper::mMeshActorTemplate; v8::Persistent ActorWrapper::mCameraActorTemplate; v8::Persistent ActorWrapper::mLayerActorTemplate; -v8::Persistent ActorWrapper::mTextViewTemplate; +v8::Persistent ActorWrapper::mTextLabelTemplate; namespace { @@ -65,11 +63,10 @@ const ActorTemplate ActorTemplateLookup[]= { { &ActorWrapper::mActorTemplate }, // ACTOR { &ActorWrapper::mImageActorTemplate }, // IMAGE_ACTOR - { &ActorWrapper::mTextActorTemplate }, // TEXT_ACTOR { &ActorWrapper::mMeshActorTemplate }, // MESH_ACTOR { &ActorWrapper::mLayerActorTemplate }, // LAYER_ACTOR { &ActorWrapper::mCameraActorTemplate}, // CAMERA_ACTOR - { &ActorWrapper::mTextViewTemplate } + { &ActorWrapper::mTextLabelTemplate } }; /** @@ -80,10 +77,9 @@ enum ActorApiBitMask ACTOR_API = 1 << 0, RENDERABLE_ACTOR_API = 1 << 1, IMAGE_ACTOR_API = 1 << 2, - TEXT_ACTOR_API = 1 << 3, - MESH_ACTOR_API = 1 << 4, - LAYER_API = 1 << 5, - CAMERA_ACTOR_API = 1 << 6, + MESH_ACTOR_API = 1 << 3, + LAYER_API = 1 << 4, + CAMERA_ACTOR_API = 1 << 5, }; /** @@ -104,11 +100,10 @@ const ActorApiStruct ActorApiLookup[]= { {"Actor", ActorWrapper::ACTOR, ActorApi::New, ACTOR_API }, {"ImageActor", ActorWrapper::IMAGE_ACTOR, ImageActorApi::New, ACTOR_API | RENDERABLE_ACTOR_API | IMAGE_ACTOR_API }, - {"TextActor", ActorWrapper::TEXT_ACTOR, TextActorApi::New, ACTOR_API | RENDERABLE_ACTOR_API | TEXT_ACTOR_API }, {"MeshActor", ActorWrapper::MESH_ACTOR, MeshActorApi::New, ACTOR_API | RENDERABLE_ACTOR_API | MESH_ACTOR_API }, {"Layer", ActorWrapper::LAYER_ACTOR, LayerApi::New, ACTOR_API | LAYER_API }, {"CameraActor",ActorWrapper::CAMERA_ACTOR, CameraActorApi::New, ACTOR_API | CAMERA_ACTOR_API }, - {"TextView", ActorWrapper::TEXT_VIEW, TextViewApi::New, ACTOR_API }, + {"TextLabel", ActorWrapper::TEXT_LABEL, TextLabelApi::New, ACTOR_API }, }; @@ -148,7 +143,7 @@ Actor CreateActor( const v8::FunctionCallbackInfo< v8::Value >& args, else { // run the constructor for this type of actor so it can pull out - // custom parameters, e.g. new TextActor("hello world"); or ImageActor( MyImage ); + // custom parameters, e.g. new ImageActor( MyImage ); actor = (ActorApiLookup[actorType].constructor)( args ); } return actor; @@ -312,40 +307,6 @@ const ActorFunctions ActorFunctionTable[]= // ignore GetFadeInDuration use imageActor.fadeInDuration //{ "GetCurrentImageSize", ImageActorApi::GetCurrentImageSize, IMAGE_ACTOR_API }, - - /************************************** - * Text Actor API (in order of text-actor.h) - **************************************/ - //ignore SetText use textActor.text - { "SetToNaturalSize", TextActorApi::SetToNaturalSize, TEXT_ACTOR_API }, - // ignore GetFont use textActor.font - // ignore SetFont use textActor.font - // ignore SetGradient use textActor.gradientColor - // ignore GetGradient textActor.gradientColor - // ignore SetGradientStartPoint use textActor.gradientStartPoint - // ignore GetGradientStartPoint textActor.gradientStartPoint - // ignore SetGradientEndPoint use textActor.gradientEndPoint - // ignore GetGradientEndPoint textActor.gradientEndPoint - // @todo? SetTextStyle ( can use individual properties as a work around ) - // @todo? GetTextStyle ( can use individual properties as a work around ) - // ignore SetTextColor use textActor.textColor - // ignore GetTextColor use textActor.textColor - // ignore SetSmoothEdge use textActor.smoothEdge - // ignore SetOutline use textActor.outLineEnable, outlineColor, thicknessWidth - // ignore SetGlow use textActor.glowEnable, glowColor, glowIntensity - // ignore SetShadow use textActor.shadowEnable, shadowColor, shadowOffset, shadowSize - // ignore SetItalics use textActor.italicsAngle ? - // ignore GetItalics @todo add italics flag? or just stick with angle - // ignore GetItalicsAngle use textActor.italicsAngle - // ignore SetUnderline use textActor.underline - // ignore GetUnderline use textActor.underline - // ignore SetWeight use textActor.weight - // ignore GetWeight use textActor.weight - // ignore SetFontDetectionAutomatic use textActor.fontDetectionAutomatic - // ignore IsFontDetectionAutomatic use textActor.fontDetectionAutomatic - // ignore GetLoadingState text is loaded synchronously - // ignore TextAvailableSignal text is loaded synchronously - /************************************** * Mesh Actor API (in order of mesh-actor.h) **************************************/ @@ -487,7 +448,7 @@ void ActorWrapper::NewActor( const v8::FunctionCallbackInfo< v8::Value >& args) return; } - // find out the callee function name...e.g. TextActor, ImageActor, MeshActor + // find out the callee function name...e.g. ImageActor, MeshActor v8::Local callee = args.Callee(); v8::Local v8String = callee->GetName(); std::string typeName = V8Utils::v8StringToStdString( v8String ); diff --git a/plugins/dali-script-v8/src/actors/actor-wrapper.h b/plugins/dali-script-v8/src/actors/actor-wrapper.h index 79381ba..ab6999b 100644 --- a/plugins/dali-script-v8/src/actors/actor-wrapper.h +++ b/plugins/dali-script-v8/src/actors/actor-wrapper.h @@ -48,12 +48,11 @@ public: UNKNOWN_ACTOR = -1, ACTOR = 0, IMAGE_ACTOR =1, - TEXT_ACTOR =2, - MESH_ACTOR =3, - LAYER_ACTOR =4, - CAMERA_ACTOR =5, - LIGHT_ACTOR =6, - TEXT_VIEW =7 + MESH_ACTOR =2, + LAYER_ACTOR =3, + CAMERA_ACTOR =4, + LIGHT_ACTOR =5, + TEXT_LABEL =6 }; /** @@ -91,11 +90,10 @@ public: // The Actor ObjectTemplates. static v8::Persistent mActorTemplate; static v8::Persistent mImageActorTemplate; - static v8::Persistent mTextActorTemplate; static v8::Persistent mMeshActorTemplate; static v8::Persistent mCameraActorTemplate; static v8::Persistent mLayerActorTemplate; - static v8::Persistent mTextViewTemplate; + static v8::Persistent mTextLabelTemplate; /** * @return the wrapped actor diff --git a/plugins/dali-script-v8/src/actors/text-actor-api.cpp b/plugins/dali-script-v8/src/actors/text-actor-api.cpp deleted file mode 100644 index 483b345..0000000 --- a/plugins/dali-script-v8/src/actors/text-actor-api.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (c) 2015 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// CLASS HEADER -#include "text-actor-api.h" - -// EXTERNAL INCLUDES -#include - -// INTERNAL INCLUDES -#include -#include -#include -#include - - -namespace Dali -{ - -namespace V8Plugin -{ - -namespace //unnamed name space -{ - -struct TextActorParametersInternal -{ - TextActorParametersInternal() - : fontDetection( true ) - { - } - bool fontDetection; - Font font; -}; - - -TextActor GetTextActor( v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args ) -{ - HandleWrapper* handleWrapper = HandleWrapper::Unwrap( isolate, args.This() ); - return TextActor::DownCast( handleWrapper->mHandle ); -} - - -void GetTextOptions( v8::Isolate* isolate, - v8::Local options, - TextActorParametersInternal& textParams ) -{ - // fontDetection: true / false ( default true) - // font: dali font object - v8::HandleScope handleScope( isolate ); - - if( options->IsObject() ) - { - v8::Local obj = options->ToObject(); - - v8::Local fontDetect = obj->Get( v8::String::NewFromUtf8( isolate, "fontDetection" ) ); - if( fontDetect->IsBoolean() ) - { - - textParams.fontDetection = fontDetect->ToBoolean()->Value(); - } - - v8::Local fontValue = obj->Get( v8::String::NewFromUtf8( isolate, "font" ) ); - if( fontValue->IsObject() ) - { - textParams.font = FontApi::GetFont( isolate, fontValue ); - } - - } -} - -} - -/** - * @constructor - * @for TextActor - * @method TextActor - * @param {String} text - * @param {Object} [textOptions] data - * Options text options struct - * @param {Boolean} [textOptions.fontDetection] - * if true the fontDetection is used to make sure the text is displayed. - * E.g. if the current font used by the text-actor does not support certain characters - * it will find a new font that does. Default = true. - * @param {Object} [textOptions.font] - * Dali font object - * @return {Object} TextActor - */ -Actor TextActorApi::New( const v8::FunctionCallbackInfo& args ) -{ - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope handleScope( isolate ); - - // - // TextActor( text, options (optional) ) - // - // options = - // { - // font: font - // fontDetection: true / false ( default true) - // } - - // get the text (if passed in) - - bool found( false ); - std::string text = V8Utils::GetStringParameter( PARAMETER_0, found, isolate, args ); - - TextActorParametersInternal params; - TextActor actor; - - GetTextOptions( isolate, args[1], params ); - - TextStyle style; - - if( params.font ) - { - style.SetFontName( params.font.GetName() ); - style.SetFontStyle( params.font.GetStyle() ); - style.SetFontPointSize( PointSize(params.font.GetPointSize())); - - } - TextActorParameters textActorParameters( style, params.fontDetection? TextActorParameters::FONT_DETECTION_OFF:TextActorParameters::FONT_DETECTION_ON ); - - actor = TextActor::New( text, textActorParameters ); - - return actor; - -} - -/** - * Set text to the natural size of the text string. - * - * After this method the text actor always uses the natural size of the text - * when SetText is called unless SetSize is called to override the size. - * - * @for TextActor - * @method setToNaturalSize - */ -void TextActorApi::SetToNaturalSize( const v8::FunctionCallbackInfo& args ) -{ - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope handleScope( isolate ); - - TextActor textActor = GetTextActor( isolate, args ); - textActor.SetToNaturalSize(); -} - -} // namespace V8Plugin - -} // namespace Dali diff --git a/plugins/dali-script-v8/src/actors/text-actor-api.h b/plugins/dali-script-v8/src/actors/text-actor-api.h deleted file mode 100644 index f074703..0000000 --- a/plugins/dali-script-v8/src/actors/text-actor-api.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef __DALI_V8PLUGIN_TEXT_ACTOR_API_H__ -#define __DALI_V8PLUGIN_TEXT_ACTOR_API_H__ - -/* - * Copyright (c) 2015 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - - -// EXTERNAL INCLUDES -#include -#include - -namespace Dali -{ - -namespace V8Plugin -{ - -namespace TextActorApi -{ - Actor New( const v8::FunctionCallbackInfo< v8::Value >& args ); - void SetToNaturalSize( const v8::FunctionCallbackInfo< v8::Value >& args ); - -}; // namespace TextActorApi - -} // namespace V8Plugin - -} // namespace Dali - -#endif // header __DALI_V8PLUGIN_TEXT_ACTOR_API_H__ diff --git a/plugins/dali-script-v8/src/dali-wrapper.cpp b/plugins/dali-script-v8/src/dali-wrapper.cpp index 55df482..20fa9f6 100644 --- a/plugins/dali-script-v8/src/dali-wrapper.cpp +++ b/plugins/dali-script-v8/src/dali-wrapper.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -59,7 +58,6 @@ const ApiFunction ConstructorFunctionTable[]= { { "Rotation", PropertyValueWrapper::NewRotation}, { "Matrix", PropertyValueWrapper::NewMatrix}, - { "Font", FontWrapper::NewFont }, { "Path", PathWrapper::NewPath }, { "Actor", ActorWrapper::NewActor }, { "TextActor", ActorWrapper::NewActor }, @@ -183,7 +181,7 @@ void DaliWrapper::CreateContext( ) // Context = multiple contexts can exist in a given Isolate, and share data between contexts v8::Handle context = v8::Context::New( mIsolate, NULL, global); - mGlobalObjectTemplate.Reset( mIsolate, global); + mGlobalObjectTemplate.Reset( mIsolate, global); mContext.Reset( mIsolate, context); } @@ -192,10 +190,16 @@ void DaliWrapper::Initialize() { if( !mIsolate ) { - v8::V8::Initialize(); v8::V8::InitializeICU(); + + v8::V8::Initialize(); + + // default isolate removed from V8 version 3.27.1 and beyond. + mIsolate = v8::Isolate::New(); + mIsolate->Enter(); + v8::V8::SetFatalErrorHandler( FatalErrorCallback ); - mIsolate = v8::Isolate::GetCurrent(); + } // if context is null, create it and add dali object to the global object. if( mContext.IsEmpty()) @@ -214,10 +218,6 @@ void DaliWrapper::Initialize() v8::Local stageObject = StageWrapper::WrapStage( mIsolate, Stage::GetCurrent() ); daliObject->Set( v8::String::NewFromUtf8( mIsolate, "stage") , stageObject ); - // fontObject provides static font functionality like GetFontList... - v8::Local fontObject = FontWrapper::GetStaticFontObject( mIsolate ); - daliObject->Set( v8::String::NewFromUtf8( mIsolate, "font") , fontObject ); - // keyboard focus manager is a singleton v8::Local keyboardObject = KeyboardFocusManagerWrapper::WrapKeyboardFocusManager( mIsolate,Toolkit::KeyboardFocusManager::Get() ); daliObject->Set( v8::String::NewFromUtf8( mIsolate, "keyboardFocusManager") , keyboardObject ); diff --git a/plugins/dali-script-v8/src/shader-effects/shader-effect-api.cpp b/plugins/dali-script-v8/src/shader-effects/shader-effect-api.cpp index 74762f2..a793c07 100644 --- a/plugins/dali-script-v8/src/shader-effects/shader-effect-api.cpp +++ b/plugins/dali-script-v8/src/shader-effects/shader-effect-api.cpp @@ -44,7 +44,6 @@ struct GeometryTypePair const GeometryTypePair GeometryTypeTable[]= { {"image", GEOMETRY_TYPE_IMAGE }, - {"text", GEOMETRY_TYPE_TEXT }, {"mesh", GEOMETRY_TYPE_UNTEXTURED_MESH }, {"textured-mesh", GEOMETRY_TYPE_TEXTURED_MESH }, }; diff --git a/plugins/dali-script-v8/src/text/font-api.cpp b/plugins/dali-script-v8/src/text/font-api.cpp deleted file mode 100644 index 385f58d..0000000 --- a/plugins/dali-script-v8/src/text/font-api.cpp +++ /dev/null @@ -1,458 +0,0 @@ -/* - * Copyright (c) 2015 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// CLASS HEADER -#include "font-api.h" - -// INTERNAL INCLUDES -#include -#include -#include - -namespace Dali -{ - -namespace V8Plugin -{ - -namespace // un named namespace -{ - - - - -} //un named namespace - -/*************************************** - * IMAGE FUNCTIONS - * - ****************************************/ -Font FontApi::GetFont( v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args ) -{ - v8::HandleScope handleScope( isolate ); - - v8::Local object = args.This(); - v8::Local field = v8::Local::Cast( object->GetInternalField(0) ); - void* ptr = field->Value(); - - FontWrapper* wrapper = static_cast< FontWrapper *>(ptr); - return wrapper->GetFont(); -} -Font FontApi::GetFont( v8::Isolate* isolate, v8::Local& value ) -{ - v8::HandleScope handleScope( isolate ); - v8::Local object = value->ToObject(); - v8::Local field = v8::Local::Cast( object->GetInternalField(0) ); - void* ptr = field->Value(); - - FontWrapper* wrapper = static_cast< FontWrapper *>(ptr); - return wrapper->GetFont(); -} - -struct FontParams -{ - typedef enum - { - NO_SIZE_SET, - USE_POINT_SIZE, - USE_PIXEL_SIZE, - USE_CAP_SIZE, - } SizeType; - - - FontParams() - :pointSize( 0 ), - pixelSize( 0 ), - capsSize( 0 ), - sizeType( FontParams::NO_SIZE_SET ) - { - } - - std::string family; - std::string style; - PointSize pointSize; - PixelSize pixelSize; - CapsHeight capsSize; - SizeType sizeType; - - -}; - - -void ReadFontParameters( v8::Isolate* isolate, - v8::Local options, - FontParams& fontParams ) -{ - // foont options is an optional parameter passed in which holds - // optional settings - // var fontOptions = { - // family: "arial", - // style: "bold", - // // one of the following - // pixelSize: xx - // pointSize: xx - // capsHeight:xx // height of a capital letter above the baseline for a particular typeface. - // - // }; - v8::HandleScope handleScope( isolate ); - if( !options->IsObject() ) - { - DALI_SCRIPT_EXCEPTION( isolate, "bad parameter 0 ( font parameters)" ); - return; - } - v8::Local obj = options->ToObject(); - - v8::Local familyValue = obj->Get( v8::String::NewFromUtf8( isolate, "family" ) ); - if( familyValue->IsString() ) - { - fontParams.family = V8Utils::v8StringToStdString( familyValue ); - } - - v8::Local styleValue = obj->Get( v8::String::NewFromUtf8( isolate, "style" ) ); - if( styleValue->IsString() ) - { - fontParams.style = V8Utils::v8StringToStdString( styleValue ); - } - - v8::Local pixelSize = obj->Get( v8::String::NewFromUtf8( isolate, "pixelSize" ) ); - v8::Local pointSize = obj->Get( v8::String::NewFromUtf8( isolate, "pointSize" ) ); - v8::Local capsHeight = obj->Get( v8::String::NewFromUtf8( isolate, "capsHeight" ) ); - - if( pixelSize->IsUint32() ) - { - fontParams.pixelSize.value = pixelSize->ToUint32()->Value(); - fontParams.sizeType = FontParams::USE_PIXEL_SIZE; - } - else if( pointSize->IsUint32() ) - { - fontParams.pointSize.value = pointSize->ToUint32()->Value(); - fontParams.sizeType = FontParams::USE_POINT_SIZE; - } - else if( capsHeight->IsUint32() ) - { - fontParams.capsSize.value = capsHeight->ToUint32()->Value(); - fontParams.sizeType = FontParams::USE_CAP_SIZE; - } - -} - -Font FontApi::New( const v8::FunctionCallbackInfo< v8::Value >& args ) -{ - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope handleScope( isolate ); - - // if no parameters just create a default font - if ( args.Length() == 0) - { - return Font::New(); - } - FontParams params; - - ReadFontParameters( isolate, args[0], params ); - - FontParameters fontParams; - // construct a dali font parameters object - switch( params.sizeType) - { - case FontParams::USE_PIXEL_SIZE: - { - fontParams = FontParameters( params.family, params.style, params.pixelSize ); - break; - } - case FontParams::USE_POINT_SIZE: - { - fontParams = FontParameters( params.family, params.style, params.pointSize ); - break; - } - case FontParams::USE_CAP_SIZE: - { - fontParams = FontParameters( params.family, params.style, params.capsSize ); - break; - } - default: - { - fontParams = FontParameters( params.family, params.style, PointSize(0.f)); - break; - } - } - return Font::New( fontParams ); - -} - - -void FontApi::GetFamilyForText( const v8::FunctionCallbackInfo< v8::Value >& args ) -{ - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope handleScope( isolate ); - - - bool foundString; - std::string text = V8Utils::GetStringParameter( PARAMETER_0, foundString, isolate, args ); - if( !foundString ) - { - DALI_SCRIPT_EXCEPTION( isolate, "bad parameter 0 ( text )" ); - return; - } - std::string family = Font::GetFamilyForText( text ); - - args.GetReturnValue().Set( v8::String::NewFromUtf8( isolate, family.c_str()) ); - -} -void FontApi::GetLineHeightFromCapsHeight( const v8::FunctionCallbackInfo< v8::Value >& args ) -{ - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope handleScope( isolate ); - - FontParams params; - ReadFontParameters( isolate, args[0], params ); - if( params.sizeType != FontParams::USE_CAP_SIZE ) - { - DALI_SCRIPT_EXCEPTION( isolate, "caps height not found" ); - return; - } - - PixelSize size = Font::GetLineHeightFromCapsHeight( params.family, params.style, params.capsSize); - args.GetReturnValue().Set( v8::Integer::New( isolate, size.value ) ); -} - -void FontApi::GetInstalledFonts( const v8::FunctionCallbackInfo< v8::Value >& args ) -{ - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope handleScope( isolate ); - - bool found( false ); - std::vector fontList; - - std::string mode = V8Utils::GetStringParameter( PARAMETER_0, found, isolate, args ); - - if( mode == "LIST_APPLICATION_FONTS" ) - { - fontList = Font::GetInstalledFonts( Font::LIST_APPLICATION_FONTS ); - } - else if( mode == "LIST_ALL_FONTS") - { - fontList = Font::GetInstalledFonts( Font::LIST_ALL_FONTS ); - } - else // default - { - fontList = Font::GetInstalledFonts( Font::LIST_SYSTEM_FONTS ); - } - // create a javascript array - v8::Local array = v8::Array::New(isolate, fontList.size() ); - for( std::size_t i = 0; i < fontList.size(); i++) - { - const char* fontName = fontList[i].c_str(); - array->Set(v8::Integer::New(args.GetIsolate(), i), v8::String::NewFromUtf8( isolate,fontName)); - } - - args.GetReturnValue().Set( array ); -} - -void FontApi::MeasureTextWidth( const v8::FunctionCallbackInfo< v8::Value >& args ) -{ - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope handleScope( isolate ); - Font font = GetFont( isolate, args ); - - //float MeasureTextWidth(const std::string& text, float textHeightPx) const; - - bool found( false ); - std::string text = V8Utils::GetStringParameter( PARAMETER_0, found, isolate, args ); - if(! found ) - { - DALI_SCRIPT_EXCEPTION( isolate, "text not found" ); - return; - } - int height = V8Utils::GetIntegerParameter( PARAMETER_1, found, isolate, args, 0 ); - if( !found ) - { - DALI_SCRIPT_EXCEPTION( isolate, "missing text height" ); - return; - } - float width = font.MeasureTextWidth( text, height ); - - args.GetReturnValue().Set( v8::Integer::New( isolate, width ) ); - -} -void FontApi::MeasureTextHeight( const v8::FunctionCallbackInfo< v8::Value >& args ) -{ - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope handleScope( isolate ); - Font font = GetFont( isolate, args ); - - //float MeasureTextHeight(const std::string& text, float textHeightPx) const; - - bool found( false ); - std::string text = V8Utils::GetStringParameter( PARAMETER_0, found, isolate, args ); - if(! found ) - { - DALI_SCRIPT_EXCEPTION( isolate, "text not found" ); - return; - } - int width= V8Utils::GetIntegerParameter( PARAMETER_1, found, isolate, args, 0 ); - if( !found ) - { - DALI_SCRIPT_EXCEPTION( isolate, "missing text height" ); - return; - } - float height = font.MeasureTextHeight( text, width ); - - args.GetReturnValue().Set( v8::Integer::New( isolate, height ) ); -} -void FontApi::MeasureText( const v8::FunctionCallbackInfo< v8::Value >& args ) -{ - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope handleScope( isolate ); - Font font = GetFont( isolate, args ); - - bool found( false ); - std::string text = V8Utils::GetStringParameter( PARAMETER_0, found, isolate, args ); - if(! found ) - { - DALI_SCRIPT_EXCEPTION( isolate, "text not found" ); - return; - } - - Vector3 vec3 = font.MeasureText( text ); - Dali::Property::Value value( vec3 ); - v8::Local object = PropertyValueWrapper::WrapDaliProperty( isolate, value); - args.GetReturnValue().Set( object ); - -} -void FontApi::AllGlyphsSupported( const v8::FunctionCallbackInfo< v8::Value >& args ) -{ - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope handleScope( isolate ); - Font font = GetFont( isolate, args ); - - bool found( false ); - std::string text = V8Utils::GetStringParameter( PARAMETER_0, found, isolate, args ); - if(! found ) - { - DALI_SCRIPT_EXCEPTION( isolate, "text not found" ); - return; - } - - bool supported = font.AllGlyphsSupported( text ); - args.GetReturnValue().Set( v8::Boolean::New( isolate, supported) ); - -} - -// This one function is use to create a property map, instead of the many individual property -// getters used by the C++ Dali API. -// propertyMap -// { -// name: -// style: -// pointSize: -// pixelSize: -// lineHeight: -// ascender: -// underlineThickness: -// underlinePosition: -// isDefaultSystemFont: -// isDefaultSystemSize: -// } - -void FontApi::GetProperties( const v8::FunctionCallbackInfo< v8::Value >& args ) -{ - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope handleScope( isolate ); - Font font = GetFont( isolate, args ); - - v8::Local keyObject = v8::Object::New( isolate ); - - keyObject->Set( v8::String::NewFromUtf8( isolate, "family" ), v8::String::NewFromUtf8( isolate, font.GetName().c_str() ) ); - keyObject->Set( v8::String::NewFromUtf8( isolate, "style" ), v8::String::NewFromUtf8( isolate, font.GetStyle().c_str() ) ); - keyObject->Set( v8::String::NewFromUtf8( isolate, "pointSize" ), v8::Integer::New( isolate, font.GetPointSize() ) ); - keyObject->Set( v8::String::NewFromUtf8( isolate, "pixelSize" ), v8::Integer::New( isolate, font.GetPixelSize() ) ); - keyObject->Set( v8::String::NewFromUtf8( isolate, "lineHeight" ), v8::Integer::New( isolate, font.GetLineHeight() ) ); - keyObject->Set( v8::String::NewFromUtf8( isolate, "ascender" ), v8::Integer::New( isolate, font.GetAscender() ) ); - keyObject->Set( v8::String::NewFromUtf8( isolate, "underlineThickness" ), v8::Integer::New( isolate, font.GetUnderlineThickness() ) ); - keyObject->Set( v8::String::NewFromUtf8( isolate, "underlinePosition" ), v8::Integer::New( isolate, font.GetUnderlinePosition()) ); - keyObject->Set( v8::String::NewFromUtf8( isolate, "isDefaultSystemFont" ), v8::Boolean::New( isolate, font.IsDefaultSystemFont() ) ); - keyObject->Set( v8::String::NewFromUtf8( isolate, "isDefaultSystemSize" ), v8::Boolean::New( isolate, font.IsDefaultSystemSize() ) ); - - args.GetReturnValue().Set( keyObject ); - -} - -void FontApi::GetMetrics( const v8::FunctionCallbackInfo< v8::Value >& args ) -{ - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope handleScope( isolate ); - Font font = GetFont( isolate, args ); - - bool found( false ); - std::string text = V8Utils::GetStringParameter( PARAMETER_0, found, isolate, args ); - - if(! found ) - { - DALI_SCRIPT_EXCEPTION( isolate, "character not found" ); - return; - } - - Text textObject( text ); - - Font::Metrics metric = font.GetMetrics( textObject[0] ); - - v8::Local keyObject = v8::Object::New( isolate ); - keyObject->Set( v8::String::NewFromUtf8( isolate, "advance" ), v8::Integer::New( isolate, metric.GetAdvance() ) ); - keyObject->Set( v8::String::NewFromUtf8( isolate, "bearing" ), v8::Integer::New( isolate, metric.GetBearing() ) ); - keyObject->Set( v8::String::NewFromUtf8( isolate, "width" ), v8::Integer::New( isolate, metric.GetWidth() ) ); - keyObject->Set( v8::String::NewFromUtf8( isolate, "height" ), v8::Integer::New( isolate, metric.GetHeight() ) ); - - args.GetReturnValue().Set( keyObject ); - -} - - -void FontApi::PointsToPixels( const v8::FunctionCallbackInfo< v8::Value >& args ) -{ - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope handleScope( isolate ); - - bool found(false); - int pointSize= V8Utils::GetIntegerParameter( PARAMETER_0, found, isolate, args, 0 ); - if( !found ) - { - DALI_SCRIPT_EXCEPTION( isolate, "missing pointSize" ); - return; - } - args.GetReturnValue().Set( v8::Integer::New( isolate, Font::PointsToPixels(pointSize) ) ); - -} -void FontApi::PixelsToPoints( const v8::FunctionCallbackInfo< v8::Value >& args ) -{ - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope handleScope( isolate ); - - bool found(false); - int pixelSize= V8Utils::GetIntegerParameter( PARAMETER_0, found, isolate, args, 0 ); - if( !found ) - { - DALI_SCRIPT_EXCEPTION( isolate, "missing pixelSize" ); - return; - } - args.GetReturnValue().Set( v8::Integer::New( isolate, Font::PixelsToPoints(pixelSize) ) ); -} - - - -} // namespace V8Plugin - -} // namespace Dali diff --git a/plugins/dali-script-v8/src/text/font-api.h b/plugins/dali-script-v8/src/text/font-api.h deleted file mode 100644 index 129c240..0000000 --- a/plugins/dali-script-v8/src/text/font-api.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef __DALI_V8PLUGIN_FONT_API_H__ -#define __DALI_V8PLUGIN_FONT_API_H__ - -/* - * Copyright (c) 2015 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// EXTERNAL INCLUDES -#include -#include - - -namespace Dali -{ - -namespace V8Plugin -{ - -namespace FontApi -{ - Font GetFont( v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args ); - Font GetFont( v8::Isolate* isolate, v8::Local& value ); - - Font GetFontFromParams( int paramIndex, - bool& found, - v8::Isolate* isolate, - const v8::FunctionCallbackInfo< v8::Value >& args ); - - /** - * Constructor - */ - Font New( const v8::FunctionCallbackInfo< v8::Value >& args ); - - /** - * Font API see image.h for a description - */ - void GetFamilyForText( const v8::FunctionCallbackInfo< v8::Value >& args ); - void GetLineHeightFromCapsHeight( const v8::FunctionCallbackInfo< v8::Value >& args ); - void GetInstalledFonts( const v8::FunctionCallbackInfo< v8::Value >& args ); - void MeasureTextWidth( const v8::FunctionCallbackInfo< v8::Value >& args ); - void MeasureTextHeight( const v8::FunctionCallbackInfo< v8::Value >& args ); - void MeasureText( const v8::FunctionCallbackInfo< v8::Value >& args ); - void AllGlyphsSupported( const v8::FunctionCallbackInfo< v8::Value >& args ); - void GetProperties( const v8::FunctionCallbackInfo< v8::Value >& args ); - void GetMetrics( const v8::FunctionCallbackInfo< v8::Value >& args ); - void PointsToPixels( const v8::FunctionCallbackInfo< v8::Value >& args ); - void PixelsToPoints( const v8::FunctionCallbackInfo< v8::Value >& args ); - -}; // namespace FontApi - -} // namespace V8Plugin - -} // namespace Dali - -#endif // header __DALI_V8PLUGIN_FONT_API_H__ diff --git a/plugins/dali-script-v8/src/text/font-wrapper.cpp b/plugins/dali-script-v8/src/text/font-wrapper.cpp deleted file mode 100644 index 9760f51..0000000 --- a/plugins/dali-script-v8/src/text/font-wrapper.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (c) 2015 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// CLASS HEADER -#include "font-wrapper.h" - -// INTERNAL INCLUDES -#include -#include -#include -#include -#include - -namespace Dali -{ - -namespace V8Plugin -{ - -namespace // un-named name space -{ - -/** - * Contains a list of all functions that can be called on the font object - */ -const ApiFunction FontFunctionTable[]= -{ - /************************************** - * Font API (in order of font.h) - **************************************/ - { "MeasureTextWidth", FontApi::MeasureTextWidth }, - { "MeasureTextHeight", FontApi::MeasureTextHeight }, - { "MeasureText", FontApi::MeasureText }, - { "AllGlyphsSupported", FontApi::AllGlyphsSupported }, - { "GetProperties", FontApi::GetProperties }, // replace all getters - { "GetMetrics", FontApi::GetMetrics }, -}; - -const unsigned int FontFunctionTableCount = sizeof(FontFunctionTable)/sizeof(FontFunctionTable[0]); - -/** - * Contains a list of all functions that can be called - */ -const ApiFunction StaticFontFunctionTable[]= -{ - /************************************** - * Static font functions, called without a font object - **************************************/ - { "GetFamilyForText", FontApi::GetFamilyForText }, - { "GetLineHeightFromCapsHeight", FontApi::GetLineHeightFromCapsHeight }, - { "GetInstalledFonts", FontApi::GetInstalledFonts }, - { "PointsToPixels", FontApi::PointsToPixels }, - { "PixelsToPoints", FontApi::PixelsToPoints }, -}; - -const unsigned int StaticFontFunctionTableCount = sizeof(StaticFontFunctionTable)/sizeof(FontFunctionTable[0]); - -} //un-named space - - -FontWrapper::FontWrapper( const Dali::Font& font, GarbageCollectorInterface& gc ) -: BaseWrappedObject( BaseWrappedObject::FONT , gc ) -{ - mFont = font; -} - -v8::Handle FontWrapper::WrapFont(v8::Isolate* isolate, const Dali::Font& font ) -{ - v8::EscapableHandleScope handleScope( isolate ); - v8::Local objectTemplate; - - objectTemplate = MakeFontTemplate( isolate ); - - // create an instance of the template - v8::Local localObject = objectTemplate->NewInstance(); - - // create the Font wrapper - FontWrapper* pointer = new FontWrapper( font, Dali::V8Plugin::DaliWrapper::Get().GetDaliGarbageCollector() ); - - // assign the JavaScript object to the wrapper. - pointer->SetJavascriptObject( isolate, localObject ); - - printf("Created Font!\n"); - return handleScope.Escape( localObject ); -} - - -v8::Handle FontWrapper::MakeFontTemplate( v8::Isolate* isolate ) -{ - v8::EscapableHandleScope handleScope( isolate ); - - v8::Local objTemplate = v8::ObjectTemplate::New(); - - objTemplate->SetInternalFieldCount( BaseWrappedObject::FIELD_COUNT ); - - // add our function properties - ObjectTemplateHelper::InstallFunctions( isolate, objTemplate, FontFunctionTable, FontFunctionTableCount ); - - return handleScope.Escape( objTemplate ); -} - -void FontWrapper::NewFont( const v8::FunctionCallbackInfo< v8::Value >& args) -{ - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope handleScope( isolate); - - if(!args.IsConstructCall()) - { - DALI_SCRIPT_EXCEPTION( isolate, "Font constructor called without 'new'"); - return; - } - - // attribs can be passed by value - Dali::Font font = FontApi::New( args ); - if( !font ) - { - DALI_SCRIPT_EXCEPTION( isolate, "bad font parameters\n"); - return; - } - - v8::Local localObject = WrapFont( isolate, font ); - args.GetReturnValue().Set( localObject ); -} - -Font FontWrapper::GetFont() -{ - return mFont; -} - -v8::Handle FontWrapper::GetStaticFontObject(v8::Isolate* isolate) -{ - v8::EscapableHandleScope handleScope( isolate ); - - v8::Local objTemplate = v8::ObjectTemplate::New(); - - // add our functions properties - ObjectTemplateHelper::InstallFunctions( isolate, objTemplate, StaticFontFunctionTable, StaticFontFunctionTableCount ); - - v8::Local localObject = objTemplate->NewInstance(); - - return handleScope.Escape( localObject ); - - } - - -} // namespace V8Plugin - -} // namespace Dali diff --git a/plugins/dali-script-v8/src/text/font-wrapper.h b/plugins/dali-script-v8/src/text/font-wrapper.h deleted file mode 100644 index 328416a..0000000 --- a/plugins/dali-script-v8/src/text/font-wrapper.h +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef __DALI_V8PLUGIN_FONT_WRAPPER_H__ -#define __DALI_V8PLUGIN_FONT_WRAPPER_H__ - -/* - * Copyright (c) 2015 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// EXTERNAL INCLUDES -#include -#include - -// INTERNAL INCLUDES -#include - -namespace Dali -{ - -namespace V8Plugin -{ - - -/** - * An Font wrapper. - * Provides access to Font specific functionality and V8 memory handling. - */ -class FontWrapper : public BaseWrappedObject -{ - -public: - - FontWrapper( const Font& font, - GarbageCollectorInterface& gc ); - - virtual ~FontWrapper() - { - }; - - /** - * @brief Creates a new Font wrapped inside a Javascript Object. - * @note: the actor type ie 'FontFont' is expected to be the name of the callee function. - * @param[in] args v8 function call arguments interpreted - */ - static void NewFont( const v8::FunctionCallbackInfo< v8::Value >& args); - - /** - * Wraps a font - */ - static v8::Handle WrapFont(v8::Isolate* isolate, const Dali::Font& ); - - Font GetFont(); - - static v8::Handle GetStaticFontObject(v8::Isolate* isolate); - -private: - - Font mFont; - static v8::Handle MakeFontTemplate( v8::Isolate* isolate ); - -}; - -} // namespace V8Plugin - -} // namespace Dali - -#endif // __DALI_V8PLUGIN_FONT_WRAPPER_H__ diff --git a/plugins/dali-script-v8/src/toolkit/builder/builder-api.cpp b/plugins/dali-script-v8/src/toolkit/builder/builder-api.cpp index 7feb259..3c499a4 100644 --- a/plugins/dali-script-v8/src/toolkit/builder/builder-api.cpp +++ b/plugins/dali-script-v8/src/toolkit/builder/builder-api.cpp @@ -32,7 +32,6 @@ #include #include #include -#include #include @@ -293,11 +292,6 @@ void BuilderApi::Create( const v8::FunctionCallbackInfo< v8::Value >& args ) v8::Local image = ImageWrapper::WrapImage(isolate, Image::DownCast(handle) ); args.GetReturnValue().Set( image ); } - if( typeName == "Font ") - { - v8::Local font = FontWrapper::WrapFont(isolate, Font::DownCast(handle) ); - args.GetReturnValue().Set( font ); - } if( typeName == "Shader") { v8::Local shader = ShaderEffectWrapper::WrapShaderEffect(isolate, ShaderEffect::DownCast( handle )); diff --git a/plugins/dali-script-v8/src/utils/v8-utils.cpp b/plugins/dali-script-v8/src/utils/v8-utils.cpp index 1d73b9c..d9fbc7e 100644 --- a/plugins/dali-script-v8/src/utils/v8-utils.cpp +++ b/plugins/dali-script-v8/src/utils/v8-utils.cpp @@ -332,7 +332,7 @@ bool GetBooleanValue( v8::Isolate* isolate, const v8::Local& value ) else if (value->IsBooleanObject() ) { const v8::Local object = v8::Local::Cast(value); - return object->ValueOf(); + return object->BooleanValue(); } DALI_SCRIPT_EXCEPTION(isolate, "no bool found"); return false;