Commit c015449ba18acb34fe217c070c7fe3302cabee93

Authored by David Steele
1 parent 1ff46af9

Example of transitions of each visual type.

Change-Id: I8d15f1aec5cdca527f93283ff179dcf572e831ea
com.samsung.dali-demo.xml
... ... @@ -177,6 +177,9 @@
177 177 <label>First Person Camera Game</label>
178 178 </ui-application>
179 179 <ui-application appid="transitions.example" exec="/usr/apps/com.samsung.dali-demo/bin/transitions.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
  180 + <label>Shadow button</label>
  181 + </ui-application>
  182 + <ui-application appid="visual-transitions.example" exec="/usr/apps/com.samsung.dali-demo/bin/visual-transitions.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
180 183 <label>Visual Transitions</label>
181 184 </ui-application>
182 185 <ui-application appid="animated-images.example" exec="/usr/apps/com.samsung.dali-demo/bin/animated-images.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
... ...
examples/styling/image-channel-control-impl.cpp
... ... @@ -37,12 +37,13 @@ const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
37 37 varying mediump vec2 vTexCoord;\n
38 38 uniform sampler2D sTexture;\n
39 39 uniform mediump vec4 uColor;\n
40   - uniform mediump vec4 mixColor;\n
  40 + uniform mediump vec3 mixColor;\n
  41 + uniform mediump float opacity;\n
41 42 uniform mediump vec3 uChannels;\n
42 43 \n
43 44 void main()\n
44 45 {\n
45   - gl_FragColor = texture2D( sTexture, vTexCoord ) * mixColor * uColor * vec4(uChannels, 1.0) ;\n
  46 + gl_FragColor = texture2D( sTexture, vTexCoord ) * vec4(mixColor,opacity) * uColor * vec4(uChannels, 1.0) ;\n
46 47 }\n
47 48 );
48 49  
... ...
examples/text-label/text-label-example.cpp
... ... @@ -80,17 +80,17 @@ struct HSVColorConstraint
80 80 {
81 81 }
82 82  
83   - void operator()(Vector4& current, const PropertyInputContainer& inputs )
  83 + void operator()(Vector3& current, const PropertyInputContainer& inputs )
84 84 {
85   - current = hsv2rgb(Vector4(inputs[0]->GetFloat(), saturation, value, current.a));
  85 + current = hsv2rgb(Vector3(inputs[0]->GetFloat(), saturation, value));
86 86 }
87 87  
88   - Vector4 hsv2rgb(Vector4 colorHSV)
  88 + Vector3 hsv2rgb(Vector3 colorHSV)
89 89 {
90 90 float r=colorHSV.z*(1+colorHSV.y*(cos(colorHSV.x)-1));
91 91 float g=colorHSV.z*(1+colorHSV.y*(cos(colorHSV.x-2.09439)-1));
92 92 float b=colorHSV.z*(1+colorHSV.y*(cos(colorHSV.x+2.09439)-1));
93   - return Vector4(r, g, b, colorHSV.a);
  93 + return Vector3(r, g, b);
94 94 }
95 95 float hue;
96 96 float saturation;
... ... @@ -173,7 +173,7 @@ public:
173 173 Renderer bgRenderer = mLabel.GetRendererAt(0);
174 174 mOverrideMixColorIndex = DevelHandle::GetPropertyIndex( bgRenderer, ColorVisual::Property::MIX_COLOR );
175 175  
176   - Constraint constraint = Constraint::New<Vector4>( bgRenderer, mOverrideMixColorIndex, HSVColorConstraint(0.0f, 0.5f, 0.8f));
  176 + Constraint constraint = Constraint::New<Vector3>( bgRenderer, mOverrideMixColorIndex, HSVColorConstraint(0.0f, 0.5f, 0.8f));
