diff --git a/com.samsung.dali-demo.xml b/com.samsung.dali-demo.xml
index b7980de..fb4f507 100644
--- a/com.samsung.dali-demo.xml
+++ b/com.samsung.dali-demo.xml
@@ -106,9 +106,6 @@
-
-
-
diff --git a/demo/dali-demo.cpp b/demo/dali-demo.cpp
index 408eb58..b39b070 100644
--- a/demo/dali-demo.cpp
+++ b/demo/dali-demo.cpp
@@ -36,6 +36,7 @@ int DALI_EXPORT_API main(int argc, char **argv)
// Create the demo launcher
DaliTableView demo(app);
+ demo.AddExample(Example("animated-shapes.example", DALI_DEMO_STR_TITLE_ANIMATED_SHAPES));
demo.AddExample(Example("bubble-effect.example", DALI_DEMO_STR_TITLE_BUBBLES));
demo.AddExample(Example("blocks.example", DALI_DEMO_STR_TITLE_BLOCKS));
demo.AddExample(Example("cube-transition-effect.example", DALI_DEMO_STR_TITLE_CUBE_TRANSITION));
diff --git a/demo/dali-table-view.cpp b/demo/dali-table-view.cpp
index d3e422e..1de6db9 100644
--- a/demo/dali-table-view.cpp
+++ b/demo/dali-table-view.cpp
@@ -45,12 +45,15 @@ const std::string TILE_BACKGROUND(DEMO_IMAGE_DIR "item-background.9.png");
const std::string TILE_BACKGROUND_ALPHA( DEMO_IMAGE_DIR "demo-tile-texture.9.png" );
const std::string TILE_FOCUS( DEMO_IMAGE_DIR "tile-focus.9.png" );
-// Keyboard focus constants.
+// Keyboard focus effect constants.
const float KEYBOARD_FOCUS_ANIMATION_DURATION = 1.0f; ///< The total duration of the keyboard focus animation
const float KEYBOARD_FOCUS_START_SCALE = 1.05f; ///< The starting scale of the focus highlight
const float KEYBOARD_FOCUS_END_SCALE = 1.18f; ///< The end scale of the focus highlight
const float KEYBOARD_FOCUS_END_ALPHA = 0.7f; ///< The end alpha of the focus highlight
const float KEYBOARD_FOCUS_INITIAL_FADE_PERCENTAGE = 0.16f; ///< The duration of the initial fade (from translucent to the end-alpha) as a percentage of the overal animation duration.
+const Vector3 startScale( KEYBOARD_FOCUS_START_SCALE, KEYBOARD_FOCUS_START_SCALE, KEYBOARD_FOCUS_START_SCALE ); ///< @see KEYBOARD_FOCUS_START_SCALE
+const Vector3 endScale( KEYBOARD_FOCUS_END_SCALE, KEYBOARD_FOCUS_END_SCALE, KEYBOARD_FOCUS_END_SCALE ); ///< @see KEYBOARD_FOCUS_END_SCALE
+const float initialFadeDuration = KEYBOARD_FOCUS_ANIMATION_DURATION * KEYBOARD_FOCUS_INITIAL_FADE_PERCENTAGE; ///< @see KEYBOARD_FOCUS_INITIAL_FADE_PERCENTAGE
const float TILE_LABEL_PADDING = 8.0f; ///< Border between edge of tile and the example text
const float BUTTON_PRESS_ANIMATION_TIME = 0.35f; ///< Time to perform button scale effect.
@@ -260,6 +263,9 @@ void DaliTableView::Initialize( Application& application )
logo.SetAnchorPoint( AnchorPoint::TOP_CENTER );
logo.SetParentOrigin( Vector3( 0.5f, 0.1f, 0.5f ) );
logo.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
+ // The logo should appear on top of everything.
+ logo.SetDrawMode( DrawMode::OVERLAY_2D );
+ mRootActor.Add( logo );
// Show version in a popup when log is tapped
mLogoTapDetector = TapGestureDetector::New();
@@ -291,9 +297,6 @@ void DaliTableView::Initialize( Application& application )
bubbleContainer.SetParentOrigin( ParentOrigin::CENTER );
SetupBackground( bubbleContainer );
- mRootActor.Add( logo );
- // We use depth index to bring the logo above the bubbles (as an alternative to creating actors).
- logo.GetRendererAt( 0 ).SetProperty( Renderer::Property::DEPTH_INDEX, 30000 );
mRootActor.Add( bubbleContainer );
mRootActor.Add( mScrollView );
@@ -324,64 +327,50 @@ void DaliTableView::Initialize( Application& application )
mAnimationTimer.Start();
mBackgroundAnimsPlaying = true;
+ CreateFocusEffect();
+}
+
+void DaliTableView::CreateFocusEffect()
+{
+ // Hook the required signals to manage the focus.
KeyboardFocusManager::Get().PreFocusChangeSignal().Connect( this, &DaliTableView::OnKeyboardPreFocusChange );
KeyboardFocusManager::Get().FocusedActorEnterKeySignal().Connect( this, &DaliTableView::OnFocusedActorActivated );
AccessibilityManager::Get().FocusedActorActivatedSignal().Connect( this, &DaliTableView::OnFocusedActorActivated );
- mFocusContainer = ImageView::New( TILE_FOCUS );
- mFocusContainer.SetParentOrigin( ParentOrigin::CENTER );
- mFocusContainer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
- mFocusContainer.SetInheritScale( false );
- mFocusContainer.SetColorMode( USE_OWN_COLOR );
- mFocusContainer.SetName( "focusActor" );
- mFocusContainer.OnStageSignal().Connect( this, &DaliTableView::OnStageConnect );
-
- mFocusInner = ImageView::New( TILE_FOCUS );
- mFocusInner.SetParentOrigin( ParentOrigin::CENTER );
- mFocusInner.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
- mFocusInner.SetInheritScale( false );
- mFocusInner.SetColorMode( USE_OWN_COLOR );
- mFocusInner.SetName( "focusActor" );
- mFocusInner.OnStageSignal().Connect( this, &DaliTableView::OnStageConnect );
- mFocusContainer.Add( mFocusInner );
-
- // Setup the keyboard focus highlight.
- Vector3 startScale( KEYBOARD_FOCUS_START_SCALE, KEYBOARD_FOCUS_START_SCALE, KEYBOARD_FOCUS_START_SCALE );
- Vector3 endScale( KEYBOARD_FOCUS_END_SCALE, KEYBOARD_FOCUS_END_SCALE, KEYBOARD_FOCUS_END_SCALE );
- mFocusAnimation = Animation::New( KEYBOARD_FOCUS_ANIMATION_DURATION );
- mFocusAnimationInner = Animation::New( KEYBOARD_FOCUS_ANIMATION_DURATION );
-
- mFocusContainer.SetScale( startScale );
- mFocusInner.SetScale( startScale );
- mFocusContainer.SetOpacity( 0.0f );
- mFocusInner.SetOpacity( 0.0f );
- const float initialFadeDuration = KEYBOARD_FOCUS_ANIMATION_DURATION * KEYBOARD_FOCUS_INITIAL_FADE_PERCENTAGE;
-
- mFocusAnimation.AnimateTo( Property( mFocusContainer, Actor::Property::COLOR_ALPHA ), KEYBOARD_FOCUS_END_ALPHA, AlphaFunction::LINEAR, TimePeriod( 0.0f, initialFadeDuration ) );
- mFocusAnimation.AnimateTo( Property( mFocusContainer, Actor::Property::SCALE ), endScale, AlphaFunction::LINEAR, TimePeriod( initialFadeDuration, KEYBOARD_FOCUS_ANIMATION_DURATION - initialFadeDuration ) );
- mFocusAnimation.AnimateTo( Property( mFocusContainer, Actor::Property::COLOR_ALPHA ), 0.0f, AlphaFunction::LINEAR, TimePeriod( initialFadeDuration, KEYBOARD_FOCUS_ANIMATION_DURATION - initialFadeDuration ) );
-
- mFocusAnimationInner.AnimateTo( Property( mFocusInner, Actor::Property::COLOR_ALPHA ), KEYBOARD_FOCUS_END_ALPHA, AlphaFunction::LINEAR, TimePeriod( 0.0f, initialFadeDuration ) );
- mFocusAnimationInner.AnimateTo( Property( mFocusInner, Actor::Property::SCALE ), endScale, AlphaFunction::LINEAR, TimePeriod( initialFadeDuration, KEYBOARD_FOCUS_ANIMATION_DURATION - initialFadeDuration ) );
- mFocusAnimationInner.AnimateTo( Property( mFocusInner, Actor::Property::COLOR_ALPHA ), 0.0f, AlphaFunction::LINEAR, TimePeriod( initialFadeDuration, KEYBOARD_FOCUS_ANIMATION_DURATION - initialFadeDuration ) );
+ // Loop to create both actors for the focus highlight effect.
+ for( unsigned int i = 0; i < FOCUS_ANIMATION_ACTOR_NUMBER; ++i )
+ {
+ mFocusEffect[i].actor = ImageView::New( TILE_FOCUS );
+ mFocusEffect[i].actor.SetParentOrigin( ParentOrigin::CENTER );
+ mFocusEffect[i].actor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+ mFocusEffect[i].actor.SetInheritScale( false );
+ mFocusEffect[i].actor.SetColorMode( USE_OWN_COLOR );
+
+ // Setup initial values pre-animation.
+ mFocusEffect[i].actor.SetScale( startScale );
+ mFocusEffect[i].actor.SetOpacity( 0.0f );
+
+ // Create and setup the animation to do the following:
+ // 1) Initial fade in over short period of time
+ // 2) Zoom in (larger) and fade out simultaneously over longer period of time.
+ mFocusEffect[i].animation = Animation::New( KEYBOARD_FOCUS_ANIMATION_DURATION );
+
+ mFocusEffect[i].animation.AnimateTo( Property( mFocusEffect[i].actor, Actor::Property::COLOR_ALPHA ), KEYBOARD_FOCUS_END_ALPHA, AlphaFunction::LINEAR, TimePeriod( 0.0f, initialFadeDuration ) );
+ mFocusEffect[i].animation.AnimateTo( Property( mFocusEffect[i].actor, Actor::Property::SCALE ), endScale, AlphaFunction::LINEAR, TimePeriod( initialFadeDuration, KEYBOARD_FOCUS_ANIMATION_DURATION - initialFadeDuration ) );
+ mFocusEffect[i].animation.AnimateTo( Property( mFocusEffect[i].actor, Actor::Property::COLOR_ALPHA ), 0.0f, AlphaFunction::LINEAR, TimePeriod( initialFadeDuration, KEYBOARD_FOCUS_ANIMATION_DURATION - initialFadeDuration ) );
+
+ mFocusEffect[i].animation.SetLooping( true );
+ }
+
+ // Parent the secondary effect from the primary.
+ mFocusEffect[0].actor.Add( mFocusEffect[1].actor );
// Play the animation on the 1st glow object.
- mFocusAnimation.SetLooping( true );
- mFocusAnimation.Play();
+ mFocusEffect[0].animation.Play();
// Stagger the animation on the 2st glow object half way through.
- mFocusAnimationInner.SetLooping( true );
- mFocusAnimationInner.PlayFrom( KEYBOARD_FOCUS_ANIMATION_DURATION / 2.0f );
+ mFocusEffect[1].animation.PlayFrom( KEYBOARD_FOCUS_ANIMATION_DURATION / 2.0f );
- KeyboardFocusManager::Get().SetFocusIndicatorActor( mFocusContainer );
-}
-
-void DaliTableView::OnStageConnect( Dali::Actor actor )
-{
- // If this is one of the keyboard focus actors, place it behind the object it is focusing.
- if( actor.GetName() == "focusActor" )
- {
- actor.GetRendererAt( 0 ).SetProperty( Dali::Renderer::Property::DEPTH_INDEX, -40000 );
- }
+ KeyboardFocusManager::Get().SetFocusIndicatorActor( mFocusEffect[0].actor );
}
void DaliTableView::ApplyCubeEffectToPages()
@@ -510,12 +499,14 @@ void DaliTableView::Rotate( unsigned int degrees )
Actor DaliTableView::CreateTile( const std::string& name, const std::string& title, const Dali::Vector3& sizeMultiplier, Vector2& position )
{
- Actor content = Actor::New();
- content.SetName( name );
- content.SetAnchorPoint( AnchorPoint::CENTER );
- content.SetParentOrigin( ParentOrigin::CENTER );
- content.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
- content.SetSizeModeFactor( sizeMultiplier );
+ Actor focusableTile = Actor::New();
+ focusableTile.SetParentOrigin( ParentOrigin::CENTER );
+ focusableTile.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
+ focusableTile.SetSizeModeFactor( sizeMultiplier );
+ focusableTile.SetName( name );
+
+ // Set the tile to be keyboard focusable
+ focusableTile.SetKeyboardFocusable( true );
Toolkit::ImageView tileContent = ImageView::New();
tileContent.SetParentOrigin( ParentOrigin::CENTER );
@@ -542,7 +533,7 @@ Actor DaliTableView::CreateTile( const std::string& name, const std::string& tit
shaderPosition.AddSource( Source( mScrollView, ScrollView::Property::SCROLL_POSITION ) );
shaderPosition.SetRemoveAction( Constraint::Discard );
shaderPosition.Apply();
- content.Add( tileContent );
+ focusableTile.Add( tileContent );
// Create an ImageView for the 9-patch border around the tile.
ImageView borderImage = ImageView::New( TILE_BACKGROUND );
@@ -564,16 +555,13 @@ Actor DaliTableView::CreateTile( const std::string& name, const std::string& tit
// Pad around the label as its size is the same as the 9-patch border. It will overlap it without padding.
label.SetPadding( Padding( TILE_LABEL_PADDING, TILE_LABEL_PADDING, TILE_LABEL_PADDING, TILE_LABEL_PADDING ) );
- content.Add( label );
-
- // Set the tile to be keyboard focusable
- content.SetKeyboardFocusable( true );
+ focusableTile.Add( label );
- // connect to the touch events
- content.TouchSignal().Connect( this, &DaliTableView::OnTilePressed );
- content.HoveredSignal().Connect( this, &DaliTableView::OnTileHovered );
+ // Connect to the touch events
+ focusableTile.TouchSignal().Connect( this, &DaliTableView::OnTilePressed );
+ focusableTile.HoveredSignal().Connect( this, &DaliTableView::OnTileHovered );
- return content;
+ return focusableTile;
}
bool DaliTableView::OnTilePressed( Actor actor, const TouchData& event )
diff --git a/demo/dali-table-view.h b/demo/dali-table-view.h
index 749bf4b..c91f2fc 100644
--- a/demo/dali-table-view.h
+++ b/demo/dali-table-view.h
@@ -1,8 +1,8 @@
-#ifndef __DALI_DEMO_H__
-#define __DALI_DEMO_H__
+#ifndef DALI_DEMO_H
+#define DALI_DEMO_H
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
@@ -32,7 +32,6 @@ typedef std::vector AnimationList;
typedef AnimationList::iterator AnimationListIter;
typedef AnimationList::const_iterator AnimationListConstIter;
-
/**
* Example information
*
@@ -97,6 +96,8 @@ public:
private: // Application callbacks & implementation
+ static const unsigned int FOCUS_ANIMATION_ACTOR_NUMBER = 2; ///< The number of elements used to form the custom focus effect
+
/**
* Shape enum for create function
*/
@@ -320,6 +321,11 @@ private: // Application callbacks & implementation
void PlayAnimation();
/**
+ * @brief Creates and sets up the custom effect used for the keyboard (and mouse) focus.
+ */
+ void CreateFocusEffect();
+
+ /**
* Callback when the keyboard focus is going to be changed.
*
* @param[in] current The current focused actor
@@ -384,10 +390,15 @@ private:
Dali::TapGestureDetector mLogoTapDetector; ///< To detect taps on the logo
Dali::Toolkit::Popup mVersionPopup; ///< Displays DALi library version information
- Dali::Toolkit::ImageView mFocusContainer; ///< The parent keyboard focus highlight actor
- Dali::Toolkit::ImageView mFocusInner; ///< The child keyboard focus highlight actor
- Dali::Animation mFocusAnimation; ///< The animation for the parent keyboard focus highlight actor
- Dali::Animation mFocusAnimationInner; ///< The animation for the child keyboard focus highlight actor
+ /**
+ * This struct encapsulates all data relevant to each of the elements used within the custom keyboard focus effect.
+ */
+ struct FocusEffect
+ {
+ Dali::Toolkit::ImageView actor; ///< The parent keyboard focus highlight actor
+ Dali::Animation animation; ///< The animation for the parent keyboard focus highlight actor
+ };
+ FocusEffect mFocusEffect[FOCUS_ANIMATION_ACTOR_NUMBER]; ///< The elements used to create the custom focus effect
std::vector< Dali::Actor > mPages; ///< List of pages.
AnimationList mBackgroundAnimations; ///< List of background bubble animations
@@ -402,4 +413,4 @@ private:
};
-#endif // __DALI_DEMO_H__
+#endif // DALI_DEMO_H
diff --git a/examples/animated-shapes/animated-shapes-example.cpp b/examples/animated-shapes/animated-shapes-example.cpp
new file mode 100644
index 0000000..dd79982
--- /dev/null
+++ b/examples/animated-shapes/animated-shapes-example.cpp
@@ -0,0 +1,475 @@
+/*
+ * Copyright (c) 2016 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
+#include "shared/view.h"
+
+#include
+
+using namespace Dali;
+using namespace Dali::Toolkit;
+
+namespace
+{
+
+const char* APPLICATION_TITLE("Animated Shapes");
+
+const char* VERTEX_SHADER = DALI_COMPOSE_SHADER
+(
+ attribute mediump vec3 aCoefficient;
+ uniform mediump mat4 uMvpMatrix;
+ uniform mediump vec3 uPosition[MAX_POINT_COUNT];
+ varying lowp vec2 vCoefficient;
+ void main()
+ {
+ int vertexId = int(aCoefficient.z);
+ gl_Position = uMvpMatrix * vec4(uPosition[vertexId], 1.0);
+
+ vCoefficient = aCoefficient.xy;
+ }
+);
+
+// Fragment shader.
+const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER
+(
+ uniform lowp vec4 uColor;
+ varying lowp vec2 vCoefficient;
+ void main()
+ {
+ lowp float C = (vCoefficient.x*vCoefficient.x-vCoefficient.y);
+ lowp float Cdx = dFdx(C);
+ lowp float Cdy = dFdy(C);
+
+ lowp float distance = float(C / sqrt(Cdx*Cdx + Cdy*Cdy));
+ lowp float alpha = 0.5 - distance;
+ gl_FragColor = vec4( uColor.rgb, uColor.a * alpha );
+ }
+);
+
+Shader CreateShader( unsigned int pointCount )
+{
+ std::ostringstream vertexShader;
+ vertexShader << "#define MAX_POINT_COUNT "<< pointCount << "\n"<