From: David Steele Date: Tue, 31 Mar 2015 14:44:46 +0000 (+0100) Subject: Merge branch 'tizen' into devel/new_mesh X-Git-Tag: dali_1.0.47~13^2~34 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=2ec164cd618f93ccafe17b1d0b8ff16401ed4aef;hp=7f336e4318945301ac6ecc5bcb19bdb3eb120be1 Merge branch 'tizen' into devel/new_mesh Change-Id: I1df97f4ad515536413b587eb178a5645c31dbf3a --- diff --git a/base/dali-toolkit/public-api/text/rendering/basic/text-basic-renderer.cpp b/base/dali-toolkit/public-api/text/rendering/basic/text-basic-renderer.cpp new file mode 100644 index 0000000..a291096 --- /dev/null +++ b/base/dali-toolkit/public-api/text/rendering/basic/text-basic-renderer.cpp @@ -0,0 +1,324 @@ +/* + * 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 + +// EXTERNAL INCLUDES +#include + +// INTERNAL INCLUDES +#include + +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(glyph.xOffset) / static_cast(mWidth); + coords.topLeft.y = 0.0f; + coords.topRight.x = static_cast(glyph.xOffset + glyph.width) / static_cast(mWidth); + coords.topRight.y = 0.0f; + coords.bottomLeft.x = static_cast(glyph.xOffset) / static_cast(mWidth); + coords.bottomLeft.y = static_cast(glyph.height) / static_cast(mHeight); + coords.bottomRight.x = static_cast(glyph.xOffset + glyph.width) / static_cast(mWidth); + coords.bottomRight.y = static_cast(glyph.height) / static_cast(mHeight); + } + + return atlas; + } + + void GetTextureCoordinates( FontId fontId, GlyphIndex index, TextureCoordinates& coords ) + { + for( unsigned int i=0; i 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& glyphs ) + { + AtlasHelper& helper = mAtlasHelper; + + // Clear previous atlas + helper.Reset(); + helper.Reserve( glyphs.Count() ); + + for( unsigned int i=0; i 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& glyphs, const std::vector& 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 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 glyphs; + glyphs.Resize( numberOfGlyphs ); + + view.GetGlyphs( 0, &glyphs[0], numberOfGlyphs ); + + std::vector 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; +} diff --git a/build/tizen/configure.ac b/build/tizen/configure.ac index 1e94aa3..5f027e6 100644 --- a/build/tizen/configure.ac +++ b/build/tizen/configure.ac @@ -57,8 +57,8 @@ AC_ARG_ENABLE([javascript], [AC_HELP_STRING([--enable-javascript], [Enable JavaScript plugin])] , [enable_javascript=$enableval], - [enable_javascript=automatic]) - + [enable_javascript=no]) +#TODO MESH_REWORK Change default back to automatic if test "x$enable_debug" = "xyes"; then DALI_TOOLKIT_CFLAGS="$DALI_TOOLKIT_CFLAGS -DDEBUG_ENABLED" diff --git a/dali-toolkit/dali-toolkit.h b/dali-toolkit/dali-toolkit.h index ea7bec4..8e4120f 100644 --- a/dali-toolkit/dali-toolkit.h +++ b/dali-toolkit/dali-toolkit.h @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -90,7 +89,6 @@ #include #include #include -#include #include #include #include @@ -104,8 +102,6 @@ #include #include #include -#include -#include #include #include #include diff --git a/dali-toolkit/internal/builder/builder-animations.cpp b/dali-toolkit/internal/builder/builder-animations.cpp index c1c8921..794b62a 100644 --- a/dali-toolkit/internal/builder/builder-animations.cpp +++ b/dali-toolkit/internal/builder/builder-animations.cpp @@ -241,13 +241,13 @@ Animation CreateAnimation( const TreeNode& child, const Replacement& constant, D // to allow animating shader uniforms if( propIndex == Property::INVALID_INDEX ) { - RenderableActor renderable = RenderableActor::DownCast( targetHandle ); - if( renderable ) + ImageActor imageActor = ImageActor::DownCast( targetHandle ); + if( imageActor ) { // A limitation here is that its possible that between creation of animation // and running it the ShaderEffect of the actor has been changed. // However this is a unlikely use case especially when using scripts. - if( ShaderEffect effect = renderable.GetShaderEffect() ) + if( ShaderEffect effect = imageActor.GetShaderEffect() ) { propIndex = effect.GetPropertyIndex( *property ); if(propIndex != Property::INVALID_INDEX) @@ -438,4 +438,3 @@ Animation CreateAnimation( const TreeNode& child, Builder* const builder ) } // namespace Toolkit } // namespace Dali - diff --git a/dali-toolkit/internal/builder/builder-impl.cpp b/dali-toolkit/internal/builder/builder-impl.cpp index 8ca0281..5386db9 100644 --- a/dali-toolkit/internal/builder/builder-impl.cpp +++ b/dali-toolkit/internal/builder/builder-impl.cpp @@ -273,7 +273,7 @@ void Builder::SetProperties( const TreeNode& node, Handle& handle, const Replace // special field 'effect' references the shader effect instances if(key == "effect") { - RenderableActor actor = RenderableActor::DownCast(handle); + ImageActor actor = ImageActor::DownCast(handle); if( actor ) { OptionalString str = constant.IsString( keyChild.second ); @@ -297,7 +297,7 @@ void Builder::SetProperties( const TreeNode& node, Handle& handle, const Replace if( Property::INVALID_INDEX == index ) { - RenderableActor actor = RenderableActor::DownCast(handle); + ImageActor actor = ImageActor::DownCast(handle); if( actor ) { if( ShaderEffect effect = actor.GetShaderEffect() ) diff --git a/dali-toolkit/internal/controls/bubble-effect/bubble-emitter-impl.cpp b/dali-toolkit/internal/controls/bubble-effect/bubble-emitter-impl.cpp deleted file mode 100644 index 1306475..0000000 --- a/dali-toolkit/internal/controls/bubble-effect/bubble-emitter-impl.cpp +++ /dev/null @@ -1,412 +0,0 @@ -/* - * 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 -#include -#include -#include - -// INTERNAL INCLUDES -#include - -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 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( 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(displacement.x) - halfRange, rand()%static_cast(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(displacement.x) - halfRange, -rand()%static_cast(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 diff --git a/dali-toolkit/internal/controls/bubble-effect/bubble-emitter-impl.h b/dali-toolkit/internal/controls/bubble-effect/bubble-emitter-impl.h deleted file mode 100644 index 3ae36a1..0000000 --- a/dali-toolkit/internal/controls/bubble-effect/bubble-emitter-impl.h +++ /dev/null @@ -1,257 +0,0 @@ -#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 -#include -#include -#include -#include -#include -#include - -// INTERNAL INCLUDES -#include -#include -#include - -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; /// mMesh; ///< The mesh vector, each mesh is used to create a meshActor which applies a BubbleEffect. - std::vector 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 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(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(handle); -} - -} // namespace Toolkit - -} // namespace Dali - -#endif /* __DALI_TOOLKIT_INTERNAL_BUBBLE_EMITTER_IMPL_H__ */ diff --git a/dali-toolkit/internal/controls/scrollable/bouncing-effect-actor.cpp b/dali-toolkit/internal/controls/scrollable/bouncing-effect-actor.cpp deleted file mode 100644 index 86ade19..0000000 --- a/dali-toolkit/internal/controls/scrollable/bouncing-effect-actor.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/* - * 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 - -// EXTERNAL INCLUDES -#include -#include -#include -#include -#include -#include -#include - -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( 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( mesh.GetPropertyIndex(j+2, AnimatableVertex::Property::POSITION ), - Source(meshActor, bouncePropertyIndex), - VertexPositionConstraint(-0.5f, LAYER_HEIGHTS[i]) ) ); - mesh.ApplyConstraint( Constraint::New( mesh.GetPropertyIndex(j+3, AnimatableVertex::Property::POSITION), - Source(meshActor, bouncePropertyIndex), - VertexPositionConstraint(-0.5f, LAYER_HEIGHTS[i]) ) ); - } - - return meshActor; -} - -} // namespace Internal - -} // namespace Toolkit - -} // namespace Dali diff --git a/dali-toolkit/internal/controls/scrollable/bouncing-effect-actor.h b/dali-toolkit/internal/controls/scrollable/bouncing-effect-actor.h deleted file mode 100644 index 0fd1b69..0000000 --- a/dali-toolkit/internal/controls/scrollable/bouncing-effect-actor.h +++ /dev/null @@ -1,69 +0,0 @@ -#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 -#include - -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__ */ diff --git a/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp b/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp index f9b3281..f27dc2f 100644 --- a/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp +++ b/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp @@ -32,7 +32,6 @@ // INTERNAL INCLUDES #include -#include #include using std::string; @@ -1558,12 +1557,6 @@ void ItemView::SetOvershootEnabled( bool enable ) 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( Actor::Property::SIZE, ParentSource( mPropertyScrollDirection ), diff --git a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-overshoot-indicator-impl.cpp b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-overshoot-indicator-impl.cpp index b02d3fc..3a9d9b9 100644 --- a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-overshoot-indicator-impl.cpp +++ b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-overshoot-indicator-impl.cpp @@ -23,7 +23,6 @@ // INTERNAL INCLUDES #include -#include #include using namespace Dali; @@ -146,12 +145,6 @@ ScrollOvershootEffectRipple::ScrollOvershootEffectRipple( bool vertical, Scrolla 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); } @@ -161,35 +154,17 @@ void ScrollOvershootEffectRipple::Apply() 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() @@ -236,59 +211,10 @@ 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.SetOrientation(Quaternion(0.0f, Vector3::ZAXIS)); - mOvershootOverlay.SetSize(parentSize.width, GetBounceActorHeight(parentSize.width), size.depth); - } - else - { - mOvershootOverlay.SetOrientation(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.SetOrientation(Quaternion(Math::PI, Vector3::ZAXIS)); - mOvershootOverlay.SetSize(parentSize.width, GetBounceActorHeight(parentSize.width), size.depth); - relativeOffset = Vector3(1.0f, 1.0f, 0.0f); - } - else - { - mOvershootOverlay.SetOrientation(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) @@ -301,60 +227,6 @@ void ScrollOvershootEffectRipple::OnOvershootNotification(PropertyNotification& 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(Toolkit::Scrollable::Property::OVERSHOOT_ANIMATION_SPEED); - - if( animate && overshootAnimationSpeed > Math::MACHINE_EPSILON_0 ) - { - float currentOvershoot = fabsf( mOvershootOverlay.GetProperty( mEffectOvershootProperty ).Get() ); - 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) @@ -362,8 +234,6 @@ void ScrollOvershootEffectRipple::OnOvershootAnimFinished(Animation& animation) bool animateOff = false; if( mAnimationStateFlags & AnimatingOut ) { - // should now be offscreen - mOvershootOverlay.SetVisible(false); } if( (mAnimationStateFlags & AnimateBack) ) { diff --git a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-overshoot-indicator-impl.h b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-overshoot-indicator-impl.h index f19e39c..8591f44 100644 --- a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-overshoot-indicator-impl.h +++ b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-overshoot-indicator-impl.h @@ -249,7 +249,6 @@ public: 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 diff --git a/dali-toolkit/internal/controls/text-input/text-input-decorator-impl.cpp b/dali-toolkit/internal/controls/text-input/text-input-decorator-impl.cpp index 25d30d1..b134d6c 100644 --- a/dali-toolkit/internal/controls/text-input/text-input-decorator-impl.cpp +++ b/dali-toolkit/internal/controls/text-input/text-input-decorator-impl.cpp @@ -580,30 +580,14 @@ void Decorator::CreateHighlight( Actor parent ) { DALI_ASSERT_DEBUG( parent && "Highlight target parent does not exist" ); - if ( !mHighlightMeshActor ) - { - mHighlightMeshActor = MeshActor::New( mTextHighlight.CreateHighLightMesh() ); - mHighlightMeshActor.SetName( "HighlightMeshActor" ); - parent.Add( mHighlightMeshActor ); - } } void Decorator::RemoveHighlight() { - if ( mHighlightMeshActor ) - { - mHighlightMeshActor.Unparent(); - mHighlightMeshActor.Reset(); - // NOTE: We cannot dereference mHighlightMesh, due to a how the scene-graph MeshRenderer uses the Mesh data. - } } void Decorator::HighlightVisibility( bool visiblility ) { - if ( mHighlightMeshActor ) - { - mHighlightMeshActor.SetVisible( visiblility ); - } } /** @@ -790,11 +774,6 @@ void Decorator::ShowPopUp() DALI_ASSERT_DEBUG( mPopUpTarget && "PopUp Target Actor does not exist" ); - if( mHighlightMeshActor ) // Text Selection mode - { - position = PositionOfPopUpRelativeToSelectionHandles(); - } - else // Not in Text Selection mode so position relative to cursor. { position = PositionOfPopUpRelativeToCursor(); } @@ -818,7 +797,7 @@ void Decorator::ShowPopupCutCopyPaste() { bool isAllTextSelectedAlready = ( mTextViewCharacterPositioning.StyledTextSize() == GetSelectedText().size() ); bool isTextEmpty = mTextViewCharacterPositioning.IsStyledTextEmpty() ; - bool isSubsetOfTextAlreadySelected = ( !isAllTextSelectedAlready ) && mHighlightMeshActor; + bool isSubsetOfTextAlreadySelected = ( !isAllTextSelectedAlready ) &&false; Clipboard clipboard = Clipboard::Get(); bool hasClipboardGotContent = clipboard.NumberOfItems(); @@ -845,11 +824,6 @@ void Decorator::PopUpLeavesVerticalBoundary( PropertyNotification& source) { Vector3 position, alternativePosition; - if( mHighlightMeshActor ) // Text Selection mode - { - alternativePosition = AlternatePopUpPositionRelativeToSelectionHandles(); - } - else // Not in Text Selection mode { alternativePosition = AlternatePopUpPositionRelativeToCursor(); // if can't be positioned above, then position below row. @@ -947,11 +921,6 @@ void Decorator::TextViewScrolled( Toolkit::TextView textView, Vector2 scrollPosi PositionSelectionHandle( selectionHandleOne, mSelectionHandleOneActualPosition, mSelectionHandleOnePosition ); PositionSelectionHandle( selectionHandleTwo, mSelectionHandleTwoActualPosition, mSelectionHandleTwoPosition ); - if( mHighlightMeshActor ) - { - mHighlightMeshActor.SetVisible( true ); - ShowUpdatedHighlight(); - } } } @@ -1061,17 +1030,6 @@ MarkupProcessor::StyledTextArray Decorator::GetSelectedText() { MarkupProcessor::StyledTextArray currentSelectedText; - if ( mHighlightMeshActor ) // Text Selected - { - MarkupProcessor::StyledTextArray::iterator it = mTextViewCharacterPositioning.GetStyledTextArray().begin() + std::min(mSelectionHandleOnePosition, mSelectionHandleTwoPosition); - MarkupProcessor::StyledTextArray::iterator end = mTextViewCharacterPositioning.GetStyledTextArray().begin() + std::max(mSelectionHandleOnePosition, mSelectionHandleTwoPosition); - - for(; it != end; ++it) - { - MarkupProcessor::StyledText& styledText( *it ); - currentSelectedText.push_back( styledText ); - } - } return currentSelectedText; } diff --git a/dali-toolkit/internal/controls/text-input/text-input-decorator-impl.h b/dali-toolkit/internal/controls/text-input/text-input-decorator-impl.h index 7de78bf..46a03e6 100644 --- a/dali-toolkit/internal/controls/text-input/text-input-decorator-impl.h +++ b/dali-toolkit/internal/controls/text-input/text-input-decorator-impl.h @@ -20,11 +20,9 @@ // EXTERNAL INCLUDES #include -#include #include #include #include -#include #include // INTERNAL INCLUDES @@ -609,7 +607,6 @@ private: Timer mScrollTimer; // Timer to scroll text over a period of time not all in one update. TextHighlight mTextHighlight; // Holds data required to construct the highlight - MeshActor mHighlightMeshActor; // Mesh Actor to display highlight PanGestureDetector mPanGestureDetector; diff --git a/dali-toolkit/internal/controls/text-input/text-input-impl.cpp b/dali-toolkit/internal/controls/text-input/text-input-impl.cpp index 304e560..c73804e 100644 --- a/dali-toolkit/internal/controls/text-input/text-input-impl.cpp +++ b/dali-toolkit/internal/controls/text-input/text-input-impl.cpp @@ -511,11 +511,6 @@ std::size_t TextInput::GetNumberOfCharacters() const void TextInput::SetMaterialDiffuseColor( const Vector4& color ) { mMaterialColor = color; - if ( mCustomMaterial ) - { - mCustomMaterial.SetDiffuseColor( mMaterialColor ); - mMeshData.SetMaterial( mCustomMaterial ); - } } const Vector4& TextInput::GetMaterialDiffuseColor() const @@ -674,7 +669,7 @@ bool TextInput::IsTextSelectable() const bool TextInput::IsTextSelected() const { - return mHighlightMeshActor; + return false; } void TextInput::DeSelectText() @@ -1514,10 +1509,6 @@ void TextInput::OnLongPress(Dali::Actor actor, const Dali::LongPressGesture& lon DALI_LOG_INFO( gLogFilter, Debug::General, "OnLongPress\n" ); // Ignore longpress if in selection mode already - if( mHighlightMeshActor ) - { - return; - } if(longPress.state == Dali::Gesture::Started) { @@ -1685,10 +1676,6 @@ void TextInput::OnPopupHideFinished(TextInputPopup& popup) popup.HideFinishedSignal().Disconnect( this, &TextInput::OnPopupHideFinished ); // Change Popup menu to Cut/Copy/Paste if text has been selected. - if(mHighlightMeshActor && mState == StateEdit) - { - ShowPopupCutCopyPaste(); - } } //FIXME this routine needs to be re-written as it contains too many branches. @@ -1753,11 +1740,6 @@ bool TextInput::OnKeyDownEvent(const KeyEvent& event) } // Return else if ( keyName == "space" ) { - if ( mHighlightMeshActor ) - { - // Some text is selected so erase it before adding space. - DeleteHighlightedText( true ); - } mCursorPosition = mCursorPosition + InsertAt(Text(keyString), mCursorPosition, 0); @@ -1772,13 +1754,6 @@ bool TextInput::OnKeyDownEvent(const KeyEvent& event) } // space else if (keyName == "BackSpace") { - if ( mHighlightMeshActor ) - { - // Some text is selected so erase it - DeleteHighlightedText( true ); - update = true; - } - else { if ( mCursorPosition > 0 ) { @@ -1984,11 +1959,6 @@ void TextInput::OnTextViewScrolled( Toolkit::TextView textView, Vector2 scrollPo mSelectionHandleOne.SetPosition( mSelectionHandleOneActualPosition + UI_OFFSET + mSelectionHandleOneOffset ); mSelectionHandleTwo.SetPosition( mSelectionHandleTwoActualPosition + UI_OFFSET + mSelectionHandleTwoOffset ); - if( mHighlightMeshActor ) - { - mHighlightMeshActor.SetVisible( true ); - UpdateHighlight(); - } } } @@ -2241,11 +2211,6 @@ ImfManager::ImfCallbackData TextInput::ImfEventReceived( Dali::ImfManager& imfMa mIgnoreFirstCommitFlag = false; // Some text may be selected, hiding keyboard causes an empty predictive string to be sent, we don't want to delete highlight in this case - if ( mHighlightMeshActor && (!imfEvent.predictiveString.empty()) ) - { - // replaces highlighted text with new character - DeleteHighlightedText( false ); - } preeditResetRequired = PreEditReceived( imfEvent.predictiveString, imfEvent.cursorOffset ); @@ -2272,11 +2237,6 @@ ImfManager::ImfCallbackData TextInput::ImfEventReceived( Dali::ImfManager& imfMa // A Commit message is a word that has been accepted, it may have been a pre-edit word previously but now commited. // Some text may be selected, hiding keyboard causes an empty predictive string to be sent, we don't want to delete highlight in this case - if ( mHighlightMeshActor && (!imfEvent.predictiveString.empty()) ) - { - // replaces highlighted text with new character - DeleteHighlightedText( false ); - } // A PreEditReset can cause a commit message to be sent, the Ignore Commit flag is used in scenarios where the word is // not needed, one such scenario is when the pre-edit word is too long to fit. @@ -2312,13 +2272,6 @@ ImfManager::ImfCallbackData TextInput::ImfEventReceived( Dali::ImfManager& imfMa std::size_t toDelete = 0; std::size_t numberOfCharacters = 0; - if( mHighlightMeshActor ) - { - // delete highlighted text. - toDelete = std::min( mSelectionHandleOnePosition, mSelectionHandleTwoPosition ); - numberOfCharacters = std::max( mSelectionHandleOnePosition, mSelectionHandleTwoPosition ) - toDelete; - } - else { if( static_cast(std::abs( imfEvent.cursorOffset )) < mCursorPosition ) { @@ -2348,7 +2301,7 @@ ImfManager::ImfCallbackData TextInput::ImfEventReceived( Dali::ImfManager& imfMa { // If text is selected/highlighted and surrounding text received we do not want the keyboard to store the word at cursor and return it as a predictive word along with // the next key pressed. Instead the Select function sets the cursor position and surrounding text. - if (! ( mHighlightMeshActor || mSelectingText ) ) + if (! ( false || mSelectingText ) ) { std::string text( GetText() ); DALI_LOG_INFO( gLogFilter, Debug::General, "OnKey - surrounding text - set text [%s] and cursor[%u] \n", text.c_str(), mCursorPosition ); @@ -2633,78 +2586,6 @@ void TextInput::DeleteHighlightedText( bool inheritStyle ) { DALI_LOG_INFO( gLogFilter, Debug::General, "DeleteHighlightedText handlePosOne[%u] handlePosTwo[%u]\n", mSelectionHandleOnePosition, mSelectionHandleTwoPosition); - if( mHighlightMeshActor ) - { - mCursorPosition = std::min( mSelectionHandleOnePosition, mSelectionHandleTwoPosition ); - - MarkupProcessor::StyledTextArray::iterator start = mStyledText.begin() + mCursorPosition; - MarkupProcessor::StyledTextArray::iterator end = mStyledText.begin() + std::max( mSelectionHandleOnePosition, mSelectionHandleTwoPosition ); - - // Get the styled text of the characters to be deleted as it may be needed if - // the "exceed the text-input's boundaries" option is disabled. - MarkupProcessor::StyledTextArray styledCharactersToDelete; - - styledCharactersToDelete.insert( styledCharactersToDelete.begin(), start, end ); - - mStyledText.erase( start, end ); // erase range of characters - - // Remove text from TextView and update place holder text if required - - // Set the placeholder text only if the styled text is empty. - if( mStyledText.empty() ) - { - ShowPlaceholderText( mStyledPlaceHolderText ); - } - else - { - const std::size_t numberOfCharacters = std::max( mSelectionHandleOnePosition, mSelectionHandleTwoPosition ) - mCursorPosition; - - mDisplayedTextView.RemoveTextFrom( mCursorPosition, numberOfCharacters ); - - // It may happen than after removing a white space or a new line character, - // two words merge, this new word could be big enough to not fit in its - // current line, so moved to the next one, and make some part of the text to - // exceed the text-input's boundary. - if( !mExceedEnabled ) - { - // Get the new text layout after removing some characters. - mDisplayedTextView.GetTextLayoutInfo( mTextLayoutInfo ); - - // Get text-input's size. - const Vector3& size = GetControlSize(); - - if( ( mTextLayoutInfo.mTextSize.width > size.width ) || - ( mTextLayoutInfo.mTextSize.height > size.height ) ) - { - mDisplayedTextView.InsertTextAt( mCursorPosition, styledCharactersToDelete ); - - mStyledText.insert( mStyledText.begin() + mCursorPosition, - styledCharactersToDelete.begin(), - styledCharactersToDelete.end() ); - } - } - } - GetTextLayoutInfo(); - - RemoveHighlight(); - - EmitTextModified(); - - if( inheritStyle ) - { - const TextStyle oldInputStyle( mInputStyle ); - - mInputStyle = GetStyleAtCursor(); // Inherit style from cursor position - - if( oldInputStyle != mInputStyle ) - { - // Updates the line height accordingly with the input style. - UpdateLineHeight(); - - EmitStyleChangedSignal(); - } - } - } } void TextInput::DeleteRange( const std::size_t start, const std::size_t ncharacters ) @@ -2723,29 +2604,6 @@ void TextInput::DeleteRange( const std::size_t start, const std::size_t ncharact mStyledText.erase(itStart, itEnd); // update the selection handles if they are visible. - if( mHighlightMeshActor ) - { - std::size_t& minHandle = ( mSelectionHandleOnePosition <= mSelectionHandleTwoPosition ? mSelectionHandleOnePosition : mSelectionHandleTwoPosition ); - std::size_t& maxHandle = ( mSelectionHandleTwoPosition > mSelectionHandleOnePosition ? mSelectionHandleTwoPosition : mSelectionHandleOnePosition ); - - if( minHandle >= start + ncharacters ) - { - minHandle -= ncharacters; - } - else if( ( minHandle > start ) && ( minHandle < start + ncharacters ) ) - { - minHandle = start; - } - - if( maxHandle >= start + ncharacters ) - { - maxHandle -= ncharacters; - } - else if( ( maxHandle > start ) && ( maxHandle < start + ncharacters ) ) - { - maxHandle = start; - } - } // Set text is not called here as currently it can not process the set text from deletion and then the set text from the in-coming pre-edit. } @@ -3754,74 +3612,6 @@ void TextInput::UpdateHighlight() // 9* *7 // - if ( mHighlightMeshActor ) - { - // vertex and triangle buffers should always be present if MeshActor is alive. - HighlightInfo newHighlightInfo = CalculateHighlightInfoRtl(); - MeshData::VertexContainer vertices; - Dali::MeshData::FaceIndices faceIndices; - - if( !newHighlightInfo.mQuadList.empty() ) - { - std::vector::iterator iter = newHighlightInfo.mQuadList.begin(); - std::vector::iterator endIter = newHighlightInfo.mQuadList.end(); - - // vertex position defaults to (0 0 0) - MeshData::Vertex vertex; - // set normal for all vertices as (0 0 1) pointing outward from TextInput Actor. - vertex.nZ = 1.0f; - - for(std::size_t v = 0; iter != endIter; ++iter,v+=4 ) - { - // Add each quad geometry (a sub-selection) to the mesh data. - - // 0-----1 - // |\ | - // | \ A | - // | \ | - // | B \ | - // | \| - // 2-----3 - - QuadCoordinates& quad = *iter; - // top-left (v+0) - vertex.x = quad.min.x; - vertex.y = quad.min.y; - vertices.push_back( vertex ); - - // top-right (v+1) - vertex.x = quad.max.x; - vertex.y = quad.min.y; - vertices.push_back( vertex ); - - // bottom-left (v+2) - vertex.x = quad.min.x; - vertex.y = quad.max.y; - vertices.push_back( vertex ); - - // bottom-right (v+3) - vertex.x = quad.max.x; - vertex.y = quad.max.y; - vertices.push_back( vertex ); - - // triangle A (3, 1, 0) - faceIndices.push_back( v + 3 ); - faceIndices.push_back( v + 1 ); - faceIndices.push_back( v ); - - // triangle B (0, 2, 3) - faceIndices.push_back( v ); - faceIndices.push_back( v + 2 ); - faceIndices.push_back( v + 3 ); - - mMeshData.SetFaceIndices( faceIndices ); - } - - BoneContainer bones(0); // passed empty as bones not required - mMeshData.SetData( vertices, faceIndices, bones, mCustomMaterial ); - mHighlightMesh.UpdateMeshData(mMeshData); - } - } } void TextInput::ClearPopup() @@ -3893,7 +3683,7 @@ void TextInput::ShowPopup( bool animate ) Vector3 position; Vector2 alternativePopupPosition; - if(mHighlightMeshActor && mState == StateEdit) + if(false && mState == StateEdit) { Vector3 topHandle; Vector3 bottomHandle; // referring to the bottom most point of the handle or the bottom line of selection. @@ -4686,7 +4476,7 @@ void TextInput::OnStageTouched(const TouchEvent& event) bool textInputTouched = (touchedActor && WasTouchedCheck( touchedActor )); - if ( ( mHighlightMeshActor || popUpShown ) && !textInputTouched ) + if ( ( false || popUpShown ) && !textInputTouched ) { EndMonitoringStageForTouch(); HidePopup( true, false ); @@ -4814,7 +4604,7 @@ void TextInput::RemoveHighlight( bool hidePopup ) { DALI_LOG_INFO(gLogFilter, Debug::General, "RemoveHighlight\n"); - if ( mHighlightMeshActor ) + if ( false ) { if ( mSelectionHandleOne ) { @@ -4831,12 +4621,10 @@ void TextInput::RemoveHighlight( bool hidePopup ) mNewHighlightInfo.mQuadList.clear(); - Self().Remove( mHighlightMeshActor ); SetCursorVisibility( true ); StartCursorBlinkTimer(); - mHighlightMeshActor.Reset(); // NOTE: We cannot dereference mHighlightMesh, due // to a bug in how the scene-graph MeshRenderer uses the Mesh data incorrectly. @@ -4852,26 +4640,6 @@ void TextInput::RemoveHighlight( bool hidePopup ) void TextInput::CreateHighlight() { - if ( !mHighlightMeshActor ) - { - mMeshData = MeshData( ); - mMeshData.SetHasNormals( true ); - - mCustomMaterial = Material::New("CustomMaterial"); - mCustomMaterial.SetDiffuseColor( mMaterialColor ); - - mMeshData.SetMaterial( mCustomMaterial ); - - mHighlightMesh = Mesh::New( mMeshData ); - - mHighlightMeshActor = MeshActor::New( mHighlightMesh ); - mHighlightMeshActor.SetName( "HighlightMeshActor" ); - mHighlightMeshActor.SetParentOrigin( ParentOrigin::TOP_LEFT ); - mHighlightMeshActor.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - mHighlightMeshActor.SetPosition( 0.0f, 0.0f, DISPLAYED_HIGHLIGHT_Z_OFFSET ); - - Self().Add(mHighlightMeshActor); - } } @@ -4899,7 +4667,7 @@ void TextInput::PasteText( const Text& text ) // Any key stroke that results in a visual change of the text-input should // set this flag to true. bool update = false; - if( mHighlightMeshActor ) + if( false ) { /* if highlighted, delete entire text, and position cursor at start of deleted text. */ mCursorPosition = std::min(mSelectionHandleOnePosition, mSelectionHandleTwoPosition); @@ -5095,10 +4863,6 @@ void TextInput::SetScrollEnabled( bool enable ) mSelectionHandleOne.SetVisible( true ); mSelectionHandleTwo.SetVisible( true ); - if( mHighlightMeshActor ) - { - mHighlightMeshActor.SetVisible( true ); - } } } } diff --git a/dali-toolkit/internal/controls/text-input/text-input-impl.h b/dali-toolkit/internal/controls/text-input/text-input-impl.h index 66bf9ad..6dfe840 100644 --- a/dali-toolkit/internal/controls/text-input/text-input-impl.h +++ b/dali-toolkit/internal/controls/text-input/text-input-impl.h @@ -19,13 +19,11 @@ */ // EXTERNAL INCLUDES -#include #include #include #include #include #include -#include // INTERNAL INCLUDES #include @@ -1462,10 +1460,6 @@ private: Actor mHandleOneGrabArea; ///< invisible actor that receives pans events for the selection handle. Actor mHandleTwoGrabArea; ///< invisible actor that receives pans events for the selection handle. - Mesh mHighlightMesh; ///< Mesh Data for highlight - MeshActor mHighlightMeshActor; ///< Mesh Actor to display highlight - MeshData mMeshData; ///< Container to hold meshData for highlight - Material mCustomMaterial; ///< Custom material used for highlight HighlightInfo mNewHighlightInfo; ///< Geometry info to create highlight. Text mPreEditString; ///< Holds current input string prior to it being committed. diff --git a/dali-toolkit/internal/controls/text-input/text-input-text-highlight-impl.cpp b/dali-toolkit/internal/controls/text-input/text-input-text-highlight-impl.cpp index 7475678..2659f48 100644 --- a/dali-toolkit/internal/controls/text-input/text-input-text-highlight-impl.cpp +++ b/dali-toolkit/internal/controls/text-input/text-input-text-highlight-impl.cpp @@ -252,110 +252,10 @@ TextHighlight::HighlightInfo TextHighlight::CalculateHighlightInfo( std::size_t void TextHighlight::UpdateHighlight( TextHighlight::HighlightInfo& newHighlightInfo ) { -// Construct a Mesh with a texture to be used as the highlight 'box' for selected text -// -// Example scenarios where mesh is made from 3, 1, 2, 2 ,3 or 3 quads. -// -// [ TOP ] [ TOP ] [TOP ] [ TOP ] [ TOP ] [ TOP ] -// [ MIDDLE ] [BOTTOM] [BOTTOM] [ MIDDLE ] [ MIDDLE ] -// [ BOTTOM] [ MIDDLE ] [ MIDDLE ] -// [BOTTOM] [ MIDDLE ] -// [BOTTOM] -// -// Each quad is created as 2 triangles. -// Middle is just 1 quad regardless of its size. -// -// (0,0) (0,0) -// 0* *2 0* *2 -// TOP TOP -// 3* *1 3* *1 -// 4* *1 4* *6 -// MIDDLE BOTTOM -// 6* *5 7* *5 -// 6* *8 -// BOTTOM -// 9* *7 -// - - // vertex and triangle buffers should always be present if MeshActor is alive. - //HighlightInfo newHighlightInfo = CalculateHighlightInfo( handlePositionStart, handlePositionEnd ); - MeshData::VertexContainer vertices; - Dali::MeshData::FaceIndices faceIndices; - - if( !newHighlightInfo.mQuadList.empty() ) - { - std::vector::iterator iter = newHighlightInfo.mQuadList.begin(); - std::vector::iterator endIter = newHighlightInfo.mQuadList.end(); - - // vertex position defaults to (0 0 0) - MeshData::Vertex vertex; - // set normal for all vertices as (0 0 1) pointing outward from TextInput Actor. - vertex.nZ = 1.0f; - - for(std::size_t v = 0; iter != endIter; ++iter,v+=4 ) - { - // Add each quad geometry (a sub-selection) to the mesh data. - - // 0-----1 - // |\ | - // | \ A | - // | \ | - // | B \ | - // | \| - // 2-----3 - - QuadCoordinates& quad = *iter; - // top-left (v+0) - vertex.x = quad.min.x; - vertex.y = quad.min.y; - vertices.push_back( vertex ); - - // top-right (v+1) - vertex.x = quad.max.x; - vertex.y = quad.min.y; - vertices.push_back( vertex ); - - // bottom-left (v+2) - vertex.x = quad.min.x; - vertex.y = quad.max.y; - vertices.push_back( vertex ); - - // bottom-right (v+3) - vertex.x = quad.max.x; - vertex.y = quad.max.y; - vertices.push_back( vertex ); - - // triangle A (3, 1, 0) - faceIndices.push_back( v + 3 ); - faceIndices.push_back( v + 1 ); - faceIndices.push_back( v ); - - // triangle B (0, 2, 3) - faceIndices.push_back( v ); - faceIndices.push_back( v + 2 ); - faceIndices.push_back( v + 3 ); - } - - mMeshData.SetVertices( vertices ); - mMeshData.SetFaceIndices( faceIndices ); - - mHighlightMesh.UpdateMeshData(mMeshData); - } } -Mesh TextHighlight::CreateHighLightMesh() +void TextHighlight::CreateHighLightMesh() { - mMeshData = MeshData( ); - mMeshData.SetHasNormals( true ); - - mCustomMaterial = Material::New("CustomMaterial"); - mCustomMaterial.SetDiffuseColor( LIGHTBLUE ); - - mMeshData.SetMaterial( mCustomMaterial ); - - mHighlightMesh = Mesh::New( mMeshData ); - - return mHighlightMesh; } void TextHighlight::HighlightInfo::AddQuad( float x1, float y1, float x2, float y2 ) diff --git a/dali-toolkit/internal/controls/text-input/text-input-text-highlight-impl.h b/dali-toolkit/internal/controls/text-input/text-input-text-highlight-impl.h index 74a3421..8fdbcd9 100644 --- a/dali-toolkit/internal/controls/text-input/text-input-text-highlight-impl.h +++ b/dali-toolkit/internal/controls/text-input/text-input-text-highlight-impl.h @@ -18,10 +18,6 @@ * */ -// EXTERNAL INCLUDES -#include -#include - // INTERNAL INCLUDES #include #include @@ -141,7 +137,7 @@ public: /** * Creates the Mesh data needed by the Mesh Actor */ - Mesh CreateHighLightMesh(); + void CreateHighLightMesh(); private: @@ -163,9 +159,6 @@ private: TextViewCharacterPositioning& mTextViewCharacterPositioning; - Mesh mHighlightMesh; ///< Mesh Data for highlight - MeshData mMeshData; ///< Container to hold meshData for highlight - Material mCustomMaterial; ///< Custom material used for highlight HighlightInfo mNewHighlightInfo; ///< Geometry info to create highlight. }; diff --git a/dali-toolkit/internal/controls/text-view/relayout-utilities.cpp b/dali-toolkit/internal/controls/text-view/relayout-utilities.cpp index 33983d8..54761fb 100644 --- a/dali-toolkit/internal/controls/text-view/relayout-utilities.cpp +++ b/dali-toolkit/internal/controls/text-view/relayout-utilities.cpp @@ -242,10 +242,10 @@ void SetVisualParameters( CurrentTextActorInfo& currentTextActorInfo, relayoutData.mTextLayoutInfo.mMaxItalicsOffset = std::max( relayoutData.mTextLayoutInfo.mMaxItalicsOffset, italicsOffset ); // Sets the sort modifier value. - currentTextActorInfo.textActor.SetSortModifier( visualParameters.mSortModifier ); + // currentTextActorInfo.textActor.SetSortModifier( visualParameters.mSortModifier ); // Enables or disables the blending. - currentTextActorInfo.textActor.SetBlendMode( !visualParameters.mSnapshotModeEnabled ? BlendingMode::ON : BlendingMode::OFF ); + // currentTextActorInfo.textActor.SetBlendMode( !visualParameters.mSnapshotModeEnabled ? BlendingMode::ON : BlendingMode::OFF ); } void CalculateLineLayout( float parentWidth, @@ -1895,7 +1895,7 @@ void CreateEmoticon( const TextView::VisualParameters& visualParameters, imageActor.SetSize( characterLayout.mSize ); // Sets the sort modifier value. - imageActor.SetSortModifier( visualParameters.mSortModifier ); + // imageActor.SetSortModifier( visualParameters.mSortModifier ); characterLayout.mGlyphActor = imageActor; } @@ -2249,10 +2249,10 @@ void UpdateTextActorInfo( const TextView::VisualParameters& visualParameters, glyphActor.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT ); // Sets the sort modifier value. - glyphActor.SetSortModifier( visualParameters.mSortModifier ); + // glyphActor.SetSortModifier( visualParameters.mSortModifier ); // Enables or disables the blending. - glyphActor.SetBlendMode( !visualParameters.mSnapshotModeEnabled ? BlendingMode::ON : BlendingMode::OFF ); + // glyphActor.SetBlendMode( !visualParameters.mSnapshotModeEnabled ? BlendingMode::ON : BlendingMode::OFF ); } } diff --git a/dali-toolkit/internal/controls/text-view/text-view-impl.cpp b/dali-toolkit/internal/controls/text-view/text-view-impl.cpp index 4278d4b..a5b28ef 100644 --- a/dali-toolkit/internal/controls/text-view/text-view-impl.cpp +++ b/dali-toolkit/internal/controls/text-view/text-view-impl.cpp @@ -725,12 +725,12 @@ void TextView::SetSortModifier( float depthOffset ) it != endIt; ++it ) { - ( *it ).SetSortModifier( depthOffset ); + // ( *it ).SetSortModifier( depthOffset ); } if( mOffscreenImageActor ) { - mOffscreenImageActor.SetSortModifier( depthOffset ); + // mOffscreenImageActor.SetSortModifier( depthOffset ); } } diff --git a/dali-toolkit/internal/controls/tool-bar/tool-bar-impl.cpp b/dali-toolkit/internal/controls/tool-bar/tool-bar-impl.cpp index 73654a4..3bdc399 100644 --- a/dali-toolkit/internal/controls/tool-bar/tool-bar-impl.cpp +++ b/dali-toolkit/internal/controls/tool-bar/tool-bar-impl.cpp @@ -19,7 +19,7 @@ #include "tool-bar-impl.h" // EXTERNAL INCLUDES -#include +#include #include #include #include @@ -76,10 +76,10 @@ void ToolBar::SetBackground( Actor background ) background.SetAnchorPoint( Dali::AnchorPoint::TOP_CENTER ); background.SetPreferredSize( Vector2( mToolBarSize.width, mToolBarSize.height ) ); - RenderableActor renderableActor = RenderableActor::DownCast( background ); - if ( renderableActor ) + ImageActor imageActor = ImageActor::DownCast( background ); + if ( imageActor ) { - renderableActor.SetSortModifier( 1.f ); + imageActor.SetSortModifier( 1.f ); } Self().Add( background ); diff --git a/dali-toolkit/internal/file.list b/dali-toolkit/internal/file.list index 31800b7..b2e9a08 100644 --- a/dali-toolkit/internal/file.list +++ b/dali-toolkit/internal/file.list @@ -12,7 +12,6 @@ toolkit_src_files = \ $(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 \ @@ -36,7 +35,6 @@ toolkit_src_files = \ $(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 \ diff --git a/dali-toolkit/public-api/controls/bubble-effect/bubble-emitter.cpp b/dali-toolkit/public-api/controls/bubble-effect/bubble-emitter.cpp deleted file mode 100644 index 62389fa..0000000 --- a/dali-toolkit/public-api/controls/bubble-effect/bubble-emitter.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/* - * 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 - -// INTERNAL INCLUDES -#include - - -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 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( 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 diff --git a/dali-toolkit/public-api/controls/bubble-effect/bubble-emitter.h b/dali-toolkit/public-api/controls/bubble-effect/bubble-emitter.h deleted file mode 100644 index 5648280..0000000 --- a/dali-toolkit/public-api/controls/bubble-effect/bubble-emitter.h +++ /dev/null @@ -1,194 +0,0 @@ -#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 - -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__ */ diff --git a/dali-toolkit/public-api/controls/control-impl.cpp b/dali-toolkit/public-api/controls/control-impl.cpp index 19f2619..3aa01ef 100644 --- a/dali-toolkit/public-api/controls/control-impl.cpp +++ b/dali-toolkit/public-api/controls/control-impl.cpp @@ -21,11 +21,9 @@ // EXTERNAL INCLUDES #include #include -#include #include #include #include -#include #include #include #include @@ -94,36 +92,6 @@ struct Background } }; -/** - * 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. @@ -496,17 +464,6 @@ void Control::SetBackgroundColor( const Vector4& color ) // 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; } diff --git a/dali-toolkit/public-api/controls/text-input/text-input.cpp b/dali-toolkit/public-api/controls/text-input/text-input.cpp index f0a43e3..f38b516 100644 --- a/dali-toolkit/public-api/controls/text-input/text-input.cpp +++ b/dali-toolkit/public-api/controls/text-input/text-input.cpp @@ -19,7 +19,6 @@ #include // EXTERNAL INCLUDES -#include #include #include #include diff --git a/dali-toolkit/public-api/file.list b/dali-toolkit/public-api/file.list index 0f06f3d..dddcd30 100755 --- a/dali-toolkit/public-api/file.list +++ b/dali-toolkit/public-api/file.list @@ -7,7 +7,6 @@ public_api_src_files = \ $(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 \ @@ -62,12 +61,9 @@ public_api_src_files = \ $(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 \ @@ -128,8 +124,7 @@ public_api_buttons_header_files = \ 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 \ @@ -232,7 +227,6 @@ public_api_shader_effects_header_files = \ $(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 \ @@ -258,9 +252,7 @@ public_api_shader_effects_header_files = \ $(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 diff --git a/dali-toolkit/public-api/shader-effects/bouncing-effect.cpp b/dali-toolkit/public-api/shader-effects/bouncing-effect.cpp deleted file mode 100644 index 9961fdf..0000000 --- a/dali-toolkit/public-api/shader-effects/bouncing-effect.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* - * 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 - -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 diff --git a/dali-toolkit/public-api/shader-effects/bouncing-effect.h b/dali-toolkit/public-api/shader-effects/bouncing-effect.h deleted file mode 100644 index eebe525..0000000 --- a/dali-toolkit/public-api/shader-effects/bouncing-effect.h +++ /dev/null @@ -1,99 +0,0 @@ -#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 - -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__ diff --git a/dali-toolkit/public-api/shader-effects/motion-blur-effect.cpp b/dali-toolkit/public-api/shader-effects/motion-blur-effect.cpp index de80751..a444640 100644 --- a/dali-toolkit/public-api/shader-effects/motion-blur-effect.cpp +++ b/dali-toolkit/public-api/shader-effects/motion-blur-effect.cpp @@ -22,6 +22,7 @@ #include #include #include +#include namespace Dali { @@ -84,7 +85,11 @@ MotionBlurEffect::~MotionBlurEffect() MotionBlurEffect MotionBlurEffect::Apply( RenderableActor renderable ) { MotionBlurEffect newEffect = New( MOTION_BLUR_NUM_SAMPLES ); - renderable.SetShaderEffect( newEffect ); + ImageActor imageActor = ImageActor::DownCast(renderable); + if( imageActor ) + { + imageActor.SetShaderEffect( newEffect ); + } Dali::Property::Index uModelProperty = newEffect.GetPropertyIndex( MOTION_BLUR_MODEL_LASTFRAME ); diff --git a/dali-toolkit/public-api/shader-effects/motion-stretch-effect.cpp b/dali-toolkit/public-api/shader-effects/motion-stretch-effect.cpp index 22383f0..4dd15f2 100644 --- a/dali-toolkit/public-api/shader-effects/motion-stretch-effect.cpp +++ b/dali-toolkit/public-api/shader-effects/motion-stretch-effect.cpp @@ -22,6 +22,7 @@ #include #include #include +#include namespace Dali { @@ -98,7 +99,12 @@ MotionStretchEffect::~MotionStretchEffect() MotionStretchEffect MotionStretchEffect::Apply( RenderableActor renderable ) { MotionStretchEffect newEffect = New(); - renderable.SetShaderEffect( newEffect ); + + ImageActor imageActor = ImageActor::DownCast(renderable); + if( imageActor ) + { + imageActor.SetShaderEffect( newEffect ); + } Dali::Property::Index uModelProperty = newEffect.GetPropertyIndex( MOTION_STRETCH_MODELVIEW_LASTFRAME );