177 177 constraint.AddSource( Source( mLabel, mHueAngleIndex ) );
178 178 constraint.SetRemoveAction( Constraint::Discard );
179 179 constraint.Apply();
... ...
examples/visual-transitions/beat-control-impl.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 +#include "beat-control-impl.h"
  18 +#include <dali-toolkit/dali-toolkit.h>
  19 +#include <dali/public-api/object/type-registry-helper.h>
  20 +#include <dali-toolkit/devel-api/align-enums.h>
  21 +#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
  22 +#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
  23 +
  24 +#include <cstdio>
  25 +
  26 +using namespace Dali; // Needed for macros
  27 +using namespace Dali::Toolkit;
  28 +
  29 +namespace Demo
  30 +{
  31 +namespace Internal
  32 +{
  33 +
  34 +namespace
  35 +{
  36 +
  37 +const int BOUNCE_ANIMATION_RUNNING(0x0001);
  38 +const int FADE_ANIMATION_RUNNING (0x0002);
  39 +const int X_ANIMATION_RUNNING (0x0004);
  40 +const int Y_ANIMATION_RUNNING (0x0008);
  41 +
  42 +
  43 +Dali::BaseHandle Create()
  44 +{
  45 + return Demo::BeatControl::New();
  46 +}
  47 +
  48 +DALI_TYPE_REGISTRATION_BEGIN( BeatControl, Dali::Toolkit::Control, Create );
  49 +
  50 +DALI_PROPERTY_REGISTRATION( Demo, BeatControl, "bounceTransition", STRING, BOUNCE_TRANSITION );
  51 +DALI_PROPERTY_REGISTRATION( Demo, BeatControl, "leftTransition", STRING, LEFT_TRANSITION );
  52 +DALI_PROPERTY_REGISTRATION( Demo, BeatControl, "upTransition", STRING, UP_TRANSITION );
  53 +DALI_PROPERTY_REGISTRATION( Demo, BeatControl, "fadeTransition", STRING, FADE_TRANSITION );
  54 +DALI_PROPERTY_REGISTRATION( Demo, BeatControl, "beatVisual", MAP, BEAT_VISUAL );
  55 +DALI_TYPE_REGISTRATION_END();
  56 +
  57 +
  58 +Toolkit::TransitionData ConvertPropertyToTransition( const Property::Value& value )
  59 +{
  60 + Toolkit::TransitionData transitionData;
  61 +
  62 + if( value.GetType() == Property::ARRAY )
  63 + {
  64 + transitionData = Toolkit::TransitionData::New( *value.GetArray());
  65 + }
  66 + else if( value.GetType() == Property::MAP )
  67 + {
  68 + transitionData = Toolkit::TransitionData::New( *value.GetMap() );
  69 + }
  70 + return transitionData;
  71 +}
  72 +
  73 +} // anonymous namespace
  74 +
  75 +
  76 +Internal::BeatControl::BeatControl()
  77 +: Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ),
  78 + mTransformSize(1.0f, 1.0f),
  79 + mAnimationPlaying(0)
  80 +{
  81 +}
  82 +
  83 +Internal::BeatControl::~BeatControl()
  84 +{
  85 +}
  86 +
  87 +Demo::BeatControl Internal::BeatControl::New()
  88 +{
  89 + IntrusivePtr<Internal::BeatControl> impl = new Internal::BeatControl();
  90 + Demo::BeatControl handle = Demo::BeatControl( *impl );
  91 + impl->Initialize();
  92 + return handle;
  93 +}
  94 +
  95 +
  96 +void BeatControl::StartBounceAnimation()
  97 +{
  98 + if( mAnimation )
  99 + {
  100 + mAnimation.Stop();
  101 + mAnimation.FinishedSignal().Disconnect( this, &BeatControl::OnBounceAnimationFinished );
  102 + OnBounceAnimationFinished(mAnimation);
  103 + }
  104 +
  105 + mAnimation = CreateTransition( mBounceTransition );
  106 + mAnimation.FinishedSignal().Connect( this, &BeatControl::OnBounceAnimationFinished );
  107 + mAnimation.Play();
  108 + mAnimationPlaying |= BOUNCE_ANIMATION_RUNNING;
  109 +}
  110 +
  111 +
  112 +void BeatControl::StartXAnimation()
  113 +{
  114 + if( mXAnimation )
  115 + {
  116 + mXAnimation.Stop();
  117 + mXAnimation.FinishedSignal().Disconnect( this, &BeatControl::OnXAnimationFinished );
  118 + OnXAnimationFinished(mXAnimation);
  119 + }
  120 +
  121 + mXAnimation = CreateTransition( mLeftTransition );
  122 + mXAnimation.FinishedSignal().Connect( this, &BeatControl::OnXAnimationFinished );
  123 + mXAnimation.Play();
  124 + mAnimationPlaying |= X_ANIMATION_RUNNING;
  125 +}
  126 +
  127 +void BeatControl::StartYAnimation()
  128 +{
  129 + if( mYAnimation )
  130 + {
  131 + mYAnimation.Stop();
  132 + mYAnimation.FinishedSignal().Disconnect( this, &BeatControl::OnYAnimationFinished );
  133 + OnYAnimationFinished(mYAnimation);
  134 + }
  135 +
  136 + mYAnimation = CreateTransition( mUpTransition );
  137 + mYAnimation.FinishedSignal().Connect( this, &BeatControl::OnYAnimationFinished );
  138 + mYAnimation.Play();
  139 + mAnimationPlaying |= Y_ANIMATION_RUNNING;
  140 +}
  141 +
  142 +void BeatControl::StartFadeAnimation()
  143 +{
  144 + if( mFadeAnimation )
  145 + {
  146 + mFadeAnimation.Stop();
  147 + mFadeAnimation.FinishedSignal().Disconnect( this, &BeatControl::OnFadeAnimationFinished );
  148 + OnFadeAnimationFinished(mFadeAnimation);
  149 + }
  150 +
  151 + mFadeAnimation = CreateTransition( mFadeTransition );
  152 + mFadeAnimation.FinishedSignal().Connect( this, &BeatControl::OnFadeAnimationFinished );
  153 + mFadeAnimation.Play();
  154 + mAnimationPlaying |= FADE_ANIMATION_RUNNING;
  155 +}
  156 +
  157 +void BeatControl::OnBounceAnimationFinished( Animation& src )
  158 +{
  159 + mAnimationPlaying &= ~BOUNCE_ANIMATION_RUNNING;
  160 +}
  161 +void BeatControl::OnXAnimationFinished( Animation& src )
  162 +{
  163 + mAnimationPlaying &= ~X_ANIMATION_RUNNING;
  164 +}
  165 +void BeatControl::OnYAnimationFinished( Animation& src )
  166 +{
  167 + mAnimationPlaying &= ~Y_ANIMATION_RUNNING;
  168 +}
  169 +void BeatControl::OnFadeAnimationFinished( Animation& src )
  170 +{
  171 + mAnimationPlaying &= ~FADE_ANIMATION_RUNNING;
  172 +}
  173 +
  174 +void BeatControl::OnInitialize()
  175 +{
  176 + Actor self = Self();
  177 +}
  178 +
  179 +void BeatControl::OnStageConnection( int depth )
  180 +{
  181 + Control::OnStageConnection( depth );
  182 +}
  183 +
  184 +void BeatControl::OnStageDisconnection()
  185 +{
  186 + Control::OnStageDisconnection();
  187 +}
  188 +
  189 +void BeatControl::OnSizeSet( const Vector3& targetSize )
  190 +{
  191 + Control::OnSizeSet( targetSize );
  192 + RelayoutVisuals( Vector2( targetSize ) );
  193 +}
  194 +
  195 +void BeatControl::OnRelayout( const Vector2& targetSize, RelayoutContainer& container )
  196 +{
  197 + RelayoutVisuals( targetSize );
  198 +}
  199 +
  200 +void BeatControl::RelayoutVisuals( const Vector2& targetSize )
  201 +{
  202 + if( mVisual )
  203 + {
  204 + if( (mAnimationPlaying & (X_ANIMATION_RUNNING | Y_ANIMATION_RUNNING)) == 0)
  205 + {
  206 + Vector2 size( targetSize );
  207 + Property::Map transformMap;
  208 + // Make the visual half the size of the control, but leave
  209 + // origin and anchor point at center, position is relative, but Zer0
  210 + transformMap[ DevelVisual::Transform::Property::SIZE ] = mTransformSize;
  211 + mVisual.SetTransformAndSize( transformMap, size );
  212 + }
  213 + }
  214 +}
  215 +
  216 +Vector3 BeatControl::GetNaturalSize()
  217 +{
  218 + if( mVisual )
  219 + {
  220 + Vector2 naturalSize;
  221 + mVisual.GetNaturalSize(naturalSize);
  222 + return Vector3(naturalSize);
  223 + }
  224 + return Vector3::ZERO;
  225 +}
  226 +
  227 +void BeatControl::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change )
  228 +{
  229 + // Chain up.
  230 + Control::OnStyleChange( styleManager, change );
  231 +}
  232 +
  233 +
  234 +///////////////////////////////////////////////////////////
  235 +//
  236 +// Properties
  237 +//
  238 +
  239 +void BeatControl::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
  240 +{
  241 + Demo::BeatControl beatControl = Demo::BeatControl::DownCast( Dali::BaseHandle( object ) );
  242 +
  243 + if( beatControl )
  244 + {
  245 + BeatControl& impl = GetImpl( beatControl );
  246 + Actor self = impl.Self();
  247 + switch ( index )
  248 + {
  249 + case Demo::BeatControl::Property::BEAT_VISUAL:
  250 + {
  251 + bool sizeOnly = false;
  252 +
  253 + // Determine if a transform.size property exists in the map, and
  254 + // save it.
  255 + Property::Map* map = value.GetMap();
  256 + if( map )
  257 + {
  258 + Property::Value* value = map->Find( DevelVisual::Property::TRANSFORM, "transform" );
  259 + if( value )
  260 + {
  261 + Property::Map* transformMap = value->GetMap();
  262 + if( transformMap )
  263 + {
  264 + Property::Value* sizeValue = transformMap->Find( DevelVisual::Transform::Property::SIZE, "size" );
  265 + if( sizeValue )
  266 + {
  267 + sizeValue->Get( impl.mTransformSize );
  268 + if( map->Count() == 1 && transformMap->Count() == 1 )
  269 + {
  270 + sizeOnly = true;
  271 + }
  272 + }
  273 + }
  274 + }
  275 + if( ! sizeOnly )
  276 + {
  277 + // Only register a visual if there is more than just a size setting
  278 + impl.mVisual = Toolkit::VisualFactory::Get().CreateVisual( *map );
  279 + impl.RegisterVisual( Demo::BeatControl::Property::BEAT_VISUAL, impl.mVisual );
  280 +
  281 + // We have registered a new visual: must trigger size negotiation
  282 + // in order to call SetTransformAndSize on the visual with the right size:
  283 + impl.RelayoutRequest();
  284 + }
  285 + }
  286 + break;
  287 + }
  288 + case Demo::BeatControl::Property::BOUNCE_TRANSITION:
  289 + {
  290 + impl.mBounceTransition = ConvertPropertyToTransition( value );
  291 + break;
  292 + }
  293 + case Demo::BeatControl::Property::LEFT_TRANSITION:
  294 + {
  295 + impl.mLeftTransition = ConvertPropertyToTransition( value );
  296 + break;
  297 + }
  298 + case Demo::BeatControl::Property::UP_TRANSITION:
  299 + {
  300 + impl.mUpTransition = ConvertPropertyToTransition( value );
  301 + break;
  302 + }
  303 + case Demo::BeatControl::Property::FADE_TRANSITION:
  304 + {
  305 + impl.mFadeTransition = ConvertPropertyToTransition( value );
  306 + break;
  307 + }
  308 + }
  309 + }
  310 +}
  311 +
  312 +Property::Value BeatControl::GetProperty( BaseObject* object, Property::Index propertyIndex )
  313 +{
  314 + Property::Value value;
  315 +
  316 + Demo::BeatControl beatControl = Demo::BeatControl::DownCast( Dali::BaseHandle( object ) );
  317 +
  318 + if ( beatControl )
  319 + {
  320 + BeatControl& impl = GetImpl( beatControl );
  321 + switch ( propertyIndex )
  322 + {
  323 + case Demo::BeatControl::Property::BEAT_VISUAL:
  324 + {
  325 + if( impl.mVisual )
  326 + {
  327 + Property::Map map;
  328 + impl.mVisual.CreatePropertyMap(map);
  329 + value = map;
  330 + }
  331 + break;
  332 + }
  333 + case Demo::BeatControl::Property::BOUNCE_TRANSITION:
  334 + case Demo::BeatControl::Property::LEFT_TRANSITION:
  335 + case Demo::BeatControl::Property::UP_TRANSITION:
  336 + case Demo::BeatControl::Property::FADE_TRANSITION:
  337 + default:
  338 + break;
  339 + }
  340 + }
  341 +
  342 + return value;
  343 +}
  344 +
  345 +
  346 +} // Internal
  347 +} // Demo
