Commit c6fe710150fe1e7993354a87fb6a75399c3f321f

Authored by Victor Cebollada
2 parents 971b11c1 4b770add

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

Change-Id: Ic91b7ad6783570986e202b20c11104cc379de612
Showing 68 changed files with 3408 additions and 31 deletions
build/tizen/CMakeLists.txt
... ... @@ -29,6 +29,7 @@ ENDIF()
29 29  
30 30 SET(RESOURCE_DIR ${ROOT_SRC_DIR}/resources)
31 31 SET(LOCAL_IMAGES_DIR ${RESOURCE_DIR}/images)
  32 +SET(LOCAL_GAME_DIR ${RESOURCE_DIR}/game)
32 33 SET(LOCAL_VIDEOS_DIR ${RESOURCE_DIR}/videos)
33 34 SET(LOCAL_MODELS_DIR ${RESOURCE_DIR}/models)
34 35 SET(LOCAL_SCRIPTS_DIR ${RESOURCE_DIR}/scripts)
... ... @@ -37,6 +38,7 @@ IF(NOT DEFINED LOCAL_STYLE_DIR)
37 38 ENDIF()
38 39  
39 40 SET(IMAGES_DIR ${APP_DATA_RES_DIR}/images/)
  41 +SET(GAME_DIR ${APP_DATA_RES_DIR}/game/)
40 42 SET(VIDEOS_DIR ${APP_DATA_RES_DIR}/videos/)
41 43 SET(MODELS_DIR ${APP_DATA_RES_DIR}/models/)
42 44 SET(SCRIPTS_DIR ${APP_DATA_RES_DIR}/scripts/)
... ... @@ -46,6 +48,7 @@ IF(NOT DEFINED LOCALE_DIR)
46 48 SET(LOCALE_DIR ${PREFIX}/share/locale)
47 49 ENDIF()
48 50  
  51 +SET(DEMO_GAME_DIR \\"${GAME_DIR}\\")
49 52 SET(DEMO_IMAGE_DIR \\"${IMAGES_DIR}\\")
50 53 SET(DEMO_VIDEO_DIR \\"${VIDEOS_DIR}\\")
51 54 SET(DEMO_MODEL_DIR \\"${MODELS_DIR}\\")
... ... @@ -88,6 +91,11 @@ FOREACH(flag ${LOCAL_SCRIPTS_LIST})
88 91 INSTALL(FILES ${LOCAL_SCRIPTS_DIR}/${flag} DESTINATION ${SCRIPTS_DIR})
89 92 ENDFOREACH(flag)
90 93  
  94 +FILE(GLOB LOCAL_GAME_LIST RELATIVE "${LOCAL_GAME_DIR}" "${LOCAL_GAME_DIR}/*.*")
  95 +FOREACH(flag ${LOCAL_GAME_LIST})
  96 + INSTALL(FILES ${LOCAL_GAME_DIR}/${flag} DESTINATION ${GAME_DIR})
  97 +ENDFOREACH(flag)
  98 +
91 99 #Create resources location file
92 100 CONFIGURE_FILE( resources-location.in ${DEMO_SHARED}/resources-location.cpp )
93 101  
... ... @@ -122,7 +130,7 @@ FOREACH(flag ${REQUIRED_PKGS_CFLAGS})
122 130 SET(REQUIRED_CFLAGS "${REQUIRED_CFLAGS} ${flag}")
123 131 ENDFOREACH(flag)
124 132  
125   -SET(DALI_DEMO_CFLAGS "-DDEMO_IMAGE_DIR=${DEMO_IMAGE_DIR} -DDEMO_VIDEO_DIR=${DEMO_VIDEO_DIR} -DDEMO_MODEL_DIR=${DEMO_MODEL_DIR} -DDEMO_SCRIPT_DIR=${DEMO_SCRIPT_DIR} -DDEMO_STYLE_DIR=${DEMO_STYLE_DIR} -DDEMO_THEME_PATH=${DEMO_THEME_PATH} -DDEMO_EXAMPLE_BIN=${DEMO_EXAMPLE_BIN} -DDEMO_LOCALE_DIR=${DEMO_LOCALE_DIR} -fvisibility=hidden -DHIDE_DALI_INTERNALS -DDEMO_LANG=${DEMO_LANG}")
  133 +SET(DALI_DEMO_CFLAGS "-DDEMO_GAME_DIR=${DEMO_GAME_DIR} -DDEMO_IMAGE_DIR=${DEMO_IMAGE_DIR} -DDEMO_VIDEO_DIR=${DEMO_VIDEO_DIR} -DDEMO_MODEL_DIR=${DEMO_MODEL_DIR} -DDEMO_SCRIPT_DIR=${DEMO_SCRIPT_DIR} -DDEMO_STYLE_DIR=${DEMO_STYLE_DIR} -DDEMO_THEME_PATH=${DEMO_THEME_PATH} -DDEMO_EXAMPLE_BIN=${DEMO_EXAMPLE_BIN} -DDEMO_LOCALE_DIR=${DEMO_LOCALE_DIR} -fvisibility=hidden -DHIDE_DALI_INTERNALS -DDEMO_LANG=${DEMO_LANG}")
126 134  
127 135 ###########################################################################
128 136 # Internationalization
... ...
com.samsung.dali-demo.xml
... ... @@ -172,4 +172,7 @@
172 172 <ui-application appid="contact-cards.example" exec="/usr/apps/com.samsung.dali-demo/bin/contact-cards.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
173 173 <label>Contact Cards</label>
174 174 </ui-application>
  175 + <ui-application appid="fpp-game.example" exec="/usr/apps/com.samsung.dali-demo/bin/fpp-game.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
  176 + <label>First Person Camera Game</label>
  177 + </ui-application>
175 178 </manifest>
... ...
demo/dali-demo.cpp
... ... @@ -84,6 +84,7 @@ int DALI_EXPORT_API main(int argc, char **argv)
84 84 demo.AddExample(Example("sparkle.example", DALI_DEMO_STR_TITLE_SPARKLE));
85 85 demo.AddExample(Example("progress-bar.example", DALI_DEMO_STR_TITLE_PROGRESS_BAR));
86 86 demo.AddExample(Example("contact-cards.example", DALI_DEMO_STR_TITLE_CONTACT_CARDS));
  87 + demo.AddExample(Example("fpp-game.example", DALI_DEMO_STR_TITLE_FPP_GAME));
87 88  
88 89 demo.SortAlphabetically( true );
89 90  
... ...
examples/fpp-game/fpp-game-example.cpp 0 → 100644
  1 +/*
  2 + * Copyright (c) 2016 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 +#include "game-renderer.h"
  19 +#include "game-model.h"
  20 +#include "game-texture.h"
  21 +#include "game-scene.h"
  22 +
  23 +#include "fpp-game-tutorial-controller.h"
  24 +
  25 +#include <dali-toolkit/dali-toolkit.h>
  26 +
  27 +using namespace Dali;
  28 +
  29 +namespace
  30 +{
  31 +
  32 +const char* SCENE_URL =
  33 +{
  34 + DEMO_GAME_DIR "/scene.json"
  35 +};
  36 +
  37 +}
  38 +/* This example creates 3D environment with first person camera control
  39 + It contains following modules:
  40 +
  41 + GameScene - responsible for loading and managing the scene data,
  42 + it wraps around stage. Owns list of entities. Scene can be deserialised
  43 + from json file ( see scene.json )
  44 + GameEntity - the renderable object that has also a transformation. It wraps DALi actors.
  45 +
  46 + GameModel - loads models ( '.mod' file format ) and wraps DALi Geometry object. 'mod' format
  47 + is binary in order
  48 +
  49 + GameTexture - manages textures. Loads them, creates samplers and wraps DALi TextureSet
  50 +
  51 + GameRenderer - binds texture and model. It's created per entity. While renderer is always unique
  52 + for entity, the texture and model may be reused
  53 +
  54 + GameCamera - Wraps the CameraActor. It provides not only that but also handles user input and
  55 + implements first-person-perspective camera behavior.
  56 + GameCamera uses Dali::Timer to provide per-frame ( or rather every 16ms ) update tick.
  57 +
  58 +
  59 + .-----------.
  60 + .---------------| GameScene |---------------.
  61 + | '-----------' |
  62 + | | |
  63 + v | v
  64 + .------------. .------------.|.------------. .------------.
  65 + | GameEntity | | GameEntity |v| ... | | GameEntity |
  66 + '------------' '------------' '------------' '------------'
  67 + |
  68 + v
  69 + .--------------.
  70 + | GameRenderer |
  71 + '--------------'
  72 + |
  73 + <------'-------->
  74 +.--------------. .--------------.
  75 +| GameTexture | | GameModel |
  76 +'--------------' '--------------'
  77 + */
  78 +class GameController : public ConnectionTracker
  79 +{
  80 +public:
  81 +
  82 + GameController( Application& application )
  83 + : mApplication( application )
  84 + {
  85 + // Connect to the Application's Init signal
  86 + mApplication.InitSignal().Connect( this, &GameController::Create );
  87 + }
  88 +
  89 + ~GameController()
  90 + {
  91 + }
  92 +
  93 + // The Init signal is received once (only) during the Application lifetime
  94 + void Create( Application& application )
  95 + {
  96 + // Disable indicator
  97 + Dali::Window winHandle = application.GetWindow();
  98 + winHandle.ShowIndicator( Dali::Window::INVISIBLE );
  99 +
  100 + // Get a handle to the stage
  101 + mStage = Stage::GetCurrent();
  102 +
  103 + mStage.SetBackgroundColor( Color::BLACK );
  104 +
  105 + // Use 3D layer
  106 + mStage.GetRootLayer().SetBehavior( Layer::LAYER_3D );
  107 +
  108 + // Load game scene
  109 + mScene.Load( SCENE_URL );
  110 +
  111 + // Display tutorial
  112 + mTutorialController.DisplayTutorial();
  113 +
  114 + // Connect OnKeyEvent signal
  115 + mStage.KeyEventSignal().Connect( this, &GameController::OnKeyEvent );
  116 + }
  117 +
  118 + // Handle a quit key event
  119 + void OnKeyEvent(const KeyEvent& event)
  120 + {
  121 + if(event.state == KeyEvent::Down)
  122 + {
  123 + if( IsKey( event, Dali::DALI_KEY_ESCAPE) || IsKey( event, Dali::DALI_KEY_BACK) )
  124 + {
  125 + mApplication.Quit();
  126 + }
  127 + }
  128 + }
  129 +
  130 +private:
  131 +
  132 + Application& mApplication;
  133 + GameScene mScene;
  134 + Stage mStage;
  135 + FppGameTutorialController mTutorialController;
  136 +};
  137 +
  138 +void RunTest( Application& application )
  139 +{
  140 + GameController test( application );
  141 +
  142 + application.MainLoop();
  143 +}
  144 +
  145 +// Entry point for Linux & Tizen applications
  146 +//
  147 +int DALI_EXPORT_API main( int argc, char **argv )
  148 +{
  149 + Application application = Application::New( &argc, &argv );
  150 +
  151 + RunTest( application );
  152 +
  153 + return 0;
  154 +}
... ...
examples/fpp-game/fpp-game-tutorial-controller.cpp 0 → 100644
  1 +/*
  2 + * Copyright (c) 2016 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 +#include "fpp-game-tutorial-controller.h"
  19 +
  20 +#include <dali/public-api/events/touch-data.h>
  21 +#include <dali/public-api/animation/animation.h>
  22 +#include <dali/public-api/actors/camera-actor.h>
  23 +#include <dali/public-api/render-tasks/render-task-list.h>
  24 +
  25 +using namespace Dali;
  26 +using namespace Dali::Toolkit;
  27 +
  28 +FppGameTutorialController::FppGameTutorialController()
  29 +: mLeftTutorialComplete( false ),
  30 + mRightTutorialComplete( false )
  31 +{
  32 +
  33 +}
  34 +
  35 +FppGameTutorialController::~FppGameTutorialController()
  36 +{
  37 +
  38 +}
  39 +
  40 +void FppGameTutorialController::OnTouch( const TouchData& touchEvent )
  41 +{
  42 + Vector2 size( mStage.GetSize() );
  43 +
  44 + bool isLandscape( size.x > size.y );
  45 +
  46 + if( !isLandscape )
  47 + {
  48 + std::swap( size.x, size.y );
  49 + }
  50 +
  51 + Vector2 sizeHalf( size * 0.5f );
  52 +
  53 + for( size_t i = 0; i < touchEvent.GetPointCount(); ++i )
  54 + {
  55 + Vector2 pos = touchEvent.GetScreenPosition( i );
  56 + if( !isLandscape )
  57 + {
  58 + std::swap( pos.x, pos.y );
  59 + }
  60 +
  61 + // left label touched
  62 + if( touchEvent.GetState( i ) == PointState::STARTED )
  63 + {
  64 + if( pos.x < sizeHalf.x && !mLeftTutorialComplete )
  65 + {
  66 + mLeftTutorialComplete = true;
  67 + Animation animation = Animation::New( 1.0f );
  68 + animation.AnimateTo( Property( mLeftLabel, Actor::Property::COLOR_ALPHA ), 0.0f );
  69 +
  70 + // connect complete signal
  71 + if( mRightTutorialComplete )
  72 + {
  73 + animation.FinishedSignal().Connect( this, &FppGameTutorialController::OnTutorialComplete );
  74 + }
  75 + animation.Play();
  76 + }
  77 + // right label touched
  78 + else if( !mRightTutorialComplete )
  79 + {
  80 + mRightTutorialComplete = true;
  81 + Animation animation = Animation::New( 1.0f );
  82 + animation.AnimateTo( Property( mRightLabel, Actor::Property::COLOR_ALPHA ), 0.0f );
  83 + // connect complete signal
  84 + if( mLeftTutorialComplete )
  85 + {
  86 + animation.FinishedSignal().Connect( this, &FppGameTutorialController::OnTutorialComplete );
  87 + }
  88 + animation.Play();
  89 + }
  90 + }
  91 + }
  92 +}
  93 +
  94 +void FppGameTutorialController::DisplayTutorial()
  95 +{
  96 + mStage = Stage::GetCurrent();
  97 +
  98 + Vector2 stageSize( mStage.GetSize() );
  99 + bool isLandscape( stageSize.x > stageSize.y );
  100 + if( !isLandscape )
  101 + {
  102 + std::swap( stageSize.x, stageSize.y );
  103 + }
  104 +
  105 + mUiRoot = Actor::New();
  106 + mStage.Add( mUiRoot );
  107 +
  108 + // left tutorial text label
  109 + mLeftLabel = Toolkit::TextLabel::New("Touch here to walk");
  110 + mLeftLabel.SetParentOrigin( ParentOrigin::CENTER );
  111 + mLeftLabel.SetAnchorPoint( AnchorPoint::CENTER );
  112 + mLeftLabel.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
  113 + mLeftLabel.SetSize( Vector3( stageSize.x*0.5, stageSize.y, 1.0f ) );
  114 + mLeftLabel.SetProperty( Toolkit::Control::Property::BACKGROUND_COLOR, Vector4( 0.0, 0.0, 0.7, 0.2 ));
  115 + mLeftLabel.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) ); // White.
  116 + mLeftLabel.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
  117 + mLeftLabel.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
  118 +
  119 + // right tutorial text label
  120 + mRightLabel = Toolkit::TextLabel::New("Touch here to look around");
  121 + mRightLabel.SetParentOrigin( ParentOrigin::CENTER );
  122 + mRightLabel.SetAnchorPoint( AnchorPoint::CENTER );
  123 + mRightLabel.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
  124 + mRightLabel.SetSize( Vector3( stageSize.x*0.5, stageSize.y, 1.0f ) );
  125 + mRightLabel.SetProperty( Toolkit::Control::Property::BACKGROUND_COLOR, Vector4( 0.5, 0.0, 0.0, 0.2 ));
  126 + mRightLabel.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) ); // White.
  127 + mRightLabel.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
  128 + mRightLabel.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
  129 +
  130 + // create camera dedicated to be used with UI controls
  131 + CameraActor uiCamera = CameraActor::New();
  132 + mTutorialRenderTask = mStage.GetRenderTaskList().CreateTask();
  133 + mTutorialRenderTask.SetCameraActor( uiCamera );
  134 + mTutorialRenderTask.SetClearEnabled( false );
  135 + mTutorialRenderTask.SetSourceActor( mUiRoot );
  136 + mTutorialRenderTask.SetExclusive( true );
  137 +
  138 + if( !isLandscape )
  139 + {
  140 + uiCamera.RotateBy( Degree(90.0f), Vector3( 0.0f, 0.0f, 1.0f ));
  141 + }
  142 +
  143 + mLeftLabel.SetPosition( Vector3( -stageSize.x*0.25f, 0.0, 0.0 ) );
  144 + mRightLabel.SetPosition( Vector3( stageSize.x*0.25f, 0.0, 0.0 ) );
  145 +
  146 + mUiRoot.Add( mLeftLabel );
  147 + mUiRoot.Add( mRightLabel );
  148 + mStage.Add( uiCamera );
  149 +
  150 + Animation animation = Animation::New( 1.0f );
  151 + animation.AnimateTo( Property( mLeftLabel, Actor::Property::COLOR_ALPHA ), 1.0f, AlphaFunction::EASE_OUT );
  152 + animation.AnimateTo( Property( mRightLabel, Actor::Property::COLOR_ALPHA ), 1.0f, AlphaFunction::EASE_OUT );
  153 +
  154 + animation.FinishedSignal().Connect( this, &FppGameTutorialController::OnTutorialAnimationFinished );
  155 +
  156 + animation.Play();
  157 +}
  158 +
  159 +void FppGameTutorialController::OnTutorialAnimationFinished( Animation& animation )
  160 +{
  161 + // touch signal will wait for a single touch on each side of screen
  162 + mStage.TouchSignal().Connect( this, &FppGameTutorialController::OnTouch );
  163 +}
  164 +
  165 +void FppGameTutorialController::OnTutorialComplete( Animation& animation )
  166 +{
  167 + mStage.Remove( mUiRoot );
  168 + mUiRoot.Reset();
  169 + mStage.GetRenderTaskList().RemoveTask( mTutorialRenderTask );
  170 +}
  171 +
... ...
examples/fpp-game/fpp-game-tutorial-controller.h 0 → 100644
  1 +#ifndef FPPGAMETUTORIAL_H
  2 +#define FPPGAMETUTORIAL_H
  3 +
  4 +/*
  5 + * Copyright (c) 2016 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 +#include <dali/public-api/actors/actor.h>
  22 +#include <dali/public-api/render-tasks/render-task.h>
  23 +#include <dali/public-api/common/stage.h>
  24 +#include <dali/public-api/signals/connection-tracker.h>
  25 +#include <dali-toolkit/public-api/controls/text-controls/text-label.h>
  26 +
  27 +class FppGameTutorialController : public Dali::ConnectionTracker
  28 +{
  29 +public:
  30 +
  31 + /**
  32 + * Creates new instance of FppGameTutorialController
  33 + */
  34 + FppGameTutorialController();
  35 +
  36 + /**
  37 + * Destroys instance of FppGameTutorialController
  38 + */
  39 + ~FppGameTutorialController();
  40 +
  41 + /**
  42 + * Displays UI with tutorial
  43 + */
  44 + void DisplayTutorial();
  45 +
  46 + /**
  47 + * Handles tutorial touch input
  48 + * @param[in] touchEvent Incoming touch event in the UI space
  49 + */
  50 + void OnTouch( const Dali::TouchData& touchEvent );
  51 +
  52 + /**
  53 + * Handles tutorial animation finished signal
  54 + * @param[in] animation Animation object
  55 + */
  56 + void OnTutorialAnimationFinished( Dali::Animation& animation );
  57 +
  58 + /**
  59 + * Handles tutorial completion stage
  60 + * @param animation Animation object
  61 + */
  62 + void OnTutorialComplete( Dali::Animation& animation );
  63 +
  64 +private:
  65 +
  66 + Dali::RenderTask mTutorialRenderTask; /// RenderTask associated with rendering tutorial
  67 + Dali::Actor mUiRoot; /// The parent actor for tutorial UI
  68 + Dali::Toolkit::TextLabel mLeftLabel; /// Text label displaying left message
  69 + Dali::Toolkit::TextLabel mRightLabel; /// Text label displaying right message
  70 + bool mLeftTutorialComplete; /// Flag indicating the walk (left) tutorial action has been performed
  71 + bool mRightTutorialComplete; /// Flag indicating the look (right) tutorial action has been performed
  72 + Dali::Stage mStage;
  73 +};
  74 +
  75 +#endif // FPPGAMETUTORIAL_H
