From: Agnelo Vaz Date: Fri, 3 Mar 2017 14:07:40 +0000 (+0000) Subject: [dali_1.2.29] Merge branch 'devel/master' X-Git-Tag: dali_1.4.10~103 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=94d678d62ca15faaced5deaf379f9ea4a6f16b7d;hp=92599bec00306761453eeaaa2a212fbc44ec0ba8;p=platform%2Fcore%2Fuifw%2Fdali-demo.git [dali_1.2.29] Merge branch 'devel/master' Change-Id: I1409c2df0c9f782dfda16343b181a3088cb795c0 --- diff --git a/build/tizen/CMakeLists.txt b/build/tizen/CMakeLists.txt index 5a394e3..8894f15 100644 --- a/build/tizen/CMakeLists.txt +++ b/build/tizen/CMakeLists.txt @@ -103,6 +103,7 @@ CONFIGURE_FILE( resources-location.in ${DEMO_SHARED}/resources-location.cpp ) CONFIGURE_FILE( ${LOCAL_STYLE_DIR}/demo-theme.json.in ${LOCAL_STYLE_DIR}/demo-theme.json ) CONFIGURE_FILE( ${LOCAL_STYLE_DIR}/contact-cards-example-theme.json.in ${LOCAL_STYLE_DIR}/contact-cards-example-theme.json ) CONFIGURE_FILE( ${LOCAL_STYLE_DIR}/progress-bar-example-theme.json.in ${LOCAL_STYLE_DIR}/progress-bar-example-theme.json ) +CONFIGURE_FILE( ${LOCAL_STYLE_DIR}/simple-example-theme.json.in ${LOCAL_STYLE_DIR}/simple-example-theme.json ) CONFIGURE_FILE( ${LOCAL_STYLE_DIR}/style-example-theme-one.json.in ${LOCAL_STYLE_DIR}/style-example-theme-one.json ) CONFIGURE_FILE( ${LOCAL_STYLE_DIR}/style-example-theme-two.json.in ${LOCAL_STYLE_DIR}/style-example-theme-two.json ) CONFIGURE_FILE( ${LOCAL_STYLE_DIR}/style-example-theme-three.json.in ${LOCAL_STYLE_DIR}/style-example-theme-three.json ) diff --git a/com.samsung.dali-demo.xml b/com.samsung.dali-demo.xml index ba61290..8a205b4 100644 --- a/com.samsung.dali-demo.xml +++ b/com.samsung.dali-demo.xml @@ -32,6 +32,9 @@ + + + diff --git a/examples-reel/dali-examples-reel.cpp b/examples-reel/dali-examples-reel.cpp index 9f29f97..6dc8f5b 100644 --- a/examples-reel/dali-examples-reel.cpp +++ b/examples-reel/dali-examples-reel.cpp @@ -61,6 +61,10 @@ int DALI_EXPORT_API main(int argc, char **argv) demo.AddExample(Example("popup.example", DALI_DEMO_STR_TITLE_POPUP)); demo.AddExample(Example("primitive-shapes.example", DALI_DEMO_STR_TITLE_PRIMITIVE_SHAPES)); demo.AddExample(Example("progress-bar.example", DALI_DEMO_STR_TITLE_PROGRESS_BAR)); + demo.AddExample(Example("rendering-line.example", DALI_DEMO_STR_TITLE_RENDERING_DRAW_LINE)); + demo.AddExample(Example("rendering-triangle.example", DALI_DEMO_STR_TITLE_RENDERING_DRAW_TRIANGLE)); + demo.AddExample(Example("rendering-cube.example", DALI_DEMO_STR_TITLE_RENDERING_DRAW_CUBE)); + demo.AddExample(Example("rendering-textured-cube.example", DALI_DEMO_STR_TITLE_RENDERING_TEXTURED_CUBE)); demo.AddExample(Example("scroll-view.example", DALI_DEMO_STR_TITLE_SCROLL_VIEW)); demo.AddExample(Example("size-negotiation.example", DALI_DEMO_STR_TITLE_NEGOTIATE_SIZE)); demo.AddExample(Example("styling.example", DALI_DEMO_STR_TITLE_STYLING)); @@ -70,7 +74,7 @@ int DALI_EXPORT_API main(int argc, char **argv) demo.AddExample(Example("text-label-multi-language.example", DALI_DEMO_STR_TITLE_TEXT_LABEL_MULTI_LANGUAGE)); demo.AddExample(Example("text-label-emojis.example", DALI_DEMO_STR_TITLE_EMOJI_TEXT)); demo.AddExample(Example("text-scrolling.example", DALI_DEMO_STR_TITLE_TEXT_SCROLLING)); - demo.AddExample(Example("textured-mesh.example", DALI_DEMO_STR_TITLE_TEXTURED_MESH)); + demo.AddExample(Example("texturedss-mesh.example", DALI_DEMO_STR_TITLE_TEXTURED_MESH)); demo.AddExample(Example("tilt.example", DALI_DEMO_STR_TITLE_TILT_SENSOR)); demo.AddExample(Example("tooltip.example", DALI_DEMO_STR_TITLE_TOOLTIP)); demo.AddExample(Example("transitions.example", DALI_DEMO_STR_TITLE_VISUAL_TRANSITIONS)); diff --git a/examples/rendering-cube/rendering-cube.cpp b/examples/rendering-cube/rendering-cube.cpp new file mode 100644 index 0000000..a42e832 --- /dev/null +++ b/examples/rendering-cube/rendering-cube.cpp @@ -0,0 +1,277 @@ +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include + +using namespace Dali; +using namespace Toolkit; + +namespace +{ + +/* + * Vertex shader + */ +const char* VERTEX_SHADER = DALI_COMPOSE_SHADER( +attribute mediump vec3 aPosition;\n // DALi shader builtin +attribute mediump vec3 aColor;\n // DALi shader builtin +uniform mediump mat4 uMvpMatrix;\n // DALi shader builtin +uniform mediump vec3 uSize;\n // DALi shader builtin +\n +varying mediump vec4 vColor;\n +\n +void main()\n +{\n + mediump vec4 vertexPosition = vec4(aPosition, 1.0);\n + vertexPosition.xyz *= uSize;\n + vColor = vec4( aColor, 1.0 );\n + gl_Position = uMvpMatrix * vertexPosition;\n +}\n +); + +/* + * Fragment shader + */ +const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER( +varying mediump vec4 vColor;\n +\n +void main()\n +{\n + gl_FragColor = vColor;\n +}\n +); + +} + +// This example shows how to create a cube with colors on each side +// +class DrawCubeController : public ConnectionTracker +{ +public: + + DrawCubeController( Application& application ) + : mApplication( application ) + { + // Connect to the Application's Init signal + mApplication.InitSignal().Connect( this, &DrawCubeController::Create ); + } + + ~DrawCubeController() + { + // Nothing to do here; + } + + // The Init signal is received once (only) during the Application lifetime + void Create( Application& application ) + { + // Get a handle to the stage + Stage stage = Stage::GetCurrent(); + stage.SetBackgroundColor( Color::WHITE ); + + // Step 1. Create shader + CreateCubeShader(); + + // Step 2. Prepare geometry + CreateCubeGeometry(); + + // Step 3. Create a renderer + CreateRenderer(); + + // Step 4. Create an Actor + CreateActor(); + + // Step 5. Play animation to rotate the cube + PlayAnimation(); + + // Respond to a click anywhere on the stage + stage.GetRootLayer().TouchSignal().Connect( this, &DrawCubeController::OnTouch ); + } + + bool OnTouch( Actor actor, const TouchData& touch ) + { + // quit the application + mApplication.Quit(); + return true; + } + + /** + * This function creates a cube geometry including texture coordinates. + * Also it demonstrates using the indexed draw feature by setting an index array. + */ + void CreateCubeGeometry() + { + struct Vertex + { + Vector3 aPosition; + Vector3 aColor; + }; + + const Vector3 COLOR0( 1.0f, 1.0f, 0.0f ); + const Vector3 COLOR1( 0.0f, 1.0f, 1.0f ); + const Vector3 COLOR2( 1.0f, 0.0f, 1.0f ); + const Vector3 COLOR3( 0.0f, 1.0f, 0.0f ); + const Vector3 COLOR4( 0.0f, 0.0f, 1.0f ); + const Vector3 COLOR5( 1.0f, 0.0f, 0.0f ); + + Vertex vertices[] = { + { Vector3( 1.0f,-1.0f,-1.0f ), COLOR5 }, + { Vector3( -1.0f, 1.0f,-1.0f ), COLOR5 }, + { Vector3( 1.0f, 1.0f,-1.0f ), COLOR5 }, + { Vector3( -1.0f, 1.0f, 1.0f ), COLOR3 }, + { Vector3( 1.0f,-1.0f, 1.0f ), COLOR3 }, + { Vector3( 1.0f, 1.0f, 1.0f ), COLOR3 }, + { Vector3( 1.0f, 1.0f, 1.0f ), COLOR4 }, + { Vector3( 1.0f,-1.0f,-1.0f ), COLOR4 }, + { Vector3( 1.0f, 1.0f,-1.0f ), COLOR4 }, + { Vector3( 1.0f,-1.0f, 1.0f ), COLOR1 }, + { Vector3( -1.0f,-1.0f,-1.0f ), COLOR1 }, + { Vector3( 1.0f,-1.0f,-1.0f ), COLOR1 }, + { Vector3( -1.0f,-1.0f,-1.0f ), COLOR0 }, + { Vector3( -1.0f, 1.0f, 1.0f ), COLOR0 }, + { Vector3( -1.0f, 1.0f,-1.0f ), COLOR0 }, + { Vector3( 1.0f, 1.0f,-1.0f ), COLOR2 }, + { Vector3( -1.0f, 1.0f, 1.0f ), COLOR2 }, + { Vector3( 1.0f, 1.0f, 1.0f ), COLOR2 }, + { Vector3( 1.0f,-1.0f,-1.0f ), COLOR5 }, + { Vector3( -1.0f,-1.0f,-1.0f ), COLOR5 }, + { Vector3( -1.0f, 1.0f,-1.0f ), COLOR5 }, + { Vector3( -1.0f, 1.0f, 1.0f ), COLOR3 }, + { Vector3( -1.0f,-1.0f, 1.0f ), COLOR3 }, + { Vector3( 1.0f,-1.0f, 1.0f ), COLOR3 }, + { Vector3( 1.0f, 1.0f, 1.0f ), COLOR4 }, + { Vector3( 1.0f,-1.0f, 1.0f ), COLOR4 }, + { Vector3( 1.0f,-1.0f,-1.0f ), COLOR4 }, + { Vector3( 1.0f,-1.0f, 1.0f ), COLOR1 }, + { Vector3( -1.0f,-1.0f, 1.0f ), COLOR1 }, + { Vector3( -1.0f,-1.0f,-1.0f ), COLOR1 }, + { Vector3( -1.0f,-1.0f,-1.0f ), COLOR0 }, + { Vector3( -1.0f,-1.0f, 1.0f ), COLOR0 }, + { Vector3( -1.0f, 1.0f, 1.0f ), COLOR0 }, + { Vector3( 1.0f, 1.0f,-1.0f ), COLOR2 }, + { Vector3( -1.0f, 1.0f,-1.0f ), COLOR2 }, + { Vector3( -1.0f, 1.0f, 1.0f ), COLOR2 }, + }; + + PropertyBuffer vertexBuffer = PropertyBuffer::New( Property::Map() + .Add( "aPosition", Property::VECTOR3 ) + .Add( "aColor", Property::VECTOR3 ) ); + vertexBuffer.SetData( vertices, sizeof(vertices) / sizeof(Vertex) ); + + // create indices + const unsigned short INDEX_CUBE[] = { + 2, 1, 0, + 5, 4, 3, + 8, 7, 6, + 11, 10, 9, + 14, 13, 12, + 17, 16, 15, + 20, 19, 18, + 23, 22, 21, + 26, 25, 24, + 29, 28, 27, + 32, 31, 30, + 35, 34, 33 + }; + mGeometry = Geometry::New(); + mGeometry.AddVertexBuffer( vertexBuffer ); + mGeometry.SetIndexBuffer( INDEX_CUBE, + sizeof(INDEX_CUBE)/sizeof(INDEX_CUBE[0]) + ); + mGeometry.SetType( Geometry::TRIANGLES ); + } + + /** + * Creates a shader using inlined variable VERTEX_SHADER and FRAGMENT_SHADER + * + * Shaders are very basic and all they do is transforming vertices and interpolating + * input per-vertex color. + */ + void CreateCubeShader() + { + mShader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER ); + } + + /** + * Function creates renderer. It turns on depth test and depth write. + */ + void CreateRenderer() + { + mRenderer = Renderer::New( mGeometry, mShader ); + + // Face culling is enabled to hide the backwards facing sides of the cube + // This is sufficient to render a single object; for more complex scenes depth-testing might be required + mRenderer.SetProperty( Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::BACK ); + } + + /** + * Creates new actor and attaches renderer. + */ + void CreateActor() + { + Stage stage = Stage::GetCurrent(); + + float quarterStageWidth = stage.GetSize().x * 0.25f; + mActor = Actor::New(); + mActor.SetAnchorPoint( AnchorPoint::CENTER ); + mActor.SetParentOrigin( ParentOrigin::CENTER ); + mActor.SetPosition( Vector3( 0.0f, 0.0f, 0.0f ) ); + mActor.SetSize( Vector3( quarterStageWidth, quarterStageWidth, quarterStageWidth ) ); + mActor.AddRenderer( mRenderer ); + stage.Add( mActor ); + } + + /** + * Plays animation + */ + void PlayAnimation() + { + mAnimation = Animation::New( 5.0f ); + mAnimation.SetLooping( true ); + mAnimation.AnimateBy( Property( mActor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree( 360 )), Vector3::ZAXIS ) ); + mAnimation.AnimateBy( Property( mActor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree( 360 )), Vector3::YAXIS ) ); + mAnimation.AnimateBy( Property( mActor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree( 360 )), Vector3::XAXIS ) ); + mAnimation.Play(); + } + +private: + Application& mApplication; + + Renderer mRenderer; + Shader mShader; + Geometry mGeometry; + Actor mActor; + Animation mAnimation; +}; + +void RunTest( Application& application ) +{ + DrawCubeController test( application ); + + application.MainLoop(); +} + +// Entry point for Linux & Tizen applications +// +int DALI_EXPORT_API main( int argc, char **argv ) +{ + Application application = Application::New( &argc, &argv ); + + RunTest( application ); + + return 0; +} diff --git a/examples/rendering-line/rendering-line.cpp b/examples/rendering-line/rendering-line.cpp new file mode 100644 index 0000000..70d55cc --- /dev/null +++ b/examples/rendering-line/rendering-line.cpp @@ -0,0 +1,185 @@ +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include + +using namespace Dali; +using namespace Toolkit; + +namespace +{ + +/* + * Vertex shader + */ +const char* VERTEX_SHADER = DALI_COMPOSE_SHADER( +attribute mediump vec2 aPosition;\n // DALi shader builtin +uniform mediump mat4 uMvpMatrix;\n // DALi shader builtin +uniform mediump vec3 uSize;\n // DALi shader builtin +\n +void main()\n +{\n + mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n + vertexPosition.xyz *= uSize;\n + gl_Position = uMvpMatrix * vertexPosition;\n +}\n +); + +/* + * Fragment shader + */ +const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER( +uniform mediump vec4 uColor;\n +\n +void main()\n +{\n + gl_FragColor = uColor;\n +}\n +); + +} + +// This example shows how to draw a line in actor's color +// +class DrawLineController : public ConnectionTracker +{ +public: + + DrawLineController( Application& application ) + : mApplication( application ) + { + // Connect to the Application's Init signal + mApplication.InitSignal().Connect( this, &DrawLineController::Create ); + } + + ~DrawLineController() + { + // Nothing to do here; + } + + // The Init signal is received once (only) during the Application lifetime + void Create( Application& application ) + { + // Get a handle to the stage + Stage stage = Stage::GetCurrent(); + stage.SetBackgroundColor( Color::WHITE ); + + // Step 1. Create shader + CreateLineShader(); + + // Step 2. Prepare geometry + CreateLineGeometry(); + + // Step 3. Create a renderer + CreateRenderer(); + + // Step 4. Create an Actor + CreateActor(); + + // Respond to a click anywhere on the stage + stage.GetRootLayer().TouchSignal().Connect( this, &DrawLineController::OnTouch ); + } + + bool OnTouch( Actor actor, const TouchData& touch ) + { + // quit the application + mApplication.Quit(); + return true; + } + + /** + * This function creates a line geometry made of two vertices in order + * to draw a diagonal line. + */ + void CreateLineGeometry() + { + Vector2 vertices[] = { + Vector2( -1.0f, -1.0f ), + Vector2( 1.0f, 1.0f ) + }; + + PropertyBuffer vertexBuffer = PropertyBuffer::New( Property::Map() + .Add( "aPosition", Property::VECTOR2 ) ); + vertexBuffer.SetData( vertices, sizeof(vertices) / sizeof(Vector2) ); + + mGeometry = Geometry::New(); + mGeometry.AddVertexBuffer( vertexBuffer ); + mGeometry.SetType( Geometry::LINES ); + } + + /** + * Creates a shader using inlined variable VERTEX_SHADER and FRAGMENT_SHADER + * + * Shaders are very basic and all they do is transforming vertices and applying actor's colour. + */ + void CreateLineShader() + { + mShader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER ); + } + + /** + * Function creates renderer. + */ + void CreateRenderer() + { + mRenderer = Renderer::New( mGeometry, mShader ); + } + + /** + * Creates new actor and attaches renderer. + */ + void CreateActor() + { + Stage stage = Stage::GetCurrent(); + Size size = stage.GetSize() * 0.25f; + mActor = Actor::New(); + mActor.SetAnchorPoint( AnchorPoint::CENTER ); + mActor.SetParentOrigin( ParentOrigin::CENTER ); + mActor.SetPosition( Vector3( 0.0f, 0.0f, 0.0f ) ); + mActor.SetColor( Color::BLACK ); + mActor.SetSize( Vector3( size.x, size.x, size.x ) ); + mActor.AddRenderer( mRenderer ); + stage.Add( mActor ); + } + +private: + Application& mApplication; + + Renderer mRenderer; + Shader mShader; + Geometry mGeometry; + Actor mActor; +}; + +void RunTest( Application& application ) +{ + DrawLineController test( application ); + + application.MainLoop(); +} + +// Entry point for Linux & Tizen applications +// +int DALI_EXPORT_API main( int argc, char **argv ) +{ + Application application = Application::New( &argc, &argv ); + + RunTest( application ); + + return 0; +} diff --git a/examples/rendering-textured-cube/rendering-textured-cube.cpp b/examples/rendering-textured-cube/rendering-textured-cube.cpp new file mode 100644 index 0000000..eeda48b --- /dev/null +++ b/examples/rendering-textured-cube/rendering-textured-cube.cpp @@ -0,0 +1,296 @@ +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include + +using namespace Dali; +using namespace Toolkit; + +namespace +{ + +/* + * Vertex shader + */ +const char* VERTEX_SHADER = DALI_COMPOSE_SHADER( +attribute mediump vec3 aPosition;\n // DALi shader builtin +attribute mediump vec2 aTexCoord;\n // DALi shader builtin +uniform mediump mat4 uMvpMatrix;\n // DALi shader builtin +uniform mediump vec3 uSize;\n // DALi shader builtin +\n +varying mediump vec2 vTexCoord;\n +void main()\n +{\n + mediump vec4 vertexPosition = vec4(aPosition, 1.0);\n + vertexPosition.xyz *= uSize;\n + vTexCoord = aTexCoord;\n + gl_Position = uMvpMatrix * vertexPosition;\n +}\n +); + +/* + * Fragment shader + */ +const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER( +uniform sampler2D uTexture;\n +\n +varying mediump vec2 vTexCoord;\n +void main()\n +{\n + mediump vec4 texColor = texture2D( uTexture, vTexCoord );\n + gl_FragColor = texColor;\n +}\n +); + +const char* TEXTURE_URL = DEMO_IMAGE_DIR "wood.png"; + +} + +// This example shows how to create textured cube +// +class TexturedCubeController : public ConnectionTracker +{ +public: + + TexturedCubeController( Application& application ) + : mApplication( application ) + { + // Connect to the Application's Init signal + mApplication.InitSignal().Connect( this, &TexturedCubeController::Create ); + } + + ~TexturedCubeController() + { + // Nothing to do here; + } + + // The Init signal is received once (only) during the Application lifetime + void Create( Application& application ) + { + // Get a handle to the stage + Stage stage = Stage::GetCurrent(); + stage.SetBackgroundColor( Color::WHITE ); + + // Step 1. Create shader + CreateCubeShader(); + + // Step 2. Load a texture + CreateTexture(); + + // Step 3. Prepare geometry + CreateCubeGeometry(); + + // Step 4. Create a renderer + CreateRenderer(); + + // Step 5. Create an Actor + CreateActor(); + + // Step 6. Play animation to rotate the cube + PlayAnimation(); + + // Respond to a click anywhere on the stage + stage.GetRootLayer().TouchSignal().Connect( this, &TexturedCubeController::OnTouch ); + } + + bool OnTouch( Actor actor, const TouchData& touch ) + { + // quit the application + mApplication.Quit(); + return true; + } + + /** + * @brief CreateCubeGeometry + * This function creates a cube geometry including texture coordinates. + * Also it demonstrates using the indexed draw feature by setting an index array. + */ + void CreateCubeGeometry() + { + struct Vertex + { + Vector3 aPosition; + Vector2 aTexCoord; + }; + + Vertex vertices[] = { + { Vector3( 1.0f,-1.0f,-1.0f ), Vector2( 1.0, 1.0 ) }, + { Vector3( -1.0f, 1.0f,-1.0f ), Vector2( 0.0, 0.0 ) }, + { Vector3( 1.0f, 1.0f,-1.0f ), Vector2( 0.0, 1.0 ) }, + { Vector3( -1.0f, 1.0f, 1.0f ), Vector2( 1.0, 1.0 ) }, + { Vector3( 1.0f,-1.0f, 1.0f ), Vector2( 0.0, 0.0 ) }, + { Vector3( 1.0f, 1.0f, 1.0f ), Vector2( 0.0, 1.0 ) }, + { Vector3( 1.0f, 1.0f, 1.0f ), Vector2( 1.0, 1.0 ) }, + { Vector3( 1.0f,-1.0f,-1.0f ), Vector2( 0.0, 0.0 ) }, + { Vector3( 1.0f, 1.0f,-1.0f ), Vector2( 0.0, 1.0 ) }, + { Vector3( 1.0f,-1.0f, 1.0f ), Vector2( 1.0, 1.0 ) }, + { Vector3( -1.0f,-1.0f,-1.0f ), Vector2( 0.0, 0.0 ) }, + { Vector3( 1.0f,-1.0f,-1.0f ), Vector2( 0.0, 1.0 ) }, + { Vector3( -1.0f,-1.0f,-1.0f ), Vector2( 1.0, 1.0 ) }, + { Vector3( -1.0f, 1.0f, 1.0f ), Vector2( 0.0, 0.0 ) }, + { Vector3( -1.0f, 1.0f,-1.0f ), Vector2( 0.0, 1.0 ) }, + { Vector3( 1.0f, 1.0f,-1.0f ), Vector2( 1.0, 1.0 ) }, + { Vector3( -1.0f, 1.0f, 1.0f ), Vector2( 0.0, 0.0 ) }, + { Vector3( 1.0f, 1.0f, 1.0f ), Vector2( 0.0, 1.0 ) }, + { Vector3( 1.0f,-1.0f,-1.0f ), Vector2( 1.0, 1.0 ) }, + { Vector3( -1.0f,-1.0f,-1.0f ), Vector2( 1.0, 0.0 ) }, + { Vector3( -1.0f, 1.0f,-1.0f ), Vector2( 0.0, 0.0 ) }, + { Vector3( -1.0f, 1.0f, 1.0f ), Vector2( 1.0, 1.0 ) }, + { Vector3( -1.0f,-1.0f, 1.0f ), Vector2( 1.0, 0.0 ) }, + { Vector3( 1.0f,-1.0f, 1.0f ), Vector2( 0.0, 0.0 ) }, + { Vector3( 1.0f, 1.0f, 1.0f ), Vector2( 1.0, 1.0 ) }, + { Vector3( 1.0f,-1.0f, 1.0f ), Vector2( 1.0, 0.0 ) }, + { Vector3( 1.0f,-1.0f,-1.0f ), Vector2( 0.0, 0.0 ) }, + { Vector3( 1.0f,-1.0f, 1.0f ), Vector2( 1.0, 1.0 ) }, + { Vector3( -1.0f,-1.0f, 1.0f ), Vector2( 1.0, 0.0 ) }, + { Vector3( -1.0f,-1.0f,-1.0f ), Vector2( 0.0, 0.0 ) }, + { Vector3( -1.0f,-1.0f,-1.0f ), Vector2( 1.0, 1.0 ) }, + { Vector3( -1.0f,-1.0f, 1.0f ), Vector2( 1.0, 0.0 ) }, + { Vector3( -1.0f, 1.0f, 1.0f ), Vector2( 0.0, 0.0 ) }, + { Vector3( 1.0f, 1.0f,-1.0f ), Vector2( 1.0, 1.0 ) }, + { Vector3( -1.0f, 1.0f,-1.0f ), Vector2( 1.0, 0.0 ) }, + { Vector3( -1.0f, 1.0f, 1.0f ), Vector2( 0.0, 0.0 ) }, + }; + + PropertyBuffer vertexBuffer = PropertyBuffer::New( Property::Map() + .Add( "aPosition", Property::VECTOR3 ) + .Add( "aTexCoord", Property::VECTOR2 ) ); + vertexBuffer.SetData( vertices, sizeof(vertices) / sizeof(Vertex) ); + + // create indices + const unsigned short INDEX_CUBE[] = { + 2, 1, 0, + 5, 4, 3, + 8, 7, 6, + 11, 10, 9, + 14, 13, 12, + 17, 16, 15, + 20, 19, 18, + 23, 22, 21, + 26, 25, 24, + 29, 28, 27, + 32, 31, 30, + 35, 34, 33 + }; + mGeometry = Geometry::New(); + mGeometry.AddVertexBuffer( vertexBuffer ); + mGeometry.SetIndexBuffer( INDEX_CUBE, + sizeof(INDEX_CUBE)/sizeof(INDEX_CUBE[0]) ); + mGeometry.SetType( Geometry::TRIANGLES ); + } + + /** + * Creates a shader using inlined variable VERTEX_SHADER and FRAGMENT_SHADER + * + * Shaders are very basic and all they do is transforming vertices and sampling + * a texture. + */ + void CreateCubeShader() + { + mShader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER ); + } + + /** + * This function loads a pixel data from a file. In order to load it we use SyncImageLoader utility. + * If loading succeeds returned PixelData object can be used to create a texture. + * Texture must be uploaded. In the end the texture must be set on the TextureSet object. + */ + void CreateTexture() + { + // Load image from file + PixelData pixels = SyncImageLoader::Load( TEXTURE_URL ); + + Texture texture = Texture::New( TextureType::TEXTURE_2D, pixels.GetPixelFormat(), pixels.GetWidth(), pixels.GetHeight() ); + texture.Upload( pixels, 0, 0, 0, 0, pixels.GetWidth(), pixels.GetHeight() ); + + // create TextureSet + mTextureSet = TextureSet::New(); + mTextureSet.SetTexture( 0, texture ); + } + + /** + * Function creates renderer. It turns on depth test and depth write. + */ + void CreateRenderer() + { + mRenderer = Renderer::New( mGeometry, mShader ); + mRenderer.SetTextures( mTextureSet ); + + // Face culling is enabled to hide the backwards facing sides of the cube + // This is sufficient to render a single object; for more complex scenes depth-testing might be required + mRenderer.SetProperty( Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::BACK ); + } + + /** + * Creates new actor and attaches renderer. + */ + void CreateActor() + { + Stage stage = Stage::GetCurrent(); + + float quarterStageWidth = stage.GetSize().x * 0.25f; + mActor = Actor::New(); + mActor.SetAnchorPoint( AnchorPoint::CENTER ); + mActor.SetParentOrigin( ParentOrigin::CENTER ); + mActor.SetPosition( Vector3( 0.0f, 0.0f, 0.0f ) ); + mActor.SetSize( Vector3( quarterStageWidth, quarterStageWidth, quarterStageWidth ) ); + mActor.AddRenderer( mRenderer ); + stage.Add( mActor ); + } + + /** + * Plays animation + */ + void PlayAnimation() + { + mAnimation = Animation::New( 5.0f ); + mAnimation.SetLooping( true ); + mAnimation.AnimateBy( Property( mActor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree( 360 )), Vector3::ZAXIS ) ); + mAnimation.AnimateBy( Property( mActor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree( 360 )), Vector3::YAXIS ) ); + mAnimation.AnimateBy( Property( mActor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree( 360 )), Vector3::XAXIS ) ); + mAnimation.Play(); + } + +private: + Application& mApplication; + + Renderer mRenderer; + Shader mShader; + Geometry mGeometry; + TextureSet mTextureSet; + Actor mActor; + Animation mAnimation; +}; + +void RunTest( Application& application ) +{ + TexturedCubeController test( application ); + + application.MainLoop(); +} + +// Entry point for Linux & Tizen applications +// +int DALI_EXPORT_API main( int argc, char **argv ) +{ + Application application = Application::New( &argc, &argv ); + + RunTest( application ); + + return 0; +} diff --git a/examples/rendering-triangle/rendering-triangle.cpp b/examples/rendering-triangle/rendering-triangle.cpp new file mode 100644 index 0000000..57233f8 --- /dev/null +++ b/examples/rendering-triangle/rendering-triangle.cpp @@ -0,0 +1,186 @@ +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include + +using namespace Dali; +using namespace Toolkit; + +namespace +{ + +/* + * Vertex shader + */ +const char* VERTEX_SHADER = DALI_COMPOSE_SHADER( +attribute mediump vec2 aPosition;\n // DALi shader builtin +uniform mediump mat4 uMvpMatrix;\n // DALi shader builtin +uniform mediump vec3 uSize;\n // DALi shader builtin +\n +void main()\n +{\n + mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n + vertexPosition.xyz *= uSize;\n + gl_Position = uMvpMatrix * vertexPosition;\n +}\n +); + +/* + * Fragment shader + */ +const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER( +uniform mediump vec4 uColor;\n +\n +void main()\n +{\n + gl_FragColor = uColor;\n +}\n +); + +} + +// This example shows how to draw a triangle in actor's color +// +class DrawTriangleController : public ConnectionTracker +{ +public: + + DrawTriangleController( Application& application ) + : mApplication( application ) + { + // Connect to the Application's Init signal + mApplication.InitSignal().Connect( this, &DrawTriangleController::Create ); + } + + ~DrawTriangleController() + { + // Nothing to do here; + } + + // The Init signal is received once (only) during the Application lifetime + void Create( Application& application ) + { + // Get a handle to the stage + Stage stage = Stage::GetCurrent(); + stage.SetBackgroundColor( Color::WHITE ); + + // Step 1. Create shader + CreateTriangleShader(); + + // Step 2. Prepare geometry + CreateTriangleGeometry(); + + // Step 3. Create a renderer + CreateRenderer(); + + // Step 4. Create an Actor + CreateActor(); + + // Respond to a click anywhere on the stage + stage.GetRootLayer().TouchSignal().Connect( this, &DrawTriangleController::OnTouch ); + } + + bool OnTouch( Actor actor, const TouchData& touch ) + { + // quit the application + mApplication.Quit(); + return true; + } + + /** + * This function creates a triangle geometry made of three vertices in order + * to draw a coloured triangle. + */ + void CreateTriangleGeometry() + { + Vector2 vertices[] = { + Vector2( -1.0f, -1.0f ), + Vector2( 1.0f, 1.0f ), + Vector2( -1.0f, 1.0f ) + }; + + PropertyBuffer vertexBuffer = PropertyBuffer::New( Property::Map() + .Add( "aPosition", Property::VECTOR2 ) ); + vertexBuffer.SetData( vertices, sizeof(vertices) / sizeof(Vector2) ); + + mGeometry = Geometry::New(); + mGeometry.AddVertexBuffer( vertexBuffer ); + mGeometry.SetType( Geometry::TRIANGLES ); + } + + /** + * Creates a shader using inlined variable VERTEX_SHADER and FRAGMENT_SHADER + * + * Shaders are very basic and all they do is transforming vertices and applying actor's colour. + */ + void CreateTriangleShader() + { + mShader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER ); + } + + /** + * Function creates renderer. + */ + void CreateRenderer() + { + mRenderer = Renderer::New( mGeometry, mShader ); + } + + /** + * Creates new actor and attaches renderer. + */ + void CreateActor() + { + Stage stage = Stage::GetCurrent(); + Size size = stage.GetSize() * 0.25f; + mActor = Actor::New(); + mActor.SetAnchorPoint( AnchorPoint::CENTER ); + mActor.SetParentOrigin( ParentOrigin::CENTER ); + mActor.SetPosition( Vector3( 0.0f, 0.0f, 0.0f ) ); + mActor.SetColor( Color::RED ); + mActor.SetSize( Vector3( size.x, size.x, size.x ) ); + mActor.AddRenderer( mRenderer ); + stage.Add( mActor ); + } + +private: + Application& mApplication; + + Renderer mRenderer; + Shader mShader; + Geometry mGeometry; + Actor mActor; +}; + +void RunTest( Application& application ) +{ + DrawTriangleController test( application ); + + application.MainLoop(); +} + +// Entry point for Linux & Tizen applications +// +int DALI_EXPORT_API main( int argc, char **argv ) +{ + Application application = Application::New( &argc, &argv ); + + RunTest( application ); + + return 0; +} diff --git a/examples/simple-visuals-control/my-control-impl.cpp b/examples/simple-visuals-control/my-control-impl.cpp new file mode 100644 index 0000000..7c8a602 --- /dev/null +++ b/examples/simple-visuals-control/my-control-impl.cpp @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// CLASS HEADER + +#include "my-control-impl.h" + +// EXTERNAL INCLUDES + +#include +#include +#include +#include +#include +#include + +using namespace Dali; +using namespace Dali::Toolkit; + +namespace Demo +{ +namespace Internal +{ + +namespace +{ + + +Dali::BaseHandle Create() +{ + return Demo::MyControl::New(); +} + +// Required code for Property set up. + +DALI_TYPE_REGISTRATION_BEGIN( MyControl, Dali::Toolkit::Control, Create ); + +DALI_PROPERTY_REGISTRATION( Demo, MyControl, "iconVisual", MAP, ICON_VISUAL ) + +DALI_TYPE_REGISTRATION_END(); + +// Add an enum to string conversion entry for the control's visuals. In this case just the icon visual. +// Enables Setting of the property using enums or strings. +DALI_ENUM_TO_STRING_TABLE_BEGIN( VISUAL_PROPERTIES ) +{ "iconVisual", Demo::MyControl::Property::ICON_VISUAL }, +DALI_ENUM_TO_STRING_TABLE_END( VISUAL_PROPERTIES ) + + +} // anonymous namespace + + +Internal::MyControl::MyControl() +: Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ) +{ +} + +Demo::MyControl Internal::MyControl::New() +{ + IntrusivePtr impl = new Internal::MyControl(); + Demo::MyControl handle = Demo::MyControl( *impl ); + impl->Initialize(); + return handle; +} + +void MyControl::OnInitialize() +{ + Dali::Actor self = Self(); + self.SetKeyboardFocusable( true ); +} + +void MyControl::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value ) +{ + Demo::MyControl myControl = Demo::MyControl::DownCast( Dali::BaseHandle( object ) ); + + if( myControl ) + { + MyControl& impl = GetImpl( myControl ); + switch ( index ) + { + case Demo::MyControl::Property::ICON_VISUAL: + { + Toolkit::Visual::Base iconVisual; + Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get(); + Property::Map *map = value.GetMap(); + if( map && !map->Empty() ) + { + iconVisual = visualFactory.CreateVisual( *map ); + } + + if ( iconVisual ) + { + impl.RegisterVisual( index, iconVisual ); + } + break; + } + } + } +} + +Property::Value MyControl::GetProperty( BaseObject* object, Property::Index propertyIndex ) +{ + Property::Value value; + + Demo::MyControl myControl = Demo::MyControl::DownCast( Dali::BaseHandle( object ) ); + + if ( myControl ) + { + switch ( propertyIndex ) + { + case Demo::MyControl::Property::ICON_VISUAL: + { + Property::Map map; + Toolkit::Visual::Base visual = GetImpl( myControl ).GetVisual( propertyIndex ); + if ( visual ) + { + visual.CreatePropertyMap( map ); // Creates a Property map containing the Visual that ICON_VISUAL currently is. Can change if state changes. + value = map; + } + break; + } + default: + break; + } + } + + return value; +} + +} // Internal +} // Demo diff --git a/examples/simple-visuals-control/my-control-impl.h b/examples/simple-visuals-control/my-control-impl.h new file mode 100644 index 0000000..76d8428 --- /dev/null +++ b/examples/simple-visuals-control/my-control-impl.h @@ -0,0 +1,103 @@ +#ifndef DALI_DEMO_INTERNAL_MY_CONTROL_IMPL_H +#define DALI_DEMO_INTERNAL_MY_CONTROL_IMPL_H + +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// CLASS HEADER +#include "my-control.h" + +// EXTERNAL INCLUDES +#include +#include + +namespace Demo +{ + +namespace Internal // To use TypeRegistry, handle and body classes need the same name +{ + +/** + * @brief A Simple Control to show use of visuals with a style sheet and changing visuals with a state change + */ + +class MyControl : public Dali::Toolkit::Internal::Control +{ +public: + /** + * @brief Instantiate a new ContentView object + */ + static Demo::MyControl New(); + + /** + * @brief Default constructor + */ + MyControl(); + +public: // Properties + /** + * @brief Called when a property of an object of this type is set. + * + * @param[in] object The object whose property is set. + * @param[in] index The property index. + * @param[in] value The new property value. + */ + static void SetProperty( Dali::BaseObject* object, Dali::Property::Index index, const Dali::Property::Value& value ); + + /** + * @brief Called to retrieve a property of an object of this type. + * + * @param[in] object The object whose property is to be retrieved. + * @param[in] index The property index. + * @return The current value of the property. + */ + static Dali::Property::Value GetProperty( Dali::BaseObject* object, Dali::Property::Index propertyIndex ); + +private: // From Control + /** + * @copydoc Toolkit::Control::OnInitialize() + */ + virtual void OnInitialize(); + +private: + /** + * undefined constructor and operator= + */ + MyControl( const MyControl& ); + MyControl& operator=( const MyControl& ); + +private: +}; + +} // Internal + +inline Internal::MyControl& GetImpl( Demo::MyControl& handle ) +{ + DALI_ASSERT_ALWAYS( handle ); + Dali::RefObject& object = handle.GetImplementation(); + return static_cast(object); +} + +inline const Internal::MyControl& GetImpl( const Demo::MyControl& handle ) +{ + DALI_ASSERT_ALWAYS( handle ); + const Dali::RefObject& object = handle.GetImplementation(); + return static_cast(object); +} + +} // Demo + +#endif // DALI_DEMO_INTERNAL_MY_CONTROL_IMPL_H diff --git a/examples/simple-visuals-control/my-control.cpp b/examples/simple-visuals-control/my-control.cpp new file mode 100644 index 0000000..65f5c28 --- /dev/null +++ b/examples/simple-visuals-control/my-control.cpp @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// CLASS HEADER +#include "my-control.h" + +// INTERNAL INCLUDES +#include "my-control-impl.h" + +namespace Demo +{ + +MyControl::MyControl() +{ +} + +MyControl::MyControl( const MyControl& control ) +: Control( control ) +{ +} + +MyControl& MyControl::operator= ( const MyControl& rhs ) +{ + if( &rhs != this ) + { + Control::operator=( rhs ); + } + return *this; +} + +MyControl::~MyControl() +{ +} + +MyControl MyControl::New() +{ + MyControl control = Internal::MyControl::New(); + return control; +} + +MyControl MyControl::DownCast( BaseHandle handle ) +{ + return Control::DownCast< MyControl, Internal::MyControl > ( handle ); +} + +MyControl::MyControl( Internal::MyControl& implementation ) +: Control( implementation ) +{ +} + +MyControl::MyControl( Dali::Internal::CustomActor* internal ) +: Control( internal ) +{ + VerifyCustomActorPointer< Internal::MyControl >( internal ) ; +} + + +} //namespace Demo diff --git a/examples/simple-visuals-control/my-control.h b/examples/simple-visuals-control/my-control.h new file mode 100644 index 0000000..3517b81 --- /dev/null +++ b/examples/simple-visuals-control/my-control.h @@ -0,0 +1,135 @@ +#ifndef DALI_DEMO_MY_CONTROL_H +#define DALI_DEMO_MY_CONTROL_H + +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +namespace Demo +{ + +namespace Internal +{ +class MyControl; +} + +/** + * @brief MyControl is an example control, + * + * @details It's purpose is to show how to create a simple control to work with the style sheet and state changes. + * States changes includes Normal, Focused and Disabled, this example uses the style sheet to set visuals for Normal and Focused states. + * When the Focus manager changes the control to be focused the visual displayed is changed and vice versa. + * + * The visual has the property name ICON_VISUAL with the style sheet string equivalent of "iconVisual" + * + */ + +class MyControl : public Dali::Toolkit::Control +{ +public: + + /** + * The start and end property ranges for this Control + * My control can use properties from Toolkit::Control as it is derived from it. As control is derived from Actor, MyControl can also use Dali::Actor Properties. + * + * To ensure that the Property indexes from MyControl do not shadow any from Control we start it's index from the end of Toolkit::Control's indexes. + * + * Toolkit::Control would have done the same with Actor. + * + * The end index for this control is set to the start index + 1000 hence MyControl can have 1000 property indexes. + * + * PROPERTY_END_INDEX for MyControl is public, if another control is derived from it then if can specify MyControl::PROPERTY_END_INDEX+1 to start it's + * indexing after MyControls last index. + */ + enum PropertyRange + { + PROPERTY_START_INDEX = Dali::Toolkit::Control::CONTROL_PROPERTY_END_INDEX + 1, + PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000, + ANIMATABLE_PROPERTY_START_INDEX = Dali::ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX, + ANIMATABLE_PROPERTY_END_INDEX = ANIMATABLE_PROPERTY_START_INDEX+1000 + }; + + struct Property + { + enum + { + /** + * @brief name "iconVisual", type string if it is a url, map otherwise + * @details Sets the icon visual to be displayed by the control + */ + ICON_VISUAL = PROPERTY_START_INDEX + }; + }; + +public: // Construction / destruction + + /** + * @brief Create an uninitialized handle + */ + MyControl(); + + /** + * @brief Create a new MyControl + */ + static MyControl New(); + + /** + * @brief Destructor. This is non-virtual since derived Handle types must not contain data or virtual methods + */ + ~MyControl(); + + /** + * @brief Copy Constructor + * + * @param[in] shadowButton the handle of the control to copy + */ + MyControl( const MyControl& shadowButton ); + + /** + * @brief Assignment Operator + * + * @param[in] shadowButton the source of the assignment + */ + MyControl& operator=( const MyControl& shadowButton ); + + /** + * @brief Downcast + * + * @param[in] shadowButton the handle of control to downcast to MyControl + */ + static MyControl DownCast( BaseHandle handle ); + + +public: // // Not intended for application developers + + /// @cond internal + /** + * @brief Create a handle from an implementation + */ + MyControl( Internal::MyControl& implementation ); + + /** + * @brief Allow the creation of an ShadowButton handle from an internal CustomActor pointer + */ + MyControl( Dali::Internal::CustomActor* internal ); + /// @endcond +}; + +} // namespace Demo + +#endif // DALI_DEMO_MY_CONTROL_H diff --git a/examples/simple-visuals-control/simple-visuals-application.cpp b/examples/simple-visuals-control/simple-visuals-application.cpp new file mode 100644 index 0000000..a698f17 --- /dev/null +++ b/examples/simple-visuals-control/simple-visuals-application.cpp @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// CLASS HEADER +#include "my-control.h" + +// EXTERNAL INCLUDES +#include +#include +#include +#include +#include +#include +#include + +// INTERNAL INCLUDES +#include "simple-visuals-application.h" + +using namespace Dali; +using namespace Dali::Toolkit; + +namespace +{ + +} + +namespace Demo +{ + +const char* ICON_IMAGE( DEMO_IMAGE_DIR "application-icon-13.png" ); + +SimpleVisualsApplication::SimpleVisualsApplication( Application& application ) +: mApplication( application ), + mMyControl() +{ + application.InitSignal().Connect( this, &SimpleVisualsApplication::Create ); +} + +Dali::Actor SimpleVisualsApplication::OnKeyboardPreFocusChange( Dali::Actor current, Dali::Actor proposed, Dali::Toolkit::Control::KeyboardFocus::Direction direction ) +{ + Actor nextFocusActor = proposed; + + if( !current && !proposed ) + { + // Set the initial focus to the first tile in the current page should be focused. + nextFocusActor = mMyControl; + } + else + { + if ( current == mMyControl ) + { + nextFocusActor = mMyControl2; + } + else + { + nextFocusActor = mMyControl; + } + } + + return nextFocusActor; +} + + +void SimpleVisualsApplication::OnKeyEvent( const KeyEvent& keyEvent ) +{ + static int keyPressed = 0; + + if( keyEvent.state == KeyEvent::Down) + { + if( keyPressed == 0 ) // Is this the first down event? + { + printf("Key pressed: %s %d\n", keyEvent.keyPressedName.c_str(), keyEvent.keyCode ); + + if( IsKey( keyEvent, DALI_KEY_ESCAPE) || IsKey( keyEvent, DALI_KEY_BACK ) ) + { + mApplication.Quit(); + } + else if( keyEvent.keyPressedName.compare("Return") == 0 ) + { + } + } + keyPressed = 1; + } + else if( keyEvent.state == KeyEvent::Up ) + { + keyPressed = 0; + } +} + +void SimpleVisualsApplication::Create( Application& application ) +{ + Stage stage = Stage::GetCurrent(); + stage.SetBackgroundColor( Vector4( 0.1f, 0.1f, 0.1f, 1.0f ) ); + + // Connect to key events so can quit application + stage.KeyEventSignal().Connect(this, &SimpleVisualsApplication::OnKeyEvent); + + // Hide the indicator bar + application.GetWindow().ShowIndicator( Dali::Window::INVISIBLE ); + + // Create a table view to parent the 2 MyControls + TableView contentLayout = TableView::New( 2, 2 ); + contentLayout.SetName("ContentLayout"); + contentLayout.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); + contentLayout.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::HEIGHT ); + contentLayout.SetSizeModeFactor( Vector3( 1.0f, .5f, 1.0f ) ); + contentLayout.SetAnchorPoint( AnchorPoint::CENTER ); + contentLayout.SetParentOrigin( ParentOrigin::CENTER ); + contentLayout.SetCellPadding( Vector2( 50.0f, 15.0f ) ); + contentLayout.SetBackgroundColor( Vector4(0.949, 0.949, 0.949, 1.0) ); + + // Listen to focus change so can see Visual change from NORMAL to FOCUSED state + KeyboardFocusManager::Get().PreFocusChangeSignal().Connect( this, &SimpleVisualsApplication::OnKeyboardPreFocusChange ); + + stage.Add( contentLayout ); + + // Create 2 MyControls and add to table view. + mMyControl = MyControl::New(); + mMyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); + mMyControl.SetParentOrigin(ParentOrigin::TOP_LEFT); + + mMyControl2 = MyControl::New(); + mMyControl2.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); + mMyControl2.SetParentOrigin(ParentOrigin::CENTER); + + contentLayout.AddChild( mMyControl2, TableView::CellPosition(0, 0) ); + contentLayout.AddChild( mMyControl, TableView::CellPosition(0, 1) ); +} + +} // namespace Demo diff --git a/examples/simple-visuals-control/simple-visuals-application.h b/examples/simple-visuals-control/simple-visuals-application.h new file mode 100644 index 0000000..b0e5982 --- /dev/null +++ b/examples/simple-visuals-control/simple-visuals-application.h @@ -0,0 +1,89 @@ +#ifndef DALI_DEMO_SIMPLE_VISUALS_APPLICATION_H +#define DALI_DEMO_SIMPLE_VISUALS_APPLICATION_H + +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// EXTERNAL INCLUDES +#include +#include +#include + +// INTERNAL INCLUDES +#include "my-control.h" + +using namespace Dali; +using namespace Dali::Toolkit; + +namespace Demo +{ + +/** + * @brief An application that uses the my-control to display 2 icons, if focus is allowed ( by using a keyboard or remote ) then the icons will change + * depending on which one is focused. + * + * Inherits from connection tracker to manage connection and disconnection of signals, In this case PreFocusChangeSignal + */ +class SimpleVisualsApplication : public ConnectionTracker +{ + +public: + + /** + * @brief Constructor. + * + * @param[in] application A reference to the Application class. + */ + SimpleVisualsApplication( Application& application ); + + +private: + /** + * @brief Listen to Focus change signal + * @param[in] current Current focused Actor + * @param[in] proposed New actor that is requesting to be focused + * @param[in] direction The direction of the focus event from current actor + */ + Dali::Actor OnKeyboardPreFocusChange( Dali::Actor current, Dali::Actor proposed, Dali::Toolkit::Control::KeyboardFocus::Direction direction ); + + /** + * @brief Derived from control, enables capture of key presses + * + * @param[in] event In incoming key event + */ + void OnKeyEvent( const KeyEvent& event ); + + /** + * @brief Called to initialise the application content + * + * @param[in] application A reference to the Application class. + */ + void Create( Application& application ); + + +private: + + Application& mApplication; // Handle to the application that is created and passed in. + + MyControl mMyControl; // Handle to first instance of MyControl + MyControl mMyControl2; // Handle to second instance of MyControl + +}; + +} // Namespace Demo + + +#endif // DALI_DEMO_SIMPLE_VISUALS_APPLICATION_H diff --git a/examples/simple-visuals-control/simple-visuals-example.cpp b/examples/simple-visuals-control/simple-visuals-example.cpp new file mode 100644 index 0000000..1011243 --- /dev/null +++ b/examples/simple-visuals-control/simple-visuals-example.cpp @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file transition-example.cpp + * @brief Example of a control built with visuals + */ + +// EXTERNAL INCLUDES +#include + +// INTERNAL INCLUDES +#include "simple-visuals-application.h" + +namespace +{ +// Style sheet to be used by this application +const char* SIMPLE_DEMO_THEME( DEMO_STYLE_DIR "simple-example-theme.json" ); +} + +/// Entry point for applications +int DALI_EXPORT_API main( int argc, char** argv ) +{ + Application application = Application::New( &argc, &argv, SIMPLE_DEMO_THEME ); // Use the above defined style sheet for this application. + Demo::SimpleVisualsApplication simpleVisualsApplication( application ); + application.MainLoop(); + return 0; +} diff --git a/examples/text-field/text-field-example.cpp b/examples/text-field/text-field-example.cpp index 5e025b1..944cb71 100644 --- a/examples/text-field/text-field-example.cpp +++ b/examples/text-field/text-field-example.cpp @@ -43,7 +43,7 @@ namespace const float BORDER_WIDTH = 4.0f; - const Vector3 POPUP_SIZE_FACTOR_TO_PARENT = Vector3( 0.0, 0.25, 0.0 ); + const Vector3 POPUP_SIZE_FACTOR_TO_PARENT = Vector3( 0.8, 0.25, 0.0 ); } // unnamed namespace @@ -90,10 +90,6 @@ public: button.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, FOLDER_ICON_IMAGE ); button.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, FOLDER_OPEN_ICON_IMAGE ); button.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - button.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS ); - ImageDimensions imageSize = ResourceImage::GetImageSize( FOLDER_ICON_IMAGE ); - button.SetSize( imageSize.GetWidth(), imageSize.GetHeight() ); - return button; } @@ -107,7 +103,7 @@ public: // Launch a pop-up containing TextField mField = CreateTextField( stageSize, mButtonLabel ); - mPopup = CreatePopup( stageSize.width * 0.8f ); + mPopup = CreatePopup(); mPopup.Add( mField ); mPopup.OutsideTouchedSignal().Connect( this, &TextFieldExample::OnPopupOutsideTouched ); stage.Add( mPopup ); @@ -132,13 +128,12 @@ public: return field; } - Popup CreatePopup( float width ) + Popup CreatePopup() { Popup popup = Popup::New(); popup.SetParentOrigin( ParentOrigin::CENTER ); popup.SetAnchorPoint( AnchorPoint::CENTER ); - popup.SetSize( width, 0.0f ); - popup.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::HEIGHT ); + popup.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS ); popup.SetSizeModeFactor( POPUP_SIZE_FACTOR_TO_PARENT ); popup.TouchSignal().Connect( this, &TextFieldExample::OnPopupTouched ); diff --git a/examples/visual-transitions/transition-application.cpp b/examples/visual-transitions/transition-application.cpp index 32c4188..fcb7c00 100644 --- a/examples/visual-transitions/transition-application.cpp +++ b/examples/visual-transitions/transition-application.cpp @@ -49,6 +49,7 @@ TransitionApplication::TransitionApplication( Application& application ) mTitle(), mBeatControl(), mActionButtons(), + mVisualIndex( Property::INVALID_INDEX ), mActionIndex( Property::INVALID_INDEX ) { application.InitSignal().Connect( this, &TransitionApplication::Create ); diff --git a/packaging/com.samsung.dali-demo.spec b/packaging/com.samsung.dali-demo.spec index 8da33a6..ac29ff8 100755 --- a/packaging/com.samsung.dali-demo.spec +++ b/packaging/com.samsung.dali-demo.spec @@ -2,7 +2,7 @@ Name: com.samsung.dali-demo Summary: The OpenGLES Canvas Core Demo -Version: 1.2.28 +Version: 1.2.29 Release: 1 Group: System/Libraries License: Apache-2.0 diff --git a/resources/po/as.po b/resources/po/as.po index cc27807..62e9c3f 100755 --- a/resources/po/as.po +++ b/resources/po/as.po @@ -147,3 +147,15 @@ msgstr "Tooltip" msgid "DALI_DEMO_STR_TITLE_FPP_GAME" msgstr "FPP খেলা" + +msgid "DALI_DEMO_STR_TITLE_RENDERING_TEXTURED_CUBE" +msgstr "ৰেণ্ডাৰিং গাঁথনি" + +msgid "DALI_DEMO_STR_TITLE_RENDERING_DRAW_CUBE" +msgstr "ৰেণ্ডাৰিং ঘনক" + +msgid "DALI_DEMO_STR_TITLE_RENDERING_DRAW_TRIANGLE" +msgstr "ৰেণ্ডাৰিং ত্ৰিকোণমিতি" + +msgid "DALI_DEMO_STR_TITLE_RENDERING_DRAW_LINE" +msgstr "ৰেণ্ডাৰিং শাৰী" diff --git a/resources/po/de.po b/resources/po/de.po index ece6e56..fb5a408 100755 --- a/resources/po/de.po +++ b/resources/po/de.po @@ -147,3 +147,15 @@ msgstr "Kurzinfo" msgid "DALI_DEMO_STR_TITLE_FPP_GAME" msgstr "FPP Spiel" + +msgid "DALI_DEMO_STR_TITLE_RENDERING_TEXTURED_CUBE" +msgstr "Texturierter Würfel" + +msgid "DALI_DEMO_STR_TITLE_RENDERING_DRAW_CUBE" +msgstr "Würfel zeichnen" + +msgid "DALI_DEMO_STR_TITLE_RENDERING_DRAW_TRIANGLE" +msgstr "Dreieck zeichnen" + +msgid "DALI_DEMO_STR_TITLE_RENDERING_DRAW_LINE" +msgstr "Zeichnen" diff --git a/resources/po/en_GB.po b/resources/po/en_GB.po index 5054071..9c43823 100755 --- a/resources/po/en_GB.po +++ b/resources/po/en_GB.po @@ -109,6 +109,9 @@ msgstr "Refraction" msgid "DALI_DEMO_STR_TITLE_RENDERER_STENCIL" msgstr "Renderer Stencil" +msgid "DALI_DEMO_STR_TITLE_SIMPLE_VISUALS_CONTROL" +msgstr "Simple Visuals Control" + msgid "DALI_DEMO_STR_TITLE_SCRIPT_BASED_UI" msgstr "Script-based UI" @@ -150,3 +153,15 @@ msgstr "FPP Game" msgid "DALI_DEMO_STR_TITLE_VISUAL_TRANSITIONS" msgstr "Visual Transitions" + +msgid "DALI_DEMO_STR_TITLE_RENDERING_TEXTURED_CUBE" +msgstr "Textured cube" + +msgid "DALI_DEMO_STR_TITLE_RENDERING_DRAW_CUBE" +msgstr "Draw cube" + +msgid "DALI_DEMO_STR_TITLE_RENDERING_DRAW_TRIANGLE" +msgstr "Draw triangle" + +msgid "DALI_DEMO_STR_TITLE_RENDERING_DRAW_LINE" +msgstr "Draw line" diff --git a/resources/po/en_US.po b/resources/po/en_US.po index 28ed480..30cedc6 100755 --- a/resources/po/en_US.po +++ b/resources/po/en_US.po @@ -109,6 +109,9 @@ msgstr "Refraction" msgid "DALI_DEMO_STR_TITLE_RENDERER_STENCIL" msgstr "Renderer Stencil" +msgid "DALI_DEMO_STR_TITLE_SIMPLE_VISUALS_CONTROL" +msgstr "Simple Visuals Control" + msgid "DALI_DEMO_STR_TITLE_SCRIPT_BASED_UI" msgstr "Script-based UI" @@ -150,3 +153,15 @@ msgstr "FPP Game" msgid "DALI_DEMO_STR_TITLE_VISUAL_TRANSITIONS" msgstr "Visual Transitions" + +msgid "DALI_DEMO_STR_TITLE_RENDERING_TEXTURED_CUBE" +msgstr "Textured cube" + +msgid "DALI_DEMO_STR_TITLE_RENDERING_DRAW_CUBE" +msgstr "Draw cube" + +msgid "DALI_DEMO_STR_TITLE_RENDERING_DRAW_TRIANGLE" +msgstr "Draw triangle" + +msgid "DALI_DEMO_STR_TITLE_RENDERING_DRAW_LINE" +msgstr "Draw line" diff --git a/resources/po/es.po b/resources/po/es.po index 6426481..6f89f16 100755 --- a/resources/po/es.po +++ b/resources/po/es.po @@ -147,3 +147,15 @@ msgstr "Tooltip" msgid "DALI_DEMO_STR_TITLE_FPP_GAME" msgstr "Juego FPP" + +msgid "DALI_DEMO_STR_TITLE_RENDERING_TEXTURED_CUBE" +msgstr "Cubo con textura" + +msgid "DALI_DEMO_STR_TITLE_RENDERING_DRAW_CUBE" +msgstr "Dibujar cubo" + +msgid "DALI_DEMO_STR_TITLE_RENDERING_DRAW_TRIANGLE" +msgstr "Dibujar triángulo" + +msgid "DALI_DEMO_STR_TITLE_RENDERING_DRAW_LINE" +msgstr "Dibujar linea" diff --git a/resources/po/fi.po b/resources/po/fi.po index 57f5600..d27c376 100755 --- a/resources/po/fi.po +++ b/resources/po/fi.po @@ -147,3 +147,15 @@ msgstr "Tooltip" msgid "DALI_DEMO_STR_TITLE_FPP_GAME" msgstr "FPP peli" + +msgid "DALI_DEMO_STR_TITLE_RENDERING_TEXTURED_CUBE" +msgstr "kuvioitu kuutio" + +msgid "DALI_DEMO_STR_TITLE_RENDERING_DRAW_CUBE" +msgstr "piirtää kuutio" + +msgid "DALI_DEMO_STR_TITLE_RENDERING_DRAW_TRIANGLE" +msgstr "Piirrä kolmio" + +msgid "DALI_DEMO_STR_TITLE_RENDERING_DRAW_LINE" +msgstr "Draw linja" diff --git a/resources/po/ko.po b/resources/po/ko.po index 0b375c6..73c953d 100755 --- a/resources/po/ko.po +++ b/resources/po/ko.po @@ -147,3 +147,15 @@ msgstr "툴팁" msgid "DALI_DEMO_STR_TITLE_FPP_GAME" msgstr "FPP Game" + +msgid "DALI_DEMO_STR_TITLE_RENDERING_TEXTURED_CUBE" +msgstr "질감 입방체" + +msgid "DALI_DEMO_STR_TITLE_RENDERING_DRAW_CUBE" +msgstr "큐브 그리기" + +msgid "DALI_DEMO_STR_TITLE_RENDERING_DRAW_TRIANGLE" +msgstr "삼각형 그리기" + +msgid "DALI_DEMO_STR_TITLE_RENDERING_DRAW_LINE" +msgstr "선 그리기" diff --git a/resources/po/ml.po b/resources/po/ml.po index 414c7bd..2d6be55 100755 --- a/resources/po/ml.po +++ b/resources/po/ml.po @@ -147,3 +147,15 @@ msgstr "കൂടുതൽ വിവരങ്ങൾ" msgid "DALI_DEMO_STR_TITLE_FPP_GAME" msgstr "FPP Game" + +msgid "DALI_DEMO_STR_TITLE_RENDERING_TEXTURED_CUBE" +msgstr "ടെക്സ്ചർ ക്യൂബ്" + +msgid "DALI_DEMO_STR_TITLE_RENDERING_DRAW_CUBE" +msgstr "ക്യൂബ് വരയ്ക്കുക" + +msgid "DALI_DEMO_STR_TITLE_RENDERING_DRAW_TRIANGLE" +msgstr "ത്രികോണം വരയ്ക്കുക" + +msgid "DALI_DEMO_STR_TITLE_RENDERING_DRAW_LINE" +msgstr "സമനില ലൈൻ" diff --git a/resources/po/ur.po b/resources/po/ur.po index d7b6cc6..212d7ad 100755 --- a/resources/po/ur.po +++ b/resources/po/ur.po @@ -147,3 +147,15 @@ msgstr "مزید معلومات" msgid "DALI_DEMO_STR_TITLE_FPP_GAME" msgstr "FPP گیم" + +msgid "DALI_DEMO_STR_TITLE_RENDERING_TEXTURED_CUBE" +msgstr "بویک ٹوانب " + +msgid "DALI_DEMO_STR_TITLE_RENDERING_DRAW_CUBE" +msgstr "ارڈ بویک " + +msgid "DALI_DEMO_STR_TITLE_RENDERING_DRAW_TRIANGLE" +msgstr "ارڈ ثلثم " + +msgid "DALI_DEMO_STR_TITLE_RENDERING_DRAW_LINE" +msgstr "انچنیھک ریکل " diff --git a/resources/po/zn_CH.po b/resources/po/zn_CH.po index 55e7377..5664c1d 100755 --- a/resources/po/zn_CH.po +++ b/resources/po/zn_CH.po @@ -147,3 +147,15 @@ msgstr "更多信息" msgid "DALI_DEMO_STR_TITLE_FPP_GAME" msgstr "FPP游戏" + +msgid "DALI_DEMO_STR_TITLE_RENDERING_TEXTURED_CUBE" +msgstr "纹理的多维数据集" + +msgid "DALI_DEMO_STR_TITLE_RENDERING_DRAW_CUBE" +msgstr "绘制多维数据集" + +msgid "DALI_DEMO_STR_TITLE_RENDERING_DRAW_TRIANGLE" +msgstr "绘制三角形" + +msgid "DALI_DEMO_STR_TITLE_RENDERING_DRAW_LINE" +msgstr "画线" diff --git a/resources/style/.gitignore b/resources/style/.gitignore index 0e59dee..0922f84 100644 --- a/resources/style/.gitignore +++ b/resources/style/.gitignore @@ -1,6 +1,7 @@ demo-theme.json contact-cards-example-theme.json progress-bar-example-theme.json +simple-example-theme.json style-example-theme-three.json style-example-theme-two.json style-example-theme-one.json diff --git a/resources/style/demo-theme.json.in b/resources/style/demo-theme.json.in index d0caa87..62d717a 100644 --- a/resources/style/demo-theme.json.in +++ b/resources/style/demo-theme.json.in @@ -183,6 +183,35 @@ "units": "USER_SPACE", "stopColor": [[0.247,0.38,0.52,1.0],[0.055,0.18,0.286,1.0]] } + }, +// +// Simple Visuals Application Style section +// + "MyControl": + { + "states": + { + "NORMAL": + { + "visuals": + { + "iconVisual": + { + "url":"{APPLICATION_RESOURCE_PATH}/images/application-icon-13.png" + } + } + }, + "FOCUSED": + { + "visuals": + { + "iconVisual": + { + "url":"{APPLICATION_RESOURCE_PATH}/images/application-icon-83.png" + } + } + } + } } } } diff --git a/resources/style/mobile/simple-example-theme.json.in b/resources/style/mobile/simple-example-theme.json.in new file mode 100644 index 0000000..d2b68e5 --- /dev/null +++ b/resources/style/mobile/simple-example-theme.json.in @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2000-2017 Samsung Electronics Co., Ltd + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +{ + "styles": + { + // + // Simple Visuals Application styling + // + "MyControl": + { + "states": + { + "NORMAL": + { + "visuals": + { + "iconVisual": + { + "url":"{APPLICATION_RESOURCE_PATH}/images/application-icon-13.png" + } + } + }, + "FOCUSED": + { + "visuals": + { + "iconVisual": + { + "url":"{APPLICATION_RESOURCE_PATH}/images/application-icon-83.png" + } + } + } + } + } + } +} diff --git a/resources/style/simple-example-theme.json.in b/resources/style/simple-example-theme.json.in new file mode 100644 index 0000000..d2b68e5 --- /dev/null +++ b/resources/style/simple-example-theme.json.in @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2000-2017 Samsung Electronics Co., Ltd + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +{ + "styles": + { + // + // Simple Visuals Application styling + // + "MyControl": + { + "states": + { + "NORMAL": + { + "visuals": + { + "iconVisual": + { + "url":"{APPLICATION_RESOURCE_PATH}/images/application-icon-13.png" + } + } + }, + "FOCUSED": + { + "visuals": + { + "iconVisual": + { + "url":"{APPLICATION_RESOURCE_PATH}/images/application-icon-83.png" + } + } + } + } + } + } +} diff --git a/shared/dali-demo-strings.h b/shared/dali-demo-strings.h index 6c6d171..e8f490e 100644 --- a/shared/dali-demo-strings.h +++ b/shared/dali-demo-strings.h @@ -67,8 +67,13 @@ extern "C" #define DALI_DEMO_STR_TITLE_POPUP dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_POPUP") #define DALI_DEMO_STR_TITLE_PRIMITIVE_SHAPES dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_PRIMITIVE_SHAPES") #define DALI_DEMO_STR_TITLE_PROGRESS_BAR dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_PROGRESS_BAR") +#define DALI_DEMO_STR_TITLE_RENDERING_DRAW_LINE dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_RENDERING_DRAW_LINE") +#define DALI_DEMO_STR_TITLE_RENDERING_DRAW_TRIANGLE dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_RENDERING_DRAW_TRIANGLE") +#define DALI_DEMO_STR_TITLE_RENDERING_DRAW_CUBE dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_RENDERING_DRAW_CUBE") +#define DALI_DEMO_STR_TITLE_RENDERING_TEXTURED_CUBE dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_RENDERING_TEXTURED_CUBE") #define DALI_DEMO_STR_TITLE_REFRACTION dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_REFRACTION") #define DALI_DEMO_STR_TITLE_RENDERER_STENCIL dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_RENDERER_STENCIL") +#define DALI_DEMO_STR_TITLE_SIMPLE_VISUALS_CONTROL dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_SIMPLE_VISUALS") #define DALI_DEMO_STR_TITLE_SCRIPT_BASED_UI dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_SCRIPT_BASED_UI") #define DALI_DEMO_STR_TITLE_SCROLL_VIEW dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_SCROLL_VIEW") #define DALI_DEMO_STR_TITLE_SPARKLE dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_SPARKLE") @@ -120,8 +125,13 @@ extern "C" #define DALI_DEMO_STR_TITLE_POPUP "Popup" #define DALI_DEMO_STR_TITLE_PRIMITIVE_SHAPES "Primitive Shapes" #define DALI_DEMO_STR_TITLE_PROGRESS_BAR "Progress Bar" +#define DALI_DEMO_STR_TITLE_RENDERING_DRAW_LINE "Draw Line" +#define DALI_DEMO_STR_TITLE_RENDERING_DRAW_TRIANGLE "Draw Triangle" +#define DALI_DEMO_STR_TITLE_RENDERING_DRAW_CUBE "Draw Cube" +#define DALI_DEMO_STR_TITLE_RENDERING_TEXTURED_CUBE "Textured Cube" #define DALI_DEMO_STR_TITLE_REFRACTION "Refract Effect" #define DALI_DEMO_STR_TITLE_RENDERER_STENCIL "Renderer Stencils" +#define DALI_DEMO_STR_TITLE_SIMPLE_VISUALS_CONTROL "Simple Visuals Control" #define DALI_DEMO_STR_TITLE_SCRIPT_BASED_UI "Script Based UI" #define DALI_DEMO_STR_TITLE_SCROLL_VIEW "Scroll View" #define DALI_DEMO_STR_TITLE_SPARKLE "Sparkle"