... ...
examples/visual-transitions/beat-control-impl.h 0 → 100644
  1 +#ifndef DALI_DEMO_INTERNAL_BEAT_CONTROL_IMPL_H
  2 +#define DALI_DEMO_INTERNAL_BEAT_CONTROL_IMPL_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 +#include "beat-control.h"
  21 +#include <dali/public-api/animation/animation.h>
  22 +#include <dali-toolkit/public-api/controls/control-impl.h>
  23 +#include <dali-toolkit/devel-api/visual-factory/visual-base.h>
  24 +#include <dali-toolkit/devel-api/visual-factory/transition-data.h>
  25 +
  26 +namespace Demo
  27 +{
  28 +
  29 +namespace Internal // To use TypeRegistry, handle and body classes need the same name
  30 +{
  31 +
  32 +class BeatControl : public Dali::Toolkit::Internal::Control
  33 +{
  34 +public:
  35 + /**
  36 + * Instantiate a new BeatControl object
  37 + */
  38 + static Demo::BeatControl New();
  39 + BeatControl();
  40 + ~BeatControl();
  41 +
  42 +public: // API
  43 + void StartBounceAnimation();
  44 +
  45 + void StartXAnimation();
  46 +
  47 + void StartYAnimation();
  48 +
  49 + void StartFadeAnimation();
  50 +
  51 +public: // Properties
  52 + /**
  53 + * Called when a property of an object of this type is set.
  54 + * @param[in] object The object whose property is set.
  55 + * @param[in] index The property index.
  56 + * @param[in] value The new property value.
  57 + */
  58 + static void SetProperty( Dali::BaseObject* object, Dali::Property::Index index, const Dali::Property::Value& value );
  59 +
  60 + /**
  61 + * Called to retrieve a property of an object of this type.
  62 + * @param[in] object The object whose property is to be retrieved.
  63 + * @param[in] index The property index.
  64 + * @return The current value of the property.
  65 + */
  66 + static Dali::Property::Value GetProperty( Dali::BaseObject* object, Dali::Property::Index propertyIndex );
  67 +
  68 +private: // From Control
  69 + /**
  70 + * @copydoc Toolkit::Control::OnInitialize()
  71 + */
  72 + virtual void OnInitialize();
  73 +
  74 + /**
  75 + * @copydoc Toolkit::Control::OnStageConnect()
  76 + */
  77 + virtual void OnStageConnection( int depth );
  78 +
  79 + /**
  80 + * @copydoc Toolkit::Control::OnStageDisconnection()
  81 + */
  82 + virtual void OnStageDisconnection();
  83 +
  84 + /**
  85 + * @copydoc Toolkit::Control::OnSizeSet()
  86 + */
  87 + virtual void OnSizeSet( const Dali::Vector3& targetSize );
  88 +
  89 + /**
  90 + * @copydoc Toolkit::Control::OnRelayout()
  91 + */
  92 + virtual void OnRelayout( const Dali::Vector2& targetSize, Dali::RelayoutContainer& container );
  93 + /**
  94 + * @copydoc Toolkit::Control::GetNaturalSize
  95 + */
  96 + virtual Dali::Vector3 GetNaturalSize();
  97 +
  98 + /**
  99 + * @copydoc Toolkit::Control::OnStyleChange
  100 + */
  101 + virtual void OnStyleChange( Dali::Toolkit::StyleManager styleManager, Dali::StyleChange::Type change );
  102 +
  103 +private:
  104 + void OnBounceAnimationFinished( Dali::Animation& handle );
  105 + void OnXAnimationFinished( Dali::Animation& src );
  106 + void OnYAnimationFinished( Dali::Animation& src );
  107 + void OnFadeAnimationFinished( Dali::Animation& src );
  108 +
  109 + /**
  110 + * Relayout the visuals as a result of size negotiation
  111 + */
  112 + void RelayoutVisuals( const Dali::Vector2& targetSize );
  113 +
  114 +private:
  115 + //undefined
  116 + BeatControl( const BeatControl& );
  117 + BeatControl& operator=( const BeatControl& );
  118 +
  119 +private:
  120 + // Implementation details
  121 + Dali::Toolkit::Visual::Base mVisual;
  122 + Dali::Toolkit::TransitionData mBounceTransition;
  123 + Dali::Toolkit::TransitionData mLeftTransition;
  124 + Dali::Toolkit::TransitionData mUpTransition;
  125 + Dali::Toolkit::TransitionData mFadeTransition;
  126 + Dali::Animation mAnimation;
  127 + Dali::Animation mXAnimation;
  128 + Dali::Animation mYAnimation;
  129 + Dali::Animation mFadeAnimation;
  130 + Dali::Vector2 mTransformSize;
  131 + int mAnimationPlaying;
  132 +};
  133 +
  134 +} // Internal
  135 +
  136 +inline Internal::BeatControl& GetImpl( Demo::BeatControl& handle )
  137 +{
  138 + DALI_ASSERT_ALWAYS( handle );
  139 + Dali::RefObject& object = handle.GetImplementation();
  140 + return static_cast<Internal::BeatControl&>(object);
  141 +}
  142 +
  143 +inline const Internal::BeatControl& GetImpl( const Demo::BeatControl& handle )
  144 +{
  145 + DALI_ASSERT_ALWAYS( handle );
  146 + const Dali::RefObject& object = handle.GetImplementation();
  147 + return static_cast<const Internal::BeatControl&>(object);
  148 +}
  149 +
  150 +} // Demo
  151 +
  152 +#endif // DALI_DEMO_BEAT_CONTROL_IMPL_H