... ...
examples/fpp-game/game-camera.cpp 0 → 100644
  1 +/*
  2 + * Copyright (c) 2016 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 +#include "game-camera.h"
  19 +
  20 +#include <dali/public-api/common/stage.h>
  21 +#include <dali/public-api/render-tasks/render-task-list.h>
  22 +#include <dali/public-api/render-tasks/render-task.h>
  23 +#include <dali/public-api/events/touch-data.h>
  24 +#include <dali/public-api/events/touch-event.h>
  25 +
  26 +using namespace Dali;
  27 +
  28 +namespace
  29 +{
  30 +// Input sensitivity, the larger value, the more sensitive input
  31 +// Default value has been chosen empirically
  32 +const float CAMERA_SENSITIVITY ( 90.0f );
  33 +
  34 +// Vertical angle limit of the camera
  35 +const float CAMERA_VERTICAL_LIMIT ( 80.0f );
  36 +
  37 +// Position where camera is instantiated by default
  38 +const Vector3 CAMERA_DEFAULT_POSITION ( 1.0f, -1.5f, -3.0f );
  39 +
  40 +// Field-of-View in degrees
  41 +const float CAMERA_DEFAULT_FOV ( 60.0f );
  42 +
  43 +// Near plane
  44 +const float CAMERA_DEFAULT_NEAR ( 0.1f );
  45 +
  46 +// Far plane
  47 +const float CAMERA_DEFAULT_FAR ( 100.0f );
  48 +
  49 +// Default forward vector
  50 +const Vector3 CAMERA_FORWARD ( 0.0f, 0.0f, 1.0f );
  51 +
  52 +// Default up vector
  53 +const Vector3 CAMERA_UP ( Vector3::YAXIS );
  54 +}
  55 +
  56 +GameCamera::GameCamera()
  57 +: mFovY( CAMERA_DEFAULT_FOV ),
  58 + mNear( CAMERA_DEFAULT_NEAR ),
  59 + mFar( CAMERA_DEFAULT_FAR ),
  60 + mWalkingTouchId( -1 ),
  61 + mLookingTouchId( -1 ),
  62 + mPortraitMode( false )
  63 +{
  64 +}
  65 +
  66 +GameCamera::~GameCamera()
  67 +{
  68 + mTimer.Stop();
  69 + mCameraActor.Remove( mInterceptorActor );
  70 +}
  71 +
  72 +void GameCamera::Initialise( float fovY, float near, float far )
  73 +{
  74 + mFovY = fovY;
  75 + mNear = near;
  76 + mFar = far;
  77 +
  78 + Vector2 stageSize = Stage::GetCurrent().GetSize();
  79 + mPortraitMode = stageSize.x < stageSize.y ? true : false;
  80 +
  81 + // Initialise default camera
  82 + InitialiseDefaultCamera();
  83 +
  84 + // Create input interceptor actor
  85 + CreateInterceptorActor();
  86 +
  87 + // Start timer
  88 + mTimer = Timer::New( 16 );
  89 + mTimer.TickSignal().Connect( this, &GameCamera::OnTick );
  90 + mTimer.Start();
  91 +}
  92 +
  93 +bool GameCamera::OnTick()
  94 +{
  95 + Vector2 stageSize = Stage::GetCurrent().GetSize();
  96 +
  97 + // ---------------------------------------------------------------------
  98 + // update rotation
  99 + Vector2 tmp( mScreenLookDelta );
  100 + mScreenLookDelta = Vector2::ZERO;
  101 +
  102 + if( mPortraitMode )
  103 + {
  104 + float yaw = ( (tmp.y / stageSize.y ) * CAMERA_SENSITIVITY );
  105 + float pitch = ( (tmp.x / stageSize.x ) * CAMERA_SENSITIVITY );
  106 + mCameraYawPitch.y -= yaw;
  107 + mCameraYawPitch.x -= pitch;
  108 + if( abs( mCameraYawPitch.y ) > CAMERA_VERTICAL_LIMIT )
  109 + {
  110 + mCameraYawPitch.y = CAMERA_VERTICAL_LIMIT * ((mCameraYawPitch.y < 0) ? -1.0f : 1.0f );
  111 + }
  112 + }
  113 + else
  114 + {
  115 + float yaw = ( (tmp.y / stageSize.x ) * CAMERA_SENSITIVITY );
  116 + float pitch = ( (tmp.x / stageSize.y ) * CAMERA_SENSITIVITY );
  117 + mCameraYawPitch.x -= yaw;
  118 + mCameraYawPitch.y -= pitch;
  119 + if( abs( mCameraYawPitch.x ) > CAMERA_VERTICAL_LIMIT )
  120 + {
  121 + mCameraYawPitch.x = CAMERA_VERTICAL_LIMIT * ((mCameraYawPitch.x < 0) ? -1.0f : 1.0f );
  122 + }
  123 + }
  124 +
  125 + Quaternion rotation;
  126 + Quaternion rotX( Degree( mCameraYawPitch.x), Vector3( 1.0f, 0.0f, 0.0f ) );
  127 + Quaternion rotY( Degree( mCameraYawPitch.y), Vector3( 0.0f, 1.0f, 0.0f ) );
  128 + if (mPortraitMode )
  129 + {
  130 + Quaternion rotZ( Degree( mPortraitMode ? 90.0 : 0.0f), Vector3( 0.0f, 0.0f, 1.0f ) );
  131 + rotation = ( rotZ * rotX * rotY );
  132 + }
  133 + else
  134 + {
  135 + rotation = ( rotY * rotX );
  136 + }
  137 + mCameraActor.SetOrientation( rotation );
  138 +
  139 + // ---------------------------------------------------------------------
  140 + // update position
  141 + Vector3 position( mCameraPosition );
  142 +
  143 + // Rotate CAMERA_FORWARD vector
  144 + Vector3 forwardVector = rotation.Rotate( CAMERA_FORWARD );
  145 +
  146 + // Cancel vertical movement
  147 + forwardVector.y = 0.0f;
  148 +
  149 + // Normalize
  150 + forwardVector.Normalize();
  151 +
  152 + // compute sideways vector
  153 + Vector3 sidewaysVector = forwardVector.Cross( CAMERA_UP );
  154 +
  155 + sidewaysVector.Normalize();
  156 +
  157 + const float forwardSpeed( mScreenWalkDelta.y / stageSize.y );
  158 + const float sidewaysSpeed( mScreenWalkDelta.x / stageSize.x );
  159 +
  160 + // Adjust walking speed
  161 + if ( mPortraitMode )
  162 + {
  163 + position += forwardVector * (forwardSpeed * 0.5f);
  164 + }
  165 + else
  166 + {
  167 + position += forwardVector * (-forwardSpeed * 0.5f);
  168 + }
  169 +
  170 + position += sidewaysVector * (sidewaysSpeed * 0.5f);
  171 +
  172 + mCameraActor.SetPosition( position );
  173 +
  174 + mCameraPosition = position;
  175 +
  176 + return true;
  177 +}
  178 +
  179 +void GameCamera::InitialiseDefaultCamera()
  180 +{
  181 + Stage stage = Stage::GetCurrent();
  182 + mCameraActor = stage.GetRenderTaskList().GetTask(0).GetCameraActor();
  183 + mCameraActor.SetName( "GameCamera" );
  184 + mCameraActor.SetAnchorPoint( AnchorPoint::CENTER );
  185 + mCameraActor.SetParentOrigin( ParentOrigin::CENTER );
  186 + mCameraActor.SetFieldOfView( Radian( Degree( mFovY ) ) );
  187 +
  188 + // should be read from file
  189 + mCameraActor.SetNearClippingPlane( mNear );
  190 + mCameraActor.SetFarClippingPlane( mFar );
  191 + mCameraActor.SetPosition( CAMERA_DEFAULT_POSITION );
  192 +
  193 + // Camera position is shadowed in order to avoid using GetCurrentPosition()
  194 + mCameraPosition = CAMERA_DEFAULT_POSITION;
  195 +}
  196 +
  197 +void GameCamera::CreateInterceptorActor()
  198 +{
  199 + Stage stage = Stage::GetCurrent();
  200 +
  201 + mInterceptorActor = Actor::New();
  202 + mInterceptorActor.SetName( "GameInputInterceptor" );
  203 + mInterceptorActor.SetSize( Vector3( stage.GetSize().x, stage.GetSize().y, 1 ) );
  204 + mInterceptorActor.SetPosition( Vector3( 0.0, 0.0, 1.0 ) );
  205 + mInterceptorActor.SetAnchorPoint( AnchorPoint::CENTER );
  206 + mInterceptorActor.SetParentOrigin( ParentOrigin::CENTER );
  207 + mCameraActor.Add( mInterceptorActor );
  208 +
  209 + // Connect TouchSignal to interceptor actor
  210 + mInterceptorActor.TouchSignal().Connect( this, &GameCamera::OnTouch );
  211 +}
  212 +
  213 +bool GameCamera::OnTouch( Actor actor, const TouchData& touch )
  214 +{
  215 + Stage stage = Stage::GetCurrent();
  216 +
  217 + for( int i = 0; i < (int)touch.GetPointCount() && i < 3; ++i )
  218 + {
  219 + int id = touch.GetDeviceId( i );
  220 + Vector2 tmp( touch.GetScreenPosition( i ) );
  221 + Vector2 position;
  222 + float halfWindowSize;
  223 + if( mPortraitMode )
  224 + {
  225 + position.x = tmp.y;
  226 + position.y = tmp.x;
  227 + halfWindowSize = stage.GetSize().y / 2;
  228 + }
  229 + else
  230 + {
  231 + position.x = tmp.x;
  232 + position.y = tmp.y;
  233 + halfWindowSize = stage.GetSize().x / 2;
  234 + }
  235 +
  236 + // touch started
  237 + if( touch.GetState( i ) == PointState::STARTED )
  238 + {
  239 + // start looking
  240 + if( position.x > halfWindowSize && mLookingTouchId < 0 )
  241 + {
  242 + mLookingTouchId = id;
  243 + mOldTouchLookPosition = position;
  244 + }
  245 + // start walking
  246 + else if( position.x < halfWindowSize && mWalkingTouchId < 0 )
  247 + {
  248 + mWalkingTouchId = id;
  249 + mOldTouchWalkPosition = position;
  250 + mScreenWalkDelta = Vector2::ZERO;
  251 + }
  252 + }
  253 + else if( touch.GetState( i ) == PointState::FINISHED ||
  254 + touch.GetState( i ) == PointState::LEAVE ||
  255 + touch.GetState( i ) == PointState::INTERRUPTED
  256 + )
  257 + {
  258 + // terminate look
  259 + if( mLookingTouchId == id )
  260 + {
  261 + mScreenLookDelta = Vector2::ZERO;
  262 + mOldTouchLookPosition = Vector2::ZERO;
  263 + mLookingTouchId = -1;
  264 + }
  265 + // terminate walking
  266 + else if( mWalkingTouchId == id )
  267 + {
  268 + mScreenWalkDelta = Vector2::ZERO;
  269 + mOldTouchWalkPosition = Vector2::ZERO;
  270 + mWalkingTouchId = -1;
  271 + }
  272 + }
  273 + else // on motion
  274 + {
  275 + // update looking
  276 + if( mLookingTouchId == id )
  277 + {
  278 + mScreenLookDelta.x += ( position.x - mOldTouchLookPosition.x );
  279 + mScreenLookDelta.y += ( position.y - mOldTouchLookPosition.y );
  280 + mOldTouchLookPosition = position;
  281 + }
  282 + // update walking
  283 + else if ( mWalkingTouchId == id )
  284 + {
  285 + mScreenWalkDelta.x += ( position.x - mOldTouchWalkPosition.x );
  286 + mScreenWalkDelta.y += ( position.y - mOldTouchWalkPosition.y );
  287 + mOldTouchWalkPosition = position;
  288 + }
  289 + }
  290 + }
  291 + return true;
  292 +}
... ...
examples/fpp-game/game-camera.h 0 → 100644
  1 +#ifndef GAME_CAMERA_H
  2 +#define GAME_CAMERA_H
  3 +
  4 +/*
  5 + * Copyright (c) 2016 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 +#include <dali/public-api/actors/camera-actor.h>
  22 +#include <dali/public-api/adaptor-framework/timer.h>
  23 +#include <dali/public-api/math/vector2.h>
  24 +
  25 +/**
  26 + * @brief The GameCamera class
  27 + * First-person camera implementation with handling user input
  28 + *
  29 + * GameCamera uses the DALi camera for displaying 3D game view.
  30 + * Additionally it handles simple user input by attaching fullscreen
  31 + * sized 'interceptor' Actor to the front of the CameraActor ( to be always
  32 + * parallel to the view ). It is necessary, as with changing camera orientation
  33 + * the the stage cannot be used as a touch signal receiver ( it will simply
  34 + * go offscreen with camera rotation ).
  35 + *
  36 + * DALi camera uses left-handed coordinate system.
  37 + *
  38 + * The control scheme assumes that left half of the screen is responsible for
  39 + * movement, the right half of screen is a rotation.
  40 + */
  41 +class GameCamera : public Dali::ConnectionTracker
  42 +{
  43 +public:
  44 +
  45 + /**
  46 + * Creates an instance of GameCamera
  47 + */
  48 + GameCamera();
  49 +
  50 + /**
  51 + * Destroys an instance of GameCamera
  52 + */
  53 + ~GameCamera();
  54 +
  55 + /**
  56 + * Initialise with given fovY, near, far
  57 + * @param[in] fovY Field of view in degrees
  58 + * @param[in] near Near plane
  59 + * @param[in] far Far Plane
  60 + */
  61 + void Initialise( float fov, float near, float far );
  62 +
  63 + /**
  64 + * Retrieves actor associated with camera object
  65 + * @return Returns camera actor
  66 + */
  67 + Dali::CameraActor GetCameraActor();
  68 +
  69 +private:
  70 +
  71 + /**
  72 + * Sets up a perspective camera using Dali default camera
  73 + */
  74 + void InitialiseDefaultCamera();
  75 +
  76 + /**
  77 + * Creates 'interceptor' actor. Interceptor actor is always parallel
  78 + * to the camera and positioned little bit in front of it in order to
  79 + * intercept user input.
  80 + */
  81 + void CreateInterceptorActor();
  82 +
  83 + /**
  84 + * Handles onTouch signal on the 'interceptor' actor
  85 + * @param[in] actor Actor receiving signal
  86 + * @param[in] touch Touch data
  87 + */
  88 + bool OnTouch( Dali::Actor actor, const Dali::TouchData& touch );
  89 +
  90 + /**
  91 + * Handles camera tick() update
  92 + * @return true if continue running timer, false otherwise
  93 + */
  94 + bool OnTick();
  95 +
  96 +private:
  97 +
  98 + Dali::CameraActor mCameraActor; /// Camera actor
  99 + Dali::Actor mInterceptorActor; /// Actor intercepting user input
  100 +
  101 + Dali::Timer mTimer; /// Per-frame timer
  102 +
  103 + Dali::Vector2 mScreenLookDelta; /// Look delta vector in screen space
  104 + Dali::Vector2 mScreenWalkDelta; /// Walk delta vector in screen space
  105 + Dali::Vector2 mOldTouchLookPosition; /// Previous look vector in screen space
  106 + Dali::Vector2 mOldTouchWalkPosition; /// Previuus walk vector in screen space
  107 +
  108 + Dali::Vector2 mCameraYawPitch; /// Camera yaw-pitch angles
  109 +
  110 + float mFovY; /// Camera field-of-view
  111 + float mNear; /// Near plane
  112 + float mFar; /// Far plane
  113 +
  114 + int mWalkingTouchId; /// Touch device id bound to the walking action
  115 + int mLookingTouchId; /// Touch device id bound to the looking action
  116 +
  117 + Dali::Vector3 mCameraPosition; /// Current camera position ( shadowing the actor position )
  118 +
  119 + bool mPortraitMode; /// flag if window is in portrait mode ( physically stage width < height )
  120 +};
  121 +
  122 +#endif
