--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/public-api/text/rendering/basic/text-basic-renderer.h>
+
+// EXTERNAL INCLUDES
+#include <dali/dali.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/text/rendering/shaders/text-basic-shader.h>
+
+using namespace Dali;
+using namespace Dali::Toolkit;
+using namespace Dali::Toolkit::Text;
+
+#define NO_MESH 1
+
+namespace
+{
+
+const std::size_t PADDING = 2; //< To avoid GL filtering artefacts
+
+struct TextureCoordinates
+{
+ TextureCoordinates()
+ : topLeft( 0.0f, 0.0f ),
+ topRight( 1.0f, 0.0f ),
+ bottomLeft( 0.0f, 1.0f ),
+ bottomRight( 1.0f, 1.0f )
+ {
+ }
+
+ Vector2 topLeft;
+ Vector2 topRight;
+ Vector2 bottomLeft;
+ Vector2 bottomRight;
+};
+
+struct AtlasHelperGlyph
+{
+ AtlasHelperGlyph()
+ : fontId( 0 ),
+ index( 0 ),
+ xOffset( 0 ),
+ width( 0 ),
+ height( 0 )
+ {
+ }
+
+ AtlasHelperGlyph( FontId id,
+ GlyphIndex glyphIndex,
+ std::size_t offset,
+ std::size_t widthPixels,
+ std::size_t heightPixels )
+ : fontId( id ),
+ index( glyphIndex ),
+ xOffset( offset ),
+ width( widthPixels ),
+ height( heightPixels )
+ {
+ }
+
+ FontId fontId;
+ GlyphIndex index;
+ std::size_t xOffset;
+ std::size_t width;
+ std::size_t height;
+ TextureCoordinates coords;
+};
+
+struct AtlasHelper
+{
+ AtlasHelper()
+ : mWidth( 0.0f ),
+ mHeight( 0.0f )
+ {
+ mFontClient = TextAbstraction::FontClient::Get();
+ }
+
+ void Reset()
+ {
+ mWidth = 0.0f;
+ mHeight = 0.0f;
+ mGlyphs.clear();
+ }
+
+ void Reserve( std::size_t size )
+ {
+ mGlyphs.reserve( size );
+ }
+
+ bool GlyphFound( FontId fontId, GlyphIndex index ) const
+ {
+ for( unsigned int i=0; i<mGlyphs.size(); ++i )
+ {
+ const AtlasHelperGlyph& glyph = mGlyphs[i];
+
+ if( fontId == glyph.fontId &&
+ index == glyph.index )
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ void AddGlyph( const GlyphInfo& glyphInfo )
+ {
+ mGlyphs.push_back( AtlasHelperGlyph( glyphInfo.fontId, glyphInfo.index, mWidth, glyphInfo.width, glyphInfo.height ) );
+
+ mWidth += glyphInfo.width + PADDING;
+ if( mHeight < glyphInfo.height + PADDING )
+ {
+ mHeight = glyphInfo.height + PADDING;
+ }
+ }
+
+ Atlas CreateAtlas()
+ {
+ Atlas atlas = Atlas::New( mWidth, mHeight, Pixel::L8 );
+
+ for( unsigned int i=0; i<mGlyphs.size(); ++i )
+ {
+ AtlasHelperGlyph& glyph = mGlyphs[i];
+ BitmapImage bitmap = mFontClient.CreateBitmap( glyph.fontId, glyph.index );
+ atlas.Upload( bitmap, glyph.xOffset, 0 );
+
+ TextureCoordinates& coords = glyph.coords;
+ coords.topLeft.x = static_cast<float>(glyph.xOffset) / static_cast<float>(mWidth);
+ coords.topLeft.y = 0.0f;
+ coords.topRight.x = static_cast<float>(glyph.xOffset + glyph.width) / static_cast<float>(mWidth);
+ coords.topRight.y = 0.0f;
+ coords.bottomLeft.x = static_cast<float>(glyph.xOffset) / static_cast<float>(mWidth);
+ coords.bottomLeft.y = static_cast<float>(glyph.height) / static_cast<float>(mHeight);
+ coords.bottomRight.x = static_cast<float>(glyph.xOffset + glyph.width) / static_cast<float>(mWidth);
+ coords.bottomRight.y = static_cast<float>(glyph.height) / static_cast<float>(mHeight);
+ }
+
+ return atlas;
+ }
+
+ void GetTextureCoordinates( FontId fontId, GlyphIndex index, TextureCoordinates& coords )
+ {
+ for( unsigned int i=0; i<mGlyphs.size(); ++i )
+ {
+ const AtlasHelperGlyph& glyph = mGlyphs[i];
+
+ if( fontId == glyph.fontId &&
+ index == glyph.index )
+ {
+ coords = glyph.coords;
+ return;
+ }
+ }
+ }
+
+private: // Data
+
+ std::size_t mWidth;
+ std::size_t mHeight;
+
+ std::vector<AtlasHelperGlyph> mGlyphs;
+
+ TextAbstraction::FontClient mFontClient;
+};
+
+} // unnamed namespace
+
+struct BasicRenderer::Impl
+{
+ /**
+ * @brief Ccreate an Atlas, uploading the necessary glyph bitmaps
+ *
+ * @param[in] glyphs The glyphs to upload.
+ */
+ Atlas CreateAtlas( const Vector<GlyphInfo>& glyphs )
+ {
+ AtlasHelper& helper = mAtlasHelper;
+
+ // Clear previous atlas
+ helper.Reset();
+ helper.Reserve( glyphs.Count() );
+
+ for( unsigned int i=0; i<glyphs.Count(); ++i )
+ {
+ float width = glyphs[i].width;
+ float height = glyphs[i].height;
+
+ if( width > 0 &&
+ height > 0 ) // skip whitespace
+ {
+ if( !helper.GlyphFound( glyphs[i].fontId, glyphs[i].index ) )
+ {
+ helper.AddGlyph( glyphs[i] );
+ }
+ }
+ }
+
+ // Uploads the bitmaps to Dali
+ return helper.CreateAtlas();
+ }
+
+
+#if ! defined( NO_MESH )
+ /**
+ * @brief Helper method to create a mesh with one quad per glyph.
+ *
+ * @param[in] glyphs The glyphs to display.
+ * @param[in] positions The 2D positions of the glyphs.
+ * @param[in] image The material uses this as a diffuse texture.
+ */
+ Mesh CreateMesh( const Vector<GlyphInfo>& glyphs, const std::vector<Vector2>& positions, Image image )
+ {
+ MeshData::VertexContainer vertices( 4 * glyphs.Count() ); // 1 quad per glyph
+
+ MeshData::FaceIndices faces;
+ faces.reserve( 6 * glyphs.Count() ); // 2 triangles per quad
+
+ for( unsigned int i=0; i<glyphs.Count(); ++i )
+ {
+ float width = glyphs[i].width;
+ float height = glyphs[i].height;
+
+ if( width > 0 &&
+ height > 0 ) // skip whitespace
+ {
+ const Vector2& position = positions[i];
+
+ TextureCoordinates coords;
+ mAtlasHelper.GetTextureCoordinates( glyphs[i].fontId, glyphs[i].index, coords );
+
+ vertices[ i*4 + 0 ] = MeshData::Vertex( Vector3( position.x + 0.0f*width, position.y + 0.0f*height, 0.0f ), coords.topLeft, Vector3( 1.0f, 0.0f, 0.0f ) );
+ vertices[ i*4 + 1 ] = MeshData::Vertex( Vector3( position.x + 1.0f*width, position.y + 0.0f*height, 0.0f ), coords.topRight, Vector3( 1.0f, 1.0f, 0.0f ) );
+ vertices[ i*4 + 2 ] = MeshData::Vertex( Vector3( position.x + 0.0f*width, position.y + 1.0f*height, 0.0f ), coords.bottomLeft, Vector3( 0.0f, 1.0f, 0.0f ) );
+ vertices[ i*4 + 3 ] = MeshData::Vertex( Vector3( position.x + 1.0f*width, position.y + 1.0f*height, 0.0f ), coords.bottomRight, Vector3( 0.0f, 0.0f, 1.0f ) );
+
+ faces.push_back( i*4 + 0 ); faces.push_back( i*4 + 3 ); faces.push_back( i*4 + 1 );
+ faces.push_back( i*4 + 0 ); faces.push_back( i*4 + 2 ); faces.push_back( i*4 + 3 );
+ }
+ }
+
+ Material material = Material::New( "Material" );
+ material.SetDiffuseTexture( image );
+
+ // Create the mesh data from the vertices and faces
+ MeshData meshData;
+ meshData.SetHasColor( false );
+ meshData.SetMaterial( material );
+ meshData.SetVertices( vertices );
+ meshData.SetFaceIndices( faces );
+
+ // Create a mesh from the data
+ Dali::Mesh mesh = Mesh::New( meshData );
+ return mesh;
+ }
+#endif
+
+ RenderableActor mActor; ///< The actor which renders the text
+
+ AtlasHelper mAtlasHelper; ///< A helper class for storing atlas positions etc.
+};
+
+Text::RendererPtr BasicRenderer::New()
+{
+ return Text::RendererPtr( new BasicRenderer() );
+}
+
+RenderableActor BasicRenderer::Render( Text::ViewInterface& view )
+{
+ Text::Length numberOfGlyphs = view.GetNumberOfGlyphs();
+
+ if( numberOfGlyphs > 0 )
+ {
+ Vector<GlyphInfo> glyphs;
+ glyphs.Resize( numberOfGlyphs );
+
+ view.GetGlyphs( 0, &glyphs[0], numberOfGlyphs );
+
+ std::vector<Vector2> positions;
+ positions.resize( numberOfGlyphs );
+ view.GetGlyphPositions( 0, &positions[0], numberOfGlyphs );
+
+ Atlas atlas = mImpl->CreateAtlas( glyphs );
+
+#if ! defined( NO_MESH )
+ MeshActor actor = MeshActor::New( mImpl->CreateMesh( glyphs, positions, atlas ) );
+ actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ actor.SetAffectedByLighting( false );
+
+ ShaderEffect shader = BasicShader::New();
+ actor.SetShaderEffect( shader );
+
+ mImpl->mActor = actor;
+#endif
+ }
+
+ return mImpl->mActor;
+}
+
+BasicRenderer::BasicRenderer()
+{
+ mImpl = new Impl();
+}
+
+BasicRenderer::~BasicRenderer()
+{
+ delete mImpl;
+}
#include <dali-toolkit/public-api/builder/tree-node.h>
#include <dali-toolkit/public-api/controls/alignment/alignment.h>
#include <dali-toolkit/public-api/controls/bloom-view/bloom-view.h>
-#include <dali-toolkit/public-api/controls/bubble-effect/bubble-emitter.h>
#include <dali-toolkit/public-api/controls/buttons/button.h>
#include <dali-toolkit/public-api/controls/buttons/check-box-button.h>
#include <dali-toolkit/public-api/controls/buttons/push-button.h>
#include <dali-toolkit/public-api/shader-effects/alpha-discard-effect.h>
#include <dali-toolkit/public-api/shader-effects/bendy-effect.h>
#include <dali-toolkit/public-api/shader-effects/blind-effect.h>
-#include <dali-toolkit/public-api/shader-effects/bouncing-effect.h>
#include <dali-toolkit/public-api/shader-effects/carousel-effect.h>
#include <dali-toolkit/public-api/shader-effects/displacement-effect.h>
#include <dali-toolkit/public-api/shader-effects/dissolve-local-effect.h>
#include <dali-toolkit/public-api/shader-effects/spot-effect.h>
#include <dali-toolkit/public-api/shader-effects/square-dissolve-effect.h>
#include <dali-toolkit/public-api/shader-effects/water-effect.h>
-#include <dali-toolkit/public-api/shader-effects/bubble-effect/bubble-effect.h>
-#include <dali-toolkit/public-api/shader-effects/bubble-effect/color-adjuster.h>
#include <dali-toolkit/public-api/shader-effects/dissolve-effect.h>
#include <dali-toolkit/public-api/shader-effects/image-region-effect.h>
#include <dali-toolkit/public-api/shader-effects/iris-effect.h>
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "bubble-emitter-impl.h"
-
-// EXTERNAL INCLUDES
-#include <cmath>
-#include <dali/public-api/animation/animation.h>
-#include <dali/public-api/render-tasks/render-task-list.h>
-#include <dali/public-api/images/resource-image.h>
-
-// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/shader-effects/bubble-effect/color-adjuster.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal
-{
-BubbleEmitter::BubbleEmitter( const Vector2& movementArea,
- Image shapeImage,
- unsigned int maximumNumberOfBubble,
- const Vector2& bubbleSizeRange )
-: Control( REQUIRES_TOUCH_EVENTS ),
- mMovementArea( movementArea ),
- mShapeImage( shapeImage ),
- mTotalNumOfBubble( maximumNumberOfBubble ),
- mRenderTaskRunning(false),
- mBubbleSizeRange( bubbleSizeRange ),
- mCurrentUniform( 0 ),
- mDensity( 5 )
-{
- // Calculate how many BubbleEffect shaders are required
- if( mTotalNumOfBubble>100 )
- {
- mNumBubblePerShader = 100;
- mNumShader = mTotalNumOfBubble / 100;
- }
- else
- {
- mNumBubblePerShader = mTotalNumOfBubble;
- mNumShader = 1;
- }
-}
-
-BubbleEmitter::~BubbleEmitter()
-{
-}
-
-Toolkit::BubbleEmitter BubbleEmitter::New( const Vector2& winSize,
- Image shapeImage,
- unsigned int maximumNumberOfBubble,
- const Vector2& bubbleSizeRange )
-{
- // Create the implementation
- IntrusivePtr<BubbleEmitter> internalBubbleEmitter ( new BubbleEmitter( winSize, shapeImage,
- maximumNumberOfBubble,bubbleSizeRange ) );
-
- // Pass ownership to Toolkit::BubbleEmitter handle
- Toolkit::BubbleEmitter bubbleEmitter( *internalBubbleEmitter );
-
- //Second phase of implementeation : Initialization
- internalBubbleEmitter->OnInitialize();
-
- return bubbleEmitter;
-}
-
-void BubbleEmitter::OnInitialize()
-{
- // Create the root actor, all the meshActor should be its children
- mBubbleRoot = Actor::New();
- mBubbleRoot.SetSize(mMovementArea);
-
- // Prepare the frame buffer to store the color adjusted background image
- mEffectImage = FrameBufferImage::New( mMovementArea.width/4.f, mMovementArea.height/4.f, Pixel::RGBA8888, Dali::Image::UNUSED );
-
- // Generate the material object, which is used by all meshActors
- GenMaterial();
-
- mMesh.resize( mNumShader );
- mMeshActor.resize( mNumShader );
- mEffect.resize( mNumShader );
-
- // Create the meshActor group and bubbleEffect group to emit bubbles following the given track, such as finger touch track.
- MeshData meshData;
- ConstructBubbleMesh( meshData, mNumBubblePerShader*mDensity);
- for(unsigned int i=0; i < mNumShader; i++ )
- {
- mMesh[i] = Mesh::New( meshData );
- mMeshActor[i] = MeshActor::New( mMesh[i] );
- mMeshActor[i].SetParentOrigin(ParentOrigin::TOP_LEFT);
- mEffect[i] = BubbleEffect::New( mNumBubblePerShader );
- mEffect[i].SetEffectImage( mEffectImage );
- mEffect[i].SetMovementArea( mMovementArea );
- mMeshActor[i].SetShaderEffect( mEffect[i] );
- mBubbleRoot.Add( mMeshActor[i] );
- }
-
- // Create the extra meshActor and bubbleEffect to emit bubbles in totally random angle.
- MeshData meshDataForNoise;
- ConstructBubbleMesh( meshDataForNoise, mNumBubblePerShader);
- mMeshActorForNoise = MeshActor::New( Mesh::New(meshDataForNoise) );
- mMeshActorForNoise.SetParentOrigin(ParentOrigin::TOP_LEFT);
- mEffectForNoise = BubbleEffect::New( mNumBubblePerShader );
- mEffectForNoise.SetMovementArea( mMovementArea );
- mEffectForNoise.SetEffectImage( mEffectImage );
- mMeshActorForNoise.SetShaderEffect( mEffectForNoise );
- mBubbleRoot.Add( mMeshActorForNoise );
-
- // Create a cameraActor for the off screen render task.
- mCameraActor = CameraActor::New(mMovementArea);
- mCameraActor.SetParentOrigin(ParentOrigin::CENTER);
-
- Stage stage = Stage::GetCurrent();
-
- stage.Add(mCameraActor);
- stage.ContextRegainedSignal().Connect(this, &BubbleEmitter::OnContextRegained);
-}
-
-Actor BubbleEmitter::GetRootActor()
-{
- return mBubbleRoot;
-}
-
-void BubbleEmitter::SetBackground( Image bgImage, const Vector3& hsvDelta )
-{
- mBackgroundImage = bgImage;
- mHSVDelta = hsvDelta;
-
- ImageActor sourceActor = ImageActor::New( bgImage );
- sourceActor.SetSize( mMovementArea );
- sourceActor.SetParentOrigin(ParentOrigin::CENTER);
- Stage::GetCurrent().Add( sourceActor );
-
- ColorAdjuster colorAdjuster = ColorAdjuster::New( hsvDelta, true /*ignore alpha to make bubble color always*/ );
- sourceActor.SetShaderEffect( colorAdjuster );
-
- RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
- RenderTask task = taskList.CreateTask();
- task.SetRefreshRate( RenderTask::REFRESH_ONCE );
- task.SetSourceActor( sourceActor );
- task.SetExclusive(true);
- task.SetCameraActor(mCameraActor);
- task.GetCameraActor().SetInvertYAxis(true);
- task.SetTargetFrameBuffer( mEffectImage );
- task.FinishedSignal().Connect(this, &BubbleEmitter::OnRenderFinished);
- mRenderTaskRunning = true;
-}
-
-void BubbleEmitter::SetShapeImage( Image shapeImage )
-{
- mCustomMaterial.SetDiffuseTexture( shapeImage );
-}
-
-void BubbleEmitter::SetBubbleScale( float scale )
-{
- for(unsigned int i=0; i < mNumShader; i++ )
- {
- mEffect[i].SetDynamicScale( scale );
- }
- mEffectForNoise.SetDynamicScale( scale );
-}
-
-void BubbleEmitter::SetBubbleDensity( unsigned int density )
-{
- DALI_ASSERT_ALWAYS( density>0 && density<=9 && " Only densities between 1 to 9 are valid " );
-
- if( density == mDensity )
- {
- return;
- }
- else
- {
- mDensity = density;
- MeshData meshData;
- ConstructBubbleMesh( meshData, mNumBubblePerShader*mDensity);
- for(unsigned int i=0; i < mNumShader; i++ )
- {
- mMesh[i].UpdateMeshData(meshData);
- }
- }
-}
-
-// clear the resources created for the off screen rendering
-void BubbleEmitter::OnRenderFinished(RenderTask& source)
-{
- mRenderTaskRunning = false;
- Actor sourceActor = source.GetSourceActor();
- if( sourceActor )
- {
- RenderableActor renderable = RenderableActor::DownCast( sourceActor );
- if( renderable )
- {
- renderable.RemoveShaderEffect();
- }
- }
-
- Stage stage = Stage::GetCurrent();
- stage.Remove(sourceActor);
- stage.GetRenderTaskList().RemoveTask(source);
-}
-
-void BubbleEmitter::OnContextRegained()
-{
- // Context was lost, so the framebuffer has been destroyed. Re-create render task
- // and trigger re-draw if not already running
- if( ! mRenderTaskRunning )
- {
- SetBackground( mBackgroundImage, mHSVDelta );
- }
-}
-
-void BubbleEmitter::SetBlendMode( bool enable )
-{
- if(enable)
- {
- for(unsigned int i=0; i < mNumShader; i++ )
- {
- // linear overlay
- // TODO: if BlendColor would be public api from renderable actor, then can optimize the constant color
- mMeshActor[i].SetBlendFunc(BlendingFactor::SRC_ALPHA, BlendingFactor::ONE,
- BlendingFactor::ZERO, BlendingFactor::ONE);
- }
- mMeshActorForNoise.SetBlendFunc(BlendingFactor::SRC_ALPHA, BlendingFactor::ONE,
- BlendingFactor::ZERO, BlendingFactor::ONE);
- }
- else
- {
- for(unsigned int i=0; i < mNumShader; i++ )
- {
- // using default blend func
- mMeshActor[i].SetBlendFunc( BlendingFactor::SRC_ALPHA, BlendingFactor::ONE_MINUS_SRC_ALPHA,
- BlendingFactor::ONE, BlendingFactor::ONE_MINUS_SRC_ALPHA );
- }
- mMeshActorForNoise.SetBlendFunc( BlendingFactor::SRC_ALPHA, BlendingFactor::ONE_MINUS_SRC_ALPHA,
- BlendingFactor::ONE, BlendingFactor::ONE_MINUS_SRC_ALPHA );
- }
-}
-
-void BubbleEmitter::EmitBubble( Animation& animation, const Vector2& emitPosition, const Vector2& direction, const Vector2& displacement )
-{
- unsigned int curUniform = mCurrentUniform % mNumBubblePerShader;
- unsigned int groupIdx = mCurrentUniform / mNumBubblePerShader;
- SetBubbleParameter( mEffect[groupIdx], curUniform, emitPosition, direction, displacement);
- animation.AnimateTo( Property( mEffect[groupIdx], mEffect[groupIdx].GetPercentagePropertyName(curUniform) ),
- 1.f, AlphaFunctions::Linear );
-
- if( mCurrentUniform % mNumShader == 0 )
- {
- unsigned int uniform = mCurrentUniform / mNumShader;
- SetBubbleParameter(mEffectForNoise, uniform, emitPosition, displacement);
- animation.AnimateTo( Property( mEffectForNoise, mEffectForNoise.GetPercentagePropertyName(uniform) ),
- 1.f, AlphaFunctions::Linear );
- }
-
- mCurrentUniform = (mCurrentUniform + 1) % mTotalNumOfBubble;
-}
-
-void BubbleEmitter::StartExplosion( float duration, float multiple )
-{
- Animation animation = Animation::New( duration );
- for(unsigned int i=0; i < mNumShader; i++ )
- {
- animation.AnimateTo( Property( mEffect[i], mEffect[i].GetMagnificationPropertyName() ),
- multiple, AlphaFunctions::EaseOut);
- }
- animation.AnimateTo( Property( mEffectForNoise, mEffectForNoise.GetMagnificationPropertyName() ),
- multiple, AlphaFunctions::EaseOut);
- animation.Play();
-
- animation.FinishedSignal().Connect(this, &BubbleEmitter::OnExplosionFinished);
-}
-
-void BubbleEmitter::Restore()
-{
- for(unsigned int i=0; i < mNumShader; i++ )
- {
- mEffect[i].ResetParameters();
- }
- mEffectForNoise.ResetParameters();
-}
-
-void BubbleEmitter::GenMaterial()
-{
- mCustomMaterial = Material::New("CustomMaterial");
- mCustomMaterial.SetOpacity(1.0f);
- mCustomMaterial.SetDiffuseColor(Color::WHITE);
- mCustomMaterial.SetAmbientColor(Vector4(0.0, 0.1, 0.1, 1.0));
- mCustomMaterial.SetMapU( Material::MAPPING_MODE_WRAP );
- mCustomMaterial.SetMapV( Material::MAPPING_MODE_WRAP );
- mCustomMaterial.SetDiffuseTexture( mShapeImage );
-}
-
-void BubbleEmitter::AddVertex(MeshData::VertexContainer& vertices, Vector3 XYZ, Vector2 UV)
-{
- MeshData::Vertex meshVertex;
- meshVertex.x = XYZ.x;
- meshVertex.y = XYZ.y;
- meshVertex.z = XYZ.z;
- meshVertex.u = UV.x;
- meshVertex.v = UV.y;
- vertices.push_back(meshVertex);
-}
-
-void BubbleEmitter::AddTriangle(MeshData::FaceIndices& faces,
-size_t v0, size_t v1, size_t v2)
-{
- faces.push_back(v0);
- faces.push_back(v1);
- faces.push_back(v2);
-}
-
-void BubbleEmitter::ConstructBubbleMesh( MeshData& meshData, unsigned int numOfBubble)
-{
- MeshData::VertexContainer vertices;
- MeshData::FaceIndices faces;
- BoneContainer bones(0);
-
- for(unsigned int index = 0; index < numOfBubble; index ++)
- {
- float curSize = RandomRange(mBubbleSizeRange.x, mBubbleSizeRange.y);
- if(rand()%100 < 1)
- {
- curSize *= 2.f;
- }
- float depth = static_cast<float>( index );
- AddVertex( vertices, Vector3(0.f,0.f,depth), Vector2(0.f,0.f) );
- AddVertex( vertices, Vector3(0.f,curSize,depth), Vector2( 0.f,1.f ));
- AddVertex( vertices, Vector3(curSize,curSize,depth), Vector2(1.f,1.f) );
- AddVertex( vertices, Vector3(curSize,0.f,depth), Vector2(1.f,0.f) );
-
- unsigned int idx = index * 4;
- AddTriangle( faces, idx, idx+1, idx+2);
- AddTriangle( faces, idx, idx+2, idx+3);
- }
-
- meshData.SetData(vertices, faces, bones, mCustomMaterial);
- meshData.SetHasColor(false);
- meshData.SetHasTextureCoords(true);
-}
-
-void BubbleEmitter::SetBubbleParameter( BubbleEffect& effect, unsigned int curUniform,
- const Vector2& emitPosition, const Vector2& displacement )
-{
- int halfRange = displacement.x / 2;
- Vector2 randomVec(rand()%static_cast<int>(displacement.x) - halfRange, rand()%static_cast<int>(displacement.y) - halfRange);
- if(randomVec.y > 0.0f)
- {
- randomVec.y *= 0.33f;
- }
-
- Vector4 startAndEndPos( emitPosition.x, emitPosition.y, emitPosition.x+randomVec.x, emitPosition.y+randomVec.y );
- effect.SetStartAndEndPosition( curUniform, startAndEndPos );
-
- effect.SetPercentage( curUniform, 0.f);
-}
-
-void BubbleEmitter::SetBubbleParameter( BubbleEffect& effect, unsigned int curUniform,
- const Vector2& emitPosition, const Vector2& direction, const Vector2& displacement )
-{
- Vector2 dir(direction);
-
- int halfRange = displacement.x / 2;
- // for the y coordinate, always negative, so bubbles always go upwards
- Vector2 randomVec(rand()%static_cast<int>(displacement.x) - halfRange, -rand()%static_cast<int>(displacement.y));
- dir.Normalize();
- randomVec.x -= dir.x*halfRange;
- randomVec.y *= 1.0f - fabsf(dir.x)*0.33f;
-
- if(randomVec.y > 0.0f)
- {
- randomVec.y *= 0.33f;
- }
- Vector4 startAndEndPos( emitPosition.x, emitPosition.y, emitPosition.x+randomVec.x, emitPosition.y+randomVec.y );
- effect.SetStartAndEndPosition( curUniform, startAndEndPos );
-
- effect.SetPercentage( curUniform, 0.f);
-}
-
-void BubbleEmitter::OnExplosionFinished( Animation& source )
-{
- Restore();
-}
-
-float BubbleEmitter::RandomRange(float f0, float f1)
-{
- return f0 + (rand() & 0xfff) * (f1-f0) * (1.0f/4095.0f);
-}
-
-} // namespace Internal
-
-} // namespace Toolkit
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_TOOLKIT_INTERNAL_BUBBLE_EMITTER_IMPL_H__
-#define __DALI_TOOLKIT_INTERNAL_BUBBLE_EMITTER_IMPL_H__
-
-/*
- * Copyright (c) 2014 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 <dali/public-api/actors/camera-actor.h>
-#include <dali/public-api/actors/image-actor.h>
-#include <dali/public-api/actors/mesh-actor.h>
-#include <dali/public-api/common/stage.h>
-#include <dali/public-api/images/frame-buffer-image.h>
-#include <dali/public-api/geometry/mesh.h>
-#include <dali/public-api/render-tasks/render-task.h>
-
-// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/controls/control-impl.h>
-#include <dali-toolkit/public-api/controls/bubble-effect/bubble-emitter.h>
-#include <dali-toolkit/public-api/shader-effects/bubble-effect/bubble-effect.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal
-{
-
-/**
- * BubbleEmitter implementation class.
- */
-class BubbleEmitter : public Control
-{
-public:
-
- /**
- * Destructor
- */
- ~BubbleEmitter();
-
- /**
- * @copydoc Toolkit::BubbleEmitter::New
- */
- static Toolkit::BubbleEmitter New( const Vector2& winSize,
- Image shapeImage,
- unsigned int maximumNumberOfBubble,
- const Vector2& bubbleSizeRange );
-
- /**
- * @copydoc Toolkit::BubbleEmitter::GetRootActor
- */
- Actor GetRootActor();
-
- /**
- * @copydoc Toolkit::BubbleEmitter::SetBackground
- */
- void SetBackground( Image bgImage, const Vector3& hsvDelta );
-
- /**
- * @copydoc Toolkit::BubbleEmitter::SetShapeImage
- */
- void SetShapeImage( Image shapeImage );
-
- /**
- * @copydoc Toolkit::BubbleEmiter::SetBubbleScale
- */
- void SetBubbleScale( float scale );
-
- /**
- * @copydoc Toolkit::BubbleEmitter::SetBubbleDensity
- */
- void SetBubbleDensity( unsigned int density );
-
- /**
- * @copydoc Toolkit::BubbleEmitter::SetBlendMode
- */
- void SetBlendMode( bool enable );
-
- /**
- * @copydoc Toolkit::BubbleEmitter::EmitBubble
- */
- void EmitBubble( Animation& animation, const Vector2& emitPosition, const Vector2& direction, const Vector2& displacement );
-
- /**
- * @copydoc Toolkit::BubbleEmitter::StartExplosion
- */
- void StartExplosion( float duration, float multiple );
-
- /**
- * @copydoc Toolkit::BubbleEmitter::Restore
- */
- void Restore();
-
-private:
-
- /**
- * Construct a new BubbleEmitter object.
- * @param[in] movementArea The size of the bubble moving area
- * @param[in] shapeImage The alpha channnel of this texture defines the bubble shape.
- * @param[in] maximumNumberOfBubble The maximum number of bubble needed.
- * @param[in] bubbleSizeRange The size range of the bubbles; x component is the minimal size, and y component is the maximum size.
- */
- BubbleEmitter( const Vector2& movementArea,
- Image shapeImage,
- unsigned int maximumNumberOfBubble,
- const Vector2& bubbleSizeRange );
-
- /**
- * This method is called after the CubeTransitionEffect has been initialized.
- * The meshActors and BubbleEffects are created here.
- */
- void OnInitialize();
-
- /**
- * Callback function of the finished signal of off-screen render task.
- * @param[in] source The render task used to create the color adjusted background image.
- */
- void OnRenderFinished(RenderTask& source);
-
- /**
- * Callback function from Stage to tell us if the context has been regained.
- */
- void OnContextRegained();
-
- /**
- * Generate the material object which is attached to the meshActor to describe its color, texture, texture mapping mode etc.
- */
- void GenMaterial();
-
- /**
- * Add a vertex to the mesh data.
- * @param[in] vertices The collection of vertices.
- * @param[in] XYZ The vertex position coordinates.
- * @param[in] UV The vertex texture coordinate.
- */
- void AddVertex(MeshData::VertexContainer& vertices, Vector3 XYZ, Vector2 UV);
-
- /**
- * Add a triangle to the mesh data.
- * @param[in] faces The collection od FaceIndex items.
- * @param[in] v0 The index of the first point of the triangle.
- * @param[in] v1 The index of the second point of the triangle.
- * @param[in] v3 The index of the first point of the triangle.
- */
- void AddTriangle(MeshData::FaceIndices& faces,size_t v0, size_t v1, size_t v2);
-
- /**
- * Create a new mesh.
- * @param[in] meshData The MeshData object which encompasses all the data required to describe and render the 3D mesh.
- * @param[in] numberOfBubble The triangle number in the meshData is 2*numOfBubble; two triangles for each bubble
- */
- void ConstructBubbleMesh( MeshData& meshData, unsigned int numOfBubble);
-
- /**
- * Set the uniform values to the shader effect to emit a bubble
- * @param[in] effect The BubbleEffect to render the current bubble
- * @param[in] curUniform The index of the uniform array in the shader
- * @param[in] emitPosition The start position of the bubble movement.
- * @param[in] displacement The displacement used to bound the moving distance of the bubble.
- */
- void SetBubbleParameter( BubbleEffect& effect, unsigned int curUniform,
- const Vector2& emitPosition, const Vector2& displacement );
-
- /**
- * Set the uniform values to the shader effect to emit a bubble
- * @param[in] effect The BubbleEffect to render the current bubble
- * @param[in] curUniform The index of the uniform array in the shader
- * @param[in] emitPosition The start position of the bubble movement.
- * @param[in] direction The direction used to constrain the bubble to move in an adjacent direction around it.
- * @param[in] displacement The displacement used to bound the moving distance of the bubble.
- */
- void SetBubbleParameter( BubbleEffect& effect, unsigned int curUniform,
- const Vector2& emitPosition, const Vector2& direction, const Vector2& displacement );
-
- /**
- * Callback function of the explosion animation finished signal to reset the shader parameters
- * @param[in] source The explosion animation.
- */
- void OnExplosionFinished( Animation& source );
-
- /**
- * Return a random value between the given interval.
- * @param[in] f0 The low bound
- * @param[in] f1 The up bound
- * @return A random value between the given interval
- */
- float RandomRange(float f0, float f1);
-
-private:
-
- Vector2 mMovementArea; ///< The size of the bubble moving area, usually the same size as the background image actor.
- Image mShapeImage; ///< The alpha channnel of this texture defines the bubble shape.
- Actor mBubbleRoot; ///<The bubble root actor. Need to add it to stage to get the bubbles rendered.
-
- unsigned int mNumBubblePerShader; ///< How many bubbles for each BubbleEffect shader.
- unsigned int mNumShader; ///< How many BubbleEffect shaders are used.
- unsigned int mTotalNumOfBubble; ///< mNumBubblePerShader*mNumShader.
- bool mRenderTaskRunning; ///< If the background render task is currently running
-
- Vector2 mBubbleSizeRange; ///< The bubble size range.
-
- std::vector<Mesh> mMesh; ///< The mesh vector, each mesh is used to create a meshActor which applies a BubbleEffect.
- std::vector<MeshActor> mMeshActor; ///< The meshActor vector, its size is mNumShader.
- MeshActor mMeshActorForNoise; ///< An Extra mesh data to emit bubbles which emit bubble in totally random angle.
- Material mCustomMaterial; ///< The material object which is attached to the meshActor to describe its color, texture, texture mapping mode etc.
-
- std::vector<BubbleEffect> mEffect; ///< The bubbleEffect vector, corresponding to the mMeshActoe vector.
- BubbleEffect mEffectForNoise; ///< The extra bubbleEffect, corresponding to the mMeshActorForNoise.
-
- unsigned int mCurrentUniform; ///< Keep track of the uniform index for the newly emitted bubble
-
- Vector3 mHSVDelta; ///< The HSV difference used to adjust the background image color.
- Image mBackgroundImage; ///< The original background image
- FrameBufferImage mEffectImage; ///< The image stores the adjusted color of the background image.The bubbles pick color from this image.
- CameraActor mCameraActor; ///< The render task views the scene from the perspective of this actor.
-
- unsigned int mDensity; ///< How many bubbles will emit at each time, they are controlled by same uniforms in the shader.
-
-};
-
-} // namespace Internal
-
-// Helpers for public-api forwarding methods
-inline Internal::BubbleEmitter& GetImpl(Dali::Toolkit::BubbleEmitter& obj)
-{
- DALI_ASSERT_ALWAYS(obj && "BubbleEmitter handle is empty");
- Dali::RefObject& handle = obj.GetImplementation();
- return static_cast<Toolkit::Internal::BubbleEmitter&>(handle);
-}
-
-inline const Internal::BubbleEmitter& GetImpl(const Dali::Toolkit::BubbleEmitter& obj)
-{
- DALI_ASSERT_ALWAYS(obj && "BubbleEmitter handle is empty");
- const Dali::RefObject& handle = obj.GetImplementation();
- return static_cast<const Toolkit::Internal::BubbleEmitter&>(handle);
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif /* __DALI_TOOLKIT_INTERNAL_BUBBLE_EMITTER_IMPL_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali-toolkit/internal/controls/scrollable/bouncing-effect-actor.h>
-
-// EXTERNAL INCLUDES
-#include <math.h>
-#include <dali/public-api/actors/mesh-actor.h>
-#include <dali/public-api/animation/active-constraint.h>
-#include <dali/public-api/animation/constraint.h>
-#include <dali/public-api/geometry/animatable-mesh.h>
-#include <dali/public-api/shader-effects/shader-effect.h>
-#include <dali/public-api/math/vector3.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal
-{
-
-namespace
-{
-// Bouncing effect is presented by stacked three layers with same color and opacity
-const size_t NUM_LAYERS( 3 );
-const Vector3 LAYER_HEIGHTS( 1.f, 27.f/42.f, 13.f/42.f);
-
-// use the actor color to paint every layer
-const char* MESH_FRAGMENT_SHADER =
-"void main()\n"
-"{\n"
-" gl_FragColor = uColor;\n"
-"}\n";
-
-// Constraint to move the vertices vertically
-struct VertexPositionConstraint
-{
- VertexPositionConstraint( float initialY, float range )
- : mInitialY( initialY ),
- mRange( range )
- {
- }
-
- Vector3 operator()( const Vector3& current, const PropertyInput& bounceCoef )
- {
- float positionY = mInitialY + mRange * fabsf(bounceCoef.GetFloat());
- return Vector3( current.x, positionY, current.z );
- }
-
- float mInitialY;
- float mRange;
-};
-
-} // namespace Anon
-
-Actor CreateBouncingEffectActor( Property::Index& bouncePropertyIndex )
-{
- Dali::AnimatableMesh mesh;
- Dali::MeshActor meshActor;
-
- Dali::AnimatableMesh::Faces faces;
- faces.reserve( NUM_LAYERS * 6 ); // 2 triangles per layer
- for( size_t i=0; i<NUM_LAYERS; i++ )
- {
- size_t j=i*4;
- faces.push_back(j); faces.push_back(j+3); faces.push_back(j+1);
- faces.push_back(j); faces.push_back(j+2); faces.push_back(j+3);
- }
-
- mesh = Dali::AnimatableMesh::New(NUM_LAYERS*4, faces); // 4 vertices per layer
- for( size_t i=0;i<NUM_LAYERS;i++ )
- {
- size_t j=i*4;
- float positionZ = 0.01f*static_cast<float>( i ); // the interval between each layer is 0.01
- mesh[j ].SetPosition( Vector3( -0.5f, -0.5f, positionZ ) );
- mesh[j+1].SetPosition( Vector3( 0.5f, -0.5f, positionZ ) );
- mesh[j+2].SetPosition( Vector3( -0.5f, -0.5f, positionZ ) );
- mesh[j+3].SetPosition( Vector3( 0.5f, -0.5f, positionZ ) );
- }
-
- meshActor = Dali::MeshActor::New(mesh);
-
- Dali::ShaderEffect shaderEffect = Dali::ShaderEffect::New( "", MESH_FRAGMENT_SHADER,
- GEOMETRY_TYPE_UNTEXTURED_MESH,
- Dali::ShaderEffect::HINT_BLENDING );
- meshActor.SetShaderEffect(shaderEffect);
-
- // To control the movement of all vertices with one custom property
- bouncePropertyIndex = meshActor.RegisterProperty("BounceCoeffcient", 0.f);
- for( size_t i=0;i<NUM_LAYERS;i++ )
- {
- size_t j=i*4;
- mesh.ApplyConstraint( Constraint::New<Vector3>( mesh.GetPropertyIndex(j+2, AnimatableVertex::Property::Position ),
- Source(meshActor, bouncePropertyIndex),
- VertexPositionConstraint(-0.5f, LAYER_HEIGHTS[i]) ) );
- mesh.ApplyConstraint( Constraint::New<Vector3>( mesh.GetPropertyIndex(j+3, AnimatableVertex::Property::Position),
- Source(meshActor, bouncePropertyIndex),
- VertexPositionConstraint(-0.5f, LAYER_HEIGHTS[i]) ) );
- }
-
- return meshActor;
-}
-
-} // namespace Internal
-
-} // namespace Toolkit
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_TOOLKIT_INTERNAL_BOUNCING_EFFECT_ACTOR_H__
-#define __DALI_TOOLKIT_INTERNAL_BOUNCING_EFFECT_ACTOR_H__
-
-/*
- * Copyright (c) 2014 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 <dali/public-api/actors/actor.h>
-#include <dali/public-api/object/property.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal
-{
-
-/**
- * @brief Creates a Dali::Actor to display the bouncing effect for overshoot
- *
- * Usage example:
- * @code
- * // create the actor and get the property index for animation
- * Property::Index bouncePropertyIndex = Property::INVALID_INDEX;
- * Actor bounceActor = CreateBouncingEffectActor( bouncePropertyIndex );
-
- * // set size and color
- * bounceActor.SetSize(720.f, 42.f );
- * bounceActor.SetColor( Vector4( 0.0,0.64f,0.85f,0.25f ) );
- *
- * // add to stage
- * bounceActor.SetParentOrigin(ParentOrigin::CENTER);
- * Stage::GetCurrent().Add(bounceActor);
-
- * // start the bouncing animation
- * Animation anim = Animation::New(2.0f);
- * anim.AnimateTo( Property( bounceActor, bouncePropertyIndex ), 1.f, AlphaFunctions::Sin );
- * anim.Play();
- * @endcode
- *
- * @param[out] bouncePropertyIndex The property index which controls the bouncing
- * @return The actor which displays the bouncing effect
- */
-Actor CreateBouncingEffectActor( Property::Index& bouncePropertyIndex);
-
-} // namespace Internal
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-
-#endif /* __DALI_TOOLKIT_INTERNAL_BOUNCING_EFFECT_ACTOR_H__ */
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/scrollable/item-view/item-factory.h>
#include <dali-toolkit/internal/controls/scrollable/scroll-connector-impl.h>
-#include <dali-toolkit/internal/controls/scrollable/bouncing-effect-actor.h>
using std::string;
using std::set;
if( enable )
{
Property::Index effectOvershootPropertyIndex = Property::INVALID_INDEX;
- mOvershootOverlay = CreateBouncingEffectActor( effectOvershootPropertyIndex );
- mOvershootOverlay.SetColor(mOvershootEffectColor);
- mOvershootOverlay.SetParentOrigin(ParentOrigin::TOP_LEFT);
- mOvershootOverlay.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- mOvershootOverlay.SetDrawMode(DrawMode::OVERLAY);
- self.Add(mOvershootOverlay);
Constraint constraint = Constraint::New<Vector3>( Actor::Property::Size,
ParentSource( mPropertyScrollDirection ),
// INTERNAL INCLUDES
#include <dali-toolkit/internal/controls/scrollable/scrollable-impl.h>
-#include <dali-toolkit/internal/controls/scrollable/bouncing-effect-actor.h>
#include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.h>
using namespace Dali;
mOvershoot(0.0f),
mAnimationStateFlags(0)
{
- mOvershootOverlay = CreateBouncingEffectActor(mEffectOvershootProperty);
- mOvershootOverlay.SetColor(mAttachedScrollView.GetOvershootEffectColor());
- mOvershootOverlay.SetParentOrigin(ParentOrigin::TOP_LEFT);
- mOvershootOverlay.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- mOvershootOverlay.SetDrawMode(DrawMode::OVERLAY);
- mOvershootOverlay.SetVisible(false);
}
mOvershootProperty = self.GetPropertyIndex(IsVertical() ? Toolkit::ScrollView::SCROLL_OVERSHOOT_Y_PROPERTY_NAME : Toolkit::ScrollView::SCROLL_OVERSHOOT_X_PROPERTY_NAME);
// make sure height is set, since we only create a constraint for image width
- mOvershootOverlay.SetSize(OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.width, OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.height);
- mAttachedScrollView.AddOverlay(mOvershootOverlay);
UpdatePropertyNotifications();
}
void ScrollOvershootEffectRipple::Remove( Scrollable& scrollable )
{
- if(mOvershootOverlay)
- {
- if(mOvershootIncreaseNotification)
- {
- scrollable.Self().RemovePropertyNotification(mOvershootIncreaseNotification);
- mOvershootIncreaseNotification.Reset();
- }
- if(mOvershootDecreaseNotification)
- {
- scrollable.Self().RemovePropertyNotification(mOvershootDecreaseNotification);
- mOvershootDecreaseNotification.Reset();
- }
- scrollable.RemoveOverlay(mOvershootOverlay);
- }
}
void ScrollOvershootEffectRipple::Reset()
{
- mOvershootOverlay.SetVisible(false);
- mOvershootOverlay.SetProperty( mEffectOvershootProperty, 0.f);
}
void ScrollOvershootEffectRipple::UpdatePropertyNotifications()
void ScrollOvershootEffectRipple::SetOvershootEffectColor( const Vector4& color )
{
- if(mOvershootOverlay)
- {
- mOvershootOverlay.SetColor(color);
- }
}
void ScrollOvershootEffectRipple::UpdateVisibility( bool visible )
{
- mOvershootOverlay.SetVisible(visible);
- // make sure overshoot image is correctly placed
- if( visible )
- {
- Actor self = mAttachedScrollView.Self();
- if(mOvershoot > 0.0f)
- {
- // positive overshoot
- const Vector3 size = mOvershootOverlay.GetCurrentSize();
- Vector3 relativeOffset;
- const Vector3 parentSize = self.GetCurrentSize();
- if(IsVertical())
- {
- mOvershootOverlay.SetRotation(Quaternion(0.0f, Vector3::ZAXIS));
- mOvershootOverlay.SetSize(parentSize.width, GetBounceActorHeight(parentSize.width), size.depth);
- }
- else
- {
- mOvershootOverlay.SetRotation(Quaternion(1.5f * Math::PI, Vector3::ZAXIS));
- mOvershootOverlay.SetSize(parentSize.height, GetBounceActorHeight(parentSize.height), size.depth);
- relativeOffset = Vector3(0.0f, 1.0f, 0.0f);
- }
- mOvershootOverlay.SetPosition(relativeOffset * parentSize);
- }
- else
- {
- // negative overshoot
- const Vector3 size = mOvershootOverlay.GetCurrentSize();
- Vector3 relativeOffset;
- const Vector3 parentSize = self.GetCurrentSize();
- if(IsVertical())
- {
- mOvershootOverlay.SetRotation(Quaternion(Math::PI, Vector3::ZAXIS));
- mOvershootOverlay.SetSize(parentSize.width, GetBounceActorHeight(parentSize.width), size.depth);
- relativeOffset = Vector3(1.0f, 1.0f, 0.0f);
- }
- else
- {
- mOvershootOverlay.SetRotation(Quaternion(0.5f * Math::PI, Vector3::ZAXIS));
- mOvershootOverlay.SetSize(parentSize.height, GetBounceActorHeight(parentSize.height), size.depth);
- relativeOffset = Vector3(1.0f, 0.0f, 0.0f);
- }
- mOvershootOverlay.SetPosition(relativeOffset * parentSize);
- }
- }
}
void ScrollOvershootEffectRipple::OnOvershootNotification(PropertyNotification& source)
void ScrollOvershootEffectRipple::SetOvershoot(float amount, bool animate)
{
- float absAmount = fabsf(amount);
- bool animatingOn = absAmount > Math::MACHINE_EPSILON_0;
- if( (animatingOn && (mAnimationStateFlags & AnimatingIn)) )
- {
- // trying to do what we are already doing
- if( mAnimationStateFlags & AnimateBack )
- {
- mAnimationStateFlags &= ~AnimateBack;
- }
- return;
- }
- if( (!animatingOn && (mAnimationStateFlags & AnimatingOut)) )
- {
- // trying to do what we are already doing
- return;
- }
- if( !animatingOn && (mAnimationStateFlags & AnimatingIn) )
- {
- // dont interrupt while animating on
- mAnimationStateFlags |= AnimateBack;
- return;
- }
-
- if( absAmount > Math::MACHINE_EPSILON_1 )
- {
- UpdateVisibility(true);
- }
-
- float overshootAnimationSpeed = mAttachedScrollView.Self().GetProperty<float>(Toolkit::Scrollable::PROPERTY_OVERSHOOT_ANIMATION_SPEED);
-
- if( animate && overshootAnimationSpeed > Math::MACHINE_EPSILON_0 )
- {
- float currentOvershoot = fabsf( mOvershootOverlay.GetProperty( mEffectOvershootProperty ).Get<float>() );
- float duration = mOvershootOverlay.GetCurrentSize().height * (animatingOn ? (1.0f - currentOvershoot) : currentOvershoot) / overshootAnimationSpeed;
-
- if( duration > Math::MACHINE_EPSILON_0 )
- {
- if(mScrollOvershootAnimation)
- {
- mScrollOvershootAnimation.FinishedSignal().Disconnect( this, &ScrollOvershootEffectRipple::OnOvershootAnimFinished );
- mScrollOvershootAnimation.Stop();
- mScrollOvershootAnimation.Reset();
- }
- mScrollOvershootAnimation = Animation::New(duration);
- mScrollOvershootAnimation.FinishedSignal().Connect( this, &ScrollOvershootEffectRipple::OnOvershootAnimFinished );
- mScrollOvershootAnimation.AnimateTo( Property(mOvershootOverlay, mEffectOvershootProperty), amount, TimePeriod(duration) );
- mScrollOvershootAnimation.Play();
- mAnimationStateFlags = animatingOn ? AnimatingIn : AnimatingOut;
- }
- }
- else
- {
- mOvershootOverlay.SetProperty( mEffectOvershootProperty, amount);
- }
}
void ScrollOvershootEffectRipple::OnOvershootAnimFinished(Animation& animation)
bool animateOff = false;
if( mAnimationStateFlags & AnimatingOut )
{
- // should now be offscreen
- mOvershootOverlay.SetVisible(false);
}
if( (mAnimationStateFlags & AnimateBack) )
{
static ScrollOvershootEffectRipplePtr New( bool vertical, Scrollable& scrollable );
private:
- Actor mOvershootOverlay; ///< the actor which displays the overshoot effect
Scrollable& mAttachedScrollView; ///< the actor that this indicator has been attached to
Animation mScrollOvershootAnimation; ///< overshoot animation
PropertyNotification mOvershootIncreaseNotification;///< notification used to inform as overshoot increases
$(toolkit_src_dir)/builder/replacement.cpp \
$(toolkit_src_dir)/controls/alignment/alignment-impl.cpp \
$(toolkit_src_dir)/controls/bloom-view/bloom-view-impl.cpp \
- $(toolkit_src_dir)/controls/bubble-effect/bubble-emitter-impl.cpp \
$(toolkit_src_dir)/controls/buttons/button-impl.cpp \
$(toolkit_src_dir)/controls/buttons/check-box-button-impl.cpp \
$(toolkit_src_dir)/controls/buttons/push-button-impl.cpp \
$(toolkit_src_dir)/controls/scroll-bar/scroll-bar-impl.cpp \
$(toolkit_src_dir)/controls/scroll-component/scroll-bar-internal-impl.cpp \
$(toolkit_src_dir)/controls/scroll-component/scroll-bar-internal.cpp \
- $(toolkit_src_dir)/controls/scrollable/bouncing-effect-actor.cpp \
$(toolkit_src_dir)/controls/scrollable/item-view/item-view-impl.cpp \
$(toolkit_src_dir)/controls/scrollable/scrollable-impl.cpp \
$(toolkit_src_dir)/controls/scrollable/scroll-connector-impl.cpp \
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali-toolkit/public-api/controls/bubble-effect/bubble-emitter.h>
-
-// INTERNAL INCLUDES
-#include <dali-toolkit/internal/controls/bubble-effect/bubble-emitter-impl.h>
-
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-BubbleEmitter::BubbleEmitter()
-{
-}
-
-BubbleEmitter::~BubbleEmitter()
-{
-}
-
-BubbleEmitter::BubbleEmitter( Internal::BubbleEmitter& implementation )
-: Control( implementation )
-{
-}
-
-BubbleEmitter::BubbleEmitter(Dali::Internal::CustomActor* internal)
-: Control( internal )
-{
- VerifyCustomActorPointer<Internal::BubbleEmitter>( internal );
-}
-
-BubbleEmitter BubbleEmitter::New( const Vector2& winSize,
- Image shapeImage,
- unsigned int maximumNumberOfBubble,
- const Vector2& bubbleSizeRange )
-{
- return Internal::BubbleEmitter::New( winSize, shapeImage, maximumNumberOfBubble, bubbleSizeRange );
-}
-
-BubbleEmitter::BubbleEmitter( const BubbleEmitter& handle )
-: Control( handle )
-{
-}
-
-BubbleEmitter& BubbleEmitter::operator=( const BubbleEmitter& rhs )
-{
- if( &rhs != this )
- {
- Control::operator=(rhs);
- }
- return *this;
-}
-
-BubbleEmitter BubbleEmitter::DownCast( BaseHandle handle )
-{
- return Control::DownCast<BubbleEmitter, Internal::BubbleEmitter>( handle );
-}
-
-Actor BubbleEmitter::GetRootActor()
-{
- return GetImpl(*this).GetRootActor();
-}
-
-void BubbleEmitter::SetBackground( Image bgImage, const Vector3& hsvDelta )
-{
- GetImpl(*this).SetBackground( bgImage, hsvDelta );
-}
-
-void BubbleEmitter::SetShapeImage( Image shapeImage )
-{
- GetImpl(*this).SetShapeImage( shapeImage );
-}
-
-void BubbleEmitter::SetBubbleScale( float scale )
-{
- GetImpl(*this).SetBubbleScale( scale );
-}
-
-void BubbleEmitter::SetBubbleDensity( unsigned int density )
-{
- GetImpl(*this).SetBubbleDensity( density );
-}
-
-void BubbleEmitter::SetBlendMode( bool enable )
-{
- GetImpl(*this).SetBlendMode( enable );
-}
-
-void BubbleEmitter::EmitBubble( Animation& animation, const Vector2& emitPosition, const Vector2& direction, const Vector2& displacement )
-{
- GetImpl(*this).EmitBubble( animation, emitPosition, direction, displacement );
-}
-
-void BubbleEmitter::StartExplosion( float duration, float multiple )
-{
- GetImpl(*this).StartExplosion( duration, multiple );
-}
-
-void BubbleEmitter::Restore()
-{
- GetImpl(*this).Restore();
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_TOOLKIT_BUBBLE_EMMITER_H__
-#define __DALI_TOOLKIT_BUBBLE_EMMITER_H__
-
-/*
- * Copyright (c) 2014 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.
- *
- */
-
-// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/controls/control.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal DALI_INTERNAL
-{
- /**
- * @brief BubbleEmitter implementation class.
- */
- class BubbleEmitter;
-}
-
-/**
- * @brief BubbleEmitter is used to display lots of moving bubbles on the stage.
- *
- * This is done by applying BubbleEffect to multiple specifically created meshActors.
- */
-class DALI_IMPORT_API BubbleEmitter : public Control
-{
-public:
-
- /**
- * @brief Create an empty BubbleEmitter handle.
- */
- BubbleEmitter();
-
- /**
- * @brief Virtual destructor.
- */
- ~BubbleEmitter();
-
- /**
- * @brief Create an initialized BubbleEmitter.
- *
- * @param[in] winSize The size of the bubble moving area, usually the same size as the background image actor.
- * @param[in] shapeImage The alpha channnel of this texture defines the bubble shape.
- * @param[in] maximumNumberOfBubble The maximum number of bubble needed.
- * @param[in] bubbleSizeRange The size range of the bubbles; x component is the low bound, and y component is the up bound.
- * @return The initialized BubbleEmitter object.
- */
- static BubbleEmitter New( const Vector2& winSize,
- Image shapeImage,
- unsigned int maximumNumberOfBubble,
- const Vector2& bubbleSizeRange );
-
-
- /**
- * @brief Copy constructor.
- *
- * Creates another handle that points to the same real object
- * @param[in] handle The handle to copy
- */
- BubbleEmitter( const BubbleEmitter& handle );
-
- /**
- * @brief Assignment operator.
- *
- * Changes this handle to point to another real object
- * @param[in] rhs The object to point at
- * @return A reference to this
- */
- BubbleEmitter& operator=( const BubbleEmitter& rhs );
-
- /**
- * @brief Downcast an Object handle to SuperBlurView.
- *
- * If handle points to a BubbleEmitter, the downcast produces valid handle.
- * If not, the returned handle is left uninitialized.
- * @param[in] handle Handle to an object
- * @return handle to a BubbleEmitter or an uninitialized handle
- */
- static BubbleEmitter DownCast( BaseHandle handle );
-
- /**
- * @brief Return the root actor of all bubbles, should then be added to stage.
- *
- * @return The bubble root actor.
- */
- Actor GetRootActor();
-
- /**
- * @brief Set Background image.
- *
- * The bubbles pick color from this image with HSV values adjusted.
- * @param[in] bgImage The background image which provide color to bubbles.
- * @param[in] hsvDelta The hsv channel difference used to adjust the background image color.
- * If set these vector as Vector3::Zero, original colors are used.
- */
- void SetBackground( Image bgImage, const Vector3& hsvDelta );
-
- /**
- * @brief Set bubble shape.
- *
- * The bubble mesh is a rectangular patch, but its displayed shape is decided by the alpha channel of the shape image.
- * @param[in] shapeImage The image whose alpha channel defines the bubble shape.
- */
- void SetShapeImage( Image shapeImage );
-
- /**
- * @brief Set the scale factor applied to all the bubbles.
- *
- * @param [in] scale The scale factor applied on bubbles.
- */
- void SetBubbleScale( float scale );
-
- /**
- * @brief Set the density of the bubble.
- *
- * Ideally every bubble's moving track is controlled by different uniforms in BubbleEffect shaders.
- * To increase the density, 'density' number of bubbles are sharing one group of uniforms, but with random offsets between these bubbles.
- * The available density is one to nine. The default density is five.
- * By set the density bigger than one, instead of emit one bubble each time, a 'density' number of bubbles are emitted.
- * @param[in] density The density of the bubble.
- */
- void SetBubbleDensity( unsigned int density );
-
- /**
- * @brief Enable different blending mode for rendering.
- *
- * @param[in] enable If false, the default blending function for RenderableActor is used.
- */
- void SetBlendMode( bool enable );
-
- /**
- * @brief Add a bubble movement to the animation.
- *
- * @param[in] animation The animation reference.
- * By passing the animation into BubbleEmitter, the animation's duration and how many bubbles contained within this animation are freely decided in App.
- * @param[in] emitPosition The start position of the bubble movement.
- * @param[in] direction The direction used to constrain the bubble to move in an adjacent direction around it.
- * @param[in] displacement The displacement used to bound the moving distance of the bubble.
- */
- void EmitBubble( Animation& animation, const Vector2& emitPosition, const Vector2& direction, const Vector2& displacement );
-
- /**
- * @brief Start an animation to enlarge every activated bubble's size and moving speed.
- *
- * @param[in] duration The duration of the animation
- * @param[in] multiple The bubble size and moving speed will be increased gradually to multiple speed during the animation.
- */
- void StartExplosion( float duration, float multiple );
-
- /**
- * @brief Reset all the parameters controlling the bubbles after animation.
- */
- void Restore();
-
-public: // Not intended for developer use
-
- /**
- * @brief Creates a handle using the Toolkit::Internal implementation.
- *
- * @param[in] implementation The Control implementation.
- */
- DALI_INTERNAL BubbleEmitter(Internal::BubbleEmitter& implementation);
-
- /**
- * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
- *
- * @param[in] internal A pointer to the internal CustomActor.
- */
- explicit DALI_INTERNAL BubbleEmitter(Dali::Internal::CustomActor* internal);
-};
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif /* __DALI_TOOLKIT_BUBBLE_EMMITER_H__ */
// EXTERNAL INCLUDES
#include <stack>
#include <dali/public-api/actors/image-actor.h>
-#include <dali/public-api/actors/mesh-actor.h>
#include <dali/public-api/animation/active-constraint.h>
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/animation/constraints.h>
-#include <dali/public-api/geometry/mesh.h>
#include <dali/public-api/object/type-registry.h>
#include <dali/public-api/scripting/scripting.h>
#include <dali/integration-api/debug.h>
return size;
}
-/**
- * Creates a white coloured Mesh.
- */
-Mesh CreateMesh()
-{
- Vector3 white( Color::WHITE );
-
- MeshData meshData;
-
- // Create vertices with a white color (actual color is set by actor color)
- MeshData::VertexContainer vertices(4);
- vertices[ 0 ] = MeshData::Vertex( Vector3( -0.5f, -0.5f, 0.0f ), Vector2::ZERO, white );
- vertices[ 1 ] = MeshData::Vertex( Vector3( 0.5f, -0.5f, 0.0f ), Vector2::ZERO, white );
- vertices[ 2 ] = MeshData::Vertex( Vector3( -0.5f, 0.5f, 0.0f ), Vector2::ZERO, white );
- vertices[ 3 ] = MeshData::Vertex( Vector3( 0.5f, 0.5f, 0.0f ), Vector2::ZERO, white );
-
- // Specify all the faces
- MeshData::FaceIndices faces;
- faces.reserve( 6 ); // 2 triangles in Quad
- faces.push_back( 0 ); faces.push_back( 3 ); faces.push_back( 1 );
- faces.push_back( 0 ); faces.push_back( 2 ); faces.push_back( 3 );
-
- // Create the mesh data from the vertices and faces
- meshData.SetMaterial( Material::New( "ControlMaterial" ) );
- meshData.SetVertices( vertices );
- meshData.SetFaceIndices( faces );
- meshData.SetHasColor( true );
-
- return Mesh::New( meshData );
-}
/**
* Sets all the required properties for the background actor.
// Just set the actor color
background.actor.SetColor( color );
}
- else
- {
- // Create Mesh Actor
- MeshActor meshActor = MeshActor::New( CreateMesh() );
-
- SetupBackgroundActor( meshActor, Actor::Property::Scale, color );
-
- // Set the background actor before adding so that we do not inform deriving classes
- background.actor = meshActor;
- Self().Add( meshActor );
- }
background.color = color;
}
$(public_api_src_dir)/controls/control-impl.cpp \
$(public_api_src_dir)/controls/control.cpp \
$(public_api_src_dir)/controls/alignment/alignment.cpp \
- $(public_api_src_dir)/controls/bubble-effect/bubble-emitter.cpp \
$(public_api_src_dir)/controls/buttons/button.cpp \
$(public_api_src_dir)/controls/buttons/check-box-button.cpp \
$(public_api_src_dir)/controls/buttons/push-button.cpp \
$(public_api_src_dir)/focus-manager/keyboard-focus-manager.cpp \
$(public_api_src_dir)/focus-manager/keyinput-focus-manager.cpp \
$(public_api_src_dir)/markup-processor/markup-processor.cpp \
- $(public_api_src_dir)/shader-effects/bubble-effect/bubble-effect.cpp \
- $(public_api_src_dir)/shader-effects/bubble-effect/color-adjuster.cpp \
$(public_api_src_dir)/shader-effects/alpha-discard-effect.cpp \
$(public_api_src_dir)/shader-effects/bendy-effect.cpp \
$(public_api_src_dir)/shader-effects/blind-effect.cpp \
- $(public_api_src_dir)/shader-effects/bouncing-effect.cpp \
$(public_api_src_dir)/shader-effects/carousel-effect.cpp \
$(public_api_src_dir)/shader-effects/displacement-effect.cpp \
$(public_api_src_dir)/shader-effects/dissolve-effect.cpp \
public_api_bloom_view_header_files = \
$(public_api_src_dir)/controls/bloom-view/bloom-view.h
-public_api_bubble_emitter_header_files = \
- $(public_api_src_dir)/controls/bubble-effect/bubble-emitter.h
+public_api_bubble_emitter_header_files =
public_api_cluster_header_files = \
$(public_api_src_dir)/controls/cluster/cluster-style.h \
$(public_api_src_dir)/shader-effects/alpha-discard-effect.h \
$(public_api_src_dir)/shader-effects/bendy-effect.h \
$(public_api_src_dir)/shader-effects/blind-effect.h \
- $(public_api_src_dir)/shader-effects/bouncing-effect.h \
$(public_api_src_dir)/shader-effects/carousel-effect.h \
$(public_api_src_dir)/shader-effects/displacement-effect.h \
$(public_api_src_dir)/shader-effects/dissolve-effect.h \
$(public_api_src_dir)/shader-effects/swirl-effect.h \
$(public_api_src_dir)/shader-effects/water-effect.h
-public_api_bubble_effect_header_files = \
- $(public_api_src_dir)/shader-effects/bubble-effect/bubble-effect.h \
- $(public_api_src_dir)/shader-effects/bubble-effect/color-adjuster.h
+public_api_bubble_effect_header_files =
public_api_styling_header_files = \
$(public_api_src_dir)/styling/style-manager.h
+++ /dev/null
-/*
- * Copyright (c) 2014 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 <dali-toolkit/public-api/shader-effects/bouncing-effect.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace
-{
-
-#define MAKE_STRING(A)#A
-
-const std::string PROGRESS_RATE_PROPERTY_NAME( "uProgressRate" );
-
-} // namespace
-
-BouncingEffect::BouncingEffect()
-{
-}
-
-BouncingEffect::BouncingEffect( ShaderEffect handle )
-:ShaderEffect( handle )
-{
-}
-
-BouncingEffect::~BouncingEffect()
-{
-}
-
-BouncingEffect BouncingEffect::New( const Vector4& color )
-{
- std::string fragmentShader = MAKE_STRING(
- precision mediump float;\n
- uniform float uProgressRate;\n
- uniform vec4 uAssignedColor;\n
- void main()\n
- {\n
- float progressRate = abs(uProgressRate)*0.5;\n
- float amplitude = 0.15 - progressRate*0.15 ;\n
- float x1 = 7.5 * (vTexCoord.x - progressRate);\n
- float x2 = 7.5 * (vTexCoord.x - 1.0 + progressRate);\n
- float height1 = max(0.00001, 0.3 - amplitude * ( exp(x1) + exp(-x1) ) );\n
- float height2 = max(0.00001, 0.3 - amplitude * ( exp(x2) + exp(-x2) ) );\n
- float height3 = max(0.00001, 1.0 - 3.0 * amplitude * ( exp(x1*0.5) + exp(-x1*0.5) ) );\n
- float height4 = max(0.00001, 1.0 - 3.0 * amplitude * ( exp(x2*0.5) + exp(-x2*0.5) ) );\n
- vec4 fragColor = vec4(0.0);\n
- float y = vTexCoord.y/(height1+height2);\n
- float y2 = vTexCoord.y/max(height3,height4);\n
- float coef = max(height1,height2)*5.0/( 1.0+exp(y*12.0-6.0) );\n
- float alpha = pow( max(0.0,(1.0-y2))*(1.0-min(abs(x1),abs(x2))/5.0), 2.0);\n
- if( vTexCoord.y < 0.075 )\n
- {\n
- fragColor= mix(uAssignedColor, vec4(1.0), coef);\n
- fragColor += (vec4(1.0)-fragColor) * alpha;\n
- }\n
- else if (y2<1.0)\n
- {\n
- fragColor =vec4(1.0,1.0,1.0, alpha + (1.0-alpha)*coef);\n
- fragColor.rgb -= ( vec3(1.0)-uAssignedColor.rgb )*min(clamp(y*1.2-0.3, 0.0, 0.3),clamp(0.9-y*1.2,0.0,0.3));\n
- }\n
- fragColor.a *= 10.0*min(min(vTexCoord.x, 1.0-vTexCoord.x),0.1)*min(1.0, progressRate/0.2);\n
- gl_FragColor = fragColor;\n
- }
- );
-
- ShaderEffect shaderEffect;
- shaderEffect = ShaderEffect::New( "", fragmentShader,
- GeometryType( GEOMETRY_TYPE_IMAGE),
- ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING ) );
- BouncingEffect handle( shaderEffect );
-
- handle.SetUniform( "uAssignedColor", color );
- handle.SetProgressRate( 0.f );
-
- return handle;
-}
-
-void BouncingEffect::SetProgressRate( float progress )
-{
- SetUniform( PROGRESS_RATE_PROPERTY_NAME, progress );
-}
-
-const std::string& BouncingEffect::GetProgressRatePropertyName() const
-{
- return PROGRESS_RATE_PROPERTY_NAME;
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_TOOLKIT_SHADER_EFFECT_BOUNCING_H__
-#define __DALI_TOOLKIT_SHADER_EFFECT_BOUNCING_H__
-
-/*
- * Copyright (c) 2014 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 <dali/public-api/shader-effects/shader-effect.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-/**
- * @brief BouncingEffect is a custom overscroll effect with two waves appearing at two sides then moving towards center and overlapping.
- *
- * Usage Example:
- *
- * // Create the an imageActor, set shader effect, and add it to the stage
- * ImageActor imageActor = ImageActor::New( BufferImage::New( 1, 1 ) );
- * imageActor.SetSize(720.f,58.f);
- * Toolkit::BouncingEffect bouncingEffect = Toolkit::BouncingEffect::New( Vector4(0.f,1.f,1.f,0.5f) );
- * imageActor.SetShaderEffect( bouncingEffect );
- * imageActor.SetParentOrigin( ParentOrigin::CENTER );
- * Stage::GetCurrent().Add( imageActor );
- *
- * // Start the animation
- * Animation animation = Animation::New(1.f);
- * animation.AnimateTo( Property( bouncingEffect, bouncingEffect.GetProgressRatePropertyName() ),
- * 1.f, AlphaFunctions::Bounce );
- * animation.Play();
- */
-class DALI_IMPORT_API BouncingEffect : public ShaderEffect
-{
-public:
-
- /**
- * @brief Creates an empty BouncingEffect handle
- */
- BouncingEffect();
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~BouncingEffect();
-
- /**
- * @brief Create a BouncingEffect object
- *
- * @param[in] color The color used on the bouncing stripe
- * @return A handle to a newly allocated Dali resource.
- */
- static BouncingEffect New( const Vector4& color );
-
- /**
- * @brief Set the progress rate to the effect.
- *
- * The whole progress ( with progress rate from 0.0 to 1.0 ):
- * two waves appear at two sides; move towards center and overlap.
- * @param[in] progressRate The progress rate value.
- */
- void SetProgressRate( float progressRate );
-
- /**
- * @brief Get the name for the progress rate property.
- *
- * @return A std::string containing the property name.
- */
- const std::string& GetProgressRatePropertyName() const;
-
-
-private: // Not intended for application developers
- DALI_INTERNAL BouncingEffect( ShaderEffect handle );
-
-};
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // __DALI_TOOLKIT_SHADER_EFFECT_BOUNCING_H__