... ...
examples/visual-transitions/beat-control.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 +#include "beat-control.h"
  18 +#include "beat-control-impl.h"
  19 +
  20 +namespace Demo
  21 +{
  22 +
  23 +BeatControl::BeatControl()
  24 +{
  25 +}
  26 +
  27 +BeatControl::BeatControl( const BeatControl& beatControl )
  28 +: Control( beatControl )
  29 +{
  30 +}
  31 +
  32 +BeatControl& BeatControl::operator= ( const BeatControl& rhs )
  33 +{
  34 + if( &rhs != this )
  35 + {
  36 + Control::operator=( rhs );
  37 + }
  38 + return *this;
  39 +}
  40 +
  41 +BeatControl::~BeatControl()
  42 +{
  43 +}
  44 +
  45 +BeatControl BeatControl::New()
  46 +{
  47 + BeatControl beatControl = Internal::BeatControl::New();
  48 + return beatControl;
  49 +}
  50 +
  51 +BeatControl BeatControl::New( const std::string& url )
  52 +{
  53 + BeatControl beatControl = Internal::BeatControl::New();
  54 + return beatControl;
  55 +}
  56 +
  57 +BeatControl BeatControl::DownCast( BaseHandle handle )
  58 +{
  59 + return Control::DownCast< BeatControl, Internal::BeatControl > ( handle );
  60 +}
  61 +
  62 +void BeatControl::StartBounceAnimation()
  63 +{
  64 + GetImpl(*this).StartBounceAnimation();
  65 +}
  66 +
  67 +void BeatControl::StartXAnimation()
  68 +{
  69 + GetImpl(*this).StartXAnimation();
  70 +}
  71 +void BeatControl::StartYAnimation()
  72 +{
  73 + GetImpl(*this).StartYAnimation();
  74 +}
  75 +void BeatControl::StartFadeAnimation()
  76 +{
  77 + GetImpl(*this).StartFadeAnimation();
  78 +}
  79 +
  80 +BeatControl::BeatControl( Internal::BeatControl& implementation )
  81 +: Control( implementation )
  82 +{
  83 +}
  84 +
  85 +BeatControl::BeatControl( Dali::Internal::CustomActor* internal )
  86 +: Control( internal )
  87 +{
  88 + VerifyCustomActorPointer< Internal::BeatControl >( internal ) ;
  89 +}
  90 +
  91 +
  92 +} //namespace Demo
... ...
examples/visual-transitions/beat-control.h 0 → 100644
  1 +#ifndef DALI_DEMO_BEAT_CONTROL_H
  2 +#define DALI_DEMO_BEAT_CONTROL_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 +#include <dali-toolkit/dali-toolkit.h>
  21 +#include <string>
  22 +
  23 +namespace Demo
  24 +{
  25 +
  26 +namespace Internal
  27 +{
  28 +// All type registered types need to have the same name for the body and the handle
  29 +class BeatControl;
  30 +}
  31 +
  32 +/**
  33 + * Control that allows the RGB channels of an image to be altered.
  34 + */
  35 +class BeatControl : public Dali::Toolkit::Control
  36 +{
  37 +public:
  38 + /**
  39 + * The start and end property ranges for this control
  40 + */
  41 + enum PropertyRange
  42 + {
  43 + PROPERTY_START_INDEX = Dali::Toolkit::Control::CONTROL_PROPERTY_END_INDEX + 1,
  44 + PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000,
  45 + ANIMATABLE_PROPERTY_START_INDEX = Dali::ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX,
  46 + ANIMATABLE_PROPERTY_END_INDEX = ANIMATABLE_PROPERTY_START_INDEX+1000
  47 + };
  48 +
  49 + struct Property
  50 + {
  51 + enum
  52 + {
  53 + BOUNCE_TRANSITION = PROPERTY_START_INDEX,
  54 + LEFT_TRANSITION,
  55 + UP_TRANSITION,
  56 + FADE_TRANSITION,
  57 + BEAT_VISUAL
  58 + };
  59 + };
  60 +
  61 +public: // Construction / destruction
  62 +
  63 + /**
  64 + * Create an uninitialized handle
  65 + */
  66 + BeatControl();
  67 +
  68 + /**
  69 + * Create a new image channel control without an image. Use
  70 + * SetImage to give this control an image
  71 + */
  72 + static BeatControl New();
  73 +
  74 + /**
  75 + * Create a new image channel control from a given URL
  76 + */
  77 + static BeatControl New( const std::string& url );
  78 +
  79 + /**
  80 + * Destructor. This is non-virtual since derived Handle types must not
  81 + * contain data or virtual methods
  82 + */
  83 + ~BeatControl();
  84 +
  85 + /**
  86 + * Copy Constructor
  87 + */
  88 + BeatControl( const BeatControl& beatControl );
  89 +
  90 + /**
  91 + * Assignment Operator
  92 + */
  93 + BeatControl& operator=( const BeatControl& beatControl );
  94 +
  95 + /**
  96 + * Downcast
  97 + */
  98 + static BeatControl DownCast( BaseHandle handle );
  99 +
  100 +public: // API
  101 +
  102 + void StartBounceAnimation();
  103 +
  104 + void StartXAnimation();
  105 +
  106 + void StartYAnimation();
  107 +
  108 + void StartFadeAnimation();
  109 +
  110 +public: // Not for public use
  111 + /**
  112 + * Create a handle from an implementation
  113 + */
  114 + BeatControl( Internal::BeatControl& implementation );
  115 +
  116 + /**
  117 + * Allow the creation of an BeatControl handle from an internal CustomActor pointer
  118 + */
  119 + BeatControl( Dali::Internal::CustomActor* internal );
  120 +};
  121 +
  122 +} // namespace Demo
  123 +
  124 +#endif // DALI_DEMO_BEAT_CONTROL_H
