$(public_api_base_src_dir)/focus-manager/keyboard-focus-manager.cpp \
$(public_api_base_src_dir)/focus-manager/keyinput-focus-manager.cpp \
$(public_api_base_src_dir)/markup-processor/markup-processor.cpp \
- $(public_api_base_src_dir)/shader-effects/image-region-effect.cpp
+ $(public_api_base_src_dir)/shader-effects/image-region-effect.cpp \
+ $(public_api_base_src_dir)/shader-effects/bouncing-effect.cpp
# Add public header files here
public_api_base_markup_processor_header_files =
+public_api_base_shader_effects_header_files = \
+ $(public_api_base_src_dir)/shader-effects/bouncing-effect.h
+
--- /dev/null
+//
+// Copyright (c) 2014 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.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://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <dali-toolkit/public-api/shader-effects/bouncing-effect.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace
+{
+
+#define MAKE_STRING(A)#A
+
+const std::string PROGRESS_RATE_PROPERTY_NAME( "uProgressRate" );
+
+} // namespace
+
+BouncingEffect::BouncingEffect()
+{
+}
+
+BouncingEffect::BouncingEffect( ShaderEffect handle )
+:ShaderEffect( handle )
+{
+}
+
+BouncingEffect::~BouncingEffect()
+{
+}
+
+BouncingEffect BouncingEffect::New( const Vector4& color )
+{
+ std::string fragmentShader = MAKE_STRING(
+ uniform float uProgressRate;\n
+ uniform vec4 uAssignedColor;\n
+ void main()\n
+ {\n
+ float progressRate = abs(uProgressRate)*0.5;\n
+ float amplitude = 0.15 - progressRate*0.15 ;\n
+ float x1 = 7.5 * (vTexCoord.x - progressRate);\n
+ float x2 = 7.5 * (vTexCoord.x - 1.0 + progressRate);\n
+ float height1 = max(0.00001, 0.3 - amplitude * ( exp(x1) + exp(-x1) ) );\n
+ float height2 = max(0.00001, 0.3 - amplitude * ( exp(x2) + exp(-x2) ) );\n
+ float height3 = max(0.00001, 1.0 - 3.0 * amplitude * ( exp(x1*0.5) + exp(-x1*0.5) ) );\n
+ float height4 = max(0.00001, 1.0 - 3.0 * amplitude * ( exp(x2*0.5) + exp(-x2*0.5) ) );\n
+ vec4 fragColor = vec4(0.0);\n
+ float y = vTexCoord.y/(height1+height2);\n
+ float y2 = vTexCoord.y/max(height3,height4);\n
+ float coef = max(height1,height2)*5.0/( 1.0+exp(y*12.0-6.0) );\n
+ float alpha = pow( max(0.0,(1.0-y2))*(1.0-min(abs(x1),abs(x2))/5.0), 2.0);\n
+ if( vTexCoord.y < 0.075 )\n
+ {\n
+ fragColor= mix(uAssignedColor, vec4(1.0), coef);\n
+ fragColor += (vec4(1.0)-fragColor) * alpha;\n
+ }\n
+ else if (y2<1.0)\n
+ {\n
+ fragColor =vec4(1.0,1.0,1.0, alpha + (1.0-alpha)*coef);\n
+ fragColor.rgb -= ( vec3(1.0)-uAssignedColor.rgb )*min(clamp(y*1.2-0.3, 0.0, 0.3),clamp(0.9-y*1.2,0.0,0.3));\n
+ }\n
+ fragColor.a *= 10.0*min(min(vTexCoord.x, 1.0-vTexCoord.x),0.1)*min(1.0, progressRate/0.2);\n
+ gl_FragColor = fragColor;\n
+ }
+ );
+
+ ShaderEffect shaderEffect;
+ shaderEffect = ShaderEffect::New( "", fragmentShader, GeometryType( GEOMETRY_TYPE_IMAGE),
+ ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING ) );
+ BouncingEffect handle( shaderEffect );
+
+ handle.SetUniform( "uAssignedColor", color );
+ handle.SetProgressRate( 0.f );
+
+ return handle;
+}
+
+void BouncingEffect::SetProgressRate( float progress )
+{
+ SetUniform( PROGRESS_RATE_PROPERTY_NAME, progress );
+}
+
+const std::string& BouncingEffect::GetProgressRatePropertyName() const
+{
+ return PROGRESS_RATE_PROPERTY_NAME;
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_TOOLKIT_SHADER_EFFECT_BOUNCING_H__
+#define __DALI_TOOLKIT_SHADER_EFFECT_BOUNCING_H__
+
+//
+// Copyright (c) 2014 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.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://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+// INTERNAL INCLUDES
+#include <dali/dali.h>
+
+namespace Dali DALI_IMPORT_API
+{
+
+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( BitmapImage::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 BouncingEffect : public ShaderEffect
+{
+public:
+
+ /**
+ * @brief Creates an empty BouncingEffect handle
+ */
+ BouncingEffect();
+
+ /**
+ * @brief Virtual destructor
+ */
+ virtual ~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
+ BouncingEffect( ShaderEffect handle );
+
+};
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // __DALI_TOOLKIT_SHADER_EFFECT_BOUNCING_H__
publicapibasefactorydir = $(publicapibasedir)/factory
publicapibasefocusmanagerdir = $(publicapibasedir)/focus-manager
publicapibasemarkupprocessordir = $(publicapibasedir)/markup-processor
+publicapibaseshadereffectsdir = $(publicapibasedir)/shader-effects
publicapibase_HEADERS = $(public_api_base_header_files)
publicapibasecontrols_HEADERS = $(public_api_base_controls_header_files)
publicapibasefactory_HEADERS = $(public_api_base_factory_header_files)
publicapibasefocusmanager_HEADERS = $(public_api_base_focus_manager_header_files)
publicapibasemarkupprocessor_HEADERS = $(public_api_base_markup_processor_header_files)
+publicapibaseshadereffects_HEADERS = $(public_api_base_shader_effects_header_files)
# Install Optional headers
#include <dali-toolkit/public-api/shader-effects/alpha-discard-effect.h>
#include <dali-toolkit/public-api/shader-effects/bendy-effect.h>
#include <dali-toolkit/public-api/shader-effects/blind-effect.h>
+#include <dali-toolkit/public-api/shader-effects/bouncing-effect.h>
#include <dali-toolkit/public-api/shader-effects/carousel-effect.h>
#include <dali-toolkit/public-api/shader-effects/displacement-effect.h>
#include <dali-toolkit/public-api/shader-effects/dissolve-local-effect.h>