diff --git a/com.samsung.dali-demo.xml b/com.samsung.dali-demo.xml index 4511e54..ba61290 100644 --- a/com.samsung.dali-demo.xml +++ b/com.samsung.dali-demo.xml @@ -177,6 +177,9 @@ + + + diff --git a/examples/image-scaling-and-filtering/image-scaling-and-filtering-example.cpp b/examples/image-scaling-and-filtering/image-scaling-and-filtering-example.cpp index 1c4563c..c6941b4 100644 --- a/examples/image-scaling-and-filtering/image-scaling-and-filtering-example.cpp +++ b/examples/image-scaling-and-filtering/image-scaling-and-filtering-example.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include "shared/view.h" #include @@ -522,21 +523,6 @@ public: } } - void OnImageLoaded( ResourceImage image ) - { - DALI_ASSERT_DEBUG( image == mNextImage ); - mImageView.SetImage( image ); - mImageView.SetSize( Size( image.GetWidth(), image.GetHeight() ) ); - mImageLoading = false; - - // We have finished loading, if a resize had occured during the load, trigger another load now. - if( mQueuedImageLoad ) - { - mQueuedImageLoad = false; - LoadImage(); - } - } - bool OnControlTouched( Actor actor, const TouchData& event ) { if(event.GetPointCount() > 0) @@ -687,21 +673,17 @@ private: const char * const path = IMAGE_PATHS[ mCurrentPath ]; Stage stage = Stage::GetCurrent(); Size imageSize = stage.GetSize() * mImageStageScale; - const ImageDimensions imageSizeInt = ImageDimensions::FromFloatArray( &imageSize.x ); + mImageView.SetSize( imageSize ); - ResourceImage image = ResourceImage::New( path, imageSizeInt, mFittingMode, mSamplingMode ); + Property::Map map; + map[Toolkit::ImageVisual::Property::URL] = path; + map[Toolkit::ImageVisual::Property::DESIRED_WIDTH] = imageSize.x; + map[Toolkit::ImageVisual::Property::DESIRED_HEIGHT] = imageSize.y; + map[Toolkit::ImageVisual::Property::FITTING_MODE] = mFittingMode; + map[Toolkit::ImageVisual::Property::SAMPLING_MODE] = mSamplingMode; - // If the image was cached, the load has already occured, bypass hooking the signal. - if( image.GetLoadingState() ) - { - OnImageLoaded( image ); - } - else - { - image.LoadingFinishedSignal().Connect( this, &ImageScalingAndFilteringController::OnImageLoaded ); - } + mImageView.SetProperty( Toolkit::ImageView::Property::IMAGE, map ); - mNextImage = image; } void ResizeImage() @@ -710,16 +692,7 @@ private: Stage stage = Stage::GetCurrent(); Size imageSize = stage.GetSize() * mImageStageScale; - // If an image is already loading, queue another load when it has finished. - // This way we get continuous updates instead of constantly re-requesting loads. - if( mImageLoading ) - { - mQueuedImageLoad = true; - } - else - { - LoadImage(); - } + LoadImage(); // Border size needs to be modified to take into account the width of the frame. Vector2 borderScale( ( imageSize + Vector2( BORDER_WIDTH * 2.0f, BORDER_WIDTH * 2.0f ) ) / stage.GetSize() ); @@ -742,7 +715,6 @@ private: Toolkit::ImageView mGrabCorner; PanGestureDetector mPanGestureDetector; Toolkit::ImageView mImageView; - ResourceImage mNextImage; //< Currently-loading image Vector2 mImageStageScale; int mCurrentPath; FittingMode::Type mFittingMode; diff --git a/examples/image-scaling-irregular-grid/image-scaling-irregular-grid-example.cpp b/examples/image-scaling-irregular-grid/image-scaling-irregular-grid-example.cpp index fdae2c4..7edeec6 100644 --- a/examples/image-scaling-irregular-grid/image-scaling-irregular-grid-example.cpp +++ b/examples/image-scaling-irregular-grid/image-scaling-irregular-grid-example.cpp @@ -168,23 +168,6 @@ const char* IMAGE_PATHS[] = { const unsigned NUM_IMAGE_PATHS = sizeof(IMAGE_PATHS) / sizeof(IMAGE_PATHS[0]) - 1u; -/** - * Creates an Image - * - * @param[in] filename The path of the image. - * @param[in] width The width of the image in pixels. - * @param[in] height The height of the image in pixels. - * @param[in] fittingMode The mode to use when scaling the image to fit the desired dimensions. - */ -Image CreateImage(const std::string& filename, unsigned int width, unsigned int height, Dali::FittingMode::Type fittingMode ) -{ -#ifdef DEBUG_PRINT_DIAGNOSTICS - fprintf( stderr, "CreateImage(%s, %u, %u, fittingMode=%u)\n", filename.c_str(), width, height, unsigned( fittingMode ) ); -#endif - Image image = ResourceImage::New( filename, ImageDimensions( width, height ), fittingMode, Dali::SamplingMode::BOX_THEN_LINEAR ); - - return image; -} /** * Creates an ImageView @@ -194,15 +177,23 @@ Image CreateImage(const std::string& filename, unsigned int width, unsigned int * @param[in] height The height of the image in pixels. * @param[in] fittingMode The mode to use when scaling the image to fit the desired dimensions. */ -ImageView CreateImageView(const std::string& filename, unsigned int width, unsigned int height, Dali::FittingMode::Type fittingMode ) +ImageView CreateImageView(const std::string& filename, int width, int height, Dali::FittingMode::Type fittingMode ) { - Image img = CreateImage( filename, width, height, fittingMode ); - ImageView actor = ImageView::New( img ); - actor.SetName( filename ); - actor.SetParentOrigin(ParentOrigin::CENTER); - actor.SetAnchorPoint(AnchorPoint::CENTER); - return actor; + ImageView imageView = ImageView::New(); + + Property::Map map; + map[Toolkit::ImageVisual::Property::URL] = filename; + map[Toolkit::ImageVisual::Property::DESIRED_WIDTH] = width; + map[Toolkit::ImageVisual::Property::DESIRED_HEIGHT] = height; + map[Toolkit::ImageVisual::Property::FITTING_MODE] = fittingMode; + imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, map ); + + imageView.SetName( filename ); + imageView.SetParentOrigin(ParentOrigin::CENTER); + imageView.SetAnchorPoint(AnchorPoint::CENTER); + + return imageView; } /** Cycle the scaling mode options. */ @@ -494,13 +485,18 @@ public: Dali::FittingMode::Type newMode = NextMode( mFittingModes[id] ); const Vector2 imageSize = mSizes[actor.GetId()]; - const std::string& url = mResourceUrls[id]; - Image newImage = CreateImage( url, imageSize.width + 0.5f, imageSize.height + 0.5f, newMode ); ImageView imageView = ImageView::DownCast( actor ); - if(imageView) + if( imageView) { - imageView.SetImage( newImage ); + Property::Map map; + map[Visual::Property::TYPE] = Visual::IMAGE; + map[ImageVisual::Property::URL] = mResourceUrls[id]; + map[ImageVisual::Property::DESIRED_WIDTH] = imageSize.width + 0.5f; + map[ImageVisual::Property::DESIRED_HEIGHT] = imageSize.height + 0.5f; + map[ImageVisual::Property::FITTING_MODE] = newMode; + imageView.SetProperty( ImageView::Property::IMAGE, map ); } + mFittingModes[id] = newMode; } } @@ -542,8 +538,16 @@ public: const Vector2 imageSize = mSizes[ id ]; Dali::FittingMode::Type newMode = NextMode( mFittingModes[ id ] ); - Image newImage = CreateImage( mResourceUrls[ id ], imageSize.width, imageSize.height, newMode ); - gridImageView.SetImage( newImage ); + + Property::Map map; + map[Visual::Property::TYPE] = Visual::IMAGE; + map[ImageVisual::Property::URL] = mResourceUrls[id]; + map[ImageVisual::Property::DESIRED_WIDTH] = imageSize.width; + map[ImageVisual::Property::DESIRED_HEIGHT] = imageSize.height; + map[ImageVisual::Property::FITTING_MODE] = newMode; + gridImageView.SetProperty( ImageView::Property::IMAGE, map ); + + mFittingModes[ id ] = newMode; diff --git a/examples/mesh-visual/mesh-visual-example.cpp b/examples/mesh-visual/mesh-visual-example.cpp index 24901bd..341a72c 100644 --- a/examples/mesh-visual/mesh-visual-example.cpp +++ b/examples/mesh-visual/mesh-visual-example.cpp @@ -6,65 +6,67 @@ using namespace Dali::Toolkit; namespace { - //Keeps information about each model for access. - struct Model - { - Control control; // Control housing the mesh visual of the model. - Vector2 rotation; // Keeps track of rotation about x and y axis for manual rotation. - Animation rotationAnimation; // Automatically rotates when left alone. - }; +// Keeps information about each model for access. +struct Model +{ + Control control; // Control housing the mesh visual of the model. + Vector2 rotation; // Keeps track of rotation about x and y axis for manual rotation. + Animation rotationAnimation; // Automatically rotates when left alone. +}; - //Files for meshes - const char * const MODEL_FILE_TABLE[] = - { - DEMO_MODEL_DIR "Dino.obj", - DEMO_MODEL_DIR "ToyRobot-Metal.obj", - DEMO_MODEL_DIR "Toyrobot-Plastic.obj" - }; +// Files for meshes +const char * const MODEL_FILE_TABLE[] = +{ + DEMO_MODEL_DIR "Dino.obj", + DEMO_MODEL_DIR "ToyRobot-Metal.obj", + DEMO_MODEL_DIR "Toyrobot-Plastic.obj" +}; - const char * const MATERIAL_FILE_TABLE[] = - { - DEMO_MODEL_DIR "Dino.mtl", - DEMO_MODEL_DIR "ToyRobot-Metal.mtl", - DEMO_MODEL_DIR "Toyrobot-Plastic.mtl" - }; +const char * const MATERIAL_FILE_TABLE[] = +{ + DEMO_MODEL_DIR "Dino.mtl", + DEMO_MODEL_DIR "ToyRobot-Metal.mtl", + DEMO_MODEL_DIR "Toyrobot-Plastic.mtl" +}; - const char * const TEXTURES_PATH( DEMO_IMAGE_DIR "" ); +const char * const TEXTURES_PATH( DEMO_IMAGE_DIR "" ); - //Possible shading modes. - MeshVisual::ShadingMode::Value SHADING_MODE_TABLE[] = - { - MeshVisual::ShadingMode::TEXTURED_WITH_DETAILED_SPECULAR_LIGHTING, - MeshVisual::ShadingMode::TEXTURED_WITH_SPECULAR_LIGHTING, - MeshVisual::ShadingMode::TEXTURELESS_WITH_DIFFUSE_LIGHTING - }; - - //Button labels. - const char * const PAUSE = " || "; - const char * const PLAY = " > "; - const char * const FIXED = "FIXED"; - const char * const MANUAL = "MANUAL"; - const char * const FRONT = "FRONT"; - const char * const BACK = "BACK"; - - //Image urls for the light. - const char * const LIGHT_URL_FRONT = DEMO_IMAGE_DIR "light-icon-front.png"; - const char * const LIGHT_URL_BACK = DEMO_IMAGE_DIR "light-icon-back.png"; - - const float X_ROTATION_DISPLACEMENT_FACTOR = 60.0f; - const float Y_ROTATION_DISPLACEMENT_FACTOR = 60.0f; - const float MODEL_SCALE = 0.75f; - const float LIGHT_SCALE = 0.15f; - const float BUTTONS_OFFSET_BOTTOM = 0.08f; - const float BUTTONS_OFFSET_SIDE = 0.2f; - const int NUM_MESHES = 2; - - //Used to identify actors. - const int MODEL_TAG = 0; - const int LIGHT_TAG = 1; - const int LAYER_TAG = 2; - -} //End namespace +// Possible shading modes. +MeshVisual::ShadingMode::Value SHADING_MODE_TABLE[] = +{ + MeshVisual::ShadingMode::TEXTURED_WITH_DETAILED_SPECULAR_LIGHTING, + MeshVisual::ShadingMode::TEXTURED_WITH_SPECULAR_LIGHTING, + MeshVisual::ShadingMode::TEXTURELESS_WITH_DIFFUSE_LIGHTING +}; + +// Button labels. +const char * const PAUSE = " || "; +const char * const PLAY = " > "; +const char * const FIXED = "FIXED"; +const char * const MANUAL = "MANUAL"; +const char * const FRONT = "FRONT"; +const char * const BACK = "BACK"; + +// Image urls for the light. +const char * const LIGHT_URL_FRONT = DEMO_IMAGE_DIR "light-icon-front.png"; +const char * const LIGHT_URL_BACK = DEMO_IMAGE_DIR "light-icon-back.png"; + +const float X_ROTATION_DISPLACEMENT_FACTOR = 60.0f; +const float Y_ROTATION_DISPLACEMENT_FACTOR = 60.0f; +const float MODEL_SCALE = 0.75f; +const float LIGHT_SCALE = 0.15f; +const float BUTTONS_OFFSET_BOTTOM = 0.08f; +const float BUTTONS_OFFSET_SIDE = 0.2f; +const int NUM_MESHES = 2; + +// Used to identify actors. +const int MODEL_TAG = 0; +const int LIGHT_TAG = 1; +const int LAYER_TAG = 2; + +const Vector4 STAGE_COLOR( 211.0f / 255.0f, 211.0f / 255.0f, 211.0f / 255.0f, 1.0f ); ///< The color of the stage + +} // unnamed namespace class MeshVisualController : public ConnectionTracker { @@ -93,7 +95,7 @@ public: { // Get a handle to the stage Stage stage = Stage::GetCurrent(); - stage.SetBackgroundColor( Vector4( 0.0, 0.5, 1.0, 1.0 ) ); + stage.SetBackgroundColor( STAGE_COLOR ); //Set up root layer to receive touch gestures. Layer rootLayer = stage.GetRootLayer(); diff --git a/examples/motion-blur/motion-blur-example.cpp b/examples/motion-blur/motion-blur-example.cpp index e002e73..9c80f5c 100644 --- a/examples/motion-blur/motion-blur-example.cpp +++ b/examples/motion-blur/motion-blur-example.cpp @@ -37,20 +37,8 @@ namespace // unnamed namespace // Demo setup parameters // -//#define MULTIPLE_MOTION_BLURRED_ACTORS -#ifndef MULTIPLE_MOTION_BLURRED_ACTORS - const float MOTION_BLUR_ACTOR_WIDTH = 256; // actor size on screen const float MOTION_BLUR_ACTOR_HEIGHT = 256; // "" - -#else //#ifndef MULTIPLE_MOTION_BLURRED_ACTORS - -const float MOTION_BLUR_ACTOR_WIDTH = 150; // actor size on screen -const float MOTION_BLUR_ACTOR_HEIGHT = 112; // "" - -#endif //#ifndef MULTIPLE_MOTION_BLURRED_ACTORS - - const unsigned int MOTION_BLUR_NUM_SAMPLES = 8; const int MOTION_BLUR_NUM_ACTOR_IMAGES = 5; @@ -230,71 +218,6 @@ public: // set actor shader to the blur one Toolkit::SetMotionBlurProperties( mMotionBlurImageView, MOTION_BLUR_NUM_SAMPLES ); - -#ifdef MULTIPLE_MOTION_BLURRED_ACTORS - - /////////////////////////////////////////////////////// - // - // Motion blurred actor 2 - // - - mMotionBlurImageView2 = ImageView::New(image); - mMotionBlurImageView2.SetParentOrigin( ParentOrigin::CENTER ); - mMotionBlurImageView2.SetSize(mMotionBlurActorSize.x, mMotionBlurActorSize.y); - mMotionBlurImageView2.SetPosition(mMotionBlurActorSize.x * 1.1f, 0.0f); - mMotionBlurImageView.Add( mMotionBlurImageView2 ); - - // set actor shader to the blur one - Toolkit::SetMotionBlurProperties( mMotionBlurImageView2, MOTION_BLUR_NUM_SAMPLES ); - mMotionBlurImageView2.SetProperty( Toolkit::ImageView::Property::IMAGE, mMotionBlurEffect ); - - - /////////////////////////////////////////////////////// - // - // Motion blurred actor 3 - // - - mMotionBlurImageView3 = ImageView::New(image); - mMotionBlurImageView3.SetParentOrigin( ParentOrigin::CENTER ); - mMotionBlurImageView3.SetSize(mMotionBlurActorSize.x, mMotionBlurActorSize.y); - mMotionBlurImageView3.SetPosition(-mMotionBlurActorSize.x * 1.1f, 0.0f); - mMotionBlurImageView.Add( mMotionBlurImageView3 ); - - // set actor shader to the blur one - Toolkit::SetMotionBlurProperties( mMotionBlurImageView3, MOTION_BLUR_NUM_SAMPLES ); - mMotionBlurImageView3.SetProperty( Toolkit::ImageView::Property::IMAGE, mMotionBlurEffect ); - - - /////////////////////////////////////////////////////// - // - // Motion blurred actor 4 - // - - mMotionBlurImageView4 = ImageView::New(image); - mMotionBlurImageView4.SetParentOrigin( ParentOrigin::CENTER ); - mMotionBlurImageView4.SetSize(mMotionBlurActorSize.x, mMotionBlurActorSize.y); - mMotionBlurImageView4.SetPosition(0.0f, mMotionBlurActorSize.y * 1.1f); - mMotionBlurImageView.Add( mMotionBlurImageView4 ); - - // set actor shader to the blur one - Toolkit::SetMotionBlurProperties( mMotionBlurImageView4, MOTION_BLUR_NUM_SAMPLES ); - mMotionBlurImageView4.SetProperty( Toolkit::ImageView::Property::IMAGE, mMotionBlurEffect ); - - /////////////////////////////////////////////////////// - // - // Motion blurred actor 5 - // - - mMotionBlurImageView5 = ImageView::New(image); - mMotionBlurImageView5.SetParentOrigin( ParentOrigin::CENTER ); - mMotionBlurImageView5.SetSize(mMotionBlurActorSize.x, mMotionBlurActorSize.y); - mMotionBlurImageView5.SetPosition(0.0f, -mMotionBlurActorSize.y * 1.1f); - mMotionBlurImageView.Add( mMotionBlurImageView5 ); - - // set actor shader to the blur one - Toolkit::SetMotionBlurProperties( mMotionBlurImageView5, MOTION_BLUR_NUM_SAMPLES ); - mMotionBlurImageView5.SetProperty( Toolkit::ImageView::Property::IMAGE, mMotionBlurEffect ); -#endif //#ifdef MULTIPLE_MOTION_BLURRED_ACTORS } void Rotate( DeviceOrientation orientation ) @@ -494,12 +417,6 @@ public: } SetImageFittedInBox( mMotionBlurImageView, mMotionBlurEffect, MOTION_BLUR_ACTOR_IMAGES[mCurrentImage], mMotionBlurActorSize.x, mMotionBlurActorSize.y ); -#ifdef MULTIPLE_MOTION_BLURRED_ACTORS - mMotionBlurImageView2.SetImage(blurImage); - mMotionBlurImageView3.SetImage(blurImage); - mMotionBlurImageView4.SetImage(blurImage); - mMotionBlurImageView5.SetImage(blurImage); -#endif } @@ -517,13 +434,6 @@ private: ImageView mMotionBlurImageView; Size mMotionBlurActorSize; -#ifdef MULTIPLE_MOTION_BLURRED_ACTORS - ImageView mMotionBlurImageView2; - ImageView mMotionBlurImageView3; - ImageView mMotionBlurImageView4; - ImageView mMotionBlurImageView5; -#endif //#ifdef MULTIPLE_MOTION_BLURRED_ACTORS - // animate actor to position where user taps screen Animation mActorTapMovementAnimation; diff --git a/examples/styling/image-channel-control-impl.cpp b/examples/styling/image-channel-control-impl.cpp index c805e39..631c0fa 100644 --- a/examples/styling/image-channel-control-impl.cpp +++ b/examples/styling/image-channel-control-impl.cpp @@ -37,12 +37,13 @@ const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER( varying mediump vec2 vTexCoord;\n uniform sampler2D sTexture;\n uniform mediump vec4 uColor;\n - uniform mediump vec4 mixColor;\n + uniform mediump vec3 mixColor;\n + uniform mediump float opacity;\n uniform mediump vec3 uChannels;\n \n void main()\n {\n - gl_FragColor = texture2D( sTexture, vTexCoord ) * mixColor * uColor * vec4(uChannels, 1.0) ;\n + gl_FragColor = texture2D( sTexture, vTexCoord ) * vec4(mixColor,opacity) * uColor * vec4(uChannels, 1.0) ;\n }\n ); diff --git a/examples/styling/styling-application.cpp b/examples/styling/styling-application.cpp index b5b876e..2a4d7b6 100644 --- a/examples/styling/styling-application.cpp +++ b/examples/styling/styling-application.cpp @@ -178,7 +178,7 @@ void StylingApplication::Create( Application& application ) for( int i=0; i<3; ++i ) { std::ostringstream thumbnailName; thumbnailName << "thumbnail" << i+1; - ImageView image = ImageView::New( ResourceImage::New( images[i] ) ); + ImageView image = ImageView::New( images[i] ); image.SetName( thumbnailName.str() ); image.SetSize( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) ); diff --git a/examples/text-label/text-label-example.cpp b/examples/text-label/text-label-example.cpp index e3f0523..85c51eb 100644 --- a/examples/text-label/text-label-example.cpp +++ b/examples/text-label/text-label-example.cpp @@ -80,17 +80,17 @@ struct HSVColorConstraint { } - void operator()(Vector4& current, const PropertyInputContainer& inputs ) + void operator()(Vector3& current, const PropertyInputContainer& inputs ) { - current = hsv2rgb(Vector4(inputs[0]->GetFloat(), saturation, value, current.a)); + current = hsv2rgb(Vector3(inputs[0]->GetFloat(), saturation, value)); } - Vector4 hsv2rgb(Vector4 colorHSV) + Vector3 hsv2rgb(Vector3 colorHSV) { float r=colorHSV.z*(1+colorHSV.y*(cos(colorHSV.x)-1)); float g=colorHSV.z*(1+colorHSV.y*(cos(colorHSV.x-2.09439)-1)); float b=colorHSV.z*(1+colorHSV.y*(cos(colorHSV.x+2.09439)-1)); - return Vector4(r, g, b, colorHSV.a); + return Vector3(r, g, b); } float hue; float saturation; @@ -173,7 +173,7 @@ public: Renderer bgRenderer = mLabel.GetRendererAt(0); mOverrideMixColorIndex = DevelHandle::GetPropertyIndex( bgRenderer, ColorVisual::Property::MIX_COLOR ); - Constraint constraint = Constraint::New( bgRenderer, mOverrideMixColorIndex, HSVColorConstraint(0.0f, 0.5f, 0.8f)); + Constraint constraint = Constraint::New( bgRenderer, mOverrideMixColorIndex, HSVColorConstraint(0.0f, 0.5f, 0.8f)); constraint.AddSource( Source( mLabel, mHueAngleIndex ) ); constraint.SetRemoveAction( Constraint::Discard ); constraint.Apply(); diff --git a/examples/transitions/transition-application.cpp b/examples/transitions/transition-application.cpp index da81bb9..d3acd98 100644 --- a/examples/transitions/transition-application.cpp +++ b/examples/transitions/transition-application.cpp @@ -24,6 +24,7 @@ // External includes #include +#include #include #include #include "shadow-button.h" @@ -110,6 +111,9 @@ void TransitionApplication::Create( Application& application ) mShadowButton.SetAnchorPoint( AnchorPoint::CENTER ); mShadowButton.SetParentOrigin( ParentOrigin::CENTER ); mShadowButton.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); + mShadowButton.SetProperty( DevelControl::Property::STATE, DevelControl::DISABLED ); + mShadowButton.SetProperty( DevelControl::Property::SUB_STATE, "UNCHECKED" ); + buttonLayout.AddChild( mShadowButton, TableView::CellPosition(1, 1) ); TableView actionButtonLayout = TableView::New( 1, NUMBER_OF_ACTION_BUTTONS+1 ); @@ -135,7 +139,7 @@ void TransitionApplication::Create( Application& application ) mActionButtons[i].ClickedSignal().Connect( this, &TransitionApplication::OnActionButtonClicked ); actionButtonLayout.AddChild( mActionButtons[i], TableView::CellPosition( 0, 1+i ) ); } - SetLabelText( mActionButtons[0], "Activate" ); + SetLabelText( mActionButtons[0], "Enable" ); SetLabelText( mActionButtons[1], "Check" ); mActionButtons[1].SetProperty( Button::Property::DISABLED, true ); @@ -154,11 +158,13 @@ bool TransitionApplication::OnActionButtonClicked( Button button ) mShadowButton.SetActiveState( ! activeState ); if( activeState ) { - SetLabelText( button, "Activate" ); + SetLabelText( button, "Enable" ); + mShadowButton.SetProperty( DevelControl::Property::STATE, DevelControl::DISABLED ); } else { - SetLabelText( button, "Deactivate" ); + SetLabelText( button, "Disable" ); + mShadowButton.SetProperty( DevelControl::Property::STATE, DevelControl::NORMAL ); } mActionButtons[1].SetProperty( Button::Property::DISABLED, activeState ); break; @@ -170,10 +176,12 @@ bool TransitionApplication::OnActionButtonClicked( Button button ) if( checkState ) { SetLabelText( button, "Check" ); + mShadowButton.SetProperty( DevelControl::Property::SUB_STATE, "UNCHECKED" ); } else { SetLabelText( button, "Uncheck" ); + mShadowButton.SetProperty( DevelControl::Property::SUB_STATE, "CHECKED" ); } break; } diff --git a/examples/visual-transitions/beat-control-impl.cpp b/examples/visual-transitions/beat-control-impl.cpp new file mode 100644 index 0000000..ef0c56d --- /dev/null +++ b/examples/visual-transitions/beat-control-impl.cpp @@ -0,0 +1,347 @@ +/* + * 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 "beat-control-impl.h" +#include +#include +#include +#include +#include + +#include + +using namespace Dali; // Needed for macros +using namespace Dali::Toolkit; + +namespace Demo +{ +namespace Internal +{ + +namespace +{ + +const int BOUNCE_ANIMATION_RUNNING(0x0001); +const int FADE_ANIMATION_RUNNING (0x0002); +const int X_ANIMATION_RUNNING (0x0004); +const int Y_ANIMATION_RUNNING (0x0008); + + +Dali::BaseHandle Create() +{ + return Demo::BeatControl::New(); +} + +DALI_TYPE_REGISTRATION_BEGIN( BeatControl, Dali::Toolkit::Control, Create ); + +DALI_PROPERTY_REGISTRATION( Demo, BeatControl, "bounceTransition", STRING, BOUNCE_TRANSITION ); +DALI_PROPERTY_REGISTRATION( Demo, BeatControl, "leftTransition", STRING, LEFT_TRANSITION ); +DALI_PROPERTY_REGISTRATION( Demo, BeatControl, "upTransition", STRING, UP_TRANSITION ); +DALI_PROPERTY_REGISTRATION( Demo, BeatControl, "fadeTransition", STRING, FADE_TRANSITION ); +DALI_PROPERTY_REGISTRATION( Demo, BeatControl, "beatVisual", MAP, BEAT_VISUAL ); +DALI_TYPE_REGISTRATION_END(); + + +Toolkit::TransitionData ConvertPropertyToTransition( const Property::Value& value ) +{ + Toolkit::TransitionData transitionData; + + if( value.GetType() == Property::ARRAY ) + { + transitionData = Toolkit::TransitionData::New( *value.GetArray()); + } + else if( value.GetType() == Property::MAP ) + { + transitionData = Toolkit::TransitionData::New( *value.GetMap() ); + } + return transitionData; +} + +} // anonymous namespace + + +Internal::BeatControl::BeatControl() +: Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ), + mTransformSize(1.0f, 1.0f), + mAnimationPlaying(0) +{ +} + +Internal::BeatControl::~BeatControl() +{ +} + +Demo::BeatControl Internal::BeatControl::New() +{ + IntrusivePtr impl = new Internal::BeatControl(); + Demo::BeatControl handle = Demo::BeatControl( *impl ); + impl->Initialize(); + return handle; +} + + +void BeatControl::StartBounceAnimation() +{ + if( mAnimation ) + { + mAnimation.Stop(); + mAnimation.FinishedSignal().Disconnect( this, &BeatControl::OnBounceAnimationFinished ); + OnBounceAnimationFinished(mAnimation); + } + + mAnimation = CreateTransition( mBounceTransition ); + mAnimation.FinishedSignal().Connect( this, &BeatControl::OnBounceAnimationFinished ); + mAnimation.Play(); + mAnimationPlaying |= BOUNCE_ANIMATION_RUNNING; +} + + +void BeatControl::StartXAnimation() +{ + if( mXAnimation ) + { + mXAnimation.Stop(); + mXAnimation.FinishedSignal().Disconnect( this, &BeatControl::OnXAnimationFinished ); + OnXAnimationFinished(mXAnimation); + } + + mXAnimation = CreateTransition( mLeftTransition ); + mXAnimation.FinishedSignal().Connect( this, &BeatControl::OnXAnimationFinished ); + mXAnimation.Play(); + mAnimationPlaying |= X_ANIMATION_RUNNING; +} + +void BeatControl::StartYAnimation() +{ + if( mYAnimation ) + { + mYAnimation.Stop(); + mYAnimation.FinishedSignal().Disconnect( this, &BeatControl::OnYAnimationFinished ); + OnYAnimationFinished(mYAnimation); + } + + mYAnimation = CreateTransition( mUpTransition ); + mYAnimation.FinishedSignal().Connect( this, &BeatControl::OnYAnimationFinished ); + mYAnimation.Play(); + mAnimationPlaying |= Y_ANIMATION_RUNNING; +} + +void BeatControl::StartFadeAnimation() +{ + if( mFadeAnimation ) + { + mFadeAnimation.Stop(); + mFadeAnimation.FinishedSignal().Disconnect( this, &BeatControl::OnFadeAnimationFinished ); + OnFadeAnimationFinished(mFadeAnimation); + } + + mFadeAnimation = CreateTransition( mFadeTransition ); + mFadeAnimation.FinishedSignal().Connect( this, &BeatControl::OnFadeAnimationFinished ); + mFadeAnimation.Play(); + mAnimationPlaying |= FADE_ANIMATION_RUNNING; +} + +void BeatControl::OnBounceAnimationFinished( Animation& src ) +{ + mAnimationPlaying &= ~BOUNCE_ANIMATION_RUNNING; +} +void BeatControl::OnXAnimationFinished( Animation& src ) +{ + mAnimationPlaying &= ~X_ANIMATION_RUNNING; +} +void BeatControl::OnYAnimationFinished( Animation& src ) +{ + mAnimationPlaying &= ~Y_ANIMATION_RUNNING; +} +void BeatControl::OnFadeAnimationFinished( Animation& src ) +{ + mAnimationPlaying &= ~FADE_ANIMATION_RUNNING; +} + +void BeatControl::OnInitialize() +{ + Actor self = Self(); +} + +void BeatControl::OnStageConnection( int depth ) +{ + Control::OnStageConnection( depth ); +} + +void BeatControl::OnStageDisconnection() +{ + Control::OnStageDisconnection(); +} + +void BeatControl::OnSizeSet( const Vector3& targetSize ) +{ + Control::OnSizeSet( targetSize ); + RelayoutVisuals( Vector2( targetSize ) ); +} + +void BeatControl::OnRelayout( const Vector2& targetSize, RelayoutContainer& container ) +{ + RelayoutVisuals( targetSize ); +} + +void BeatControl::RelayoutVisuals( const Vector2& targetSize ) +{ + if( mVisual ) + { + if( (mAnimationPlaying & (X_ANIMATION_RUNNING | Y_ANIMATION_RUNNING)) == 0) + { + Vector2 size( targetSize ); + Property::Map transformMap; + // Make the visual half the size of the control, but leave + // origin and anchor point at center, position is relative, but Zer0 + transformMap[ DevelVisual::Transform::Property::SIZE ] = mTransformSize; + mVisual.SetTransformAndSize( transformMap, size ); + } + } +} + +Vector3 BeatControl::GetNaturalSize() +{ + if( mVisual ) + { + Vector2 naturalSize; + mVisual.GetNaturalSize(naturalSize); + return Vector3(naturalSize); + } + return Vector3::ZERO; +} + +void BeatControl::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change ) +{ + // Chain up. + Control::OnStyleChange( styleManager, change ); +} + + +/////////////////////////////////////////////////////////// +// +// Properties +// + +void BeatControl::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value ) +{ + Demo::BeatControl beatControl = Demo::BeatControl::DownCast( Dali::BaseHandle( object ) ); + + if( beatControl ) + { + BeatControl& impl = GetImpl( beatControl ); + Actor self = impl.Self(); + switch ( index ) + { + case Demo::BeatControl::Property::BEAT_VISUAL: + { + bool sizeOnly = false; + + // Determine if a transform.size property exists in the map, and + // save it. + Property::Map* map = value.GetMap(); + if( map ) + { + Property::Value* value = map->Find( DevelVisual::Property::TRANSFORM, "transform" ); + if( value ) + { + Property::Map* transformMap = value->GetMap(); + if( transformMap ) + { + Property::Value* sizeValue = transformMap->Find( DevelVisual::Transform::Property::SIZE, "size" ); + if( sizeValue ) + { + sizeValue->Get( impl.mTransformSize ); + if( map->Count() == 1 && transformMap->Count() == 1 ) + { + sizeOnly = true; + } + } + } + } + if( ! sizeOnly ) + { + // Only register a visual if there is more than just a size setting + impl.mVisual = Toolkit::VisualFactory::Get().CreateVisual( *map ); + impl.RegisterVisual( Demo::BeatControl::Property::BEAT_VISUAL, impl.mVisual ); + + // We have registered a new visual: must trigger size negotiation + // in order to call SetTransformAndSize on the visual with the right size: + impl.RelayoutRequest(); + } + } + break; + } + case Demo::BeatControl::Property::BOUNCE_TRANSITION: + { + impl.mBounceTransition = ConvertPropertyToTransition( value ); + break; + } + case Demo::BeatControl::Property::LEFT_TRANSITION: + { + impl.mLeftTransition = ConvertPropertyToTransition( value ); + break; + } + case Demo::BeatControl::Property::UP_TRANSITION: + { + impl.mUpTransition = ConvertPropertyToTransition( value ); + break; + } + case Demo::BeatControl::Property::FADE_TRANSITION: + { + impl.mFadeTransition = ConvertPropertyToTransition( value ); + break; + } + } + } +} + +Property::Value BeatControl::GetProperty( BaseObject* object, Property::Index propertyIndex ) +{ + Property::Value value; + + Demo::BeatControl beatControl = Demo::BeatControl::DownCast( Dali::BaseHandle( object ) ); + + if ( beatControl ) + { + BeatControl& impl = GetImpl( beatControl ); + switch ( propertyIndex ) + { + case Demo::BeatControl::Property::BEAT_VISUAL: + { + if( impl.mVisual ) + { + Property::Map map; + impl.mVisual.CreatePropertyMap(map); + value = map; + } + break; + } + case Demo::BeatControl::Property::BOUNCE_TRANSITION: + case Demo::BeatControl::Property::LEFT_TRANSITION: + case Demo::BeatControl::Property::UP_TRANSITION: + case Demo::BeatControl::Property::FADE_TRANSITION: + default: + break; + } + } + + return value; +} + + +} // Internal +} // Demo diff --git a/examples/visual-transitions/beat-control-impl.h b/examples/visual-transitions/beat-control-impl.h new file mode 100644 index 0000000..7138a8e --- /dev/null +++ b/examples/visual-transitions/beat-control-impl.h @@ -0,0 +1,152 @@ +#ifndef DALI_DEMO_INTERNAL_BEAT_CONTROL_IMPL_H +#define DALI_DEMO_INTERNAL_BEAT_CONTROL_IMPL_H + +/* + * 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 "beat-control.h" +#include +#include +#include +#include + +namespace Demo +{ + +namespace Internal // To use TypeRegistry, handle and body classes need the same name +{ + +class BeatControl : public Dali::Toolkit::Internal::Control +{ +public: + /** + * Instantiate a new BeatControl object + */ + static Demo::BeatControl New(); + BeatControl(); + ~BeatControl(); + +public: // API + void StartBounceAnimation(); + + void StartXAnimation(); + + void StartYAnimation(); + + void StartFadeAnimation(); + +public: // Properties + /** + * 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 ); + + /** + * 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(); + + /** + * @copydoc Toolkit::Control::OnStageConnect() + */ + virtual void OnStageConnection( int depth ); + + /** + * @copydoc Toolkit::Control::OnStageDisconnection() + */ + virtual void OnStageDisconnection(); + + /** + * @copydoc Toolkit::Control::OnSizeSet() + */ + virtual void OnSizeSet( const Dali::Vector3& targetSize ); + + /** + * @copydoc Toolkit::Control::OnRelayout() + */ + virtual void OnRelayout( const Dali::Vector2& targetSize, Dali::RelayoutContainer& container ); + /** + * @copydoc Toolkit::Control::GetNaturalSize + */ + virtual Dali::Vector3 GetNaturalSize(); + + /** + * @copydoc Toolkit::Control::OnStyleChange + */ + virtual void OnStyleChange( Dali::Toolkit::StyleManager styleManager, Dali::StyleChange::Type change ); + +private: + void OnBounceAnimationFinished( Dali::Animation& handle ); + void OnXAnimationFinished( Dali::Animation& src ); + void OnYAnimationFinished( Dali::Animation& src ); + void OnFadeAnimationFinished( Dali::Animation& src ); + + /** + * Relayout the visuals as a result of size negotiation + */ + void RelayoutVisuals( const Dali::Vector2& targetSize ); + +private: + //undefined + BeatControl( const BeatControl& ); + BeatControl& operator=( const BeatControl& ); + +private: + // Implementation details + Dali::Toolkit::Visual::Base mVisual; + Dali::Toolkit::TransitionData mBounceTransition; + Dali::Toolkit::TransitionData mLeftTransition; + Dali::Toolkit::TransitionData mUpTransition; + Dali::Toolkit::TransitionData mFadeTransition; + Dali::Animation mAnimation; + Dali::Animation mXAnimation; + Dali::Animation mYAnimation; + Dali::Animation mFadeAnimation; + Dali::Vector2 mTransformSize; + int mAnimationPlaying; +}; + +} // Internal + +inline Internal::BeatControl& GetImpl( Demo::BeatControl& handle ) +{ + DALI_ASSERT_ALWAYS( handle ); + Dali::RefObject& object = handle.GetImplementation(); + return static_cast(object); +} + +inline const Internal::BeatControl& GetImpl( const Demo::BeatControl& handle ) +{ + DALI_ASSERT_ALWAYS( handle ); + const Dali::RefObject& object = handle.GetImplementation(); + return static_cast(object); +} + +} // Demo + +#endif // DALI_DEMO_BEAT_CONTROL_IMPL_H diff --git a/examples/visual-transitions/beat-control.cpp b/examples/visual-transitions/beat-control.cpp new file mode 100644 index 0000000..2dc16fd --- /dev/null +++ b/examples/visual-transitions/beat-control.cpp @@ -0,0 +1,92 @@ +/* + * 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 "beat-control.h" +#include "beat-control-impl.h" + +namespace Demo +{ + +BeatControl::BeatControl() +{ +} + +BeatControl::BeatControl( const BeatControl& beatControl ) +: Control( beatControl ) +{ +} + +BeatControl& BeatControl::operator= ( const BeatControl& rhs ) +{ + if( &rhs != this ) + { + Control::operator=( rhs ); + } + return *this; +} + +BeatControl::~BeatControl() +{ +} + +BeatControl BeatControl::New() +{ + BeatControl beatControl = Internal::BeatControl::New(); + return beatControl; +} + +BeatControl BeatControl::New( const std::string& url ) +{ + BeatControl beatControl = Internal::BeatControl::New(); + return beatControl; +} + +BeatControl BeatControl::DownCast( BaseHandle handle ) +{ + return Control::DownCast< BeatControl, Internal::BeatControl > ( handle ); +} + +void BeatControl::StartBounceAnimation() +{ + GetImpl(*this).StartBounceAnimation(); +} + +void BeatControl::StartXAnimation() +{ + GetImpl(*this).StartXAnimation(); +} +void BeatControl::StartYAnimation() +{ + GetImpl(*this).StartYAnimation(); +} +void BeatControl::StartFadeAnimation() +{ + GetImpl(*this).StartFadeAnimation(); +} + +BeatControl::BeatControl( Internal::BeatControl& implementation ) +: Control( implementation ) +{ +} + +BeatControl::BeatControl( Dali::Internal::CustomActor* internal ) +: Control( internal ) +{ + VerifyCustomActorPointer< Internal::BeatControl >( internal ) ; +} + + +} //namespace Demo diff --git a/examples/visual-transitions/beat-control.h b/examples/visual-transitions/beat-control.h new file mode 100644 index 0000000..f0e6e00 --- /dev/null +++ b/examples/visual-transitions/beat-control.h @@ -0,0 +1,124 @@ +#ifndef DALI_DEMO_BEAT_CONTROL_H +#define DALI_DEMO_BEAT_CONTROL_H + +/* + * 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 + +namespace Demo +{ + +namespace Internal +{ +// All type registered types need to have the same name for the body and the handle +class BeatControl; +} + +/** + * Control that allows the RGB channels of an image to be altered. + */ +class BeatControl : public Dali::Toolkit::Control +{ +public: + /** + * The start and end property ranges for this control + */ + 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 + { + BOUNCE_TRANSITION = PROPERTY_START_INDEX, + LEFT_TRANSITION, + UP_TRANSITION, + FADE_TRANSITION, + BEAT_VISUAL + }; + }; + +public: // Construction / destruction + + /** + * Create an uninitialized handle + */ + BeatControl(); + + /** + * Create a new image channel control without an image. Use + * SetImage to give this control an image + */ + static BeatControl New(); + + /** + * Create a new image channel control from a given URL + */ + static BeatControl New( const std::string& url ); + + /** + * Destructor. This is non-virtual since derived Handle types must not + * contain data or virtual methods + */ + ~BeatControl(); + + /** + * Copy Constructor + */ + BeatControl( const BeatControl& beatControl ); + + /** + * Assignment Operator + */ + BeatControl& operator=( const BeatControl& beatControl ); + + /** + * Downcast + */ + static BeatControl DownCast( BaseHandle handle ); + +public: // API + + void StartBounceAnimation(); + + void StartXAnimation(); + + void StartYAnimation(); + + void StartFadeAnimation(); + +public: // Not for public use + /** + * Create a handle from an implementation + */ + BeatControl( Internal::BeatControl& implementation ); + + /** + * Allow the creation of an BeatControl handle from an internal CustomActor pointer + */ + BeatControl( Dali::Internal::CustomActor* internal ); +}; + +} // namespace Demo + +#endif // DALI_DEMO_BEAT_CONTROL_H diff --git a/examples/visual-transitions/transition-application.cpp b/examples/visual-transitions/transition-application.cpp new file mode 100644 index 0000000..32c4188 --- /dev/null +++ b/examples/visual-transitions/transition-application.cpp @@ -0,0 +1,342 @@ +/* + * 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. + */ + +/** + * @file transition-application.cpp + * @brief Application class for showing stylable transitions + */ + +// Class include +#include "transition-application.h" + +// External includes +#include +#include +#include +#include "beat-control.h" +#include +#include + +// Internal includes + +using namespace Dali; +using namespace Dali::Toolkit; + +namespace Demo +{ + +const char* TransitionApplication::DEMO_THEME_ONE_PATH( DEMO_STYLE_DIR "style-example-theme-one.json" ); +const char* DALI_LOGO_PATH( DEMO_IMAGE_DIR "Logo-for-demo.png" ); +const char* DALI_ROBOT_MODEL_PATH( DEMO_MODEL_DIR "ToyRobot-Metal.obj" ); +const char* DALI_ROBOT_MATERIAL_PATH( DEMO_MODEL_DIR "ToyRobot-Metal.mtl" ); + + +TransitionApplication::TransitionApplication( Application& application ) +: mApplication( application ), + mTitle(), + mBeatControl(), + mActionButtons(), + mActionIndex( Property::INVALID_INDEX ) +{ + application.InitSignal().Connect( this, &TransitionApplication::Create ); +} + +TransitionApplication::~TransitionApplication() +{ +} + +void TransitionApplication::Create( Application& application ) +{ + Stage stage = Stage::GetCurrent(); + stage.KeyEventSignal().Connect(this, &TransitionApplication::OnKeyEvent); + stage.SetBackgroundColor( Vector4( 0.1f, 0.1f, 0.1f, 1.0f ) ); + + // Hide the indicator bar + application.GetWindow().ShowIndicator( Dali::Window::INVISIBLE ); + + // Content panes: + TableView contentLayout = TableView::New( 4, 1 ); + contentLayout.SetName("ContentLayout"); + contentLayout.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); + contentLayout.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + contentLayout.SetParentOrigin( ParentOrigin::TOP_LEFT ); + contentLayout.SetCellPadding( Vector2( 0.0f, 5.0f ) ); + + // Assign all rows the size negotiation property of fitting to children + + stage.Add( contentLayout ); + + mTitle = TextLabel::New( "Custom Control Transition Example" ); + mTitle.SetName( "Title" ); + mTitle.SetStyleName("Title"); + mTitle.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); + mTitle.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT ); + mTitle.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); + contentLayout.Add( mTitle ); + contentLayout.SetFitHeight(0); // Fill width + + mBeatControl = BeatControl::New(); + mBeatControl.SetName("BeatControl"); + mBeatControl.SetProperty( BeatControl::Property::BEAT_VISUAL, Property::Map() + .Add( DevelVisual::Property::TRANSFORM, Property::Map() + .Add( DevelVisual::Transform::Property::SIZE, Vector2(0.5f, 0.5f) ) ) ); + + mBeatControl.SetAnchorPoint( AnchorPoint::CENTER ); + mBeatControl.SetParentOrigin( ParentOrigin::CENTER ); + mBeatControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); + contentLayout.Add( mBeatControl ); + // beat control should fill the tableview cell, so no change to default parameters + + TableView visualTypeLayout = TableView::New( 1, NUMBER_OF_VISUAL_BUTTONS ); + visualTypeLayout.SetName("VisualTypeLayout"); + visualTypeLayout.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); + visualTypeLayout.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::HEIGHT ); + visualTypeLayout.SetFitHeight( 0 ); + + contentLayout.Add( visualTypeLayout ); + contentLayout.SetFitHeight(2); + + for( int i=0; i( mVisualIndex ); + Property::Map map; + CreateVisualMap( visual, map ); + map.Add( DevelVisual::Property::TRANSFORM, Property::Map() + .Add( DevelVisual::Transform::Property::SIZE, Vector2( 0.5f, 0.5f ) ) ); + mBeatControl.SetProperty( BeatControl::Property::BEAT_VISUAL, map ); + } + return true; +} + +bool TransitionApplication::OnActionButtonClicked( Button button ) +{ + int action = button.GetProperty( mActionIndex ); + switch( action ) + { + case 0: + { + mBeatControl.StartBounceAnimation(); + break; + } + case 1: + { + mBeatControl.StartXAnimation(); + break; + } + case 2: + { + mBeatControl.StartYAnimation(); + break; + } + case 3: + { + mBeatControl.StartFadeAnimation(); + break; + } + } + + return true; +} + +void TransitionApplication::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; + } +} + +} // namespace Demo diff --git a/examples/visual-transitions/transition-application.h b/examples/visual-transitions/transition-application.h new file mode 100644 index 0000000..9846c11 --- /dev/null +++ b/examples/visual-transitions/transition-application.h @@ -0,0 +1,85 @@ +#ifndef DALI_DEMO_TRANSITION_APPLICATION_H +#define DALI_DEMO_TRANSITION_APPLICATION_H + +/* + * 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. + */ + +// External includes +#include +//#include +#include +#include "beat-control.h" +#include +#include + +// Internal includes + +using namespace Dali; +using namespace Dali::Toolkit; + +namespace Demo +{ + +class TransitionApplication : public ConnectionTracker +{ +public: + static const int NUMBER_OF_ACTION_BUTTONS=4; + static const int NUMBER_OF_VISUAL_BUTTONS=10; + +public: + // Constructor + TransitionApplication( Application& application ); + + // Destructor + ~TransitionApplication(); + + // Init signal handler + void Create( Application& application ); + + // Create the GUI components + Toolkit::TextLabel CreateTitle( std::string title ); + Actor CreateContentPane(); + + // Key event handler + void OnKeyEvent( const KeyEvent& event ); + + bool OnActionButtonClicked( Button button ); + bool OnVisualButtonClicked( Actor actor, const TouchData& touchData ); + + static const char* DEMO_THEME_ONE_PATH; + +private: + + /** Create a visual map + * + * @param[in] index The index of the visual to create + * @param[out] map The map to generate + */ + void CreateVisualMap( int index, Property::Map& map ); + + Application& mApplication; + TextLabel mTitle; + BeatControl mBeatControl; + PushButton mActionButtons[NUMBER_OF_ACTION_BUTTONS]; + BeatControl mVisualButtons[NUMBER_OF_VISUAL_BUTTONS]; + Property::Index mVisualIndex; + Property::Index mActionIndex; +}; + +} // Namespace Demo + + +#endif // DALI_DEMO_TRANSITION_APPLICATION_H diff --git a/examples/visual-transitions/transition-example.cpp b/examples/visual-transitions/transition-example.cpp new file mode 100644 index 0000000..adc4563 --- /dev/null +++ b/examples/visual-transitions/transition-example.cpp @@ -0,0 +1,38 @@ +/* + * 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. + */ + +/** + * @file transition-example.cpp + * @brief Example of stylable transitions. + */ + +// External includes +#include + +// Internal includes +#include "transition-application.h" + + +/// Entry point for applications +int DALI_EXPORT_API main( int argc, char** argv ) +{ + const char* themeName = Demo::TransitionApplication::DEMO_THEME_ONE_PATH; + + Application application = Application::New( &argc, &argv, themeName ); + Demo::TransitionApplication transitionApplication( application ); + application.MainLoop(); + return 0; +} diff --git a/packaging/com.samsung.dali-demo.spec b/packaging/com.samsung.dali-demo.spec index 88d02d1..8da33a6 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.27 +Version: 1.2.28 Release: 1 Group: System/Libraries License: Apache-2.0 diff --git a/resources/style/mobile/style-example-theme-one.json.in b/resources/style/mobile/style-example-theme-one.json.in index 6d6c7d8..53bbcde 100644 --- a/resources/style/mobile/style-example-theme-one.json.in +++ b/resources/style/mobile/style-example-theme-one.json.in @@ -73,9 +73,9 @@ [ { "target":"imageVisual", - "property":"mixColor", - "initialValue":[1,1,1,0], - "targetValue":[1,1,1,1], + "property":"opacity", + "initialValue":0, + "targetValue":1, "animator": { "alphaFunction":"EASE_IN_OUT", @@ -96,8 +96,8 @@ [ { "target":"imageVisual", - "property":"mixColor", - "targetValue":[1,1,1,0], + "property":"opacity", + "targetValue":0, "animator": { "alphaFunction":"EASE_IN_OUT", @@ -117,262 +117,306 @@ }, "ShadowButton": { - "backgroundVisual":{ - "visualType":"IMAGE", - "url":"{STYLE_DIR}/images/shadowButtonBg.9.png", - "mixColor":[1,1,1,0] - }, - "checkboxBgVisual":{ - "visualType":"IMAGE", - "url":"{STYLE_DIR}/images/CheckBg.png", - "transform":{ - "size":[0.09, 0.28], - "offset":[30,0], - "offsetSizeMode":[1,1,0,0], - "origin":"CENTER_BEGIN", - "anchorPoint":"CENTER_BEGIN" - } - }, - "checkboxFgVisual":{ - "visualType":"IMAGE", - "url":"{STYLE_DIR}/images/Tick.png", - "transform":{ - "size":[0.09, 0.28], - "offset":[30,0], - "offsetSizeMode":[1,1,0,0], - "origin":"CENTER_BEGIN", - "anchorPoint":"CENTER_BEGIN" - } - }, - "labelVisual":{ - "visualType":"TEXT", - "text":"Don't show again", - "pointSize":8, - "horizontalAlignment":"END", - "verticalAlignment":"CENTER", - "textColor":[1,1,1,1], - "mixColor":[0.3, 0.3, 0.3, 1], - "transform":{ - "size":[0.9, 0.9], - "offset":[-30,0], - "offsetSizeMode":[1,1,0,0], - "origin":"CENTER_END", - "anchorPoint":"CENTER_END" - } - }, - "activeTransition": - [ + "states": + { + "NORMAL": { - "target":"checkboxBgVisual", - "property":"size", - "initialValue":[0.09, 0.28], - "targetValue":[0.12, 0.37], - "animator": + "visuals": { - "alphaFunction":"EASE_OUT_BACK", - "timePeriod": - { - "duration":0.8, - "delay":0 + "backgroundVisual":{ + "visualType":"IMAGE", + "url":"{STYLE_DIR}/images/shadowButtonBg.9.png" + }, + + "checkboxBgVisual":{ + "visualType":"IMAGE", + "url":"{STYLE_DIR}/images/CheckBg.png", + "transform":{ + "size":[0.09, 0.28], + "offset":[30,0], + "offsetSizeMode":[1,1,0,0], + "origin":"CENTER_BEGIN", + "anchorPoint":"CENTER_BEGIN" + } + }, + + "labelVisual":{ + "visualType":"TEXT", + "text":"Don't show again", + "pointSize":8, + "horizontalAlignment":"END", + "verticalAlignment":"CENTER", + "textColor":[1,1,1,1], + "mixColor":[0, 0, 0, 1], + "transform":{ + "size":[0.9, 0.9], + "offset":[-30,0], + "offsetSizeMode":[1,1,0,0], + "origin":"CENTER_END", + "anchorPoint":"CENTER_END" + } } - } - }, - { - "target":"backgroundVisual", - "property":"mixColor", - "initialValue":[1,1,1,0], - "targetValue":[1,1,1,1], - "animator": + }, + + "states": { - "alphaFunction":"EASE_OUT_BACK", - "timePeriod": + "CHECKED": { - "duration":0.8, - "delay":0 - } - } - }, - { - "target":"backgroundVisual", - "property":"size", - "initialValue":[0.9, 0.9], - "targetValue":[1, 1], - "animator": - { - "alphaFunction":"EASE_OUT_BACK", - "timePeriod": - { - "duration":0.8, - "delay":0 - } - } - }, - { - "target":"checkboxFgVisual", - "property":"size", - "initialValue":[0.09, 0.28], - "targetValue":[0.12, 0.37], - "animator": - { - "alphaFunction":"EASE_OUT_BACK", - "timePeriod": + "visuals": + { + "checkboxFgVisual":{ + "visualType":"IMAGE", + "url":"{STYLE_DIR}/images/Tick.png", + "transform":{ + "size":[0.09, 0.28], + "offset":[30,0], + "offsetSizeMode":[1,1,0,0], + "origin":"CENTER_BEGIN", + "anchorPoint":"CENTER_BEGIN" + } + } + }, + "entryTransition": + [ + { + "target":"checkboxFgVisual", + "property":"pixelArea", + "initialValue":[0.0, 0.0, 0.0, 1.0], + "targetValue":[0.0, 0.0, 1.0, 1.0], + "animator": + { + "alphaFunction":"EASE_IN", + "timePeriod": + { + "duration":0.4, + "delay":0 + } + } + }, + { + "target":"checkboxFgVisual", + "property":"size", + "initialValue":[0.0, 0.37], + "targetValue":[0.12, 0.37], + "animator": + { + "alphaFunction":"EASE_IN", + "timePeriod": + { + "duration":0.4, + "delay":0 + } + } + } + ], + "exitTransition": + [ + { + "target":"checkboxFgVisual", + "property":"pixelArea", + "initialValue":[0.0, 0.0, 1.0, 1.0], + "targetValue":[0.0, 0.0, 0.0, 1.0], + "animator": + { + "alphaFunction":"EASE_OUT", + "timePeriod": + { + "duration":0.4, + "delay":0 + } + } + }, + { + "target":"checkboxFgVisual", + "property":"size", + "targetValue":[0.0, 0.37], + "animator": + { + "alphaFunction":"EASE_OUT", + "timePeriod": + { + "duration":0.4, + "delay":0 + } + } + } + ] + }, + "UNCHECKED": { - "duration":0.8, - "delay":0 } } }, + //"FOCUSED" + "DISABLED": { - "target":"labelVisual", - "property":"mixColor", - "initialValue":[0.2, 0.2, 0.2, 1.0], - "targetValue":[0, 0, 0, 1], - "animator": + "visuals": { - "alphaFunction":"EASE_OUT_BACK", - "timePeriod": - { - "duration":0.8, - "delay":0 + "checkboxBgVisual":{ + "visualType":"IMAGE", + "url":"{STYLE_DIR}/images/CheckBg.png", + "transform":{ + "size":[0.09, 0.28], + "offset":[30,0], + "offsetSizeMode":[1,1,0,0], + "origin":"CENTER_BEGIN", + "anchorPoint":"CENTER_BEGIN" + } + }, + + "checkboxFgVisual":{ + "visualType":"IMAGE", + "url":"{STYLE_DIR}/images/Tick.png", + "transform":{ + "size":[0.09, 0.28], + "offset":[30,0], + "offsetSizeMode":[1,1,0,0], + "origin":"CENTER_BEGIN", + "anchorPoint":"CENTER_BEGIN" + } + }, + + "labelVisual":{ + "visualType":"TEXT", + "text":"Don't show again", + "pointSize":8, + "horizontalAlignment":"END", + "verticalAlignment":"CENTER", + "textColor":[1,1,1,1], + "mixColor":[0.3, 0.3, 0.3, 1], + "transform":{ + "size":[0.9, 0.9], + "offset":[-30,0], + "offsetSizeMode":[1,1,0,0], + "origin":"CENTER_END", + "anchorPoint":"CENTER_END" + } } } } - ], - "inactiveTransition": + }, + "transitions": [ { - "target":"checkboxBgVisual", - "property":"size", - "initialValue":[0.12, 0.37], - "targetValue":[0.09, 0.28], + "from":"DISABLED", + "to":"NORMAL", + "visualName":"backgroundVisual", + "effect":"FADE_IN", "animator": { "alphaFunction":"EASE_OUT_BACK", - "timePeriod": - { - "duration":0.8, - "delay":0 - } + "duration":0.8 } }, { - "target":"backgroundVisual", - "property":"mixColor", - "targetValue":[1,1,1,0], + "from":"DISABLED", + "to":"NORMAL", + "visualName":"*", "animator": { "alphaFunction":"EASE_OUT_BACK", - "timePeriod": - { - "duration":0.8, - "delay":0 - } + "duration":0.8 } }, { - "target":"checkboxFgVisual", - "property":"size", - "initialValue":[0.12, 0.37], - "targetValue":[0.09, 0.28], + "from":"NORMAL", + "to":"DISABLED", + "visualName":"backgroundVisual", + "effect":"FADE_OUT", "animator": { "alphaFunction":"EASE_OUT_BACK", - "timePeriod": - { - "duration":0.8, - "delay":0 - } + "duration":0.8 } }, { - "target":"labelVisual", - "property":"mixColor", - "targetValue":[0.4, 0.4, 0.4, 1.0], + "from":"NORMAL", + "to":"DISABLED", + "visualName":"*", "animator": { "alphaFunction":"EASE_OUT_BACK", - "timePeriod": - { - "duration":0.8, - "delay":0 - } + "duration":0.8 } - }, + } + ] + }, + "BeatControl": + { + "beatVisual":{ + "visualType":"IMAGE", + "url":"{APPLICATION_RESOURCE_PATH}/images/Logo-for-demo.png" + }, + + "bounceTransition": + [ { - "target":"backgroundVisual", + "target":"beatVisual", "property":"size", - "targetValue":[0.9, 0.9], + "initialValue":[0.5, 0.5], + "targetValue":[0.75, 0.75], "animator": { - "alphaFunction":"EASE_OUT_BACK", + "alphaFunction":"BOUNCE", "timePeriod": { - "duration":0.8, + "duration":0.5, "delay":0 } } } ], - "checkTransition": + + "leftTransition": [ { - "target":"checkboxFgVisual", - "property":"pixelArea", - "initialValue":[0.0, 0.0, 0.0, 1.0], - "targetValue":[0.0, 0.0, 1.0, 1.0], - "animator": - { - "alphaFunction":"EASE_IN", - "timePeriod": - { - "duration":0.4, - "delay":0 - } - } - }, - { - "target":"checkboxFgVisual", - "property":"size", - "initialValue":[0.0, 0.37], - "targetValue":[0.12, 0.37], + "target":"beatVisual", + "property":"offset", + "initialValue":[0, 0], + "targetValue":[0.25, 0], "animator": { - "alphaFunction":"EASE_IN", + "alphaFunction":"BOUNCE", "timePeriod": { - "duration":0.4, + "duration":0.5, "delay":0 } } } ], - "uncheckTransition": + + "upTransition": [ { - "target":"checkboxFgVisual", - "property":"pixelArea", - "initialValue":[0.0, 0.0, 1.0, 1.0], - "targetValue":[0.0, 0.0, 0.0, 1.0], + "target":"beatVisual", + "property":"offset", + "initialValue":[0, 0], + "targetValue":[0, 0.25], "animator": { - "alphaFunction":"EASE_OUT", + "alphaFunction":"BOUNCE", "timePeriod": { - "duration":0.4, + "duration":0.5, "delay":0 } } - }, + } + ], + + "fadeTransition": + [ { - "target":"checkboxFgVisual", - "property":"size", - "targetValue":[0.0, 0.37], + "target":"beatVisual", + "property":"opacity", + "targetValue":0, "animator": { - "alphaFunction":"EASE_OUT", + "alphaFunction":"BOUNCE", "timePeriod": { - "duration":0.4, + "duration":0.8, "delay":0 } } diff --git a/resources/style/style-example-theme-one.json.in b/resources/style/style-example-theme-one.json.in index a28f842..d495a3d 100644 --- a/resources/style/style-example-theme-one.json.in +++ b/resources/style/style-example-theme-one.json.in @@ -73,9 +73,9 @@ [ { "target":"imageVisual", - "property":"mixColor", - "initialValue":[1,1,1,0], - "targetValue":[1,1,1,1], + "property":"opacity", + "initialValue":0, + "targetValue":1, "animator": { "alphaFunction":"EASE_IN_OUT", @@ -96,8 +96,8 @@ [ { "target":"imageVisual", - "property":"mixColor", - "targetValue":[1,1,1,0], + "property":"opacity", + "targetValue":0, "animator": { "alphaFunction":"EASE_IN_OUT", @@ -117,262 +117,306 @@ }, "ShadowButton": { - "backgroundVisual":{ - "visualType":"IMAGE", - "url":"{STYLE_DIR}/images/shadowButtonBg.9.png", - "mixColor":[1,1,1,0] - }, - "checkboxBgVisual":{ - "visualType":"IMAGE", - "url":"{STYLE_DIR}/images/CheckBg.png", - "transform":{ - "size":[0.09, 0.28], - "offset":[30,0], - "offsetSizeMode":[1,1,0,0], - "origin":"CENTER_BEGIN", - "anchorPoint":"CENTER_BEGIN" - } - }, - "checkboxFgVisual":{ - "visualType":"IMAGE", - "url":"{STYLE_DIR}/images/Tick.png", - "transform":{ - "size":[0.09, 0.28], - "offset":[30,0], - "offsetSizeMode":[1,1,0,0], - "origin":"CENTER_BEGIN", - "anchorPoint":"CENTER_BEGIN" - } - }, - "labelVisual":{ - "visualType":"TEXT", - "text":"Don't show again", - "pointSize":20, - "horizontalAlignment":"END", - "verticalAlignment":"CENTER", - "textColor":[1,1,1,1], - "mixColor":[0.3, 0.3, 0.3, 1], - "transform":{ - "size":[0.9, 0.9], - "offset":[-30,0], - "offsetSizeMode":[1,1,0,0], - "origin":"CENTER_END", - "anchorPoint":"CENTER_END" - } - }, - "activeTransition": - [ + "states": + { + "NORMAL": { - "target":"checkboxBgVisual", - "property":"size", - "initialValue":[0.09, 0.28], - "targetValue":[0.12, 0.37], - "animator": + "visuals": { - "alphaFunction":"EASE_OUT_BACK", - "timePeriod": - { - "duration":0.8, - "delay":0 + "backgroundVisual":{ + "visualType":"IMAGE", + "url":"{STYLE_DIR}/images/shadowButtonBg.9.png" + }, + + "checkboxBgVisual":{ + "visualType":"IMAGE", + "url":"{STYLE_DIR}/images/CheckBg.png", + "transform":{ + "size":[0.09, 0.28], + "offset":[30,0], + "offsetSizeMode":[1,1,0,0], + "origin":"CENTER_BEGIN", + "anchorPoint":"CENTER_BEGIN" + } + }, + + "labelVisual":{ + "visualType":"TEXT", + "text":"Don't show again", + "pointSize":20, + "horizontalAlignment":"END", + "verticalAlignment":"CENTER", + "textColor":[1,1,1,1], + "mixColor":[0, 0, 0, 1], + "transform":{ + "size":[0.9, 0.9], + "offset":[-30,0], + "offsetSizeMode":[1,1,0,0], + "origin":"CENTER_END", + "anchorPoint":"CENTER_END" + } } - } - }, - { - "target":"backgroundVisual", - "property":"mixColor", - "initialValue":[1,1,1,0], - "targetValue":[1,1,1,1], - "animator": + }, + + "states": { - "alphaFunction":"EASE_OUT_BACK", - "timePeriod": + "CHECKED": { - "duration":0.8, - "delay":0 - } - } - }, - { - "target":"backgroundVisual", - "property":"size", - "initialValue":[0.9, 0.9], - "targetValue":[1, 1], - "animator": - { - "alphaFunction":"EASE_OUT_BACK", - "timePeriod": - { - "duration":0.8, - "delay":0 - } - } - }, - { - "target":"checkboxFgVisual", - "property":"size", - "initialValue":[0.09, 0.28], - "targetValue":[0.12, 0.37], - "animator": - { - "alphaFunction":"EASE_OUT_BACK", - "timePeriod": + "visuals": + { + "checkboxFgVisual":{ + "visualType":"IMAGE", + "url":"{STYLE_DIR}/images/Tick.png", + "transform":{ + "size":[0.09, 0.28], + "offset":[30,0], + "offsetSizeMode":[1,1,0,0], + "origin":"CENTER_BEGIN", + "anchorPoint":"CENTER_BEGIN" + } + } + }, + "entryTransition": + [ + { + "target":"checkboxFgVisual", + "property":"pixelArea", + "initialValue":[0.0, 0.0, 0.0, 1.0], + "targetValue":[0.0, 0.0, 1.0, 1.0], + "animator": + { + "alphaFunction":"EASE_IN", + "timePeriod": + { + "duration":0.4, + "delay":0 + } + } + }, + { + "target":"checkboxFgVisual", + "property":"size", + "initialValue":[0.0, 0.37], + "targetValue":[0.12, 0.37], + "animator": + { + "alphaFunction":"EASE_IN", + "timePeriod": + { + "duration":0.4, + "delay":0 + } + } + } + ], + "exitTransition": + [ + { + "target":"checkboxFgVisual", + "property":"pixelArea", + "initialValue":[0.0, 0.0, 1.0, 1.0], + "targetValue":[0.0, 0.0, 0.0, 1.0], + "animator": + { + "alphaFunction":"EASE_OUT", + "timePeriod": + { + "duration":0.4, + "delay":0 + } + } + }, + { + "target":"checkboxFgVisual", + "property":"size", + "targetValue":[0.0, 0.37], + "animator": + { + "alphaFunction":"EASE_OUT", + "timePeriod": + { + "duration":0.4, + "delay":0 + } + } + } + ] + }, + "UNCHECKED": { - "duration":0.8, - "delay":0 } } }, + //"FOCUSED" + "DISABLED": { - "target":"labelVisual", - "property":"mixColor", - "initialValue":[0.2, 0.2, 0.2, 1.0], - "targetValue":[0, 0, 0, 1], - "animator": + "visuals": { - "alphaFunction":"EASE_OUT_BACK", - "timePeriod": - { - "duration":0.8, - "delay":0 + "checkboxBgVisual":{ + "visualType":"IMAGE", + "url":"{STYLE_DIR}/images/CheckBg.png", + "transform":{ + "size":[0.09, 0.28], + "offset":[30,0], + "offsetSizeMode":[1,1,0,0], + "origin":"CENTER_BEGIN", + "anchorPoint":"CENTER_BEGIN" + } + }, + + "checkboxFgVisual":{ + "visualType":"IMAGE", + "url":"{STYLE_DIR}/images/Tick.png", + "transform":{ + "size":[0.09, 0.28], + "offset":[30,0], + "offsetSizeMode":[1,1,0,0], + "origin":"CENTER_BEGIN", + "anchorPoint":"CENTER_BEGIN" + } + }, + + "labelVisual":{ + "visualType":"TEXT", + "text":"Don't show again", + "pointSize":20, + "horizontalAlignment":"END", + "verticalAlignment":"CENTER", + "textColor":[1,1,1,1], + "mixColor":[0.3, 0.3, 0.3, 1], + "transform":{ + "size":[0.9, 0.9], + "offset":[-30,0], + "offsetSizeMode":[1,1,0,0], + "origin":"CENTER_END", + "anchorPoint":"CENTER_END" + } } } } - ], - "inactiveTransition": + }, + "transitions": [ { - "target":"checkboxBgVisual", - "property":"size", - "initialValue":[0.12, 0.37], - "targetValue":[0.09, 0.28], + "from":"DISABLED", + "to":"NORMAL", + "visualName":"backgroundVisual", + "effect":"FADE_IN", "animator": { "alphaFunction":"EASE_OUT_BACK", - "timePeriod": - { - "duration":0.8, - "delay":0 - } + "duration":0.8 } }, { - "target":"backgroundVisual", - "property":"mixColor", - "targetValue":[1,1,1,0], + "from":"DISABLED", + "to":"NORMAL", + "visualName":"*", "animator": { "alphaFunction":"EASE_OUT_BACK", - "timePeriod": - { - "duration":0.8, - "delay":0 - } + "duration":0.8 } }, { - "target":"checkboxFgVisual", - "property":"size", - "initialValue":[0.12, 0.37], - "targetValue":[0.09, 0.28], + "from":"NORMAL", + "to":"DISABLED", + "visualName":"backgroundVisual", + "effect":"FADE_OUT", "animator": { "alphaFunction":"EASE_OUT_BACK", - "timePeriod": - { - "duration":0.8, - "delay":0 - } + "duration":0.8 } }, { - "target":"labelVisual", - "property":"mixColor", - "targetValue":[0.4, 0.4, 0.4, 1.0], + "from":"NORMAL", + "to":"DISABLED", + "visualName":"*", "animator": { "alphaFunction":"EASE_OUT_BACK", - "timePeriod": - { - "duration":0.8, - "delay":0 - } + "duration":0.8 } - }, + } + ] + }, + "BeatControl": + { + "beatVisual":{ + "visualType":"IMAGE", + "url":"{APPLICATION_RESOURCE_PATH}/images/Logo-for-demo.png" + }, + + "bounceTransition": + [ { - "target":"backgroundVisual", + "target":"beatVisual", "property":"size", - "targetValue":[0.9, 0.9], + "initialValue":[0.5, 0.5], + "targetValue":[0.75, 0.75], "animator": { - "alphaFunction":"EASE_OUT_BACK", + "alphaFunction":"BOUNCE", "timePeriod": { - "duration":0.8, + "duration":0.5, "delay":0 } } } ], - "checkTransition": + + "leftTransition": [ { - "target":"checkboxFgVisual", - "property":"pixelArea", - "initialValue":[0.0, 0.0, 0.0, 1.0], - "targetValue":[0.0, 0.0, 1.0, 1.0], - "animator": - { - "alphaFunction":"EASE_IN", - "timePeriod": - { - "duration":0.4, - "delay":0 - } - } - }, - { - "target":"checkboxFgVisual", - "property":"size", - "initialValue":[0.0, 0.37], - "targetValue":[0.12, 0.37], + "target":"beatVisual", + "property":"offset", + "initialValue":[0, 0], + "targetValue":[0.25, 0], "animator": { - "alphaFunction":"EASE_IN", + "alphaFunction":"BOUNCE", "timePeriod": { - "duration":0.4, + "duration":0.5, "delay":0 } } } ], - "uncheckTransition": + + "upTransition": [ { - "target":"checkboxFgVisual", - "property":"pixelArea", - "initialValue":[0.0, 0.0, 1.0, 1.0], - "targetValue":[0.0, 0.0, 0.0, 1.0], + "target":"beatVisual", + "property":"offset", + "initialValue":[0, 0], + "targetValue":[0, 0.25], "animator": { - "alphaFunction":"EASE_OUT", + "alphaFunction":"BOUNCE", "timePeriod": { - "duration":0.4, + "duration":0.5, "delay":0 } } - }, + } + ], + + "fadeTransition": + [ { - "target":"checkboxFgVisual", - "property":"size", - "targetValue":[0.0, 0.37], + "target":"beatVisual", + "property":"opacity", + "targetValue":0, "animator": { - "alphaFunction":"EASE_OUT", + "alphaFunction":"BOUNCE", "timePeriod": { - "duration":0.4, + "duration":0.8, "delay":0 } } diff --git a/shared/utility.h b/shared/utility.h index 283ae33..76a814b 100644 --- a/shared/utility.h +++ b/shared/utility.h @@ -36,17 +36,6 @@ Dali::PixelData LoadPixelData( const char* imagePath, return loader.GetPixelData(); } -/** - * @deprecated, dont use this anymore - */ -Dali::Image LoadImage( const char* imagePath, - Dali::ImageDimensions size = Dali::ImageDimensions(), - Dali::FittingMode::Type fittingMode = Dali::FittingMode::DEFAULT, - Dali::SamplingMode::Type samplingMode = Dali::SamplingMode::DEFAULT ) -{ - return Dali::ResourceImage::New( imagePath, size, fittingMode, samplingMode ); -} - Dali::Texture LoadTexture( const char* imagePath, Dali::ImageDimensions size = Dali::ImageDimensions(), Dali::FittingMode::Type fittingMode = Dali::FittingMode::DEFAULT, @@ -62,23 +51,6 @@ Dali::Texture LoadTexture( const char* imagePath, return texture; } -/** - * @brief Load an bitmap resource. - * @deprecated, dont use this anymore - * - * If it is required to scaled-down to no more than the stage dimensions, - * uses image scaling mode FittingMode::SCALE_TO_FILL to resize the image at - * load time to cover the entire stage with pixels with no borders, - * and filter mode BOX_THEN_LINEAR to sample the image with - * maximum quality. - */ - -Dali::Image LoadStageFillingImage( const char* imagePath ) -{ - Dali::Vector2 stageSize = Dali::Stage::GetCurrent().GetSize(); - return LoadImage( imagePath, Dali::ImageDimensions( stageSize.x, stageSize.y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR ); -} - Dali::Texture LoadStageFillingTexture( const char* imagePath ) { Dali::Vector2 stageSize = Dali::Stage::GetCurrent().GetSize();