... ...
examples/visual-transitions/transition-application.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 + * @file transition-application.cpp
  19 + * @brief Application class for showing stylable transitions
  20 + */
  21 +
  22 +// Class include
  23 +#include "transition-application.h"
  24 +
  25 +// External includes
  26 +#include <dali-toolkit/dali-toolkit.h>
  27 +#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
  28 +#include <dali-toolkit/devel-api/visuals/text-visual-properties.h>
  29 +#include "beat-control.h"
  30 +#include <cstdio>
  31 +#include <sstream>
  32 +
  33 +// Internal includes
  34 +
  35 +using namespace Dali;
  36 +using namespace Dali::Toolkit;
  37 +
  38 +namespace Demo
  39 +{
  40 +
  41 +const char* TransitionApplication::DEMO_THEME_ONE_PATH( DEMO_STYLE_DIR "style-example-theme-one.json" );
  42 +const char* DALI_LOGO_PATH( DEMO_IMAGE_DIR "Logo-for-demo.png" );
  43 +const char* DALI_ROBOT_MODEL_PATH( DEMO_MODEL_DIR "ToyRobot-Metal.obj" );
  44 +const char* DALI_ROBOT_MATERIAL_PATH( DEMO_MODEL_DIR "ToyRobot-Metal.mtl" );
  45 +
  46 +
  47 +TransitionApplication::TransitionApplication( Application& application )
  48 +: mApplication( application ),
  49 + mTitle(),
  50 + mBeatControl(),
  51 + mActionButtons(),
  52 + mActionIndex( Property::INVALID_INDEX )
  53 +{
  54 + application.InitSignal().Connect( this, &TransitionApplication::Create );
  55 +}
  56 +
  57 +TransitionApplication::~TransitionApplication()
  58 +{
  59 +}
  60 +
  61 +void TransitionApplication::Create( Application& application )
  62 +{
  63 + Stage stage = Stage::GetCurrent();
  64 + stage.KeyEventSignal().Connect(this, &TransitionApplication::OnKeyEvent);
  65 + stage.SetBackgroundColor( Vector4( 0.1f, 0.1f, 0.1f, 1.0f ) );
  66 +
  67 + // Hide the indicator bar
  68 + application.GetWindow().ShowIndicator( Dali::Window::INVISIBLE );
  69 +
  70 + // Content panes:
  71 + TableView contentLayout = TableView::New( 4, 1 );
  72 + contentLayout.SetName("ContentLayout");
  73 + contentLayout.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
  74 + contentLayout.SetAnchorPoint( AnchorPoint::TOP_LEFT );
  75 + contentLayout.SetParentOrigin( ParentOrigin::TOP_LEFT );
  76 + contentLayout.SetCellPadding( Vector2( 0.0f, 5.0f ) );
  77 +
  78 + // Assign all rows the size negotiation property of fitting to children
  79 +
  80 + stage.Add( contentLayout );
  81 +
  82 + mTitle = TextLabel::New( "Custom Control Transition Example" );
  83 + mTitle.SetName( "Title" );
  84 + mTitle.SetStyleName("Title");
  85 + mTitle.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
  86 + mTitle.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT );
  87 + mTitle.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
  88 + contentLayout.Add( mTitle );
  89 + contentLayout.SetFitHeight(0); // Fill width
  90 +
  91 + mBeatControl = BeatControl::New();
  92 + mBeatControl.SetName("BeatControl");
  93 + mBeatControl.SetProperty( BeatControl::Property::BEAT_VISUAL, Property::Map()
  94 + .Add( DevelVisual::Property::TRANSFORM, Property::Map()
  95 + .Add( DevelVisual::Transform::Property::SIZE, Vector2(0.5f, 0.5f) ) ) );
  96 +
  97 + mBeatControl.SetAnchorPoint( AnchorPoint::CENTER );
  98 + mBeatControl.SetParentOrigin( ParentOrigin::CENTER );
  99 + mBeatControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
  100 + contentLayout.Add( mBeatControl );
  101 + // beat control should fill the tableview cell, so no change to default parameters
  102 +
  103 + TableView visualTypeLayout = TableView::New( 1, NUMBER_OF_VISUAL_BUTTONS );
  104 + visualTypeLayout.SetName("VisualTypeLayout");
  105 + visualTypeLayout.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
  106 + visualTypeLayout.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::HEIGHT );
  107 + visualTypeLayout.SetFitHeight( 0 );
  108 +
  109 + contentLayout.Add( visualTypeLayout );
  110 + contentLayout.SetFitHeight(2);
  111 +
  112 + for( int i=0; i<NUMBER_OF_VISUAL_BUTTONS; ++i )
  113 + {
  114 + Property::Map map;
  115 + CreateVisualMap( i, map );
  116 + map.Add( DevelVisual::Property::TRANSFORM, Property::Map()
  117 + .Add( DevelVisual::Transform::Property::SIZE, Vector2(0.8f, 0.8f) ) );
  118 + mVisualButtons[i] = BeatControl::New();
  119 + mVisualButtons[i].SetProperty( BeatControl::Property::BEAT_VISUAL, map );
  120 + mVisualButtons[i].SetName("VisualButton");
  121 + mVisualButtons[i].SetStyleName("VisualButton");
  122 + mVisualButtons[i].SetSize(0, 50);
  123 + mVisualButtons[i].SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
  124 + mVisualButtons[i].SetResizePolicy( ResizePolicy::FIXED, Dimension::HEIGHT );
  125 + mVisualIndex = mVisualButtons[i].RegisterProperty( "visualId", i, Property::READ_WRITE );
  126 + mVisualButtons[i].TouchSignal().Connect( this, &TransitionApplication::OnVisualButtonClicked );
  127 + visualTypeLayout.AddChild( mVisualButtons[i], TableView::CellPosition( 0, i ) );
  128 + }
  129 +
  130 + TableView actionButtonLayout = TableView::New( 1, NUMBER_OF_ACTION_BUTTONS+1 );
  131 + actionButtonLayout.SetName("ThemeButtonsLayout");
  132 + actionButtonLayout.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
  133 + actionButtonLayout.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::HEIGHT );
  134 + actionButtonLayout.SetFitHeight( 0 );
  135 +
  136 + TextLabel label = TextLabel::New( "Action: ");
  137 + label.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
  138 + label.SetStyleName("ActionLabel");
  139 + actionButtonLayout.AddChild( label, TableView::CellPosition( 0, 0 ) );
  140 + actionButtonLayout.SetCellAlignment( TableView::CellPosition( 0, 0 ), HorizontalAlignment::LEFT, VerticalAlignment::CENTER );
  141 +
  142 + for( int i=0; i<NUMBER_OF_ACTION_BUTTONS; ++i )
  143 + {
  144 + mActionButtons[i] = PushButton::New();
  145 + mActionButtons[i].SetName("ActionButton");
  146 + mActionButtons[i].SetStyleName("ActionButton");
  147 + mActionButtons[i].SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
  148 + mActionButtons[i].SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT );
  149 + mActionIndex = mActionButtons[i].RegisterProperty( "actionId", i, Property::READ_WRITE );
  150 + mActionButtons[i].ClickedSignal().Connect( this, &TransitionApplication::OnActionButtonClicked );
  151 + actionButtonLayout.AddChild( mActionButtons[i], TableView::CellPosition( 0, 1+i ) );
  152 + }
  153 + mActionButtons[0].SetLabelText( "Bounce" );
  154 + mActionButtons[1].SetLabelText( "X" );
  155 + mActionButtons[2].SetLabelText( "Y" );
  156 + mActionButtons[3].SetLabelText( "Fade" );
  157 +
  158 + contentLayout.Add( actionButtonLayout );
  159 + contentLayout.SetFitHeight(3);
  160 +}
  161 +
  162 +void TransitionApplication::CreateVisualMap( int index, Property::Map& map )
  163 +{
  164 + switch(index)
  165 + {
  166 + case 0:
  167 + {
  168 + map[ Visual::Property::TYPE ] = Visual::COLOR;
  169 + map[ ColorVisual::Property::MIX_COLOR ] = Color::YELLOW;
  170 + break;
  171 + }
  172 + case 1:
  173 + {
  174 + map[ Visual::Property::TYPE ] = Visual::BORDER;
  175 + map[ BorderVisual::Property::COLOR ] = Color::GREEN;
  176 + map[ BorderVisual::Property::SIZE ] = 5;
  177 + break;
  178 + }
  179 + case 2:
  180 + {
  181 + map[ Visual::Property::TYPE ] = Visual::GRADIENT;
  182 +
  183 + Property::Array stopOffsets;
  184 + stopOffsets.PushBack( 0.0f );
  185 + stopOffsets.PushBack( 0.3f );
  186 + stopOffsets.PushBack( 0.6f );
  187 + stopOffsets.PushBack( 0.8f );
  188 + stopOffsets.PushBack( 1.0f );
  189 + map[ GradientVisual::Property::STOP_OFFSET ] = stopOffsets;
  190 +
  191 + Property::Array stopColors;
  192 + stopColors.PushBack( Vector4( 129.f, 198.f, 193.f, 255.f )/255.f );
  193 + stopColors.PushBack( Vector4( 196.f, 198.f, 71.f, 122.f )/255.f );
  194 + stopColors.PushBack( Vector4( 214.f, 37.f, 139.f, 191.f )/255.f );
  195 + stopColors.PushBack( Vector4( 129.f, 198.f, 193.f, 150.f )/255.f );
  196 + stopColors.PushBack( Color::YELLOW );
  197 + map[ GradientVisual::Property::STOP_COLOR ] = stopColors;
  198 + map[ GradientVisual::Property::START_POSITION ] = Vector2(-0.5f, -0.5f );
  199 + map[ GradientVisual::Property::END_POSITION ] = Vector2( 0.5f, 0.5f );
  200 + break;
  201 + }
  202 + case 3:
  203 + {
  204 + map[ Visual::Property::TYPE ] = Visual::IMAGE;
  205 + map[ ImageVisual::Property::URL ] = DALI_LOGO_PATH;
  206 + break;
  207 + }
  208 + case 4:
  209 + {
  210 + map[ Visual::Property::TYPE ] = Visual::IMAGE;
  211 + map[ ImageVisual::Property::URL ] = DEMO_IMAGE_DIR "preMultAlpha.png";
  212 + map[ DevelVisual::Property::PREMULTIPLIED_ALPHA ] = true;
  213 + break;
  214 + }
  215 +
  216 + case 5:
  217 + {
  218 + map[ Visual::Property::TYPE ] = Visual::MESH;
  219 + map[ MeshVisual::Property::OBJECT_URL ] = DALI_ROBOT_MODEL_PATH;
  220 + map[ MeshVisual::Property::MATERIAL_URL ] = DALI_ROBOT_MATERIAL_PATH;
  221 + map[ MeshVisual::Property::TEXTURES_PATH ] = DEMO_IMAGE_DIR;
  222 + map[ MeshVisual::Property::SHADING_MODE ] = MeshVisual::ShadingMode::TEXTURED_WITH_DETAILED_SPECULAR_LIGHTING;
  223 + break;
  224 + }
  225 +
  226 + case 6:
  227 + {
  228 + map[ Visual::Property::TYPE ] = Visual::PRIMITIVE;
  229 +
  230 + map[ PrimitiveVisual::Property::SHAPE ] = PrimitiveVisual::Shape::BEVELLED_CUBE;
  231 + map[ PrimitiveVisual::Property::BEVEL_PERCENTAGE ] = 0.3f;
  232 + map[ PrimitiveVisual::Property::BEVEL_SMOOTHNESS ] = 0.0f;
  233 + map[ PrimitiveVisual::Property::SCALE_DIMENSIONS ] = Vector3(1.0f,1.0f,0.3f);
  234 + map[ PrimitiveVisual::Property::MIX_COLOR ] = Vector4(0.7f, 0.5f, 0.05f, 1.0f);
  235 +
  236 + break;
  237 + }
  238 +
  239 + case 7:
  240 + {
  241 + // NPatch
  242 + map[ Visual::Property::TYPE ] = Visual::IMAGE;
  243 + map[ ImageVisual::Property::URL ] = DEMO_IMAGE_DIR "button-up-16.9.png";
  244 + break;
  245 + }
  246 + case 8:
  247 + {
  248 + // SVG
  249 + map[ Visual::Property::TYPE ] = Visual::IMAGE;
  250 + map[ ImageVisual::Property::URL ] = DEMO_IMAGE_DIR "Kid1.svg";
  251 + break;
  252 + }
  253 +
  254 + case 9:
  255 + {
  256 + map[ Visual::Property::TYPE ] = DevelVisual::TEXT;
  257 + map[ TextVisual::Property::TEXT ] = "Text";
  258 + map[ TextVisual::Property::TEXT_COLOR ] = Color::CYAN;
  259 + map[ TextVisual::Property::POINT_SIZE ] = 10;
  260 + break;
  261 + }
  262 +
  263 + default:
  264 + {
  265 + map[ Visual::Property::TYPE ] = Visual::COLOR;
  266 + map[ ColorVisual::Property::MIX_COLOR ] = Color::MAGENTA;
  267 + break;
  268 + }
  269 + }
  270 +}
  271 +
  272 +bool TransitionApplication::OnVisualButtonClicked( Actor actor, const TouchData& touchData )
  273 +{
  274 + if( touchData.GetState(0) == PointState::FINISHED )
  275 + {
  276 + int visual = actor.GetProperty<int>( mVisualIndex );
  277 + Property::Map map;
  278 + CreateVisualMap( visual, map );
  279 + map.Add( DevelVisual::Property::TRANSFORM, Property::Map()
  280 + .Add( DevelVisual::Transform::Property::SIZE, Vector2( 0.5f, 0.5f ) ) );
  281 + mBeatControl.SetProperty( BeatControl::Property::BEAT_VISUAL, map );
  282 + }
  283 + return true;
  284 +}
  285 +
  286 +bool TransitionApplication::OnActionButtonClicked( Button button )
  287 +{
  288 + int action = button.GetProperty<int>( mActionIndex );
  289 + switch( action )
  290 + {
  291 + case 0:
  292 + {
  293 + mBeatControl.StartBounceAnimation();
  294 + break;
  295 + }
  296 + case 1:
  297 + {
  298 + mBeatControl.StartXAnimation();
  299 + break;
  300 + }
  301 + case 2:
  302 + {
  303 + mBeatControl.StartYAnimation();
  304 + break;
  305 + }
  306 + case 3:
  307 + {
  308 + mBeatControl.StartFadeAnimation();
  309 + break;
  310 + }
  311 + }
  312 +
  313 + return true;
  314 +}
  315 +
  316 +void TransitionApplication::OnKeyEvent( const KeyEvent& keyEvent )
  317 +{
  318 + static int keyPressed = 0;
  319 +
  320 + if( keyEvent.state == KeyEvent::Down)
  321 + {
  322 + if( keyPressed == 0 ) // Is this the first down event?
  323 + {
  324 + printf("Key pressed: %s %d\n", keyEvent.keyPressedName.c_str(), keyEvent.keyCode );
  325 +
  326 + if( IsKey( keyEvent, DALI_KEY_ESCAPE) || IsKey( keyEvent, DALI_KEY_BACK ) )
  327 + {
  328 + mApplication.Quit();
  329 + }
  330 + else if( keyEvent.keyPressedName.compare("Return") == 0 )
  331 + {
  332 + }
  333 + }
  334 + keyPressed = 1;
  335 + }
  336 + else if( keyEvent.state == KeyEvent::Up )
  337 + {
  338 + keyPressed = 0;
  339 + }
  340 +}
  341 +
  342 +} // namespace Demo