... ...
examples/fpp-game/game-container.h 0 → 100644
  1 +#ifndef GAME_CONTAINER_H
  2 +#define GAME_CONTAINER_H
  3 +
  4 +/*
  5 + * Copyright (c) 2016 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 +#include <dali/public-api/common/dali-vector.h>
  22 +
  23 +
  24 +/**
  25 + * GameContainer is a vector which owns heap-allocated objects.
  26 + * Unlike vector this will call delete on the stored pointers during destruction.
  27 + * For example, you can define a vector of heap-allocated Node objects:
  28 + * @code
  29 + * typedef GameContainer< GameEntity* > EntityArray;
  30 + *
  31 + * EntityArray entites;
  32 + * entites.PushBack( new GameEntity() );
  33 + * // container is now responsible for calling delete on GameEntity
  34 + *
  35 + * @endcode
  36 + */
  37 +template< class T > class GameContainer : public Dali::Vector< T >
  38 +{
  39 +public:
  40 +
  41 + typedef typename Dali::Vector< T >::Iterator Iterator;
  42 + typedef typename Dali::Vector< T >::ConstIterator ConstIterator;
  43 +
  44 + /**
  45 + * Create a owner container.
  46 + */
  47 + GameContainer()
  48 + {
  49 + }
  50 +
  51 + /**
  52 + * Non-virtual destructor; GameCache<T> is not suitable as base class.
  53 + */
  54 + ~GameContainer()
  55 + {
  56 + Clear();
  57 + Dali::VectorBase::Release();
  58 + }
  59 +
  60 + /**
  61 + * Destroy all of the elements in the container.
  62 + */
  63 + void Clear()
  64 + {
  65 + ConstIterator end = Dali::Vector< T >::End();
  66 + for( Iterator iter = Dali::Vector< T >::Begin(); iter != end; ++iter )
  67 + {
  68 + delete (*iter);
  69 + }
  70 + Dali::Vector< T >::Clear();
  71 + }
  72 +
  73 +private:
  74 +
  75 + // Undefined copy constructor.
  76 + GameContainer( const GameContainer& );
  77 +
  78 + // Undefined assignment operator.
  79 + GameContainer& operator=( const GameContainer& );
  80 +};
  81 +
  82 +#endif // GAMECACHE_H
... ...
examples/fpp-game/game-entity.cpp 0 → 100644
  1 +/*
  2 + * Copyright (c) 2016 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 +#include "game-entity.h"
  19 +#include "game-renderer.h"
  20 +
  21 +GameEntity::GameEntity( const char* name )
  22 +{
  23 + mActor = Dali::Actor::New();
  24 + mActor.SetName( name );
  25 +}
  26 +
  27 +GameEntity::~GameEntity()
  28 +{
  29 +}
  30 +
  31 +void GameEntity::UpdateRenderer()
  32 +{
  33 + if( mActor.GetRendererCount() )
  34 + {
  35 + Dali::Renderer currentRenderer = mActor.GetRendererAt( 0 );
  36 + if( currentRenderer == mGameRenderer.GetRenderer() )
  37 + {
  38 + return;
  39 + }
  40 + mActor.RemoveRenderer( currentRenderer );
  41 + }
  42 + if( mGameRenderer.GetRenderer() )
  43 + {
  44 + mActor.AddRenderer( mGameRenderer.GetRenderer() );
  45 + }
  46 +}
  47 +
  48 +GameRenderer& GameEntity::GetGameRenderer()
  49 +{
  50 + return mGameRenderer;
  51 +}
  52 +
  53 +Dali::Actor& GameEntity::GetActor()
  54 +{
  55 + return mActor;
  56 +}
  57 +
  58 +void GameEntity::SetLocation( const Dali::Vector3& loc )
  59 +{
  60 + mActor.SetPosition( loc );
  61 +}
  62 +
  63 +void GameEntity::SetRotation( const Dali::Quaternion& rot )
  64 +{
  65 + mActor.SetOrientation( rot );
  66 +}
  67 +
  68 +void GameEntity::SetScale( const Dali::Vector3& scale )
  69 +{
  70 + mActor.SetScale( scale );
  71 +}
  72 +
  73 +void GameEntity::SetSize( const Dali::Vector3& size )
  74 +{
  75 + mActor.SetSize( size );
  76 +}
... ...
examples/fpp-game/game-entity.h 0 → 100644
  1 +#ifndef GAME_ENTITY_H
  2 +#define GAME_ENTITY_H
  3 +
  4 +/*
  5 + * Copyright (c) 2016 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 +#include "game-renderer.h"
  22 +
  23 +#include <dali/public-api/actors/actor.h>
  24 +
  25 +/**
  26 + * @brief The GameEntity class
  27 + * GameEntity wraps the Dali::Actor class and binds the GameRenderer with
  28 + * loaded entity. Entities are owned by the GameScene and populated when
  29 + * scene is being deserialized.
  30 + */
  31 +class GameEntity
  32 +{
  33 +public:
  34 +
  35 + /**
  36 + * Creates an instance of GameEntity with given name
  37 + * @param[in] name Name of created entity
  38 + */
  39 + GameEntity( const char* name );
  40 +
  41 + /**
  42 + * Destroys an instance of GameEntity
  43 + */
  44 + ~GameEntity();
  45 +
  46 + /**
  47 + * Returns the GameRenderer object
  48 + */
  49 + GameRenderer& GetGameRenderer();
  50 +
  51 + /**
  52 + * Returns associated DALi actor
  53 + * @return Returns actor associated with this GameEntity
  54 + */
  55 + Dali::Actor& GetActor();
  56 +
  57 + /**
  58 + * Sets location of entity
  59 + * @param[in] location Local position of entity
  60 + */
  61 + void SetLocation( const Dali::Vector3& location );
  62 +
  63 + /**
  64 + * Sets rotation of entity
  65 + * @param[in] rotation Local rotation of entity
  66 + */
  67 + void SetRotation( const Dali::Quaternion& rotation );
  68 +
  69 + /**
  70 + * Sets scale of entity
  71 + * @param[in] scale Local scale of entity
  72 + */
  73 + void SetScale( const Dali::Vector3& scale );
  74 +
  75 + /**
  76 + * Sets size of entity
  77 + * @param[in] size Bounding box of entity
  78 + */
  79 + void SetSize( const Dali::Vector3& size );
  80 +
  81 + /**
  82 + * Updates Dali::Renderer in case if anything changed ( geometry, texture, etc. )
  83 + */
  84 + void UpdateRenderer();
  85 +
  86 +private:
  87 +
  88 + Dali::Actor mActor;
  89 + GameRenderer mGameRenderer;
  90 +};
  91 +
  92 +#endif
... ...
examples/fpp-game/game-model.cpp 0 → 100644
  1 +/*
  2 + * Copyright (c) 2016 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 +#include "game-model.h"
  19 +#include "game-utils.h"
  20 +
  21 +using namespace GameUtils;
  22 +
  23 +namespace
  24 +{
  25 +// 'MODV' tag stored in the big-endian (network) order
  26 +const uint32_t MODV_TAG( 0x4D4F4456 );
  27 +}
  28 +
  29 +GameModel::GameModel( const char *filename )
  30 + : mUniqueId( false ),
  31 + mIsReady( false )
  32 +{
  33 + ByteArray bytes;
  34 + if( !LoadFile( filename, bytes ) )
  35 + {
  36 + return;
  37 + }
  38 +
  39 + mHeader = *(reinterpret_cast<ModelHeader*>( bytes.data() ));
  40 +
  41 + // expect big-endian
  42 + if( MODV_TAG != mHeader.tag )
  43 + {
  44 + // jump to little-endian variant
  45 + mHeader = *(reinterpret_cast<ModelHeader*>( bytes.data() + bytes.size()/2 ));
  46 + }
  47 +
  48 + mVertexBuffer = Dali::PropertyBuffer::New( Dali::Property::Map().
  49 + Add( "aPosition", Dali::Property::VECTOR3 ).
  50 + Add( "aNormal", Dali::Property::VECTOR3 ).
  51 + Add( "aTexCoord", Dali::Property::VECTOR2 )
  52 + );
  53 +
  54 + mVertexBuffer.SetData( bytes.data() + mHeader.dataBeginOffset, mHeader.vertexBufferSize/mHeader.vertexStride );
  55 +
  56 + mGeometry = Dali::Geometry::New();
  57 + mGeometry.AddVertexBuffer( mVertexBuffer );
  58 + mGeometry.SetType( Dali::Geometry::TRIANGLES );
  59 +
  60 + mUniqueId = HashString( filename );
  61 +
  62 + mIsReady = true;
  63 +}
  64 +
  65 +GameModel::~GameModel()
  66 +{
  67 +}
  68 +
  69 +Dali::Geometry& GameModel::GetGeometry()
  70 +{
  71 + return mGeometry;
  72 +}
  73 +
  74 +bool GameModel::IsReady()
  75 +{
  76 + return mIsReady;
  77 +}
  78 +
  79 +uint32_t GameModel::GetUniqueId()
  80 +{
  81 + return mUniqueId;
  82 +}
... ...
examples/fpp-game/game-model.h 0 → 100644
  1 +#ifndef GAME_MODEL_H
  2 +#define GAME_MODEL_H
  3 +
  4 +/*
  5 + * Copyright (c) 2016 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 +#include <dali/public-api/rendering/geometry.h>
  22 +#include <dali/public-api/rendering/property-buffer.h>
  23 +
  24 +#include <inttypes.h>
  25 +
  26 +/**
  27 + * @brief The ModelHeader struct
  28 + * Model file header structure
  29 + */
  30 +struct ModelHeader
  31 +{
  32 + uint32_t tag; /// 'MODV' tag
  33 + uint32_t version; /// File version
  34 + uint32_t vertexBufferSize; /// total size of the vertex buffer to allocate
  35 + uint32_t attributeCount; /// number of stored attributes
  36 + uint32_t attributeFormat[16]; /// format encoded as ((type << 16)|(count)); 'type' represents primitive type, 'count' represents number of components ( 1-4 )
  37 + uint32_t attributeOffset[16]; /// attribute offsets
  38 + uint32_t attributeSize[16]; /// attribute size in bytes
  39 + uint32_t vertexStride; /// vertex stride
  40 + uint32_t reserved; /// reserved, may point at additional structure
  41 + uint32_t dataBeginOffset; /// start of actual vertex data
  42 +};
  43 +
  44 +/**
  45 + * @brief The GameModel class
  46 + * GameModel represents model geometry. It loads model data from external model file ( .mod file ).
  47 + * Such data is ready to be used as GL buffer so it can be copied directly into the PropertyBuffer
  48 + * object.
  49 + *
  50 + * Model file is multi-architecture so can be loaded on little and big endian architectures
  51 + */
  52 +class GameModel
  53 +{
  54 +public:
  55 +
  56 + /**
  57 + * Creates an instance of GameModel and loads the '.mod' file
  58 + * @param[in] filename Name of file to load
  59 + */
  60 + GameModel( const char* filename );
  61 +
  62 + /**
  63 + * Destroys an instance of GameModel
  64 + */
  65 + ~GameModel();
  66 +
  67 + /**
  68 + * Returns DALi geometry object
  69 + * @return Returns DALi geometry object
  70 + */
  71 + Dali::Geometry& GetGeometry();
  72 +
  73 + /**
  74 + * Checks status of model, returns false if failed to load
  75 + * @return true if model has been loaded, false otherwise
  76 + */
  77 + bool IsReady();
  78 +
  79 + /**
  80 + * Returns unique Id of the texture
  81 + * @return Unique Id
  82 + */
  83 + uint32_t GetUniqueId();
  84 +
  85 +private:
  86 +
  87 + Dali::Geometry mGeometry;
  88 + Dali::PropertyBuffer mVertexBuffer;
  89 +
  90 + ModelHeader mHeader;
  91 +
  92 + uint32_t mUniqueId;
  93 + bool mIsReady;
  94 +};
  95 +
  96 +#endif
... ...
examples/fpp-game/game-renderer.cpp 0 → 100644
  1 +/*
  2 + * Copyright (c) 2016 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 +#include "game-model.h"
  19 +#include "game-texture.h"
  20 +#include "game-renderer.h"
  21 +
  22 +#include <dali/dali.h>
  23 +
  24 +namespace
  25 +{
  26 +
  27 +const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
  28 + attribute highp vec3 aPosition;\n
  29 + attribute highp vec3 aNormal;\n
  30 + attribute highp vec2 aTexCoord;\n
  31 + uniform highp mat4 uMvpMatrix;\n
  32 + varying highp vec2 vTexCoord;\n
  33 + void main()\n
  34 + {\n
  35 + gl_Position = uMvpMatrix * vec4(aPosition, 1.0 );\n
  36 + vTexCoord = aTexCoord;\n
  37 + vTexCoord.y = 1.0 - vTexCoord.y;\n
  38 + }\n
  39 +)
  40 + ;
  41 +const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
  42 + uniform sampler2D sTexture;\n
  43 + varying highp vec2 vTexCoord;\n
  44 + void main()\n
  45 + {\n
  46 + gl_FragColor = texture2D( sTexture, vTexCoord ) * vec4(1.2, 1.2, 1.2, 1.0);\n
  47 + }\n
  48 +);
  49 +
  50 +}
  51 +
  52 +GameRenderer::GameRenderer()
  53 + : mModel( NULL ),
  54 + mTexture( NULL )
  55 +{
  56 +}
  57 +
  58 +GameRenderer::~GameRenderer()
  59 +{
  60 +}
  61 +
  62 +void GameRenderer::SetModel( GameModel* model )
  63 +{
  64 + mModel = model;
  65 + Setup();
  66 +}
  67 +
  68 +void GameRenderer::SetMainTexture( GameTexture* texture )
  69 +{
  70 + mTexture = texture;
  71 + Setup();
  72 +}
  73 +
  74 +void GameRenderer::Setup()
  75 +{
  76 + if( !mRenderer && mModel )
  77 + {
  78 + Dali::Shader shader = Dali::Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
  79 + mRenderer = Dali::Renderer::New( mModel->GetGeometry(), shader );
  80 + mRenderer.SetProperty( Dali::Renderer::Property::DEPTH_WRITE_MODE, Dali::DepthWriteMode::ON );
  81 + mRenderer.SetProperty( Dali::Renderer::Property::DEPTH_FUNCTION, Dali::DepthFunction::LESS_EQUAL );
  82 + mRenderer.SetProperty( Dali::Renderer::Property::DEPTH_TEST_MODE, Dali::DepthTestMode::ON );
  83 + }
  84 +
  85 + Dali::TextureSet textureSet;
  86 + Dali::Geometry geometry;
  87 +
  88 + if( mModel )
  89 + {
  90 + geometry = mModel->GetGeometry();
  91 + }
  92 +
  93 + if( mTexture && mTexture->GetTextureSet() )
  94 + {
  95 + textureSet = mTexture->GetTextureSet();
  96 + }
  97 +
  98 + if( textureSet && geometry )
  99 + {
  100 + mRenderer.SetGeometry( geometry );
  101 + mRenderer.SetTextures( textureSet );
  102 + }
  103 +}
  104 +
  105 +Dali::Renderer& GameRenderer::GetRenderer()
  106 +{
  107 + return mRenderer;
  108 +}
  109 +
  110 +
  111 +
... ...
examples/fpp-game/game-renderer.h 0 → 100644
  1 +#ifndef GAME_RENDERER_H
  2 +#define GAME_RENDERER_H
  3 +
  4 +/*
  5 + * Copyright (c) 2016 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 +#include <dali/public-api/rendering/renderer.h>
  22 +
  23 +class GameModel;
  24 +class GameTexture;
  25 +
  26 +/**
  27 + * @brief The GameRenderer class
  28 + * GameRenderer binds the main texture with model. Can be used by multiple entities. It wraps
  29 + * Dali::Renderer.
  30 + */
  31 +class GameRenderer
  32 +{
  33 +public:
  34 +
  35 + /**
  36 + * Creates an instance of the GameRenderer
  37 + */
  38 + GameRenderer();
  39 +
  40 + /**
  41 + * Destroys an instance of the GameRenderer
  42 + */
  43 + ~GameRenderer();
  44 +
  45 + /**
  46 + * Sets current model on the renderer
  47 + * Resets the Dali::Renderer or creates new one on first time setup
  48 + * @param[in] model Pointer to the GameModel object
  49 + */
  50 + void SetModel( GameModel* model );
  51 +
  52 + /**
  53 + * Sets main texture on the renderer
  54 + * Resets the Dali::Renderer or creates new one on first time setup
  55 + * @param[in] texture Pointer to the GameTexture object
  56 + */
  57 + void SetMainTexture( GameTexture* texture );
  58 +
  59 + /**
  60 + * Retrieves DALi renderer object
  61 + */
  62 + Dali::Renderer& GetRenderer();
  63 +
  64 +private:
  65 +
  66 + /**
  67 + * Initialises rendering data
  68 + */
  69 + void Setup();
  70 +
  71 +private:
  72 +
  73 + Dali::Renderer mRenderer;
  74 + GameModel* mModel;
  75 + GameTexture* mTexture;
  76 +};
  77 +
  78 +#endif