... ...
examples/visual-transitions/transition-application.h 0 → 100644
  1 +#ifndef DALI_DEMO_TRANSITION_APPLICATION_H
  2 +#define DALI_DEMO_TRANSITION_APPLICATION_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 +// External includes
  21 +#include <dali-toolkit/dali-toolkit.h>
  22 +//#include <dali-toolkit/devel-api/controls/slider/slider.h>
  23 +#include <dali-toolkit/devel-api/controls/popup/popup.h>
  24 +#include "beat-control.h"
  25 +#include <cstdio>
  26 +#include <sstream>
  27 +
  28 +// Internal includes
  29 +
  30 +using namespace Dali;
  31 +using namespace Dali::Toolkit;
  32 +
  33 +namespace Demo
  34 +{
  35 +
  36 +class TransitionApplication : public ConnectionTracker
  37 +{
  38 +public:
  39 + static const int NUMBER_OF_ACTION_BUTTONS=4;
  40 + static const int NUMBER_OF_VISUAL_BUTTONS=10;
  41 +
  42 +public:
  43 + // Constructor
  44 + TransitionApplication( Application& application );
  45 +
  46 + // Destructor
  47 + ~TransitionApplication();
  48 +
  49 + // Init signal handler
  50 + void Create( Application& application );
  51 +
  52 + // Create the GUI components
  53 + Toolkit::TextLabel CreateTitle( std::string title );
  54 + Actor CreateContentPane();
  55 +
  56 + // Key event handler
  57 + void OnKeyEvent( const KeyEvent& event );
  58 +
  59 + bool OnActionButtonClicked( Button button );
  60 + bool OnVisualButtonClicked( Actor actor, const TouchData& touchData );
  61 +
  62 + static const char* DEMO_THEME_ONE_PATH;
  63 +
  64 +private:
  65 +
  66 + /** Create a visual map
  67 + *
  68 + * @param[in] index The index of the visual to create
  69 + * @param[out] map The map to generate
  70 + */
  71 + void CreateVisualMap( int index, Property::Map& map );
  72 +
  73 + Application& mApplication;
  74 + TextLabel mTitle;
  75 + BeatControl mBeatControl;
  76 + PushButton mActionButtons[NUMBER_OF_ACTION_BUTTONS];
  77 + BeatControl mVisualButtons[NUMBER_OF_VISUAL_BUTTONS];
  78 + Property::Index mVisualIndex;
  79 + Property::Index mActionIndex;
  80 +};
  81 +
  82 +} // Namespace Demo
  83 +
  84 +
  85 +#endif // DALI_DEMO_TRANSITION_APPLICATION_H
... ...
examples/visual-transitions/transition-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 + * @file transition-example.cpp
  19 + * @brief Example of stylable transitions.
  20 + */
  21 +
  22 +// External includes
  23 +#include <dali/dali.h>
  24 +
  25 +// Internal includes
  26 +#include "transition-application.h"
  27 +
  28 +
  29 +/// Entry point for applications
  30 +int DALI_EXPORT_API main( int argc, char** argv )
  31 +{
  32 + const char* themeName = Demo::TransitionApplication::DEMO_THEME_ONE_PATH;
  33 +
  34 + Application application = Application::New( &argc, &argv, themeName );
  35 + Demo::TransitionApplication transitionApplication( application );
  36 + application.MainLoop();
  37 + return 0;
  38 +}
... ...
resources/style/mobile/style-example-theme-one.json.in
... ... @@ -73,9 +73,9 @@
73 73 [
74 74 {
75 75 "target":"imageVisual",
76   - "property":"mixColor",
77   - "initialValue":[1,1,1,0],
78   - "targetValue":[1,1,1,1],
  76 + "property":"opacity",
  77 + "initialValue":0,
  78 + "targetValue":1,
79 79 "animator":
80 80 {
81 81 "alphaFunction":"EASE_IN_OUT",
... ... @@ -96,8 +96,8 @@
96 96 [
97 97 {
98 98 "target":"imageVisual",
99   - "property":"mixColor",
100   - "targetValue":[1,1,1,0],
  99 + "property":"opacity",
  100 + "targetValue":0,
101 101 "animator":
102 102 {
103 103 "alphaFunction":"EASE_IN_OUT",
... ... @@ -378,6 +378,88 @@
378 378 }
379 379 }
380 380 ]
  381 + },
  382 + "BeatControl":
  383 + {
  384 + "beatVisual":{
  385 + "visualType":"IMAGE",
  386 + "url":"{APPLICATION_RESOURCE_PATH}/images/Logo-for-demo.png"
  387 + },
  388 +
  389 + "bounceTransition":
  390 + [
  391 + {
  392 + "target":"beatVisual",
  393 + "property":"size",
  394 + "initialValue":[0.5, 0.5],
  395 + "targetValue":[0.75, 0.75],
  396 + "animator":
  397 + {
  398 + "alphaFunction":"BOUNCE",
  399 + "timePeriod":
  400 + {
  401 + "duration":0.5,
  402 + "delay":0
  403 + }
  404 + }
  405 + }
  406 + ],
  407 +
  408 + "leftTransition":
  409 + [
  410 + {
  411 + "target":"beatVisual",
  412 + "property":"offset",
  413 + "initialValue":[0, 0],
  414 + "targetValue":[0.25, 0],
  415 + "animator":
  416 + {
  417 + "alphaFunction":"BOUNCE",
  418 + "timePeriod":
  419 + {
  420 + "duration":0.5,
  421 + "delay":0
  422 + }
  423 + }
  424 + }
  425 + ],
  426 +
  427 + "upTransition":
  428 + [
  429 + {
  430 + "target":"beatVisual",
  431 + "property":"offset",
  432 + "initialValue":[0, 0],
  433 + "targetValue":[0, 0.25],
  434 + "animator":
  435 + {
  436 + "alphaFunction":"BOUNCE",
  437 + "timePeriod":
  438 + {
  439 + "duration":0.5,
  440 + "delay":0
  441 + }
  442 + }
  443 + }
  444 + ],
  445 +
  446 + "fadeTransition":
  447 + [
  448 + {
  449 + "target":"beatVisual",
  450 + "property":"opacity",
  451 + "targetValue":0,
  452 + "animator":
  453 + {
  454 + "alphaFunction":"BOUNCE",
  455 + "timePeriod":
  456 + {
  457 + "duration":0.8,
  458 + "delay":0
  459 + }
  460 + }
  461 + }
  462 + ]
381 463 }
382 464 }
383 465 }
... ...
resources/style/style-example-theme-one.json.in
... ... @@ -73,9 +73,9 @@
73 73 [
74 74 {
75 75 "target":"imageVisual",
76   - "property":"mixColor",
77   - "initialValue":[1,1,1,0],
78   - "targetValue":[1,1,1,1],
  76 + "property":"opacity",
  77 + "initialValue":0,
  78 + "targetValue":1,
79 79 "animator":
80 80 {
81 81 "alphaFunction":"EASE_IN_OUT",
... ... @@ -96,8 +96,8 @@
96 96 [
97 97 {
98 98 "target":"imageVisual",
99   - "property":"mixColor",
100   - "targetValue":[1,1,1,0],
  99 + "property":"opacity",
  100 + "targetValue":0,
101 101 "animator":
102 102 {
103 103 "alphaFunction":"EASE_IN_OUT",
... ... @@ -378,6 +378,88 @@
378 378 }
379 379 }
380 380 ]
  381 + },
  382 + "BeatControl":
  383 + {
  384 + "beatVisual":{
  385 + "visualType":"IMAGE",
  386 + "url":"{APPLICATION_RESOURCE_PATH}/images/Logo-for-demo.png"
  387 + },
  388 +
  389 + "bounceTransition":
  390 + [
  391 + {
  392 + "target":"beatVisual",
  393 + "property":"size",
  394 + "initialValue":[0.5, 0.5],
  395 + "targetValue":[0.75, 0.75],
  396 + "animator":
  397 + {
  398 + "alphaFunction":"BOUNCE",
  399 + "timePeriod":
  400 + {
  401 + "duration":0.5,
  402 + "delay":0
  403 + }
  404 + }
  405 + }
  406 + ],
  407 +
  408 + "leftTransition":
  409 + [
  410 + {
  411 + "target":"beatVisual",
  412 + "property":"offset",
  413 + "initialValue":[0, 0],
  414 + "targetValue":[0.25, 0],
  415 + "animator":
  416 + {
  417 + "alphaFunction":"BOUNCE",
  418 + "timePeriod":
  419 + {
  420 + "duration":0.5,
  421 + "delay":0
  422 + }
  423 + }
  424 + }
  425 + ],
  426 +
  427 + "upTransition":
  428 + [
  429 + {
  430 + "target":"beatVisual",
  431 + "property":"offset",
  432 + "initialValue":[0, 0],
  433 + "targetValue":[0, 0.25],
  434 + "animator":
  435 + {
  436 + "alphaFunction":"BOUNCE",
  437 + "timePeriod":
  438 + {
  439 + "duration":0.5,
  440 + "delay":0
  441 + }
  442 + }
  443 + }
  444 + ],
  445 +
  446 + "fadeTransition":
  447 + [
  448 + {
  449 + "target":"beatVisual",
  450 + "property":"opacity",
  451 + "targetValue":0,
  452 + "animator":
  453 + {
  454 + "alphaFunction":"BOUNCE",
  455 + "timePeriod":
  456 + {
  457 + "duration":0.8,
  458 + "delay":0
  459 + }
  460 + }
  461 + }
  462 + ]
381 463 }
382 464 }
383 465 }
... ...