... ...
examples/fpp-game/game-scene.cpp 0 → 100644
  1 +/*
  2 + * Copyright (c) 2016 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 +#include <string.h>
  19 +#include <stdio.h>
  20 +
  21 +#include "game-scene.h"
  22 +#include "game-model.h"
  23 +#include "game-texture.h"
  24 +#include "game-entity.h"
  25 +#include "game-renderer.h"
  26 +#include "game-camera.h"
  27 +
  28 +#include "third-party/picojson.h"
  29 +
  30 +#include <dali/dali.h>
  31 +
  32 +using namespace Dali;
  33 +using namespace picojson;
  34 +
  35 +using std::vector;
  36 +
  37 +using namespace GameUtils;
  38 +
  39 +GameScene::GameScene()
  40 +{
  41 +}
  42 +
  43 +GameScene::~GameScene()
  44 +{
  45 +}
  46 +
  47 +bool GameScene::Load(const char *filename)
  48 +{
  49 + ByteArray bytes;
  50 + if( !LoadFile( filename, bytes ) )
  51 + {
  52 + return false;
  53 + }
  54 +
  55 + // add EOL
  56 + bytes.push_back( '\0');
  57 +
  58 + picojson::value root;
  59 + picojson::parse( root, bytes.data() );
  60 +
  61 + bool failed( false );
  62 +
  63 + if( root.is<object>() )
  64 + {
  65 + object rootObject = root.get<object>();
  66 + for( object::iterator it = rootObject.begin(); it != rootObject.end(); ++it )
  67 + {
  68 + std::string entityName( (*it).first );
  69 +
  70 + GameEntity* entity = new GameEntity( entityName.c_str() );
  71 + mEntities.PushBack( entity );
  72 +
  73 + value& val( (*it).second );
  74 + value& vLocation = val.get( "location" );
  75 + value& vRotation = val.get( "rotation" );
  76 + value& vScale = val.get( "scale" );
  77 + value& vSize = val.get( "size" );
  78 + value& vModel = val.get( "model" );
  79 + value& vTexture = val.get( "texture" );
  80 +
  81 + if( !vLocation.is<null>() )
  82 + {
  83 + array& location = vLocation.get<array>();
  84 + entity->SetLocation( Vector3(
  85 + location.at(0).get<double>(),
  86 + location.at(1).get<double>(),
  87 + location.at(2).get<double>()
  88 + ));
  89 + }
  90 +
  91 + if( !vRotation.is<null>() )
  92 + {
  93 + array& rotation = vRotation.get<array>();
  94 + entity->SetRotation( Quaternion( Vector4(
  95 + -rotation.at(0).get<double>(),
  96 + rotation.at(1).get<double>(),
  97 + -rotation.at(2).get<double>(),
  98 + rotation.at(3).get<double>()
  99 + )) );
  100 + }
  101 +
  102 + if( !vScale.is<null>() )
  103 + {
  104 + array& scale = vScale.get<array>();
  105 + entity->SetScale( Vector3(
  106 + scale.at(0).get<double>(),
  107 + scale.at(1).get<double>(),
  108 + scale.at(2).get<double>()
  109 + ));
  110 + }
  111 +
  112 + if( !vSize.is<null>() )
  113 + {
  114 + array& size = vSize.get<array>();
  115 + entity->SetSize( Vector3(
  116 + size.at(0).get<double>(),
  117 + size.at(1).get<double>(),
  118 + size.at(2).get<double>()
  119 + ));
  120 + }
  121 +
  122 + GameModel* model( NULL );
  123 + GameTexture* texture( NULL );
  124 +
  125 + if( !vModel.is<null>() )
  126 + {
  127 + std::string& strModel = vModel.get<std::string>();
  128 + model = GetResource( strModel.c_str(), mModelCache );
  129 + }
  130 +
  131 + if( !vTexture.is<null>() )
  132 + {
  133 + std::string& strTexture = vTexture.get<std::string>();
  134 + texture = GetResource( strTexture.c_str(), mTextureCache );
  135 + }
  136 +
  137 + if( !model || !texture )
  138 + {
  139 + failed = true;
  140 + break;
  141 + }
  142 +
  143 + entity->GetGameRenderer().SetModel( model );
  144 + entity->GetGameRenderer().SetMainTexture( texture );
  145 + }
  146 + }
  147 +
  148 + if( failed )
  149 + {
  150 + return false;
  151 + }
  152 +
  153 + // add all to the stage
  154 + Stage stage = Stage::GetCurrent();
  155 + mRootActor = Actor::New();
  156 + mRootActor.SetAnchorPoint( AnchorPoint::CENTER );
  157 + mRootActor.SetParentOrigin( ParentOrigin::CENTER );
  158 + stage.GetRootLayer().Add( mRootActor );
  159 + mRootActor.SetScale( -1.0, 1.0, 1.0 );
  160 + mRootActor.SetPosition( 0.0, 0.0, 0.0 );
  161 + mRootActor.SetOrientation( Degree( 90 ), Vector3( 1.0, 0.0, 0.0 ));
  162 + for( size_t i = 0; i < mEntities.Size(); ++i )
  163 + {
  164 + Actor actor( mEntities[i]->GetActor() );
  165 + actor.SetAnchorPoint( AnchorPoint::CENTER );
  166 + actor.SetParentOrigin( ParentOrigin::CENTER );
  167 + mRootActor.Add( actor );
  168 + mEntities[i]->UpdateRenderer();
  169 + }
  170 +
  171 + // update camera
  172 + mCamera.Initialise( 60.0f, 0.1f, 100.0f );
  173 +
  174 + return true;
  175 +}
  176 +
  177 +Dali::Actor& GameScene::GetRootActor()
  178 +{
  179 + return mRootActor;
  180 +}
... ...
examples/fpp-game/game-scene.h 0 → 100644
  1 +#ifndef GAME_SCENE_H
  2 +#define GAME_SCENE_H
  3 +
  4 +/*
  5 + * Copyright (c) 2016 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 +#include <vector>
  22 +#include <stdint.h>
  23 +#include <inttypes.h>
  24 +
  25 +#include "game-container.h"
  26 +#include "game-utils.h"
  27 +#include "game-camera.h"
  28 +
  29 +#include <dali/public-api/actors/actor.h>
  30 +
  31 +class GameCamera;
  32 +class GameEntity;
  33 +class GameTexture;
  34 +class GameModel;
  35 +
  36 +/**
  37 + * Container based types owning heap allocated data of specifed types
  38 + */
  39 +typedef GameContainer< GameEntity* > EntityArray;
  40 +typedef GameContainer< GameTexture* > TextureArray;
  41 +typedef GameContainer< GameModel* > ModelArray;
  42 +
  43 +class GameScene
  44 +{
  45 +public:
  46 +
  47 + /**
  48 + * Creates an instance of the GameScene
  49 + */
  50 + GameScene();
  51 +
  52 + /**
  53 + * Destroys an instance of the GameScene
  54 + */
  55 + ~GameScene();
  56 +
  57 + /**
  58 + * Loads scene from formatted JSON file, returns true on success
  59 + *
  60 + * @param[in] filename Path to the scene file
  61 + * @return true if suceess
  62 + */
  63 + bool Load( const char* filename );
  64 +
  65 + /**
  66 + * Loads resource ( model or texture ) or gets if from cache if already loaded
  67 + * @param[in] filename Path to the resource file
  68 + * @param[in] cache Reference to the cache array to be used
  69 + * @return Pointer to the resource or NULL otherwise
  70 + */
  71 + template <typename T>
  72 + T* GetResource( const char* filename, GameContainer<T*>& cache );
  73 +
  74 + /**
  75 + * Returns scene root actor
  76 + * @return Parent actor of the whole game scene
  77 + */
  78 + Dali::Actor& GetRootActor();
  79 +
  80 +private:
  81 +
  82 + EntityArray mEntities;
  83 + GameCamera mCamera;
  84 +
  85 + // internal scene cache
  86 + ModelArray mModelCache;
  87 + TextureArray mTextureCache;
  88 +
  89 + Dali::Actor mRootActor;
  90 +};
  91 +
  92 +
  93 +template<typename T>
  94 +T* GameScene::GetResource( const char* filename, GameContainer<T*>& cache )
  95 +{
  96 + std::string path( DEMO_GAME_DIR );
  97 + path += "/";
  98 + path += filename;
  99 +
  100 + uint32_t hash( GameUtils::HashString( path.c_str() ) );
  101 +
  102 + for( typename GameContainer<T*>::Iterator iter = cache.Begin(); iter != cache.End(); ++iter )
  103 + {
  104 + if( (*iter)->GetUniqueId() == hash )
  105 + {
  106 + return (*iter);
  107 + }
  108 + }
  109 +
  110 + // load resource
  111 + T* resource = new T( path.c_str() );
  112 + if( !resource->IsReady() )
  113 + {
  114 + return NULL;
  115 + }
  116 +
  117 + cache.PushBack( resource );
  118 +
  119 + return resource;
  120 +}
  121 +
  122 +
  123 +#endif
... ...
examples/fpp-game/game-texture.cpp 0 → 100644
  1 +/*
  2 + * Copyright (c) 2016 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 +#include <stdio.h>
  19 +
  20 +#include "game-texture.h"
  21 +#include "game-utils.h"
  22 +
  23 +#include <dali-toolkit/public-api/image-loader/sync-image-loader.h>
  24 +
  25 +GameTexture::GameTexture()
  26 +: mUniqueId( 0 ),
  27 + mIsReady( false )
  28 +{
  29 +}
  30 +
  31 +GameTexture::~GameTexture()
  32 +{
  33 +}
  34 +
  35 +GameTexture::GameTexture( const char* filename )
  36 +: mUniqueId( 0 ),
  37 + mIsReady( false )
  38 +{
  39 + Load( filename );
  40 +}
  41 +
  42 +bool GameTexture::Load( const char* filename )
  43 +{
  44 + Dali::PixelData pixelData = Dali::Toolkit::SyncImageLoader::Load( filename );
  45 +
  46 + if( !pixelData )
  47 + {
  48 + return false;
  49 + }
  50 +
  51 + Dali::Texture texture = Dali::Texture::New( Dali::TextureType::TEXTURE_2D,
  52 + pixelData.GetPixelFormat(),
  53 + pixelData.GetWidth(),
  54 + pixelData.GetHeight() );
  55 + texture.Upload( pixelData );
  56 + texture.GenerateMipmaps();
  57 + Dali::TextureSet textureSet = Dali::TextureSet::New();
  58 + textureSet.SetTexture( 0, texture );
  59 + Dali::Sampler sampler = Dali::Sampler::New();
  60 + sampler.SetWrapMode( Dali::WrapMode::REPEAT, Dali::WrapMode::REPEAT, Dali::WrapMode::REPEAT );
  61 + sampler.SetFilterMode( Dali::FilterMode::LINEAR_MIPMAP_LINEAR, Dali::FilterMode::LINEAR );
  62 + textureSet.SetSampler( 0, sampler );
  63 +
  64 + mTexture = texture;
  65 + mSampler = sampler;
  66 + mTextureSet = textureSet;
  67 +
  68 + mUniqueId = GameUtils::HashString( filename );
  69 +
  70 + mIsReady = true;
  71 +
  72 + return true;
  73 +}
  74 +
  75 +Dali::TextureSet& GameTexture::GetTextureSet()
  76 +{
  77 + return mTextureSet;
  78 +}
  79 +
  80 +uint32_t GameTexture::GetUniqueId()
  81 +{
  82 + return mUniqueId;
  83 +}
  84 +
  85 +bool GameTexture::IsReady()
  86 +{
  87 + return mIsReady;
  88 +}
... ...
examples/fpp-game/game-texture.h 0 → 100644
  1 +#ifndef GAME_TEXTURE_H
  2 +#define GAME_TEXTURE_H
  3 +
  4 +/*
  5 + * Copyright (c) 2016 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 +#include <dali/public-api/rendering/texture.h>
  22 +#include <dali/public-api/rendering/texture-set.h>
  23 +#include <dali/public-api/rendering/sampler.h>
  24 +
  25 +#include <inttypes.h>
  26 +
  27 +class GameTexture
  28 +{
  29 +public:
  30 +
  31 + /**
  32 + * Creates an instance of the GameTexture
  33 + */
  34 + GameTexture();
  35 +
  36 + /**
  37 + * Creates an instance of the GameTexture with given filename
  38 + */
  39 + GameTexture( const char* filename );
  40 +
  41 + /**
  42 + * Destroys an instance of the GameTexture
  43 + */
  44 + ~GameTexture();
  45 +
  46 + /**
  47 + * @brief Loads texture from file
  48 + * @return Returns true if success
  49 + */
  50 + bool Load( const char* filename );
  51 +
  52 + /**
  53 + * Checks status of texture, returns false if failed to load
  54 + * @return true if texture has been loaded, false otherwise
  55 + */
  56 + bool IsReady();
  57 +
  58 + /**
  59 + * @brief Returns DALi texture set associated with the GameTexture
  60 + * @return Initialised TextureSet
  61 + */
  62 + Dali::TextureSet& GetTextureSet();
  63 +
  64 + /**
  65 + * Returns unique Id of the texture
  66 + * @return Value of unique Id
  67 + */
  68 + uint32_t GetUniqueId();
  69 +
  70 +private:
  71 +
  72 + Dali::Texture mTexture;
  73 + Dali::Sampler mSampler;
  74 + Dali::TextureSet mTextureSet;
  75 +
  76 + uint32_t mUniqueId;
  77 +
  78 + bool mIsReady;
  79 +};
  80 +
  81 +#endif
... ...
examples/fpp-game/game-utils.cpp 0 → 100644
  1 +/*
  2 + * Copyright (c) 2016 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 +#include <inttypes.h>
  19 +#include <stdio.h>
  20 +
  21 +#include "game-utils.h"
  22 +
  23 +namespace GameUtils
  24 +{
  25 +bool LoadFile( const char* filename, ByteArray& bytes )
  26 +{
  27 + FILE* fin = fopen( filename, "rb" );
  28 + if( fseek( fin, 0, SEEK_END ) )
  29 + {
  30 + return false;
  31 + }
  32 + bytes.resize( ftell( fin ) );
  33 + std::fill( bytes.begin(), bytes.end(), 0 );
  34 + if( fseek( fin, 0, SEEK_SET ) )
  35 + {
  36 + return false;
  37 + }
  38 + size_t result = fread( bytes.data(), 1, bytes.size(), fin );
  39 + fclose( fin );
  40 + return (result != 0);
  41 +}
  42 +
  43 +size_t HashString( const char* str )
  44 +{
  45 + size_t hash = 5381;
  46 + int c;
  47 + while( ( c = *str++ ) )
  48 + {
  49 + hash = ((hash << 5) + hash) + c;
  50 + }
  51 + return hash;
  52 +}
  53 +
  54 +}
... ...
examples/fpp-game/game-utils.h 0 → 100644
  1 +/*
  2 + * Copyright (c) 2016 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 +#ifndef GAME_UTILS_H
  19 +#define GAME_UTILS_H
  20 +
  21 +#include <vector>
  22 +#include <inttypes.h>
  23 +#include <stdlib.h>
  24 +
  25 +namespace GameUtils
  26 +{
  27 +typedef std::vector<char> ByteArray;
  28 +
  29 +/**
  30 + * Loads file from the storage and returns byte array
  31 + */
  32 +bool LoadFile( const char* filename, ByteArray& out );
  33 +
  34 +/**
  35 + * Computes hash value from string using djb2 algorithm
  36 + * @return hash value
  37 + */
  38 +size_t HashString( const char* str );
  39 +}
  40 +
  41 +#endif
  42 +
... ...
examples/fpp-game/third-party/picojson.h 0 → 100644
  1 +/*
  2 + * Copyright 2009-2010 Cybozu Labs, Inc.
  3 + * Copyright 2011-2014 Kazuho Oku
  4 + * All rights reserved.
  5 + *
  6 + * Redistribution and use in source and binary forms, with or without
  7 + * modification, are permitted provided that the following conditions are met:
  8 + *
  9 + * 1. Redistributions of source code must retain the above copyright notice,
  10 + * this list of conditions and the following disclaimer.
  11 + *
  12 + * 2. Redistributions in binary form must reproduce the above copyright notice,
  13 + * this list of conditions and the following disclaimer in the documentation
  14 + * and/or other materials provided with the distribution.
  15 + *
  16 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  17 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  18 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  19 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
  20 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  21 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  22 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  23 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  24 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  25 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  26 + * POSSIBILITY OF SUCH DAMAGE.
  27 + */
  28 +#ifndef picojson_h
  29 +#define picojson_h
  30 +
  31 +#include <algorithm>
  32 +#include <cstdio>
  33 +#include <cstdlib>
  34 +#include <cstring>
  35 +#include <cstddef>
  36 +#include <iostream>
  37 +#include <iterator>
  38 +#include <limits>
  39 +#include <map>
  40 +#include <stdexcept>
  41 +#include <string>
  42 +#include <vector>
  43 +#include <utility>
  44 +
  45 +// for isnan/isinf
  46 +#if __cplusplus>=201103L
  47 +# include <cmath>
  48 +#else
  49 +extern "C" {
  50 +# ifdef _MSC_VER
  51 +# include <float.h>
  52 +# elif defined(__INTEL_COMPILER)
  53 +# include <mathimf.h>
  54 +# else
  55 +# include <math.h>
  56 +# endif
  57 +}
  58 +#endif
  59 +
  60 +#ifndef PICOJSON_USE_RVALUE_REFERENCE
  61 +# if (defined(__cpp_rvalue_references) && __cpp_rvalue_references >= 200610) || (defined(_MSC_VER) && _MSC_VER >= 1600)
  62 +# define PICOJSON_USE_RVALUE_REFERENCE 1
  63 +# else
  64 +# define PICOJSON_USE_RVALUE_REFERENCE 0
  65 +# endif
  66 +#endif//PICOJSON_USE_RVALUE_REFERENCE
  67 +
  68 +
  69 +// experimental support for int64_t (see README.mkdn for detail)
  70 +#ifdef PICOJSON_USE_INT64
  71 +# define __STDC_FORMAT_MACROS
  72 +# include <errno.h>
  73 +# include <inttypes.h>
  74 +#endif
  75 +
  76 +// to disable the use of localeconv(3), set PICOJSON_USE_LOCALE to 0
  77 +#ifndef PICOJSON_USE_LOCALE
  78 +# define PICOJSON_USE_LOCALE 1
  79 +#endif
  80 +#if PICOJSON_USE_LOCALE
  81 +extern "C" {
  82 +# include <locale.h>
  83 +}
  84 +#endif
  85 +
  86 +#ifndef PICOJSON_ASSERT
  87 +# define PICOJSON_ASSERT(e) do { if (! (e)) throw std::runtime_error(#e); } while (0)
  88 +#endif
  89 +
  90 +#ifdef _MSC_VER
  91 + #define SNPRINTF _snprintf_s
  92 + #pragma warning(push)
  93 + #pragma warning(disable : 4244) // conversion from int to char
  94 + #pragma warning(disable : 4127) // conditional expression is constant
  95 + #pragma warning(disable : 4702) // unreachable code
  96 +#else
  97 + #define SNPRINTF snprintf
  98 +#endif
  99 +
  100 +namespace picojson {
  101 +
  102 + enum {
  103 + null_type,
  104 + boolean_type,
  105 + number_type,
  106 + string_type,
  107 + array_type,
  108 + object_type
  109 +#ifdef PICOJSON_USE_INT64
  110 + , int64_type
  111 +#endif
  112 + };
  113 +
  114 + enum {
  115 + INDENT_WIDTH = 2
  116 + };
  117 +
  118 + struct null {};
  119 +
  120 + class value {
  121 + public:
  122 + typedef std::vector<value> array;
  123 + typedef std::map<std::string, value> object;
  124 + union _storage {
  125 + bool boolean_;
  126 + double number_;
  127 +#ifdef PICOJSON_USE_INT64
  128 + int64_t int64_;
  129 +#endif
  130 + std::string* string_;
  131 + array* array_;
  132 + object* object_;
  133 + };
  134 + protected:
  135 + int type_;
  136 + _storage u_;
  137 + public:
  138 + value();
  139 + value(int type, bool);
  140 + explicit value(bool b);
  141 +#ifdef PICOJSON_USE_INT64
  142 + explicit value(int64_t i);
  143 +#endif
  144 + explicit value(double n);
  145 + explicit value(const std::string& s);
  146 + explicit value(const array& a);
  147 + explicit value(const object& o);
  148 + explicit value(const char* s);
  149 + value(const char* s, size_t len);
  150 + ~value();
  151 + value(const value& x);
  152 + value& operator=(const value& x);
  153 +#if PICOJSON_USE_RVALUE_REFERENCE
  154 + value(value&& x)throw();
  155 + value& operator=(value&& x)throw();
  156 +#endif
  157 + void swap(value& x)throw();
  158 + template <typename T> bool is() const;
  159 + template <typename T> const T& get() const;
  160 + template <typename T> T& get();
  161 + template <typename T> void set(const T &);
  162 +#if PICOJSON_USE_RVALUE_REFERENCE
  163 + template <typename T> void set(T &&);
  164 +#endif
  165 + bool evaluate_as_boolean() const;
  166 + const value& get(size_t idx) const;
  167 + const value& get(const std::string& key) const;
  168 + value& get(size_t idx);
  169 + value& get(const std::string& key);
  170 +
  171 + bool contains(size_t idx) const;
  172 + bool contains(const std::string& key) const;
  173 + std::string to_str() const;
  174 + template <typename Iter> void serialize(Iter os, bool prettify = false) const;
  175 + std::string serialize(bool prettify = false) const;
  176 + private:
  177 + template <typename T> value(const T*); // intentionally defined to block implicit conversion of pointer to bool
  178 + template <typename Iter> static void _indent(Iter os, int indent);
  179 + template <typename Iter> void _serialize(Iter os, int indent) const;
  180 + std::string _serialize(int indent) const;
  181 + void clear();
  182 + };
  183 +
  184 + typedef value::array array;
  185 + typedef value::object object;
  186 +
  187 + inline value::value() : type_(null_type) {}
  188 +
  189 + inline value::value(int type, bool) : type_(type) {
  190 + switch (type) {
  191 +#define INIT(p, v) case p##type: u_.p = v; break
  192 + INIT(boolean_, false);
  193 + INIT(number_, 0.0);
  194 +#ifdef PICOJSON_USE_INT64
  195 + INIT(int64_, 0);
  196 +#endif
  197 + INIT(string_, new std::string());
  198 + INIT(array_, new array());
  199 + INIT(object_, new object());
  200 +#undef INIT
  201 + default: break;
  202 + }
  203 + }
  204 +
  205 + inline value::value(bool b) : type_(boolean_type) {
  206 + u_.boolean_ = b;
  207 + }
  208 +
  209 +#ifdef PICOJSON_USE_INT64
  210 + inline value::value(int64_t i) : type_(int64_type) {
  211 + u_.int64_ = i;
  212 + }
  213 +#endif
  214 +
  215 + inline value::value(double n) : type_(number_type) {
  216 + if (
  217 +#ifdef _MSC_VER
  218 + ! _finite(n)
  219 +#elif __cplusplus>=201103L || !(defined(isnan) && defined(isinf))
  220 + std::isnan(n) || std::isinf(n)
  221 +#else
  222 + isnan(n) || isinf(n)
  223 +#endif
  224 + ) {
  225 + throw std::overflow_error("");
  226 + }
  227 + u_.number_ = n;
  228 + }
  229 +
  230 + inline value::value(const std::string& s) : type_(string_type) {
  231 + u_.string_ = new std::string(s);
  232 + }
  233 +
  234 + inline value::value(const array& a) : type_(array_type) {
  235 + u_.array_ = new array(a);
  236 + }
  237 +
  238 + inline value::value(const object& o) : type_(object_type) {
  239 + u_.object_ = new object(o);
  240 + }
  241 +
  242 + inline value::value(const char* s) : type_(string_type) {
  243 + u_.string_ = new std::string(s);
  244 + }
  245 +
  246 + inline value::value(const char* s, size_t len) : type_(string_type) {
  247 + u_.string_ = new std::string(s, len);
  248 + }
  249 +
  250 + inline void value::clear() {
  251 + switch (type_) {
  252 +#define DEINIT(p) case p##type: delete u_.p; break
  253 + DEINIT(string_);
  254 + DEINIT(array_);
  255 + DEINIT(object_);
  256 +#undef DEINIT
  257 + default: break;
  258 + }
  259 + }
  260 +
  261 + inline value::~value() {
  262 + clear();
  263 + }
  264 +
  265 + inline value::value(const value& x) : type_(x.type_) {
  266 + switch (type_) {
  267 +#define INIT(p, v) case p##type: u_.p = v; break
  268 + INIT(string_, new std::string(*x.u_.string_));
  269 + INIT(array_, new array(*x.u_.array_));
  270 + INIT(object_, new object(*x.u_.object_));
  271 +#undef INIT
  272 + default:
  273 + u_ = x.u_;
  274 + break;
  275 + }
  276 + }
  277 +
  278 + inline value& value::operator=(const value& x) {
  279 + if (this != &x) {
  280 + value t(x);
  281 + swap(t);
  282 + }
  283 + return *this;
  284 + }
  285 +
  286 +#if PICOJSON_USE_RVALUE_REFERENCE
  287 + inline value::value(value&& x)throw() : type_(null_type) {
  288 + swap(x);
  289 + }
  290 + inline value& value::operator=(value&& x)throw() {
  291 + swap(x);
  292 + return *this;
  293 + }
  294 +#endif
  295 + inline void value::swap(value& x)throw() {
  296 + std::swap(type_, x.type_);
  297 + std::swap(u_, x.u_);
  298 + }
  299 +
  300 +#define IS(ctype, jtype) \
  301 + template <> inline bool value::is<ctype>() const { \
  302 + return type_ == jtype##_type; \
  303 + }
  304 + IS(null, null)
  305 + IS(bool, boolean)
  306 +#ifdef PICOJSON_USE_INT64
  307 + IS(int64_t, int64)
  308 +#endif
  309 + IS(std::string, string)
  310 + IS(array, array)
  311 + IS(object, object)
  312 +#undef IS
  313 + template <> inline bool value::is<double>() const {
  314 + return type_ == number_type
  315 +#ifdef PICOJSON_USE_INT64
  316 + || type_ == int64_type
  317 +#endif
  318 + ;
  319 + }
  320 +
  321 +#define GET(ctype, var) \
  322 + template <> inline const ctype& value::get<ctype>() const { \
  323 + PICOJSON_ASSERT("type mismatch! call is<type>() before get<type>()" \
  324 + && is<ctype>()); \
  325 + return var; \
  326 + } \
  327 + template <> inline ctype& value::get<ctype>() { \
  328 + PICOJSON_ASSERT("type mismatch! call is<type>() before get<type>()" \
  329 + && is<ctype>()); \
  330 + return var; \
  331 + }
  332 + GET(bool, u_.boolean_)
  333 + GET(std::string, *u_.string_)
  334 + GET(array, *u_.array_)
  335 + GET(object, *u_.object_)
  336 +#ifdef PICOJSON_USE_INT64
  337 + GET(double, (type_ == int64_type && (const_cast<value*>(this)->type_ = number_type, const_cast<value*>(this)->u_.number_ = u_.int64_), u_.number_))
  338 + GET(int64_t, u_.int64_)
  339 +#else
  340 + GET(double, u_.number_)
  341 +#endif
  342 +#undef GET
  343 +
  344 +#define SET(ctype, jtype, setter) \
  345 + template <> inline void value::set<ctype>(const ctype &_val) { \
  346 + clear(); \
  347 + type_ = jtype##_type; \
  348 + setter \
  349 + }
  350 + SET(bool, boolean, u_.boolean_ = _val;)
  351 + SET(std::string, string, u_.string_ = new std::string(_val);)
  352 + SET(array, array, u_.array_ = new array(_val);)
  353 + SET(object, object, u_.object_ = new object(_val);)
  354 + SET(double, number, u_.number_ = _val;)
  355 +#ifdef PICOJSON_USE_INT64
  356 + SET(int64_t, int64, u_.int64_ = _val;)
  357 +#endif
  358 +#undef SET
  359 +
  360 +#if PICOJSON_USE_RVALUE_REFERENCE
  361 +#define MOVESET(ctype, jtype, setter) \
  362 + template <> inline void value::set<ctype>(ctype &&_val) { \
  363 + clear(); \
  364 + type_ = jtype##_type; \
  365 + setter \
  366 + }
  367 + MOVESET(std::string, string, u_.string_ = new std::string(std::move(_val));)
  368 + MOVESET(array, array, u_.array_ = new array(std::move(_val));)
  369 + MOVESET(object, object, u_.object_ = new object(std::move(_val));)
  370 +#undef MOVESET
  371 +#endif
  372 +
  373 + inline bool value::evaluate_as_boolean() const {
  374 + switch (type_) {
  375 + case null_type:
  376 + return false;
  377 + case boolean_type:
  378 + return u_.boolean_;
  379 + case number_type:
  380 + return u_.number_ != 0;
  381 +#ifdef PICOJSON_USE_INT64
  382 + case int64_type:
  383 + return u_.int64_ != 0;
  384 +#endif
  385 + case string_type:
  386 + return ! u_.string_->empty();
  387 + default:
  388 + return true;
  389 + }
  390 + }
  391 +
  392 + inline const value& value::get(size_t idx) const {
  393 + static value s_null;
  394 + PICOJSON_ASSERT(is<array>());
  395 + return idx < u_.array_->size() ? (*u_.array_)[idx] : s_null;
  396 + }
  397 +
  398 + inline value& value::get(size_t idx) {
  399 + static value s_null;
  400 + PICOJSON_ASSERT(is<array>());
  401 + return idx < u_.array_->size() ? (*u_.array_)[idx] : s_null;
  402 + }
  403 +
  404 + inline const value& value::get(const std::string& key) const {
  405 + static value s_null;
  406 + PICOJSON_ASSERT(is<object>());
  407 + object::const_iterator i = u_.object_->find(key);
  408 + return i != u_.object_->end() ? i->second : s_null;
  409 + }
  410 +
  411 + inline value& value::get(const std::string& key) {
  412 + static value s_null;
  413 + PICOJSON_ASSERT(is<object>());
  414 + object::iterator i = u_.object_->find(key);
  415 + return i != u_.object_->end() ? i->second : s_null;
  416 + }
  417 +
  418 + inline bool value::contains(size_t idx) const {
  419 + PICOJSON_ASSERT(is<array>());
  420 + return idx < u_.array_->size();
  421 + }
  422 +
  423 + inline bool value::contains(const std::string& key) const {
  424 + PICOJSON_ASSERT(is<object>());
  425 + object::const_iterator i = u_.object_->find(key);
  426 + return i != u_.object_->end();
  427 + }
  428 +
  429 + inline std::string value::to_str() const {
  430 + switch (type_) {
  431 + case null_type: return "null";
  432 + case boolean_type: return u_.boolean_ ? "true" : "false";
  433 +#ifdef PICOJSON_USE_INT64
  434 + case int64_type: {
  435 + char buf[sizeof("-9223372036854775808")];
  436 + SNPRINTF(buf, sizeof(buf), "%" PRId64, u_.int64_);
  437 + return buf;
  438 + }
  439 +#endif
  440 + case number_type: {
  441 + char buf[256];
  442 + double tmp;
  443 + SNPRINTF(buf, sizeof(buf), fabs(u_.number_) < (1ULL << 53) && modf(u_.number_, &tmp) == 0 ? "%.f" : "%.17g", u_.number_);
  444 +#if PICOJSON_USE_LOCALE
  445 + char *decimal_point = localeconv()->decimal_point;
  446 + if (strcmp(decimal_point, ".") != 0) {
  447 + size_t decimal_point_len = strlen(decimal_point);
  448 + for (char *p = buf; *p != '\0'; ++p) {
  449 + if (strncmp(p, decimal_point, decimal_point_len) == 0) {
  450 + return std::string(buf, p) + "." + (p + decimal_point_len);
  451 + }
  452 + }
  453 + }
  454 +#endif
  455 + return buf;
  456 + }
  457 + case string_type: return *u_.string_;
  458 + case array_type: return "array";
  459 + case object_type: return "object";
  460 + default: PICOJSON_ASSERT(0);
  461 +#ifdef _MSC_VER
  462 + __assume(0);
  463 +#endif
  464 + }
  465 + return std::string();
  466 + }
  467 +
  468 + template <typename Iter> void copy(const std::string& s, Iter oi) {
  469 + std::copy(s.begin(), s.end(), oi);
  470 + }
  471 +
  472 + template <typename Iter>
  473 + struct serialize_str_char {
  474 + Iter oi;
  475 + void operator()(char c) {
  476 + switch (c) {
  477 +#define MAP(val, sym) case val: copy(sym, oi); break
  478 + MAP('"', "\\\"");
  479 + MAP('\\', "\\\\");
  480 + MAP('/', "\\/");
  481 + MAP('\b', "\\b");
  482 + MAP('\f', "\\f");
  483 + MAP('\n', "\\n");
  484 + MAP('\r', "\\r");
  485 + MAP('\t', "\\t");
  486 +#undef MAP
  487 + default:
  488 + if (static_cast<unsigned char>(c) < 0x20 || c == 0x7f) {
  489 + char buf[7];
  490 + SNPRINTF(buf, sizeof(buf), "\\u%04x", c & 0xff);
  491 + copy(buf, buf + 6, oi);
  492 + } else {
  493 + *oi++ = c;
  494 + }
  495 + break;
  496 + }
  497 + }
  498 + };
  499 +
  500 + template <typename Iter> void serialize_str(const std::string& s, Iter oi) {
  501 + *oi++ = '"';
  502 + serialize_str_char<Iter> process_char = { oi };
  503 + std::for_each(s.begin(), s.end(), process_char);
  504 + *oi++ = '"';
  505 + }
  506 +
  507 + template <typename Iter> void value::serialize(Iter oi, bool prettify) const {
  508 + return _serialize(oi, prettify ? 0 : -1);
  509 + }
  510 +
  511 + inline std::string value::serialize(bool prettify) const {
  512 + return _serialize(prettify ? 0 : -1);
  513 + }
  514 +
  515 + template <typename Iter> void value::_indent(Iter oi, int indent) {
  516 + *oi++ = '\n';
  517 + for (int i = 0; i < indent * INDENT_WIDTH; ++i) {
  518 + *oi++ = ' ';
  519 + }
  520 + }
  521 +
  522 + template <typename Iter> void value::_serialize(Iter oi, int indent) const {
  523 + switch (type_) {
  524 + case string_type:
  525 + serialize_str(*u_.string_, oi);
  526 + break;
  527 + case array_type: {
  528 + *oi++ = '[';
  529 + if (indent != -1) {
  530 + ++indent;
  531 + }
  532 + for (array::const_iterator i = u_.array_->begin();
  533 + i != u_.array_->end();
  534 + ++i) {
  535 + if (i != u_.array_->begin()) {
  536 + *oi++ = ',';
  537 + }
  538 + if (indent != -1) {
  539 + _indent(oi, indent);
  540 + }
  541 + i->_serialize(oi, indent);
  542 + }
  543 + if (indent != -1) {
  544 + --indent;
  545 + if (! u_.array_->empty()) {
  546 + _indent(oi, indent);
  547 + }
  548 + }
  549 + *oi++ = ']';
  550 + break;
  551 + }
  552 + case object_type: {
  553 + *oi++ = '{';
  554 + if (indent != -1) {
  555 + ++indent;
  556 + }
  557 + for (object::const_iterator i = u_.object_->begin();
  558 + i != u_.object_->end();
  559 + ++i) {
  560 + if (i != u_.object_->begin()) {
  561 + *oi++ = ',';
  562 + }
  563 + if (indent != -1) {
  564 + _indent(oi, indent);
  565 + }
  566 + serialize_str(i->first, oi);
  567 + *oi++ = ':';
  568 + if (indent != -1) {
  569 + *oi++ = ' ';
  570 + }
  571 + i->second._serialize(oi, indent);
  572 + }
  573 + if (indent != -1) {
  574 + --indent;
  575 + if (! u_.object_->empty()) {
  576 + _indent(oi, indent);
  577 + }
  578 + }
  579 + *oi++ = '}';
  580 + break;
  581 + }
  582 + default:
  583 + copy(to_str(), oi);
  584 + break;
  585 + }
  586 + if (indent == 0) {
  587 + *oi++ = '\n';
  588 + }
  589 + }
  590 +
  591 + inline std::string value::_serialize(int indent) const {
  592 + std::string s;
  593 + _serialize(std::back_inserter(s), indent);
  594 + return s;
  595 + }
  596 +
  597 + template <typename Iter> class input {
  598 + protected:
  599 + Iter cur_, end_;
  600 + bool consumed_;
  601 + int line_;
  602 + public:
  603 + input(const Iter& first, const Iter& last) : cur_(first), end_(last), consumed_(false), line_(1) {}
  604 + int getc() {
  605 + if (consumed_) {
  606 + if (*cur_ == '\n') {
  607 + ++line_;
  608 + }
  609 + ++cur_;
  610 + }
  611 + if (cur_ == end_) {
  612 + consumed_ = false;
  613 + return -1;
  614 + }
  615 + consumed_ = true;
  616 + return *cur_ & 0xff;
  617 + }
  618 + void ungetc() {
  619 + consumed_ = false;
  620 + }
  621 + Iter cur() const {
  622 + if (consumed_) {
  623 + input<Iter> *self = const_cast<input<Iter>*>(this);
  624 + self->consumed_ = false;
  625 + ++self->cur_;
  626 + }
  627 + return cur_;
  628 + }
  629 + int line() const { return line_; }
  630 + void skip_ws() {
  631 + while (1) {
  632 + int ch = getc();
  633 + if (! (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r')) {
  634 + ungetc();
  635 + break;
  636 + }
  637 + }
  638 + }
  639 + bool expect(int expect) {
  640 + skip_ws();
  641 + if (getc() != expect) {
  642 + ungetc();
  643 + return false;
  644 + }
  645 + return true;
  646 + }
  647 + bool match(const std::string& pattern) {
  648 + for (std::string::const_iterator pi(pattern.begin());
  649 + pi != pattern.end();
  650 + ++pi) {
  651 + if (getc() != *pi) {
  652 + ungetc();
  653 + return false;
  654 + }
  655 + }
  656 + return true;
  657 + }
  658 + };
  659 +
  660 + template<typename Iter> inline int _parse_quadhex(input<Iter> &in) {
  661 + int uni_ch = 0, hex;
  662 + for (int i = 0; i < 4; i++) {
  663 + if ((hex = in.getc()) == -1) {
  664 + return -1;
  665 + }
  666 + if ('0' <= hex && hex <= '9') {
  667 + hex -= '0';
  668 + } else if ('A' <= hex && hex <= 'F') {
  669 + hex -= 'A' - 0xa;
  670 + } else if ('a' <= hex && hex <= 'f') {
  671 + hex -= 'a' - 0xa;
  672 + } else {
  673 + in.ungetc();
  674 + return -1;
  675 + }
  676 + uni_ch = uni_ch * 16 + hex;
  677 + }
  678 + return uni_ch;
  679 + }
  680 +
  681 + template<typename String, typename Iter> inline bool _parse_codepoint(String& out, input<Iter>& in) {
  682 + int uni_ch;
  683 + if ((uni_ch = _parse_quadhex(in)) == -1) {
  684 + return false;
  685 + }
  686 + if (0xd800 <= uni_ch && uni_ch <= 0xdfff) {
  687 + if (0xdc00 <= uni_ch) {
  688 + // a second 16-bit of a surrogate pair appeared
  689 + return false;
  690 + }
  691 + // first 16-bit of surrogate pair, get the next one
  692 + if (in.getc() != '\\' || in.getc() != 'u') {
  693 + in.ungetc();
  694 + return false;
  695 + }
  696 + int second = _parse_quadhex(in);
  697 + if (! (0xdc00 <= second && second <= 0xdfff)) {
  698 + return false;
  699 + }
  700 + uni_ch = ((uni_ch - 0xd800) << 10) | ((second - 0xdc00) & 0x3ff);
  701 + uni_ch += 0x10000;
  702 + }
  703 + if (uni_ch < 0x80) {
  704 + out.push_back(uni_ch);
  705 + } else {
  706 + if (uni_ch < 0x800) {
  707 + out.push_back(0xc0 | (uni_ch >> 6));
  708 + } else {
  709 + if (uni_ch < 0x10000) {
  710 + out.push_back(0xe0 | (uni_ch >> 12));
  711 + } else {
  712 + out.push_back(0xf0 | (uni_ch >> 18));
  713 + out.push_back(0x80 | ((uni_ch >> 12) & 0x3f));
  714 + }
  715 + out.push_back(0x80 | ((uni_ch >> 6) & 0x3f));
  716 + }
  717 + out.push_back(0x80 | (uni_ch & 0x3f));
  718 + }
  719 + return true;
  720 + }
  721 +
  722 + template<typename String, typename Iter> inline bool _parse_string(String& out, input<Iter>& in) {
  723 + while (1) {
  724 + int ch = in.getc();
  725 + if (ch < ' ') {
  726 + in.ungetc();
  727 + return false;
  728 + } else if (ch == '"') {
  729 + return true;
  730 + } else if (ch == '\\') {
  731 + if ((ch = in.getc()) == -1) {
  732 + return false;
  733 + }
  734 + switch (ch) {
  735 +#define MAP(sym, val) case sym: out.push_back(val); break
  736 + MAP('"', '\"');
  737 + MAP('\\', '\\');
  738 + MAP('/', '/');
  739 + MAP('b', '\b');
  740 + MAP('f', '\f');
  741 + MAP('n', '\n');
  742 + MAP('r', '\r');
  743 + MAP('t', '\t');
  744 +#undef MAP
  745 + case 'u':
  746 + if (! _parse_codepoint(out, in)) {
  747 + return false;
  748 + }
  749 + break;
  750 + default:
  751 + return false;
  752 + }
  753 + } else {
  754 + out.push_back(ch);
  755 + }
  756 + }
  757 + return false;
  758 + }
  759 +
  760 + template <typename Context, typename Iter> inline bool _parse_array(Context& ctx, input<Iter>& in) {
  761 + if (! ctx.parse_array_start()) {
  762 + return false;
  763 + }
  764 + size_t idx = 0;
  765 + if (in.expect(']')) {
  766 + return ctx.parse_array_stop(idx);
  767 + }
  768 + do {
  769 + if (! ctx.parse_array_item(in, idx)) {
  770 + return false;
  771 + }
  772 + idx++;
  773 + } while (in.expect(','));
  774 + return in.expect(']') && ctx.parse_array_stop(idx);
  775 + }
  776 +
  777 + template <typename Context, typename Iter> inline bool _parse_object(Context& ctx, input<Iter>& in) {
  778 + if (! ctx.parse_object_start()) {
  779 + return false;
  780 + }
  781 + if (in.expect('}')) {
  782 + return true;
  783 + }
  784 + do {
  785 + std::string key;
  786 + if (! in.expect('"')
  787 + || ! _parse_string(key, in)
  788 + || ! in.expect(':')) {
  789 + return false;
  790 + }
  791 + if (! ctx.parse_object_item(in, key)) {
  792 + return false;
  793 + }
  794 + } while (in.expect(','));
  795 + return in.expect('}');
  796 + }
  797 +
  798 + template <typename Iter> inline std::string _parse_number(input<Iter>& in) {
  799 + std::string num_str;
  800 + while (1) {
  801 + int ch = in.getc();
  802 + if (('0' <= ch && ch <= '9') || ch == '+' || ch == '-'
  803 + || ch == 'e' || ch == 'E') {
  804 + num_str.push_back(ch);
  805 + } else if (ch == '.') {
  806 +#if PICOJSON_USE_LOCALE
  807 + num_str += localeconv()->decimal_point;
  808 +#else
  809 + num_str.push_back('.');
  810 +#endif
  811 + } else {
  812 + in.ungetc();
  813 + break;
  814 + }
  815 + }
  816 + return num_str;
  817 + }
  818 +
  819 + template <typename Context, typename Iter> inline bool _parse(Context& ctx, input<Iter>& in) {
  820 + in.skip_ws();
  821 + int ch = in.getc();
  822 + switch (ch) {
  823 +#define IS(ch, text, op) case ch: \
  824 + if (in.match(text) && op) { \
  825 + return true; \
  826 + } else { \
  827 + return false; \
  828 + }
  829 + IS('n', "ull", ctx.set_null());
  830 + IS('f', "alse", ctx.set_bool(false));
  831 + IS('t', "rue", ctx.set_bool(true));
  832 +#undef IS
  833 + case '"':
  834 + return ctx.parse_string(in);
  835 + case '[':
  836 + return _parse_array(ctx, in);
  837 + case '{':
  838 + return _parse_object(ctx, in);
  839 + default:
  840 + if (('0' <= ch && ch <= '9') || ch == '-') {
  841 + double f;
  842 + char *endp;
  843 + in.ungetc();
  844 + std::string num_str = _parse_number(in);
  845 + if (num_str.empty()) {
  846 + return false;
  847 + }
  848 +#ifdef PICOJSON_USE_INT64
  849 + {
  850 + errno = 0;
  851 + intmax_t ival = strtoimax(num_str.c_str(), &endp, 10);
  852 + if (errno == 0
  853 + && std::numeric_limits<int64_t>::min() <= ival
  854 + && ival <= std::numeric_limits<int64_t>::max()
  855 + && endp == num_str.c_str() + num_str.size()) {
  856 + ctx.set_int64(ival);
  857 + return true;
  858 + }
  859 + }
  860 +#endif
  861 + f = strtod(num_str.c_str(), &endp);
  862 + if (endp == num_str.c_str() + num_str.size()) {
  863 + ctx.set_number(f);
  864 + return true;
  865 + }
  866 + return false;
  867 + }
  868 + break;
  869 + }
  870 + in.ungetc();
  871 + return false;
  872 + }
  873 +
  874 + class deny_parse_context {
  875 + public:
  876 + bool set_null() { return false; }
  877 + bool set_bool(bool) { return false; }
  878 +#ifdef PICOJSON_USE_INT64
  879 + bool set_int64(int64_t) { return false; }
  880 +#endif
  881 + bool set_number(double) { return false; }
  882 + template <typename Iter> bool parse_string(input<Iter>&) { return false; }
  883 + bool parse_array_start() { return false; }
  884 + template <typename Iter> bool parse_array_item(input<Iter>&, size_t) {
  885 + return false;
  886 + }
  887 + bool parse_array_stop(size_t) { return false; }
  888 + bool parse_object_start() { return false; }
  889 + template <typename Iter> bool parse_object_item(input<Iter>&, const std::string&) {
  890 + return false;
  891 + }
  892 + };
  893 +
  894 + class default_parse_context {
  895 + protected:
  896 + value* out_;
  897 + public:
  898 + default_parse_context(value* out) : out_(out) {}
  899 + bool set_null() {
  900 + *out_ = value();
  901 + return true;
  902 + }
  903 + bool set_bool(bool b) {
  904 + *out_ = value(b);
  905 + return true;
  906 + }
  907 +#ifdef PICOJSON_USE_INT64
  908 + bool set_int64(int64_t i) {
  909 + *out_ = value(i);
  910 + return true;
  911 + }
  912 +#endif
  913 + bool set_number(double f) {
  914 + *out_ = value(f);
  915 + return true;
  916 + }
  917 + template<typename Iter> bool parse_string(input<Iter>& in) {
  918 + *out_ = value(string_type, false);
  919 + return _parse_string(out_->get<std::string>(), in);
  920 + }
  921 + bool parse_array_start() {
  922 + *out_ = value(array_type, false);
  923 + return true;
  924 + }
  925 + template <typename Iter> bool parse_array_item(input<Iter>& in, size_t) {
  926 + array& a = out_->get<array>();
  927 + a.push_back(value());
  928 + default_parse_context ctx(&a.back());
  929 + return _parse(ctx, in);
  930 + }
  931 + bool parse_array_stop(size_t) { return true; }
  932 + bool parse_object_start() {
  933 + *out_ = value(object_type, false);
  934 + return true;
  935 + }
  936 + template <typename Iter> bool parse_object_item(input<Iter>& in, const std::string& key) {
  937 + object& o = out_->get<object>();
  938 + default_parse_context ctx(&o[key]);
  939 + return _parse(ctx, in);
  940 + }
  941 + private:
  942 + default_parse_context(const default_parse_context&);
  943 + default_parse_context& operator=(const default_parse_context&);
  944 + };
  945 +
  946 + class null_parse_context {
  947 + public:
  948 + struct dummy_str {
  949 + void push_back(int) {}
  950 + };
  951 + public:
  952 + null_parse_context() {}
  953 + bool set_null() { return true; }
  954 + bool set_bool(bool) { return true; }
  955 +#ifdef PICOJSON_USE_INT64
  956 + bool set_int64(int64_t) { return true; }
  957 +#endif
  958 + bool set_number(double) { return true; }
  959 + template <typename Iter> bool parse_string(input<Iter>& in) {
  960 + dummy_str s;
  961 + return _parse_string(s, in);
  962 + }
  963 + bool parse_array_start() { return true; }
  964 + template <typename Iter> bool parse_array_item(input<Iter>& in, size_t) {
  965 + return _parse(*this, in);
  966 + }
  967 + bool parse_array_stop(size_t) { return true; }
  968 + bool parse_object_start() { return true; }
  969 + template <typename Iter> bool parse_object_item(input<Iter>& in, const std::string&) {
  970 + return _parse(*this, in);
  971 + }
  972 + private:
  973 + null_parse_context(const null_parse_context&);
  974 + null_parse_context& operator=(const null_parse_context&);
  975 + };
  976 +
  977 + // obsolete, use the version below
  978 + template <typename Iter> inline std::string parse(value& out, Iter& pos, const Iter& last) {
  979 + std::string err;
  980 + pos = parse(out, pos, last, &err);
  981 + return err;
  982 + }
  983 +
  984 + template <typename Context, typename Iter> inline Iter _parse(Context& ctx, const Iter& first, const Iter& last, std::string* err) {
  985 + input<Iter> in(first, last);
  986 + if (! _parse(ctx, in) && err != NULL) {
  987 + char buf[64];
  988 + SNPRINTF(buf, sizeof(buf), "syntax error at line %d near: ", in.line());
  989 + *err = buf;
  990 + while (1) {
  991 + int ch = in.getc();
  992 + if (ch == -1 || ch == '\n') {
  993 + break;
  994 + } else if (ch >= ' ') {
  995 + err->push_back(ch);
  996 + }
  997 + }
  998 + }
  999 + return in.cur();
  1000 + }
  1001 +
  1002 + template <typename Iter> inline Iter parse(value& out, const Iter& first, const Iter& last, std::string* err) {
  1003 + default_parse_context ctx(&out);
  1004 + return _parse(ctx, first, last, err);
  1005 + }
  1006 +
  1007 + inline std::string parse(value& out, const std::string& s) {
  1008 + std::string err;
  1009 + parse(out, s.begin(), s.end(), &err);
  1010 + return err;
  1011 + }
  1012 +
  1013 + inline std::string parse(value& out, std::istream& is) {
  1014 + std::string err;
  1015 + parse(out, std::istreambuf_iterator<char>(is.rdbuf()),
  1016 + std::istreambuf_iterator<char>(), &err);
  1017 + return err;
  1018 + }
  1019 +
  1020 + template <typename T> struct last_error_t {
  1021 + static std::string s;
  1022 + };
  1023 + template <typename T> std::string last_error_t<T>::s;
  1024 +
  1025 + inline void set_last_error(const std::string& s) {
  1026 + last_error_t<bool>::s = s;
  1027 + }
  1028 +
  1029 + inline const std::string& get_last_error() {
  1030 + return last_error_t<bool>::s;
  1031 + }
  1032 +
  1033 + inline bool operator==(const value& x, const value& y) {
  1034 + if (x.is<null>())
  1035 + return y.is<null>();
  1036 +#define PICOJSON_CMP(type) \
  1037 + if (x.is<type>()) \
  1038 + return y.is<type>() && x.get<type>() == y.get<type>()
  1039 + PICOJSON_CMP(bool);
  1040 + PICOJSON_CMP(double);
  1041 + PICOJSON_CMP(std::string);
  1042 + PICOJSON_CMP(array);
  1043 + PICOJSON_CMP(object);
  1044 +#undef PICOJSON_CMP
  1045 + PICOJSON_ASSERT(0);
  1046 +#ifdef _MSC_VER
  1047 + __assume(0);
  1048 +#endif
  1049 + return false;
  1050 + }
  1051 +
  1052 + inline bool operator!=(const value& x, const value& y) {
  1053 + return ! (x == y);
  1054 + }
  1055 +}
  1056 +
  1057 +#if !PICOJSON_USE_RVALUE_REFERENCE
  1058 +namespace std {
  1059 + template<> inline void swap(picojson::value& x, picojson::value& y)
  1060 + {
  1061 + x.swap(y);
  1062 + }
  1063 +}
  1064 +#endif
  1065 +
  1066 +inline std::istream& operator>>(std::istream& is, picojson::value& x)
  1067 +{
  1068 + picojson::set_last_error(std::string());
  1069 + std::string err = picojson::parse(x, is);
  1070 + if (! err.empty()) {
  1071 + picojson::set_last_error(err);
  1072 + is.setstate(std::ios::failbit);
  1073 + }
  1074 + return is;
  1075 +}
  1076 +
  1077 +inline std::ostream& operator<<(std::ostream& os, const picojson::value& x)
  1078 +{
  1079 + x.serialize(std::ostream_iterator<char>(os));
  1080 + return os;
  1081 +}
  1082 +#ifdef _MSC_VER
  1083 + #pragma warning(pop)
  1084 +#endif
  1085 +
  1086 +#endif
... ...
examples/homescreen-benchmark/homescreen-benchmark.cpp
... ... @@ -25,6 +25,11 @@ using Dali::Toolkit::TextLabel;
25 25  
26 26 namespace
27 27 {
  28 +enum IconType
  29 +{
  30 + IMAGEVIEW,
  31 + CHECKBOX
  32 +};
28 33  
29 34 const char* IMAGE_PATH_PREFIX ( DEMO_IMAGE_DIR "application-icon-" );
30 35 const char* IMAGE_PATH_POSTFIX ( ".png" );
... ... @@ -41,11 +46,14 @@ const float DEFAULT_OPT_PAGE_COUNT ( 10 );
41 46 const bool DEFAULT_OPT_USE_TABLEVIEW ( true );
42 47 const bool DEFAULT_OPT_BATCHING_ENABLED ( true );
43 48 const bool DEFAULT_OPT_ICON_LABELS ( true );
  49 +const IconType DEFAULT_OPT_ICON_TYPE ( IMAGEVIEW );
44 50  
45 51 // The image/label area tries to make sure the positioning will be relative to previous sibling
46 52 const float IMAGE_AREA ( 0.60f );
47 53 const float LABEL_AREA ( 0.50f );
48 54  
  55 +
  56 +
49 57 /**
50 58 * Random words used as unique application names.
51 59 * The number matches the value of TOTAL_ICON_DEFINITIONS.
... ... @@ -103,7 +111,8 @@ public:
103 111 mPageCount( DEFAULT_OPT_PAGE_COUNT ),
104 112 mTableViewEnabled( DEFAULT_OPT_USE_TABLEVIEW ),
105 113 mBatchingEnabled( DEFAULT_OPT_BATCHING_ENABLED ),
106   - mIconLabelsEnabled( DEFAULT_OPT_ICON_LABELS )
  114 + mIconLabelsEnabled( DEFAULT_OPT_ICON_LABELS ),
  115 + mIconType( DEFAULT_OPT_ICON_TYPE )
107 116 {
108 117 }
109 118  
... ... @@ -113,6 +122,7 @@ public:
113 122 bool mTableViewEnabled;
114 123 bool mBatchingEnabled;
115 124 bool mIconLabelsEnabled;
  125 + IconType mIconType;
116 126 };
117 127  
118 128 // animation script data
... ... @@ -206,6 +216,42 @@ public:
206 216 return pageActor;
207 217 }
208 218  
  219 + Toolkit::ImageView CreateImageView( const unsigned int currentIconIndex )
  220 + {
  221 + // Create empty image to avoid early renderer creation
  222 + Toolkit::ImageView imageView = Toolkit::ImageView::New();
  223 +
  224 + // Auto-generate the Icons image URL.
  225 + Property::Map map;
  226 + std::stringstream imagePath;
  227 + imagePath << IMAGE_PATH_PREFIX << currentIconIndex << IMAGE_PATH_POSTFIX;
  228 + map[ Dali::Toolkit::ImageVisual::Property::URL ] = imagePath.str();
  229 +
  230 + // Enable/disable batching
  231 + map[ Toolkit::ImageVisual::Property::BATCHING_ENABLED ] = mConfig.mBatchingEnabled;
  232 +
  233 + imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, map );
  234 + imageView.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
  235 + imageView.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO );
  236 + imageView.SetAnchorPoint( AnchorPoint::CENTER );
  237 + imageView.SetParentOrigin( ParentOrigin::CENTER );
  238 + imageView.SetSizeModeFactor( Vector3( IMAGE_AREA, IMAGE_AREA, 1.0f ) );
  239 +
  240 + return imageView;
  241 + }
  242 +
  243 + Toolkit::Button CreateButton( const unsigned int currentIconIndex )
  244 + {
  245 + Toolkit::CheckBoxButton button = Toolkit::CheckBoxButton::New();
  246 + button.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
  247 + button.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO );
  248 + button.SetAnchorPoint( AnchorPoint::CENTER );
  249 + button.SetParentOrigin( ParentOrigin::CENTER );
  250 + button.SetProperty( Toolkit::Button::Property::SELECTED, ( currentIconIndex % 2 == 0 ) ); // Select half the button
  251 +
  252 + return button;
  253 + }
  254 +
209 255 void AddIconsToPage( Actor page )
210 256 {
211 257 Size stageSize( Stage::GetCurrent().GetSize() );
... ... @@ -241,24 +287,21 @@ public:
241 287 iconView.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO );
242 288 }
243 289  
244   - // Create empty image to avoid early renderer creation
245   - Toolkit::ImageView imageView = Toolkit::ImageView::New();
246   -
247   - // Auto-generate the Icons image URL.
248   - Property::Map map;
249   - std::stringstream imagePath;
250   - imagePath << IMAGE_PATH_PREFIX << currentIconIndex << IMAGE_PATH_POSTFIX;
251   - map[ Dali::Toolkit::ImageVisual::Property::URL ] = imagePath.str();
252   -
253   - // Enable/disable batching
254   - map[ Toolkit::ImageVisual::Property::BATCHING_ENABLED ] = mConfig.mBatchingEnabled;
  290 + Actor icon;
255 291  
256   - imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, map );
257   - imageView.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
258   - imageView.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO );
259   - imageView.SetAnchorPoint( AnchorPoint::CENTER );
260   - imageView.SetParentOrigin( ParentOrigin::CENTER );
261   - imageView.SetSizeModeFactor( Vector3( IMAGE_AREA, IMAGE_AREA, 1.0f ) );
  292 + switch( mConfig.mIconType )
  293 + {
  294 + case CHECKBOX:
  295 + {
  296 + icon = CreateButton( currentIconIndex );
  297 + break;
  298 + }
  299 + case IMAGEVIEW:
  300 + {
  301 + icon = CreateImageView( currentIconIndex );
  302 + break;
  303 + }
  304 + }
262 305  
263 306 if( mConfig.mIconLabelsEnabled )
264 307 {
... ... @@ -271,10 +314,10 @@ public:
271 314 textLabel.SetProperty( Toolkit::TextLabel::Property::POINT_SIZE, ( ( static_cast<float>( ROW_HEIGHT * LABEL_AREA ) * 72.0f ) / dpi.y ) * 0.25f );
272 315 textLabel.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
273 316 textLabel.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "TOP" );
274   - imageView.Add( textLabel );
  317 + icon.Add( textLabel );
275 318 }
276 319  
277   - iconView.Add( imageView );
  320 + iconView.Add( icon );
278 321 page.Add( iconView );
279 322  
280 323 // We only have images and names for a certain number of icons.
... ... @@ -409,6 +452,7 @@ void RunTest( Application&amp; application, const HomescreenBenchmark::Config&amp; confi
409 452 PrintHelp( "-disable-tableview", " Disables the use of TableView for layouting (must be enabled for batching)" );
410 453 PrintHelp( "-disable-batching", " Disables geometry batching" );
411 454 PrintHelp( "-disable-icon-labels", " Disables labels for each icon" );
  455 + PrintHelp( "-use-checkbox", " Uses checkboxes for icons" );
412 456 return;
413 457 }
414 458  
... ... @@ -450,7 +494,11 @@ int DALI_EXPORT_API main( int argc, char **argv )
450 494 {
451 495 config.mIconLabelsEnabled = false;
452 496 }
453   - else if( arg.compare( "--help" ) == 0 )
  497 + else if( arg.compare( "--use-checkbox" ) == 0 )
  498 + {
  499 + config.mIconType = CHECKBOX;
  500 + }
  501 + else if ( arg.compare( "--help" ) == 0 )
454 502 {
455 503 printHelpAndExit = true;
456 504 }
... ...
examples/popup/popup-example.cpp
1 1 /*
2   - * Copyright (c) 2015 Samsung Electronics Co., Ltd.
  2 + * Copyright (c) 2016 Samsung Electronics Co., Ltd.
3 3 *
4 4 * Licensed under the Apache License, Version 2.0 (the "License");
5 5 * you may not use this file except in compliance with the License.
... ... @@ -55,6 +55,7 @@ const char* const POPUP_BUTTON_TITLE_CONTENT_TEXT_ID = &quot;POPUP_BUTTON_TITLE_CONTE
55 55 const char* const POPUP_BUTTON_TITLE_LARGE_CONTENT_BUTTONS_ID = "POPUP_BUTTON_TITLE_LARGE_CONTENT_BUTTONS";
56 56 const char* const POPUP_BUTTON_FIXED_SIZE_ID = "POPUP_BUTTON_FIXED_SIZE_ID";
57 57 const char* const POPUP_BUTTON_COMPLEX_ID = "POPUP_BUTTON_COMPLEX";
  58 +const char* const POPUP_BUTTON_CUSTOM_STYLE = "POPUP_BUTTON_CUSTOM_STYLE";
58 59  
59 60 // Names to give Popup PushButton controls.
60 61 const char* const POPUP_CONTROL_OK_NAME = "controlOk";
... ... @@ -78,11 +79,13 @@ const ButtonItem POPUP_BUTTON_ITEMS[] = {
78 79 { POPUP_BUTTON_CONTENT_TEXT_ID, "Content Text" },
79 80 { POPUP_BUTTON_CONTENT_IMAGE_ID, "Content Image" },
80 81 { POPUP_BUTTON_TITLE_CONTENT_TEXT_ID, "Title + Content" },
81   - { POPUP_BUTTON_TITLE_LARGE_CONTENT_BUTTONS_ID, "Title + Large Content + Buttons" }
  82 + { POPUP_BUTTON_TITLE_LARGE_CONTENT_BUTTONS_ID, "Title + Large Content + Buttons" },
  83 + { POPUP_BUTTON_CUSTOM_STYLE, "Custom Styled Popup" }
82 84 };
83 85  
84 86 const int POPUP_BUTTON_ITEMS_COUNT = sizeof( POPUP_BUTTON_ITEMS ) / sizeof( POPUP_BUTTON_ITEMS[0] );
85 87  
  88 +const char * const CUSTOM_POPUP_STYLE_NAME = "CustomPopupStyle"; ///< Custom popup style name
86 89 } // anonymous namespace
87 90  
88 91  
... ... @@ -651,6 +654,21 @@ public:
651 654  
652 655 SetupPopup( mPopup, button );
653 656 }
  657 + else if( button.GetName() == POPUP_BUTTON_CUSTOM_STYLE )
  658 + {
  659 + mPopup = CreateConfirmationPopup( 2 );
  660 +
  661 + Toolkit::TextLabel titleActor = Toolkit::TextLabel::New( "Styled Popup" );
  662 + titleActor.SetName( "titleActor" );
  663 + titleActor.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::RED );
  664 + titleActor.SetProperty( Toolkit::TextLabel::Property::MULTI_LINE, true );
  665 + titleActor.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
  666 + mPopup.SetTitle( titleActor );
  667 +
  668 + SetupPopup( mPopup, button );
  669 +
  670 + mPopup.SetStyleName( CUSTOM_POPUP_STYLE_NAME );
  671 + }
654 672  
655 673 return true;
656 674 }
... ...
examples/styling/image-channel-control-impl.cpp
... ... @@ -19,7 +19,7 @@
19 19 #include <dali/public-api/object/type-registry-helper.h>
20 20 #include <dali-toolkit/devel-api/align-enums.h>
21 21 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
22   -#include <dali-toolkit/devel-api/visual-factory/devel-visual-properties.h>
  22 +#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
23 23  
24 24 #include <cstdio>
25 25  
... ... @@ -181,11 +181,11 @@ void ImageChannelControl::OnSizeSet( const Vector3&amp; targetSize )
181 181 Vector2 size( targetSize );
182 182 Property::Map transformMap;
183 183 transformMap
184   - .Add( Toolkit::Visual::DevelProperty::Transform::Property::OFFSET, Vector2(0.0f, 0.0f) )
185   - .Add( Toolkit::Visual::DevelProperty::Transform::Property::SIZE, Vector2(1.0f, 1.0f) )
186   - .Add( Toolkit::Visual::DevelProperty::Transform::Property::ORIGIN, Toolkit::Align::CENTER )
187   - .Add( Toolkit::Visual::DevelProperty::Transform::Property::ANCHOR_POINT, Toolkit::Align::CENTER )
188   - .Add( Toolkit::Visual::DevelProperty::Transform::Property::OFFSET_SIZE_MODE, Vector4::ZERO );
  184 + .Add( Toolkit::DevelVisual::Transform::Property::OFFSET, Vector2(0.0f, 0.0f) )
  185 + .Add( Toolkit::DevelVisual::Transform::Property::SIZE, Vector2(1.0f, 1.0f) )
  186 + .Add( Toolkit::DevelVisual::Transform::Property::ORIGIN, Toolkit::Align::CENTER )
  187 + .Add( Toolkit::DevelVisual::Transform::Property::ANCHOR_POINT, Toolkit::Align::CENTER )
  188 + .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_SIZE_MODE, Vector4::ZERO );
189 189  
190 190 mVisual.SetTransformAndSize( transformMap, size );
191 191 }
... ...
packaging/com.samsung.dali-demo.spec
... ... @@ -2,7 +2,7 @@
2 2  
3 3 Name: com.samsung.dali-demo
4 4 Summary: The OpenGLES Canvas Core Demo
5   -Version: 1.2.15
  5 +Version: 1.2.16
6 6 Release: 1
7 7 Group: System/Libraries
8 8 License: Apache-2.0
... ... @@ -137,6 +137,7 @@ exit 0
137 137 %{dali_app_exe_dir}/*.example
138 138 %{dali_app_exe_dir}/dali-builder
139 139 %{dali_app_res_dir}/images/*
  140 +%{dali_app_res_dir}/game/*
140 141 %{dali_app_res_dir}/videos/*
141 142 %{dali_app_res_dir}/models/*
142 143 %{dali_app_res_dir}/scripts/*
... ...
resources/game/Cube.mod 0 → 100644
No preview for this file type
resources/game/lm_back_wall.png 0 → 100644

1.42 MB

resources/game/lm_corridor_0.png 0 → 100644

1.27 MB

resources/game/lm_corridor_1.png 0 → 100644

1.02 MB

resources/game/lm_crate.001.png 0 → 100644

950 KB

resources/game/lm_crate.002.png 0 → 100644

968 KB

resources/game/lm_crate.003.png 0 → 100644

1.12 MB

resources/game/lm_crate.004.png 0 → 100644

669 KB

resources/game/lm_crate.005.png 0 → 100644

704 KB

resources/game/lm_crate.006.png 0 → 100644

897 KB

resources/game/lm_crate.007.png 0 → 100644

670 KB

resources/game/lm_crate.008.png 0 → 100644

782 KB

resources/game/lm_crate.009.png 0 → 100644

709 KB

resources/game/lm_crate.010.png 0 → 100644

858 KB

resources/game/lm_crate.011.png 0 → 100644

875 KB

resources/game/lm_left_corridor.png 0 → 100644

981 KB

resources/game/lm_right_corridor.png 0 → 100644

1.26 MB

resources/game/lm_side_wall_floor.png 0 → 100644

934 KB

resources/game/lm_slope.png 0 → 100644

1.17 MB

resources/game/scene.json 0 → 100644
  1 +{
  2 + "crate.011" : {
  3 + "uid" : 140636849641992,
  4 + "location" : [ 2.929080, 32.407696, -0.438286 ],
  5 + "rotation" : [ -0.000000, -0.000000, 0.210321, 0.977632 ],
  6 + "scale" : [ 1.000000, 1.000000, 1.000000 ],
  7 + "size" : [ 1.156036, 1.156036, 1.156036 ],
  8 + "model" : "Cube.mod",
  9 + "texture" : "lm_crate.011.png"
  10 + },
  11 + "crate.010" : {
  12 + "uid" : 140636849640456,
  13 + "location" : [ 1.141492, 31.771614, -0.438286 ],
  14 + "rotation" : [ -0.000000, 0.000000, -0.275506, 0.961299 ],
  15 + "scale" : [ 1.000000, 1.000000, 1.000000 ],
  16 + "size" : [ 1.156036, 1.156036, 1.156036 ],
  17 + "model" : "Cube.mod",
  18 + "texture" : "lm_crate.010.png"
  19 + },
  20 + "crate.009" : {
  21 + "uid" : 140636847323656,
  22 + "location" : [ -0.631420, 31.771614, -0.438286 ],
  23 + "rotation" : [ -0.000000, -0.000000, 0.101605, 0.994825 ],
  24 + "scale" : [ 1.000000, 1.000000, 1.000000 ],
  25 + "size" : [ 1.156036, 1.156036, 1.156036 ],
  26 + "model" : "Cube.mod",
  27 + "texture" : "lm_crate.009.png"
  28 + },
  29 + "crate.008" : {
  30 + "uid" : 140636847322120,
  31 + "location" : [ -3.485219, 30.717421, -0.438286 ],
  32 + "rotation" : [ -0.000000, -0.000000, 0.651881, 0.758321 ],
  33 + "scale" : [ 1.000000, 1.000000, 1.000000 ],
  34 + "size" : [ 1.156036, 1.156036, 1.156036 ],
  35 + "model" : "Cube.mod",
  36 + "texture" : "lm_crate.008.png"
  37 + },
  38 + "crate.007" : {
  39 + "uid" : 140636847320584,
  40 + "location" : [ -2.265040, 31.771614, -0.438286 ],
  41 + "rotation" : [ -0.000000, -0.000000, 0.466266, 0.884644 ],
  42 + "scale" : [ 1.000000, 1.000000, 1.000000 ],
  43 + "size" : [ 1.156036, 1.156036, 1.156036 ],
  44 + "model" : "Cube.mod",
  45 + "texture" : "lm_crate.007.png"
  46 + },
  47 + "crate.006" : {
  48 + "uid" : 140636847319048,
  49 + "location" : [ -2.962721, 31.168840, 0.717751 ],
  50 + "rotation" : [ -0.000000, -0.000000, 0.466266, 0.884644 ],
  51 + "scale" : [ 1.000000, 1.000000, 1.000000 ],
  52 + "size" : [ 1.156036, 1.156036, 1.156036 ],
  53 + "model" : "Cube.mod",
  54 + "texture" : "lm_crate.006.png"
  55 + },
  56 + "back_wall" : {
  57 + "uid" : 140636847303688,
  58 + "location" : [ -0.927336, 23.381512, 4.328736 ],
  59 + "rotation" : [ -0.000000, 0.000000, -0.000000, 1.000000 ],
  60 + "scale" : [ 1.000000, 1.000000, 1.000000 ],
  61 + "size" : [ 16.032043, 23.978968, 11.872409 ],
  62 + "model" : "tile_1.011.mod",
  63 + "texture" : "lm_back_wall.png"
  64 + },
  65 + "side_wall_floor" : {
  66 + "uid" : 140636849654280,
  67 + "location" : [ -0.911298, 25.371010, 4.919888 ],
  68 + "rotation" : [ -0.000000, 0.000000, -0.000000, 1.000000 ],
  69 + "scale" : [ 1.000000, 1.000000, 1.000000 ],
  70 + "size" : [ 20.064106, 20.000000, 11.872391 ],
  71 + "model" : "tile_1.010.mod",
  72 + "texture" : "lm_side_wall_floor.png"
  73 + },
  74 + "slope" : {
  75 + "uid" : 140636849655816,
  76 + "location" : [ -0.879243, 13.510683, -0.510011 ],
  77 + "rotation" : [ -0.000000, 0.000000, -0.000000, 1.000000 ],
  78 + "scale" : [ 1.000000, 1.000000, 1.000000 ],
  79 + "size" : [ 19.999998, 3.720652, 1.012590 ],
  80 + "model" : "tile_1.009.mod",
  81 + "texture" : "lm_slope.png"
  82 + },
  83 + "left_corridor" : {
  84 + "uid" : 140636849645064,
  85 + "location" : [ -12.219622, 24.306738, 2.417727 ],
  86 + "rotation" : [ -0.061628, 0.061629, -0.704416, 0.704416 ],
  87 + "scale" : [ 1.000000, 1.000000, 1.000000 ],
  88 + "size" : [ 6.548267, 8.015736, 5.146265 ],
  89 + "model" : "tile_1.005.mod",
  90 + "texture" : "lm_left_corridor.png"
  91 + },
  92 + "right_corridor" : {
  93 + "uid" : 140636849652744,
  94 + "location" : [ 11.361787, 24.607277, 2.269830 ],
  95 + "rotation" : [ -0.061628, -0.061629, 0.704416, 0.704416 ],
  96 + "scale" : [ 1.000000, 1.000000, 1.000000 ],
  97 + "size" : [ 6.548267, 8.015736, 5.146265 ],
  98 + "model" : "tile_1.005.mod",
  99 + "texture" : "lm_right_corridor.png"
  100 + },
  101 + "crate.005" : {
  102 + "uid" : 140636847317512,
  103 + "location" : [ 0.990019, 8.702949, 1.887937 ],
  104 + "rotation" : [ -0.020922, 0.250372, -0.080603, 0.964562 ],
  105 + "scale" : [ 1.000000, 1.000000, 1.000000 ],
  106 + "size" : [ 1.156036, 1.156036, 1.156036 ],
  107 + "model" : "Cube.mod",
  108 + "texture" : "lm_crate.005.png"
  109 + },
  110 + "crate.004" : {
  111 + "uid" : 140636847315976,
  112 + "location" : [ 0.269215, 8.675555, 0.574302 ],
  113 + "rotation" : [ -0.000000, 0.000000, -0.295460, 0.955355 ],
  114 + "scale" : [ 1.000000, 1.000000, 1.000000 ],
  115 + "size" : [ 1.156036, 1.156036, 1.156036 ],
  116 + "model" : "Cube.mod",
  117 + "texture" : "lm_crate.004.png"
  118 + },
  119 + "crate.003" : {
  120 + "uid" : 140636847314440,
  121 + "location" : [ -1.762900, 0.681778, 1.730339 ],
  122 + "rotation" : [ -0.000000, -0.000000, 0.055911, 0.998436 ],
  123 + "scale" : [ 1.000000, 1.000000, 1.000000 ],
  124 + "size" : [ 1.156036, 1.156036, 1.156036 ],
  125 + "model" : "Cube.mod",
  126 + "texture" : "lm_crate.003.png"
  127 + },
  128 + "crate.002" : {
  129 + "uid" : 140636847312904,
  130 + "location" : [ -1.762900, 1.603783, 0.574302 ],
  131 + "rotation" : [ -0.000000, -0.000000, 0.055911, 0.998436 ],
  132 + "scale" : [ 1.000000, 1.000000, 1.000000 ],
  133 + "size" : [ 1.156036, 1.156036, 1.156036 ],
  134 + "model" : "Cube.mod",
  135 + "texture" : "lm_crate.002.png"
  136 + },
  137 + "crate.001" : {
  138 + "uid" : 140636847311368,
  139 + "location" : [ -1.762900, -0.008718, 0.574302 ],
  140 + "rotation" : [ -0.000000, -0.000000, 0.277257, 0.960796 ],
  141 + "scale" : [ 1.000000, 1.000000, 1.000000 ],
  142 + "size" : [ 1.156036, 1.156036, 1.156036 ],
  143 + "model" : "Cube.mod",
  144 + "texture" : "lm_crate.001.png"
  145 + },
  146 + "corridor_1" : {
  147 + "uid" : 140636847308296,
  148 + "location" : [ -0.732166, 6.650357, 2.804132 ],
  149 + "rotation" : [ -0.000000, 0.000000, -0.000000, 1.000000 ],
  150 + "scale" : [ 1.000000, 1.000000, 1.000000 ],
  151 + "size" : [ 6.548267, 8.015736, 5.146265 ],
  152 + "model" : "tile_1.005.mod",
  153 + "texture" : "lm_corridor_1.png"
  154 + },
  155 + "corridor_0" : {
  156 + "uid" : 140636847306760,
  157 + "location" : [ -0.728281, -1.365378, 2.804132 ],
  158 + "rotation" : [ -0.000000, 0.000000, -0.000000, 1.000000 ],
  159 + "scale" : [ 1.000000, 1.000000, 1.000000 ],
  160 + "size" : [ 6.548267, 8.015736, 5.146265 ],
  161 + "model" : "tile_1.005.mod",
  162 + "texture" : "lm_corridor_0.png"
  163 + }
  164 +}
... ...
resources/game/tile_1.005.mod 0 → 100644
No preview for this file type
resources/game/tile_1.009.mod 0 → 100644
No preview for this file type
resources/game/tile_1.010.mod 0 → 100644
No preview for this file type
resources/game/tile_1.011.mod 0 → 100644
No preview for this file type
resources/images/popup-tail-down.png 0 → 100644

19.6 KB

resources/images/popup-tail-left.png 0 → 100644

19.1 KB

resources/images/popup-tail-right.png 0 → 100644

19.2 KB

resources/images/popup-tail-up.png 0 → 100644

19.2 KB

resources/images/popup.9.png 0 → 100644

3.64 KB

resources/po/as.po
... ... @@ -144,3 +144,6 @@ msgstr &quot;অকনিষ্ঠ অৰ্জুন বঁটা&quot;
144 144  
145 145 msgid "DALI_DEMO_STR_TITLE_TILT_SENSOR"
146 146 msgstr "টিল্ট অনুভূতি"
  147 +
  148 +msgid "DALI_DEMO_STR_TITLE_FPP_GAME"
  149 +msgstr "FPP খেলা"
... ...
resources/po/de.po
... ... @@ -144,3 +144,6 @@ msgstr &quot;Text Scrollen&quot;
144 144  
145 145 msgid "DALI_DEMO_STR_TITLE_TILT_SENSOR"
146 146 msgstr "Neigungssensor"
  147 +
  148 +msgid "DALI_DEMO_STR_TITLE_FPP_GAME"
  149 +msgstr "FPP Spiel"
... ...
resources/po/en_GB.po
... ... @@ -144,3 +144,6 @@ msgstr &quot;Text Scrolling&quot;
144 144  
145 145 msgid "DALI_DEMO_STR_TITLE_TILT_SENSOR"
146 146 msgstr "Tilt Sensor"
  147 +
  148 +msgid "DALI_DEMO_STR_TITLE_FPP_GAME"
  149 +msgstr "FPP Game"
... ...
resources/po/en_US.po
... ... @@ -144,3 +144,6 @@ msgstr &quot;Text Scrolling&quot;
144 144  
145 145 msgid "DALI_DEMO_STR_TITLE_TILT_SENSOR"
146 146 msgstr "Tilt Sensor"
  147 +
  148 +msgid "DALI_DEMO_STR_TITLE_FPP_GAME"
  149 +msgstr "FPP Game"
... ...
resources/po/es.po
... ... @@ -144,3 +144,6 @@ msgstr &quot;Texto con desplazamiento&quot;
144 144  
145 145 msgid "DALI_DEMO_STR_TITLE_TILT_SENSOR"
146 146 msgstr "Sensor de inclinacion"
  147 +
  148 +msgid "DALI_DEMO_STR_TITLE_FPP_GAME"
  149 +msgstr "Juego FPP"
... ...
resources/po/fi.po
... ... @@ -144,3 +144,6 @@ msgstr &quot;Tekstin Vieritys&quot;
144 144  
145 145 msgid "DALI_DEMO_STR_TITLE_TILT_SENSOR"
146 146 msgstr "Kallistustunnistin"
  147 +
  148 +msgid "DALI_DEMO_STR_TITLE_FPP_GAME"
  149 +msgstr "FPP peli"
... ...
resources/po/ko.po
... ... @@ -144,3 +144,6 @@ msgstr &quot;텍스트 스크롤&quot;
144 144  
145 145 msgid "DALI_DEMO_STR_TITLE_TILT_SENSOR"
146 146 msgstr "기울기 센서"
  147 +
  148 +msgid "DALI_DEMO_STR_TITLE_FPP_GAME"
  149 +msgstr "FPP Game"
... ...
resources/po/ml.po
... ... @@ -144,3 +144,6 @@ msgstr &quot;ടെക്സ്റ്റ് സ്ക്രോളിംഗ്&quot;
144 144  
145 145 msgid "DALI_DEMO_STR_TITLE_TILT_SENSOR"
146 146 msgstr "ചെരിവ് സെൻസർ"
  147 +
  148 +msgid "DALI_DEMO_STR_TITLE_FPP_GAME"
  149 +msgstr "FPP Game"
... ...
resources/po/ur.po
... ... @@ -144,3 +144,6 @@ msgstr &quot;حروف کاسکرال &quot;
144 144  
145 145 msgid "DALI_DEMO_STR_TITLE_TILT_SENSOR"
146 146 msgstr "ٹلٹ سینسر"
  147 +
  148 +msgid "DALI_DEMO_STR_TITLE_FPP_GAME"
  149 +msgstr "FPP گیم"
... ...
resources/po/zn_CH.po
... ... @@ -144,3 +144,6 @@ msgstr &quot;滚动文字&quot;
144 144  
145 145 msgid "DALI_DEMO_STR_TITLE_TILT_SENSOR"
146 146 msgstr "倾斜传感器"
  147 +
  148 +msgid "DALI_DEMO_STR_TITLE_FPP_GAME"
  149 +msgstr "FPP遊戲"
... ...
resources/style/demo-theme.json.in
... ... @@ -21,6 +21,15 @@
21 21 "popupBackgroundImage":"{APPLICATION_RESOURCE_PATH}/images/00_popup_bg.9.png"
22 22 },
23 23  
  24 + "CustomPopupStyle":{
  25 + "popupBackgroundImage":"{APPLICATION_RESOURCE_PATH}/images/popup.9.png",
  26 + "popupBackgroundBorder":[0,4,4,0],
  27 + "tailUpImage":"{APPLICATION_RESOURCE_PATH}/images/popup-tail-up.png",
  28 + "tailDownImage":"{APPLICATION_RESOURCE_PATH}/images/popup-tail-down.png",
  29 + "tailLeftImage":"{APPLICATION_RESOURCE_PATH}/images/popup-tail-left.png",
  30 + "tailRightImage":"{APPLICATION_RESOURCE_PATH}/images/popup-tail-right.png"
  31 + },
  32 +
24 33 "TextLabelRosemary":
25 34 {
26 35 "fontFamily":"Rosemary"
... ...
resources/style/mobile/demo-theme.json.in
... ... @@ -18,6 +18,14 @@
18 18 {
19 19 "styles":
20 20 {
  21 + "CustomPopupStyle":{
  22 + "popupBackgroundImage":"{APPLICATION_RESOURCE_PATH}/images/popup.9.png",
  23 + "popupBackgroundBorder":[0,4,4,0],
  24 + "tailUpImage":"{APPLICATION_RESOURCE_PATH}/images/popup-tail-up.png",
  25 + "tailDownImage":"{APPLICATION_RESOURCE_PATH}/images/popup-tail-down.png",
  26 + "tailLeftImage":"{APPLICATION_RESOURCE_PATH}/images/popup-tail-left.png",
  27 + "tailRightImage":"{APPLICATION_RESOURCE_PATH}/images/popup-tail-right.png"
  28 + },
21 29 "TextLabelRosemary":
22 30 {
23 31 "fontFamily":"Rosemary"
... ...
shared/dali-demo-strings.h
... ... @@ -80,6 +80,7 @@ extern &quot;C&quot;
80 80 #define DALI_DEMO_STR_TITLE_TEXT_LABEL_MULTI_LANGUAGE dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_TEXT_LABEL_MULTI_LANGUAGE")
81 81 #define DALI_DEMO_STR_TITLE_TEXT_SCROLLING dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_TEXT_SCROLLING")
82 82 #define DALI_DEMO_STR_TITLE_TILT_SENSOR dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_TILT_SENSOR")
  83 +#define DALI_DEMO_STR_TITLE_FPP_GAME dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_FPP_GAME")
83 84  
84 85 #else // !INTERNATIONALIZATION_ENABLED
85 86  
... ... @@ -131,6 +132,7 @@ extern &quot;C&quot;
131 132 #define DALI_DEMO_STR_TITLE_TEXT_SCROLLING "Text Scrolling"
132 133 #define DALI_DEMO_STR_TITLE_TILT_SENSOR "Tilt Sensor"
133 134 #define DALI_DEMO_STR_TITLE_PROGRESS_BAR "Progress Bar"
  135 +#define DALI_DEMO_STR_TITLE_FPP_GAME "First Person Game"
134 136  
135 137 #endif
136 138  
... ...