#include <dali-toolkit/dali-toolkit.h>
#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
-#include <dali-toolkit/devel-api/visual-factory/devel-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali-toolkit/devel-api/align-enums.h>
namespace Dali
{
Property::Map transformMap;
transformMap
- .Add( Toolkit::VisualProperty::Transform::Property::OFFSET, Vector2(0.0f, 0.0f) )
- .Add( Toolkit::VisualProperty::Transform::Property::SIZE, Vector2(1.0f, 1.0f) )
- .Add( Toolkit::VisualProperty::Transform::Property::ORIGIN, Toolkit::Align::CENTER )
- .Add( Toolkit::VisualProperty::Transform::Property::ANCHOR_POINT, Toolkit::Align::CENTER )
- .Add( Toolkit::VisualProperty::Transform::Property::OFFSET_SIZE_MODE, Vector4::ZERO );
+ .Add( Toolkit::DevelVisual::Transform::Property::OFFSET, Vector2(0.0f, 0.0f) )
+ .Add( Toolkit::DevelVisual::Transform::Property::SIZE, Vector2(1.0f, 1.0f) )
+ .Add( Toolkit::DevelVisual::Transform::Property::ORIGIN, Toolkit::Align::CENTER )
+ .Add( Toolkit::DevelVisual::Transform::Property::ANCHOR_POINT, Toolkit::Align::CENTER )
+ .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_SIZE_MODE, Vector4::ZERO );
for( VisualIndices::iterator iter = mRegisteredVisualIndices.begin(); iter != mRegisteredVisualIndices.end() ; ++iter )
{
return time;
}
-static Image CreateSolidColorImage( ToolkitTestApplication& application, const Vector4& color, unsigned int width, unsigned int height )
+static Texture CreateSolidColorTexture( ToolkitTestApplication& application, const Vector4& color, unsigned int width, unsigned int height )
{
- BufferImage imageData = BufferImage::New( width, height, Pixel::RGBA8888 );
-
- // Create the image
- PixelBuffer* pixbuf = imageData.GetBuffer();
- unsigned int size = width * height;
-
- for( size_t i = 0; i < size; i++ )
- {
- pixbuf[i*4+0] = 0xFF * color.r;
- pixbuf[i*4+1] = 0xFF * color.g;
- pixbuf[i*4+2] = 0xFF * color.b;
- pixbuf[i*4+3] = 0xFF * color.a;
- }
- imageData.Update();
-
- application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE );
- application.SendNotification();
- application.Render(RENDER_FRAME_INTERVAL);
- application.Render(RENDER_FRAME_INTERVAL);
- application.SendNotification();
-
- return imageData;
+ Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height );
+ return texture;
}
}//namespace
DALI_TEST_CHECK( !emitter );
// Test object creation
- Image shapeImage = CreateSolidColorImage( application, Color::GREEN, 5, 5 );
+ Texture shapeImage = CreateSolidColorTexture( application, Color::GREEN, 5, 5 );
emitter = BubbleEmitter::New( Vector2(50.f,50.f),shapeImage, 200, Vector2( 5.f, 10.f ));
DALI_TEST_CHECK( emitter );
tet_infoline(" UtcDaliBubbleEmitterDownCast01 ");
- Image shapeImage = CreateSolidColorImage( application, Color::GREEN, 5, 5 );
+ Texture shapeImage = CreateSolidColorTexture( application, Color::GREEN, 5, 5 );
BubbleEmitter emitter = BubbleEmitter::New( Vector2(50.f,50.f),shapeImage, 200, Vector2( 5.f, 10.f ));
BaseHandle handle(emitter);
ToolkitTestApplication application;
tet_infoline( " UtcDaliBubbleEmitterGetRootActor " );
- Image shapeImage = CreateSolidColorImage( application, Color::GREEN, 5, 5 );
+ Texture shapeImage = CreateSolidColorTexture( application, Color::GREEN, 5, 5 );
BubbleEmitter emitter = BubbleEmitter::New( Vector2(50.f,50.f),shapeImage, 270, Vector2( 5.f, 10.f ));
Actor root = emitter.GetRootActor();
DALI_TEST_CHECK( root );
- DALI_TEST_CHECK( root.GetChildCount() == 3 );
+ DALI_TEST_CHECK( root.GetChildCount() == 0 );
END_TEST;
}
ToolkitTestApplication application;
tet_infoline( " UtcDaliBubbleEmitterSetBackground " );
- Image shapeImage = CreateSolidColorImage( application, Color::GREEN, 5, 5 );
+ Texture shapeImage = CreateSolidColorTexture( application, Color::GREEN, 5, 5 );
BubbleEmitter emitter = BubbleEmitter::New( Vector2(50.f,50.f),shapeImage, 200, Vector2( 5.f, 10.f ));
RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
unsigned int taskCount = taskList.GetTaskCount();
- Image bgImage = CreateSolidColorImage( application, Color::RED, 50, 50 );
+ Texture bgImage = CreateSolidColorTexture( application, Color::RED, 50, 50 );
emitter.SetBackground( bgImage, Vector3(0.f, 0.f, 0.5f) );
DALI_TEST_CHECK( taskList.GetTaskCount() == taskCount+1 );
ToolkitTestApplication application;
tet_infoline( " UtcDaliBubbleEmitterSetBubbleScale " );
- Image shapeImage = CreateSolidColorImage( application, Color::GREEN, 5, 5 );
+ Texture shapeImage = CreateSolidColorTexture( application, Color::GREEN, 5, 5 );
BubbleEmitter emitter = BubbleEmitter::New( Vector2(50.f,50.f),shapeImage, 150, Vector2( 5.f, 10.f ));
DALI_TEST_CHECK(emitter);
Actor root = emitter.GetRootActor();
ToolkitTestApplication application;
tet_infoline( " UtcDaliBubbleEmitterSetBubbleDensity " );
- Image shapeImage = CreateSolidColorImage( application, Color::GREEN, 5, 5 );
+ Texture shapeImage = CreateSolidColorTexture( application, Color::GREEN, 5, 5 );
BubbleEmitter emitter = BubbleEmitter::New( Vector2(50.f,50.f),shapeImage, 200, Vector2( 5.f, 10.f ));
try
ToolkitTestApplication application;
tet_infoline( " UtcDaliBubbleEmitterSetBubbleDensity " );
- Image shapeImage = CreateSolidColorImage( application, Color::GREEN, 5, 5 );
+ Texture shapeImage = CreateSolidColorTexture( application, Color::GREEN, 5, 5 );
BubbleEmitter emitter = BubbleEmitter::New( Vector2(50.f,50.f),shapeImage, 200, Vector2( 5.f, 10.f ));
try
ToolkitTestApplication application;
tet_infoline( " UtcDaliBubbleEmitterEmitBubble " );
- Image shapeImage1 = CreateSolidColorImage( application, Color::GREEN, 5, 5 );
+ Texture shapeImage1 = CreateSolidColorTexture( application, Color::GREEN, 5, 5 );
BubbleEmitter emitter = BubbleEmitter::New( Vector2(50.f,50.f),shapeImage1, 200, Vector2( 5.f, 10.f ));
Actor root = emitter.GetRootActor();
- Actor bubbleMesh = root.GetChildAt( 0 );
+ Renderer bubbleRenderer = root.GetRendererAt( 0 );
Stage::GetCurrent().Add( root );
- DALI_TEST_CHECK( bubbleMesh );
+ DALI_TEST_CHECK( bubbleRenderer );
- Property::Index propertyIndex0 = bubbleMesh.GetPropertyIndex( "uPercentage[0]" );
- Property::Index propertyIndex1 = bubbleMesh.GetPropertyIndex( "uPercentage[1]" );
+ Property::Index propertyIndex0 = bubbleRenderer.GetPropertyIndex( "uPercentage[0]" );
+ Property::Index propertyIndex1 = bubbleRenderer.GetPropertyIndex( "uPercentage[1]" );
float value0, value1;
Animation animation = Animation::New( 0.5f );
emitter.EmitBubble( animation, Vector2(40.f,40.f), Vector2(-5.f,-5.f), Vector2(30.f,30.f) );
emitter.EmitBubble( animation, Vector2(10.f,10.f), Vector2(5.f,5.f), Vector2(30.f,30.f) );
- (bubbleMesh.GetProperty(propertyIndex0)).Get( value0 );
- (bubbleMesh.GetProperty(propertyIndex1)).Get( value1 );
+ (bubbleRenderer.GetProperty(propertyIndex0)).Get( value0 );
+ (bubbleRenderer.GetProperty(propertyIndex1)).Get( value1 );
DALI_TEST_EQUALS(value0, 0.f, TEST_LOCATION );
DALI_TEST_EQUALS(value1, 0.f, TEST_LOCATION );
animation.Play();
Wait(application, 300);
- propertyIndex0 = bubbleMesh.GetPropertyIndex( "uPercentage[0]" );
- propertyIndex1 = bubbleMesh.GetPropertyIndex( "uPercentage[1]" );
- (bubbleMesh.GetProperty(propertyIndex0)).Get( value0 );
- (bubbleMesh.GetProperty(propertyIndex1)).Get( value1 );
+ propertyIndex0 = bubbleRenderer.GetPropertyIndex( "uPercentage[0]" );
+ propertyIndex1 = bubbleRenderer.GetPropertyIndex( "uPercentage[1]" );
+ (bubbleRenderer.GetProperty(propertyIndex0)).Get( value0 );
+ (bubbleRenderer.GetProperty(propertyIndex1)).Get( value1 );
DALI_TEST_CHECK( value0 >= 0.6f );
DALI_TEST_CHECK( value1 >= 0.6f );
Wait(application,500);
- (bubbleMesh.GetProperty(propertyIndex0)).Get( value0 );
- (bubbleMesh.GetProperty(propertyIndex1)).Get( value1 );
+ (bubbleRenderer.GetProperty(propertyIndex0)).Get( value0 );
+ (bubbleRenderer.GetProperty(propertyIndex1)).Get( value1 );
DALI_TEST_EQUALS(value0, 1.f, TEST_LOCATION );
DALI_TEST_EQUALS(value1, 1.f, TEST_LOCATION );
END_TEST;
ToolkitTestApplication application;
tet_infoline( " UtcDaliBubbleEmitterRestore " );
- Image shapeImage = CreateSolidColorImage( application, Color::GREEN, 5, 5 );
- BubbleEmitter emitter = BubbleEmitter::New( Vector2(50.f,50.f),shapeImage, 90, Vector2( 5.f, 10.f ));
+ Vector2 movementArea(50.f,50.f);
+ Texture shapeImage = CreateSolidColorTexture( application, Color::GREEN, 5, 5 );
+ BubbleEmitter emitter = BubbleEmitter::New( movementArea,shapeImage, 90, Vector2( 5.f, 10.f ));
Actor root = emitter.GetRootActor();
Stage::GetCurrent().Add( root );
root.SetPosition( Vector3::ZERO );
root.SetParentOrigin( ParentOrigin::CENTER );
root.SetAnchorPoint( AnchorPoint::CENTER );
- Actor bubbleMesh = root.GetChildAt( 0 );
- Renderer renderer = bubbleMesh.GetRendererAt( 0 );
+ Renderer renderer = root.GetRendererAt( 0 );
DALI_TEST_CHECK( renderer );
TestGlAbstraction& gl = application.GetGlAbstraction();
DALI_TEST_EQUALS( percentageValue, 0.f, TEST_LOCATION );
DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uStartEndPosition[0]", startEndPosValue ) );
- DALI_TEST_EQUALS( startEndPosValue.x, 40.f, TEST_LOCATION );
- DALI_TEST_EQUALS( startEndPosValue.y, 40.f, TEST_LOCATION );
+ DALI_TEST_EQUALS( startEndPosValue.x, 40.f - movementArea.x*0.5f, TEST_LOCATION );
+ DALI_TEST_EQUALS( startEndPosValue.y, 40.f- movementArea.x*0.5f, TEST_LOCATION );
animation.Play();
Wait(application, 200);
DALI_TEST_CHECK( percentageValue < 0.5f && percentageValue >= 0.4);
DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uStartEndPosition[0]", startEndPosValue ) );
- DALI_TEST_EQUALS( startEndPosValue.x, 40.f, TEST_LOCATION );
- DALI_TEST_EQUALS( startEndPosValue.y, 40.f, TEST_LOCATION );
+ DALI_TEST_EQUALS( startEndPosValue.x, 40.f- movementArea.x*0.5f, TEST_LOCATION );
+ DALI_TEST_EQUALS( startEndPosValue.y, 40.f- movementArea.x*0.5f, TEST_LOCATION );
emitter.Restore();
application.SendNotification();
/*
- * Copyright (c) 2014-2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016-2016 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
" }\n"
" ]\n"
" }\n"
- " },\n"
- " \"shaderEffects\": {\n"
- " \"Ripple2D\": {\n"
- " \"program\": {\n"
- " \"vertexPrefix\": \"\",\n"
- " \"vertex\": \"void main(void)\\n{\\n gl_Position = uProjection * uModelView * vec4(aPosition, 1.0);\\n vTexCoord = aTexCoord;\\n}\\n\\n\",\n"
- " \"fragmentPrefix\": \"\",\n"
- " \"fragment\": \"precision mediump float;\\nuniform float uAmplitude; // 0.02; (< 1)\\nuniform float uTime;\\nvoid main()\\n{\\n highp vec2 textureSize = sTextureRect.zw - sTextureRect.xy;\\n highp vec2 pos = -1.0 + 2.0 * vTexCoord.st/textureSize;\\n highp float len = length(pos);\\n highp vec2 texCoord = vTexCoord.st/textureSize + pos/len * sin( len * 12.0 - uTime * 4.0 ) * uAmplitude; \\n gl_FragColor = texture2D(sTexture, texCoord) * uColor;\\n}\\n\\n\\n\",\n"
- " \"geometryType\": \"GEOMETRY_TYPE_IMAGE\"\n"
- " },\n"
- " \"geometryHints\": \"HINT_NONE\",\n"
- " \"gridDensity\": 0,\n"
- " \"loop\": true,\n"
- " \"uAmplitude\": 0.02,\n"
- " \"uTime\": 0.0\n"
- " }\n"
" }\n"
"}\n");
" }\n"
" ]\n"
" }\n"
- " },\n"
- " \"shaderEffects\": {\n"
- " \"Ripple2D\": {\n"
- " \"program\": {\n"
- " \"vertexPrefix\": \"\",\n"
- " \"vertex\": \"void main(void)\\n{\\n gl_Position = uProjection * uModelView * vec4(aPosition, 1.0);\\n vTexCoord = aTexCoord;\\n}\\n\\n\",\n"
- " \"fragmentPrefix\": \"\",\n"
- " \"fragment\": \"precision mediump float;\\nuniform float uAmplitude; // 0.02; (< 1)\\nuniform float uTime;\\nvoid main()\\n{\\n highp vec2 textureSize = sTextureRect.zw - sTextureRect.xy;\\n highp vec2 pos = -1.0 + 2.0 * vTexCoord.st/textureSize;\\n highp float len = length(pos);\\n highp vec2 texCoord = vTexCoord.st/textureSize + pos/len * sin( len * 12.0 - uTime * 4.0 ) * uAmplitude; \\n gl_FragColor = texture2D(sTexture, texCoord) * uColor;\\n}\\n\\n\\n\",\n"
- " \"geometryType\": \"GEOMETRY_TYPE_IMAGE\"\n"
- " },\n"
- " \"geometryHints\": \"HINT_NONE\",\n"
- " \"gridDensity\": 0,\n"
- " \"loop\": true,\n"
- " \"uAmplitude\": 0.02,\n"
- " \"uTime\": 0.0\n"
- " }\n"
" }\n"
"}\n");
Property::Value propValue = control.GetProperty( Control::Property::BACKGROUND );
Property::Map* resultMap = propValue.GetMap();
DALI_TEST_CHECK( resultMap->Find( Visual::Property::TYPE ) );
- DALI_TEST_CHECK( resultMap->Find( Visual::Property::TYPE )->Get<int>() == Visual::IMAGE );
+ DALI_TEST_EQUALS( resultMap->Find( Visual::Property::TYPE )->Get<int>(),(int)Visual::IMAGE, TEST_LOCATION );
DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL ) );
- DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL )->Get<std::string>() == "TestImage" );
+ DALI_TEST_EQUALS( resultMap->Find( ImageVisual::Property::URL )->Get<std::string>(), "TestImage", TEST_LOCATION );
Property::Map rendererMap;
rendererMap[Visual::Property::TYPE] = Visual::COLOR;
propValue = control.GetProperty( Control::Property::BACKGROUND );
resultMap = propValue.GetMap();
DALI_TEST_CHECK( resultMap->Find( Visual::Property::TYPE ) );
- DALI_TEST_CHECK( resultMap->Find( Visual::Property::TYPE )->Get<int>() == Visual::COLOR );
+ DALI_TEST_EQUALS( resultMap->Find( Visual::Property::TYPE )->Get<int>(), (int)Visual::COLOR, TEST_LOCATION );
DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR ) );
- DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR )->Get<Vector4>() == Color::CYAN );
+ DALI_TEST_EQUALS( resultMap->Find( ColorVisual::Property::MIX_COLOR )->Get<Vector4>(), Color::CYAN, TEST_LOCATION );
Property::Map emptyMap;
control.SetProperty( Control::Property::BACKGROUND, emptyMap );
DALI_TEST_CHECK( control.GetProperty( Control::Property::BACKGROUND ).Get< Property::Map >().Empty() );
+ // set as URL
+ control.SetProperty( Control::Property::BACKGROUND, "Foobar.png" );
+ propValue = control.GetProperty( Control::Property::BACKGROUND );
+ resultMap = propValue.GetMap();
+ DALI_TEST_EQUALS( resultMap->Find( Visual::Property::TYPE )->Get<int>(), (int)Visual::IMAGE, TEST_LOCATION );
+ DALI_TEST_EQUALS( resultMap->Find( ImageVisual::Property::URL )->Get<std::string>(), "Foobar.png", TEST_LOCATION );
+
// Deprecated Properties
control.SetProperty( Control::Property::BACKGROUND_COLOR, Color::YELLOW );
- DALI_TEST_EQUALS( control.GetProperty( Control::Property::BACKGROUND_COLOR ).Get< Vector4 >(), Color::YELLOW , TEST_LOCATION );
+ DALI_TEST_EQUALS( control.GetProperty( Control::Property::BACKGROUND_COLOR ).Get< Vector4 >(), Color::YELLOW, TEST_LOCATION );
DALI_TEST_EQUALS( control.GetProperty( Control::Property::BACKGROUND_COLOR ).Get< Vector4 >(), control.GetBackgroundColor(), TEST_LOCATION );
control.ClearBackground();
control.SetProperty( Control::Property::BACKGROUND_IMAGE, deprecatedImageMap );
propValue = control.GetProperty( Control::Property::BACKGROUND_IMAGE );
resultMap = propValue.GetMap();
- DALI_TEST_EQUALS( resultMap->Find( ImageVisual::Property::URL )->Get< std::string >(), "TestImage" , TEST_LOCATION );
+ DALI_TEST_EQUALS( resultMap->Find( ImageVisual::Property::URL )->Get< std::string >(), "TestImage" , TEST_LOCATION );
control.SetProperty( Control::Property::BACKGROUND_IMAGE, emptyMap );
DALI_TEST_CHECK( control.GetProperty( Control::Property::BACKGROUND_IMAGE ).Get< Property::Map >().Empty() );
#include <dali-toolkit/dali-toolkit.h>
#include <dali-toolkit/devel-api/shader-effects/alpha-discard-effect.h>
-#include <dali-toolkit/devel-api/shader-effects/bendy-effect.h>
-#include <dali-toolkit/devel-api/shader-effects/blind-effect.h>
-#include <dali-toolkit/devel-api/shader-effects/bouncing-effect.h>
-#include <dali-toolkit/devel-api/shader-effects/carousel-effect.h>
-#include <dali-toolkit/devel-api/shader-effects/displacement-effect.h>
#include <dali-toolkit/devel-api/shader-effects/dissolve-effect.h>
-#include <dali-toolkit/devel-api/shader-effects/dissolve-local-effect.h>
#include <dali-toolkit/devel-api/shader-effects/distance-field-effect.h>
#include <dali-toolkit/devel-api/shader-effects/image-region-effect.h>
-#include <dali-toolkit/devel-api/shader-effects/iris-effect.h>
-#include <dali-toolkit/devel-api/shader-effects/mask-effect.h>
-#include <dali-toolkit/devel-api/shader-effects/mirror-effect.h>
#include <dali-toolkit/devel-api/shader-effects/motion-blur-effect.h>
#include <dali-toolkit/devel-api/shader-effects/motion-stretch-effect.h>
-#include <dali-toolkit/devel-api/shader-effects/overlay-effect.h>
-#include <dali-toolkit/devel-api/shader-effects/quadratic-bezier.h>
-#include <dali-toolkit/devel-api/shader-effects/ripple-effect.h>
-#include <dali-toolkit/devel-api/shader-effects/ripple2d-effect.h>
-#include <dali-toolkit/devel-api/shader-effects/shear-effect.h>
-#include <dali-toolkit/devel-api/shader-effects/soft-button-effect.h>
-#include <dali-toolkit/devel-api/shader-effects/spot-effect.h>
-#include <dali-toolkit/devel-api/shader-effects/square-dissolve-effect.h>
-#include <dali-toolkit/devel-api/shader-effects/swirl-effect.h>
using namespace Dali;
using namespace Dali::Toolkit;
END_TEST;
}
-int UtcDaliCreateBendyEffect(void)
-{
- ToolkitTestApplication application;
-
- ShaderEffect effect = Toolkit::CreateBendyEffect();
- DALI_TEST_CHECK( effect );
-
- END_TEST;
-}
-
-int UtcDaliCreateBlindEffect(void)
-{
- ToolkitTestApplication application;
-
- ShaderEffect effect = Toolkit::CreateBlindEffect();
- DALI_TEST_CHECK( effect );
-
- END_TEST;
-}
-
-int UtcDaliCreateBouncingEffect(void)
-{
- ToolkitTestApplication application;
-
- Vector4 color(1.0f,1.0f,1.0f,1.0f);
-
- ShaderEffect effect = Toolkit::CreateBouncingEffect(color);
- DALI_TEST_CHECK( effect );
-
- Property::Value value = effect.GetProperty( effect.GetPropertyIndex("uAssignedColor"));
- DALI_TEST_EQUALS( value.Get<Vector4>(), color, TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcDaliCreateCarouselEffect(void)
-{
- ToolkitTestApplication application;
-
- ShaderEffect effect = Toolkit::CreateCarouselEffect();
- DALI_TEST_CHECK( effect );
-
- END_TEST;
-}
-
-int UtcDaliCreateDisplacementEffectDisplaced(void)
-{
- ToolkitTestApplication application;
-
- ShaderEffect effect = Toolkit::CreateDisplacementEffect(Toolkit::DISPLACEMENT_EFFECT_DISPLACED);
- DALI_TEST_CHECK( effect );
-
- END_TEST;
-}
-
-int UtcDaliCreateDisplacementEffectFixed(void)
-{
- ToolkitTestApplication application;
-
- ShaderEffect effect = Toolkit::CreateDisplacementEffect(Toolkit::DISPLACEMENT_EFFECT_FIXED);
- DALI_TEST_CHECK( effect );
-
- END_TEST;
-}
-
int UtcDaliCreateDissolveEffect( bool highPrecision )
{
ToolkitTestApplication application;
return UtcDaliCreateDissolveEffect(false);
}
-int UtcDaliCreateDissolveLocalEffect(void)
-{
- ToolkitTestApplication application;
-
- ShaderEffect effect = Toolkit::CreateDissolveLocalEffect(0);
- DALI_TEST_CHECK( effect );
-
- END_TEST;
-}
-
int UtcDaliCreateDissolveEffect(void)
{
ToolkitTestApplication application;
END_TEST;
}
-int UtcDaliCreateIrisEffect(void)
-{
- ToolkitTestApplication application;
-
- ShaderEffect effect = Toolkit::CreateIrisEffect();
- DALI_TEST_CHECK( effect );
-
- END_TEST;
-}
-
-int UtcDaliCreateMaskEffect(void)
-{
- ToolkitTestApplication application;
-
- BufferImage image = CreateBufferImage();
- ShaderEffect effect = Toolkit::CreateMaskEffect(image);
- DALI_TEST_CHECK( effect );
-
- END_TEST;
-}
-
-int UtcDaliCreateMirrorEffect(void)
-{
- ToolkitTestApplication application;
-
- BufferImage image = CreateBufferImage();
- ShaderEffect effect = Toolkit::CreateMirrorEffect();
- DALI_TEST_CHECK( effect );
-
- END_TEST;
-}
-
int UtcDaliCreateMotionBlurEffect(void)
{
ToolkitTestApplication application;
END_TEST;
}
-
-int UtcDaliCreateOverlayEffect(void)
-{
- ToolkitTestApplication application;
-
- BufferImage image = CreateBufferImage();
- ShaderEffect effect = Toolkit::CreateOverlayEffect(image);
- DALI_TEST_CHECK( effect );
-
- END_TEST;
-}
-
-int UtcDaliCreateQuadraticBezier(void)
-{
- ToolkitTestApplication application;
-
- ShaderEffect effect = Toolkit::CreateQuadraticBezier(3,false);
- DALI_TEST_CHECK( effect );
-
- END_TEST;
-}
-
-int UtcDaliCreateQuadraticBezierFilled(void)
-{
- ToolkitTestApplication application;
-
- ShaderEffect effect = Toolkit::CreateQuadraticBezier(3,true);
- DALI_TEST_CHECK( effect );
-
- END_TEST;
-}
-
-int UtcDaliCreateRipple2DEffect(void)
-{
- ToolkitTestApplication application;
-
- ShaderEffect effect = Toolkit::CreateRipple2DEffect();
- DALI_TEST_CHECK( effect );
-
- END_TEST;
-}
-
-int UtcDaliCreateRippleEffect(void)
-{
- ToolkitTestApplication application;
-
- ShaderEffect effect = Toolkit::CreateRippleEffect();
- DALI_TEST_CHECK( effect );
-
- END_TEST;
-}
-
-int UtcDaliCreateShearEffect(void)
-{
- ToolkitTestApplication application;
-
- ShaderEffect effect = Toolkit::CreateShearEffect();
- DALI_TEST_CHECK( effect );
-
- END_TEST;
-}
-
-int UtcDaliSoftButtonEffectElliptical(void)
-{
- ToolkitTestApplication application;
-
- ShaderEffect effect = Toolkit::CreateSoftButtonEffect(Toolkit::SOFT_BUTTON_ELLIPTICAL);
- DALI_TEST_CHECK( effect );
-
- END_TEST;
-}
-
-int UtcDaliSoftButtonEffectRectangular(void)
-{
- ToolkitTestApplication application;
-
- ShaderEffect effect = Toolkit::CreateSoftButtonEffect(Toolkit::SOFT_BUTTON_RECTANGULAR);
- DALI_TEST_CHECK( effect );
-
- END_TEST;
-}
-
-int UtcDaliSoftButtonEffectFixed(void)
-{
- ToolkitTestApplication application;
-
- ShaderEffect effect = Toolkit::CreateSoftButtonEffect(Toolkit::SOFT_BUTTON_FIXED);
- DALI_TEST_CHECK( effect );
-
- END_TEST;
-}
-
-int UtcDaliCreateSpotEffect(void)
-{
- ToolkitTestApplication application;
-
- ShaderEffect effect = Toolkit::CreateSpotEffect();
- DALI_TEST_CHECK( effect );
-
- END_TEST;
-}
-
-int UtcDaliCreateSquareDissolveEffect(void)
-{
- ToolkitTestApplication application;
-
- ShaderEffect effect = Toolkit::CreateSquareDissolveEffect();
- DALI_TEST_CHECK( effect );
-
- END_TEST;
-}
-
-int UtcDaliSwirlEffect(void)
-{
- ToolkitTestApplication application;
-
- ShaderEffect effect = Toolkit::CreateSwirlEffect(false);
- DALI_TEST_CHECK( effect );
-
- END_TEST;
-}
-
-int UtcDaliSwirlEffectWrap(void)
-{
- ToolkitTestApplication application;
-
- ShaderEffect effect = Toolkit::CreateSwirlEffect(true);
- DALI_TEST_CHECK( effect );
-
- END_TEST;
-}
#include <stdlib.h>
#include <dali-toolkit-test-suite-utils.h>
#include <dali.h>
+#include <dali/devel-api/object/handle-devel.h>
#include <dali-toolkit/dali-toolkit.h>
#include <dali-toolkit/devel-api/visual-factory/transition-data.h>
#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
DALI_TEST_CHECK( anim );
Renderer renderer = actor.GetRendererAt(0);
- Property::Index mixColorIndex = renderer.GetPropertyIndex( ColorVisual::Property::MIX_COLOR );
+ Property::Index mixColorIndex = DevelHandle::GetPropertyIndex( renderer, ColorVisual::Property::MIX_COLOR );
application.SendNotification();
application.Render(0);
DALI_TEST_CHECK( anim );
Renderer renderer = actor.GetRendererAt(0);
- Property::Index mixColorIndex = renderer.GetPropertyIndex( ColorVisual::Property::MIX_COLOR );
+ Property::Index mixColorIndex = DevelHandle::GetPropertyIndex( renderer, ColorVisual::Property::MIX_COLOR );
application.SendNotification();
application.Render(0);
application.SendNotification();
Renderer renderer = actor.GetRendererAt(0);
- Property::Index mixColorIdx = renderer.GetPropertyIndex(ColorVisual::Property::MIX_COLOR);
+ Property::Index mixColorIdx = DevelHandle::GetPropertyIndex( renderer, ColorVisual::Property::MIX_COLOR );
tet_printf( "Test that the property has been set to target value\n");
DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(mixColorIdx), Color::RED, 0.001, TEST_LOCATION);
application.SendNotification();
Renderer renderer = actor.GetRendererAt(0);
- Property::Index mixColorIdx = renderer.GetPropertyIndex(ColorVisual::Property::MIX_COLOR);
+ Property::Index mixColorIdx = DevelHandle::GetPropertyIndex( renderer, ColorVisual::Property::MIX_COLOR );
tet_printf( "Test that the property has been set to target value\n");
DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(mixColorIdx), Color::RED, 0.001, TEST_LOCATION);
application.SendNotification();
Renderer renderer = actor.GetRendererAt(0);
- Property::Index mixColorIdx = renderer.GetPropertyIndex(ColorVisual::Property::MIX_COLOR);
+ Property::Index mixColorIdx = DevelHandle::GetPropertyIndex( renderer, ColorVisual::Property::MIX_COLOR );
tet_printf( "Test that the property has been set to target value\n");
DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(mixColorIdx), Color::RED, 0.001, TEST_LOCATION);
#include <dali/public-api/rendering/renderer.h>
#include <dali/public-api/rendering/texture-set.h>
#include <dali/public-api/rendering/shader.h>
+#include <dali/devel-api/object/handle-devel.h>
#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
-#include <dali-toolkit/devel-api/visual-factory/devel-visual-properties.h>
#include <dali-toolkit/devel-api/visuals/text-visual-properties.h>
#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali-toolkit/devel-api/align-enums.h>
{
Property::Map transformMap;
transformMap
- .Add( Toolkit::VisualProperty::Transform::Property::OFFSET, Vector2(0.0f, 0.0f) )
- .Add( Toolkit::VisualProperty::Transform::Property::SIZE, Vector2(1.0f, 1.0f) )
- .Add( Toolkit::VisualProperty::Transform::Property::ORIGIN, Toolkit::Align::CENTER )
- .Add( Toolkit::VisualProperty::Transform::Property::ANCHOR_POINT, Toolkit::Align::CENTER )
- .Add( Toolkit::VisualProperty::Transform::Property::OFFSET_SIZE_MODE, Vector4::ZERO );
+ .Add( Toolkit::DevelVisual::Transform::Property::OFFSET, Vector2(0.0f, 0.0f) )
+ .Add( Toolkit::DevelVisual::Transform::Property::SIZE, Vector2(1.0f, 1.0f) )
+ .Add( Toolkit::DevelVisual::Transform::Property::ORIGIN, Toolkit::Align::CENTER )
+ .Add( Toolkit::DevelVisual::Transform::Property::ANCHOR_POINT, Toolkit::Align::CENTER )
+ .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_SIZE_MODE, Vector4::ZERO );
return transformMap;
}
Property::Map propertyMap;
propertyMap.Insert( Visual::Property::TYPE, DevelVisual::TEXT );
propertyMap.Insert( "renderingBackend", static_cast<int>( Toolkit::Text::DEFAULT_RENDERING_BACKEND ) );
+ propertyMap.Insert( "enableMarkup", false );
propertyMap.Insert( "text", "Hello world" );
propertyMap.Insert( "fontFamily", "TizenSans" );
propertyMap.Insert( "horizontalAlignment", "CENTER" );
propertyMap.Insert( "verticalAlignment", "CENTER" );
propertyMap.Insert( "textColor", Color::RED );
- propertyMap.Insert( "enableMarkup", false );
Visual::Base textVisual = factory.CreateVisual( propertyMap );
Property::Map resultMap;
DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
Renderer renderer = actor.GetRendererAt(0);
- Property::Index index = renderer.GetPropertyIndex( BorderVisual::Property::COLOR );
+ Property::Index index = DevelHandle::GetPropertyIndex( renderer, BorderVisual::Property::COLOR );
Animation animation = Animation::New(4.0f);
animation.AnimateTo( Property(renderer, index), Color::WHITE );
DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
Renderer renderer = actor.GetRendererAt(0);
- Property::Index index = renderer.GetPropertyIndex( BorderVisual::Property::SIZE );
+ Property::Index index = DevelHandle::GetPropertyIndex( renderer, BorderVisual::Property::SIZE );
Animation animation = Animation::New(4.0f);
animation.AnimateTo( Property(renderer, index), 9.0f );
DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
Renderer renderer = actor.GetRendererAt(0);
- Property::Index index = renderer.GetPropertyIndex( ColorVisual::Property::MIX_COLOR );
+ Property::Index index = DevelHandle::GetPropertyIndex( renderer, ColorVisual::Property::MIX_COLOR );
Animation animation = Animation::New(4.0f);
animation.AnimateTo( Property(renderer, index), Color::WHITE );
DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
Renderer renderer = actor.GetRendererAt(0);
- Property::Index index = renderer.GetPropertyIndex( PrimitiveVisual::Property::MIX_COLOR );
+ Property::Index index = DevelHandle::GetPropertyIndex( renderer, PrimitiveVisual::Property::MIX_COLOR );
// The property isn't registered on the renderer, it's instead registered on the shader.
DALI_TEST_EQUALS( index, Property::INVALID_INDEX, TEST_LOCATION );
Dali::Property::Map visualMap;
colorVisual.CreatePropertyMap( visualMap );
- Property::Value* value = visualMap.Find( Dali::Toolkit::Visual::DevelProperty::TRANSFORM );
+ Property::Value* value = visualMap.Find( Dali::Toolkit::DevelVisual::Property::TRANSFORM );
Dali::Property::Map* map = value->GetMap();
DALI_TEST_CHECK( map );
//Test default values
{
- Property::Value* typeValue = map->Find( Toolkit::Visual::DevelProperty::Transform::Property::OFFSET );
+ Property::Value* typeValue = map->Find( Toolkit::DevelVisual::Transform::Property::OFFSET );
DALI_TEST_CHECK( typeValue );
DALI_TEST_CHECK( typeValue->Get<Vector2>() == Vector2(0.0f,0.0f) );
}
{
- Property::Value* typeValue = map->Find( Toolkit::Visual::DevelProperty::Transform::Property::SIZE );
+ Property::Value* typeValue = map->Find( Toolkit::DevelVisual::Transform::Property::SIZE );
DALI_TEST_CHECK( typeValue );
DALI_TEST_CHECK( typeValue->Get<Vector2>() == Vector2(1.0f,1.0f) );
}
{
- Property::Value* typeValue = map->Find( Toolkit::Visual::DevelProperty::Transform::Property::OFFSET_SIZE_MODE );
+ Property::Value* typeValue = map->Find( Toolkit::DevelVisual::Transform::Property::OFFSET_SIZE_MODE );
DALI_TEST_CHECK( typeValue );
DALI_TEST_CHECK( typeValue->Get<Vector4>() == Vector4(0.0f,0.0f,0.0f,0.0f) );
}
{
- Property::Value* typeValue = map->Find( Toolkit::Visual::DevelProperty::Transform::Property::ORIGIN );
+ Property::Value* typeValue = map->Find( Toolkit::DevelVisual::Transform::Property::ORIGIN );
DALI_TEST_CHECK( typeValue );
DALI_TEST_CHECK( (Toolkit::Align::Type)typeValue->Get<int>() == Toolkit::Align::CENTER );
}
{
- Property::Value* typeValue = map->Find( Toolkit::Visual::DevelProperty::Transform::Property::ANCHOR_POINT );
+ Property::Value* typeValue = map->Find( Toolkit::DevelVisual::Transform::Property::ANCHOR_POINT );
DALI_TEST_CHECK( typeValue );
DALI_TEST_CHECK( (Toolkit::Align::Type)typeValue->Get<int>() == Toolkit::Align::CENTER );
}
static void TestTransform( ToolkitTestApplication& application, Visual::Base visual )
{
Property::Map transform;
- transform.Insert( Visual::DevelProperty::Transform::Property::OFFSET, Vector2(10.0f, 10.0f) );
- transform.Insert( Visual::DevelProperty::Transform::Property::SIZE, Vector2(0.2f, 0.2f) );
- transform.Insert( Visual::DevelProperty::Transform::Property::OFFSET_SIZE_MODE, Vector4(1.0f, 1.0f, 0.0f,0.0f) );
- transform.Insert( Visual::DevelProperty::Transform::Property::ORIGIN, "TOP_BEGIN" );
- transform.Insert( Visual::DevelProperty::Transform::Property::ANCHOR_POINT, Toolkit::Align::BOTTOM_END );
+ transform.Insert( DevelVisual::Transform::Property::OFFSET, Vector2(10.0f, 10.0f) );
+ transform.Insert( DevelVisual::Transform::Property::SIZE, Vector2(0.2f, 0.2f) );
+ transform.Insert( DevelVisual::Transform::Property::OFFSET_SIZE_MODE, Vector4(1.0f, 1.0f, 0.0f,0.0f) );
+ transform.Insert( DevelVisual::Transform::Property::ORIGIN, "TOP_BEGIN" );
+ transform.Insert( DevelVisual::Transform::Property::ANCHOR_POINT, Toolkit::Align::BOTTOM_END );
visual.SetTransformAndSize( transform, Vector2(100, 100) );
Dali::Property::Map visualMap;
visual.CreatePropertyMap( visualMap );
- Property::Value* value = visualMap.Find( Dali::Toolkit::Visual::DevelProperty::TRANSFORM );
+ Property::Value* value = visualMap.Find( Dali::Toolkit::DevelVisual::Property::TRANSFORM );
Dali::Property::Map* map = value->GetMap();
DALI_TEST_CHECK( map );
{
- Property::Value* typeValue = map->Find( Toolkit::Visual::DevelProperty::Transform::Property::OFFSET );
+ Property::Value* typeValue = map->Find( Toolkit::DevelVisual::Transform::Property::OFFSET );
DALI_TEST_CHECK( typeValue );
DALI_TEST_EQUALS( typeValue->Get<Vector2>(),Vector2(10.0f,10.0f), TEST_LOCATION );
}
{
- Property::Value* typeValue = map->Find( Toolkit::Visual::DevelProperty::Transform::Property::SIZE );
+ Property::Value* typeValue = map->Find( Toolkit::DevelVisual::Transform::Property::SIZE );
DALI_TEST_CHECK( typeValue );
DALI_TEST_EQUALS( typeValue->Get<Vector2>(), Vector2(0.2f,0.2f), TEST_LOCATION );
}
{
- Property::Value* typeValue = map->Find( Toolkit::Visual::DevelProperty::Transform::Property::OFFSET_SIZE_MODE );
+ Property::Value* typeValue = map->Find( Toolkit::DevelVisual::Transform::Property::OFFSET_SIZE_MODE );
DALI_TEST_CHECK( typeValue );
DALI_TEST_EQUALS( typeValue->Get<Vector4>(), Vector4(1.0f,1.0f,0.0f,0.0f), TEST_LOCATION );
}
{
- Property::Value* typeValue = map->Find( Toolkit::Visual::DevelProperty::Transform::Property::ORIGIN );
+ Property::Value* typeValue = map->Find( Toolkit::DevelVisual::Transform::Property::ORIGIN );
DALI_TEST_CHECK( typeValue );
DALI_TEST_EQUALS( (Toolkit::Align::Type)typeValue->Get<int>(), Toolkit::Align::TOP_BEGIN, TEST_LOCATION );
}
{
- Property::Value* typeValue = map->Find( Toolkit::Visual::DevelProperty::Transform::Property::ANCHOR_POINT );
+ Property::Value* typeValue = map->Find( Toolkit::DevelVisual::Transform::Property::ANCHOR_POINT );
DALI_TEST_CHECK( typeValue );
DALI_TEST_EQUALS( (Toolkit::Align::Type)typeValue->Get<int>(), Toolkit::Align::BOTTOM_END, TEST_LOCATION );
}
//Set a new transform
transform.Clear();
- transform.Insert( Visual::DevelProperty::Transform::Property::OFFSET, Vector2(20.0f, 20.0f) );
- transform.Insert( Visual::DevelProperty::Transform::Property::SIZE, Vector2(100.0f, 100.0f) );
- transform.Insert( Visual::DevelProperty::Transform::Property::OFFSET_SIZE_MODE, Vector4(0.0f, 0.0f, 1.0f,1.0f) );
+ transform.Insert( DevelVisual::Transform::Property::OFFSET, Vector2(20.0f, 20.0f) );
+ transform.Insert( DevelVisual::Transform::Property::SIZE, Vector2(100.0f, 100.0f) );
+ transform.Insert( DevelVisual::Transform::Property::OFFSET_SIZE_MODE, Vector4(0.0f, 0.0f, 1.0f,1.0f) );
visual.SetTransformAndSize( transform, Vector2(100, 100) );
application.SendNotification();
application.Render(0);
Property::Map propertyMap;
propertyMap.Insert( Visual::Property::TYPE, DevelVisual::TEXT );
propertyMap.Insert( "renderingBackend", static_cast<int>( Toolkit::Text::DEFAULT_RENDERING_BACKEND ) );
+ propertyMap.Insert( "enableMarkup", false );
propertyMap.Insert( "text", "Hello world" );
propertyMap.Insert( "fontFamily", "TizenSans" );
propertyMap.Insert( "horizontalAlignment", "CENTER" );
propertyMap.Insert( "verticalAlignment", "CENTER" );
propertyMap.Insert( "textColor", Color::RED );
- propertyMap.Insert( "enableMarkup", false );
Visual::Base textVisual = factory.CreateVisual( propertyMap );
textVisual.SetDepthIndex( 1.f );
application.SendNotification();
application.Render();
+
+ // Create a texture bigger than the maximum allowed by the image atlas. Used to increase coverage.
+ propertyMap.Clear();
+ propertyMap.Insert( Visual::Property::TYPE, DevelVisual::TEXT );
+ propertyMap.Insert( TextVisual::Property::ENABLE_MARKUP, true );
+ propertyMap.Insert( TextVisual::Property::TEXT, "<font family='TizenSans' size='12'>Hello world</font>" );
+ propertyMap.Insert( TextVisual::Property::MULTI_LINE, true );
+
+ Property::Map transformMap;
+ transformMap.Insert( DevelVisual::Transform::Property::SIZE, Vector2( 720.f, 640.f ) );
+ propertyMap.Insert( DevelVisual::Property::TRANSFORM, transformMap );
+
+ textVisual = factory.CreateVisual( propertyMap );
+ textVisual.SetDepthIndex( 1.f );
+
+ dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, textVisual );
+ dummyControl.SetSize( 720.f, 640.f );
+
+ application.SendNotification();
+ application.Render();
+
END_TEST;
}
#include <dali/public-api/rendering/shader.h>
#include <dali/devel-api/images/nine-patch-image.h>
#include <dali-toolkit/devel-api/align-enums.h>
-#include <dali-toolkit/devel-api/visual-factory/devel-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
#include <dali-toolkit/dali-toolkit.h>
#include "dummy-control.h"
{
Property::Map transformMap;
transformMap
- .Add( Toolkit::VisualProperty::Transform::Property::OFFSET, Vector2(0.0f, 0.0f) )
- .Add( Toolkit::VisualProperty::Transform::Property::SIZE, Vector2(1.0f, 1.0f) )
- .Add( Toolkit::VisualProperty::Transform::Property::ORIGIN, Toolkit::Align::CENTER )
- .Add( Toolkit::VisualProperty::Transform::Property::ANCHOR_POINT, Toolkit::Align::CENTER )
- .Add( Toolkit::VisualProperty::Transform::Property::OFFSET_SIZE_MODE, Vector4::ZERO );
+ .Add( Toolkit::DevelVisual::Transform::Property::OFFSET, Vector2(0.0f, 0.0f) )
+ .Add( Toolkit::DevelVisual::Transform::Property::SIZE, Vector2(1.0f, 1.0f) )
+ .Add( Toolkit::DevelVisual::Transform::Property::ORIGIN, Toolkit::Align::CENTER )
+ .Add( Toolkit::DevelVisual::Transform::Property::ANCHOR_POINT, Toolkit::Align::CENTER )
+ .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_SIZE_MODE, Vector4::ZERO );
return transformMap;
}
doxygen-errors.txt
+dali.doxy.bak
all-local:
@rm -f doxygen-errors.txt
+ @-doxygen -u dali.doxy
@-doxygen dali.doxy &> doxygen-errors.txt || rm doxygen-errors.txt
@touch doxygen-errors.txt
@cat doxygen-errors.txt
@rm doxygen-errors.txt
# Build JavaScript API documentation using yuidoc ( Yahoo JavaScript Documentation Tool )
# We first test yuidoc exists, then change in to the dali-script-v8 docs directory and run yuidoc
- @if [ ! `which yuidoc` = "" ]; then cd ../../../plugins/dali-script-v8/docs && yuidoc --config yuidoc.json -e ".cpp,.js,.md" -o generated .. ../../../docs/content/shared-javascript-and-cpp-documentation/ ; fi
\ No newline at end of file
+ @if [ ! `which yuidoc` = "" ]; then cd ../../../plugins/dali-script-v8/docs && yuidoc --config yuidoc.json -e ".cpp,.js,.md" -o generated .. ../../../docs/content/shared-javascript-and-cpp-documentation/ ; fi
}
BubbleEmitter BubbleEmitter::New( const Vector2& winSize,
- Image shapeImage,
+ Dali::Texture shapeTexture,
unsigned int maximumNumberOfBubble,
const Vector2& bubbleSizeRange )
{
- return Internal::BubbleEmitter::New( winSize, shapeImage, maximumNumberOfBubble, bubbleSizeRange );
+ return Internal::BubbleEmitter::New( winSize, shapeTexture, maximumNumberOfBubble, bubbleSizeRange );
}
BubbleEmitter::BubbleEmitter( const BubbleEmitter& handle )
return GetImpl(*this).GetRootActor();
}
-void BubbleEmitter::SetBackground( Image bgImage, const Vector3& hsvDelta )
+void BubbleEmitter::SetBackground( Dali::Texture bgTexture, const Vector3& hsvDelta )
{
- GetImpl(*this).SetBackground( bgImage, hsvDelta );
+ GetImpl(*this).SetBackground( bgTexture, hsvDelta );
}
-void BubbleEmitter::SetShapeImage( Image shapeImage )
+void BubbleEmitter::SetBubbleShape( Dali::Texture shapeTexture )
{
- GetImpl(*this).SetShapeImage( shapeImage );
+ GetImpl(*this).SetBubbleShape( shapeTexture );
}
void BubbleEmitter::SetBubbleScale( float scale )
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/control.h>
+#include <dali/public-api/rendering/texture.h>
namespace Dali
{
* @brief Create an initialized BubbleEmitter.
*
* @param[in] winSize The size of the bubble moving area, usually the same size as the background.
- * @param[in] shapeImage The alpha channnel of this texture defines the bubble shape.
+ * @param[in] shapeTexture 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,
+ Dali::Texture shapeTexture,
unsigned int maximumNumberOfBubble,
const Vector2& bubbleSizeRange );
* @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] bgTexture The background texture 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 );
+ void SetBackground( Dali::Texture bgTexture, 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.
+ * The bubble mesh is a rectangular patch, but its displayed shape is decided by the alpha channel of the shape texture.
+ * @param[in] shapeTexture The texture whose alpha channel defines the bubble shape.
*/
- void SetShapeImage( Image shapeImage );
+ void SetBubbleShape( Dali::Texture shapeTexture );
/**
* @brief Set the scale factor applied to all the bubbles.
/**
* @copydoc Toolkit::ControlWrapper
*/
-class ControlWrapper : public Control
+class DALI_IMPORT_API ControlWrapper : public Control
{
public:
private:
- // Undefined.
- ControlWrapper( const ControlWrapper& );
-
- // Undefined.
- ControlWrapper& operator=( const ControlWrapper& rhs );
+ /// @cond internal
+ /// Undefined.
+ DALI_INTERNAL ControlWrapper( const ControlWrapper& );
+ /// Undefined.
+ DALI_INTERNAL ControlWrapper& operator=( const ControlWrapper& rhs );
+ /// @endcond
};
} // namespace Internal
*
* @param[in] implementation The Control implementation.
*/
- DALI_INTERNAL ControlWrapper( Internal::ControlWrapper& implementation );
+ ControlWrapper( Internal::ControlWrapper& 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 ControlWrapper( Dali::Internal::CustomActor* internal );
+ explicit ControlWrapper( Dali::Internal::CustomActor* internal );
};
} // namespace Toolkit
devel_api_visual_factory_header_files = \
$(devel_api_src_dir)/visual-factory/transition-data.h \
- $(devel_api_src_dir)/visual-factory/devel-visual-properties.h \
$(devel_api_src_dir)/visual-factory/visual-factory.h \
$(devel_api_src_dir)/visual-factory/visual-base.h
devel_api_shader_effects_header_files = \
$(devel_api_src_dir)/shader-effects/alpha-discard-effect.h \
- $(devel_api_src_dir)/shader-effects/bendy-effect.h \
- $(devel_api_src_dir)/shader-effects/blind-effect.h \
- $(devel_api_src_dir)/shader-effects/bouncing-effect.h \
- $(devel_api_src_dir)/shader-effects/carousel-effect.h \
- $(devel_api_src_dir)/shader-effects/displacement-effect.h \
$(devel_api_src_dir)/shader-effects/dissolve-effect.h \
- $(devel_api_src_dir)/shader-effects/dissolve-local-effect.h \
$(devel_api_src_dir)/shader-effects/distance-field-effect.h \
$(devel_api_src_dir)/shader-effects/image-region-effect.h \
- $(devel_api_src_dir)/shader-effects/iris-effect.h \
- $(devel_api_src_dir)/shader-effects/mask-effect.h \
- $(devel_api_src_dir)/shader-effects/mirror-effect.h \
$(devel_api_src_dir)/shader-effects/motion-blur-effect.h \
- $(devel_api_src_dir)/shader-effects/motion-stretch-effect.h \
- $(devel_api_src_dir)/shader-effects/overlay-effect.h \
- $(devel_api_src_dir)/shader-effects/quadratic-bezier.h \
- $(devel_api_src_dir)/shader-effects/ripple-effect.h \
- $(devel_api_src_dir)/shader-effects/ripple2d-effect.h \
- $(devel_api_src_dir)/shader-effects/shear-effect.h \
- $(devel_api_src_dir)/shader-effects/soft-button-effect.h \
- $(devel_api_src_dir)/shader-effects/spot-effect.h \
- $(devel_api_src_dir)/shader-effects/square-dissolve-effect.h \
- $(devel_api_src_dir)/shader-effects/swirl-effect.h
+ $(devel_api_src_dir)/shader-effects/motion-stretch-effect.h
devel_api_super_blur_view_header_files = \
$(devel_api_src_dir)/controls/super-blur-view/super-blur-view.h
* Property::Map alphaDiscardEffect = CreateAlphaDiscardEffect();
* actor.SetProperty( ImageView::Property::IMAGE, alphaDiscardEffect );
*
- * @return A handle to a newly allocated ShaderEffect.
+ * @return A property map of the required shaders.
*/
inline Property::Map CreateAlphaDiscardEffect()
{
+++ /dev/null
-#ifndef __DALI_TOOLKIT_SHADER_EFFECT_BENDY_H__
-#define __DALI_TOOLKIT_SHADER_EFFECT_BENDY_H__
-
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/devel-api/shader-effects/shader-effect.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-/**
- * Creates a new Bendy effect
- *
- * BendyEffect is a custom shader effect to achieve bendy effects in Image actors
- *
- * Animatable/Constrainable uniforms:
- * "uCenter" - The center point of the bendy effect
- * "uDirection" - The direction of the bendy effect
- * "uRadius" - The radius of the bendy effect
- *
- * @return A handle to a newly allocated ShaderEffect.
- */
-inline ShaderEffect CreateBendyEffect()
-{
- // append the default version
- std::string vertextShader(
- "uniform mediump vec2 uCenter;\n"
- "uniform mediump vec2 uDirection;\n"
- "uniform mediump float uRadius;\n"
- "\n"
- "varying mediump float vShade;\n"
- "\n"
- "void main()\n"
- "{\n"
- " mediump float lighting = 0.25;\n"
- " mediump vec4 position = uModelView * vec4(aPosition, 1.0);\n"
- "\n"
- " mediump vec2 d = position.xy - uCenter;\n"
- " mediump float dist = max( 0.0, dot(d,uDirection) );\n"
- " mediump float radius = max(0.0, uRadius - dist * 0.01);\n"
- "\n"
- " mediump float cs = cos(dist / radius / 2.0);\n"
- " mediump float sn = sin(dist / radius / 2.0);\n"
- "\n"
- "position.xy = position.xy - uDirection * dist;\n"
- "\n"
- "position.xy += uDirection * sn * radius;\n"
- "position.z += (1.0 - cs) * radius;\n"
- "\n"
- "gl_Position = uProjection * position;\n"
- "\n"
- "vShade = 1.0 - abs(sn) * lighting;\n"
- "\n"
- "vTexCoord = mix( sTextureRect.xy, sTextureRect.zw, aTexCoord );\n"
- "}" );
-
- std::string fragmentShader(
- "varying mediump float vShade;\n"
- "\n"
- "void main()\n"
- "{\n"
- " gl_FragColor = texture2D(sTexture, vTexCoord) * uColor * vec4(vShade,vShade,vShade,1.0);\n"
- "}" );
-
- // Create the implementation, temporarily owned on stack,
- Dali::ShaderEffect shaderEffect = Dali::ShaderEffect::New(
- vertextShader,
- fragmentShader,
- ShaderEffect::GeometryHints( ShaderEffect::HINT_GRID | ShaderEffect::HINT_DEPTH_BUFFER ));
-
- shaderEffect.SetUniform( "uCenter", Vector2(0.0f, 0.0f), ShaderEffect::COORDINATE_TYPE_VIEWPORT_POSITION );
- shaderEffect.SetUniform( "uDirection", Vector2(0.0f, 0.0f), ShaderEffect::COORDINATE_TYPE_VIEWPORT_DIRECTION );
- shaderEffect.SetUniform( "uRadius", 0.0f );
-
-
- return shaderEffect;
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // __DALI_TOOLKIT_SHADER_EFFECT_BENDY_H__
+++ /dev/null
-#ifndef __DALI_TOOLKIT_SHADER_EFFECT_BLIND_H__
-#define __DALI_TOOLKIT_SHADER_EFFECT_BLIND_H__
-
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/devel-api/shader-effects/shader-effect.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-/**
- * @brief BlindEffect is a custom shader effect to achieve blind effects in Image actors
- *
- * Animatable/Constrainable uniforms:
- * "uStep" - The step of the blind effect.
- *
- * @return A handle to a newly allocated ShaderEffect
- */
-
-inline ShaderEffect CreateBlindEffect()
-{
- std::string fragmentShader(
- "uniform mediump float uStep; \n"
- "void main() \n"
- "{ \n"
- " mediump vec4 alphaColor; \n"
- " mediump vec4 baseColor; \n"
- " baseColor = texture2D( sTexture, vTexCoord); \n"
- " alphaColor = vec4(0.1,0.1,0.1,1.0); \n"
- " lowp float index = 0.0; \n"
- " index = floor(vTexCoord.y/0.1); \n"
- " if((vTexCoord.y < (index * 0.1 + uStep * 0.005)) && (vTexCoord.y > index * 0.1))\n"
- " { \n"
- " gl_FragColor = alphaColor; \n"
- " } \n"
- " else \n"
- " { \n"
- " gl_FragColor = baseColor; \n"
- " } \n"
- " gl_FragColor*=uColor; \n"
- "} \n"
- );
-
- Dali::ShaderEffect shaderEffect = Dali::ShaderEffect::New(
- "",
- fragmentShader,
- ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING | ShaderEffect::HINT_GRID ));
-
- shaderEffect.SetUniform( "uStep", 0.0f );
-
- return shaderEffect;
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // __DALI_TOOLKIT_SHADER_EFFECT_BLIND_H__
+++ /dev/null
-#ifndef __DALI_TOOLKIT_SHADER_EFFECT_BOUNCING_H__
-#define __DALI_TOOLKIT_SHADER_EFFECT_BOUNCING_H__
-
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/devel-api/shader-effects/shader-effect.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-/**
- * @brief Creates a new bouncing effect
- *
- * 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::ShaderEffect bouncingEffect = CreateBouncingEffect( 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,"uProgressRate" ),
- * 1.f, AlphaFunction::BOUNCE );
- * animation.Play();
- *
- * Animatable/Constrainable uniforms:
- * "uProgressRate" - The progress rate to the effect
- *
- * @param[in] color The color used on the bouncing stripe
- * @return A handle to a newly allocated ShaderEffect
- */
-
-inline ShaderEffect CreateBouncingEffect(const Vector4& color)
-{
- std::string fragmentShader = DALI_COMPOSE_SHADER(
- 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,
- ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING ) );
-
- shaderEffect.SetUniform( "uAssignedColor", color );
- shaderEffect.SetUniform( "uProgressRate", 0.0f );
-
- return shaderEffect;
-}
-
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // __DALI_TOOLKIT_SHADER_EFFECT_BOUNCING_H__
+++ /dev/null
-#ifndef __DALI_TOOLKIT_CAROUSEL_EFFECT_H__
-#define __DALI_TOOLKIT_CAROUSEL_EFFECT_H__
-
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/devel-api/shader-effects/shader-effect.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-/**
- * @brief Creates a new Carousel effect
- *
- * CarouselEffect is a custom shader effect to achieve Carousel effects in actors
- *
- * A Carousel has a Radius property which can be +ve (appear as if viewing from the outside of
- * a cylinder/sphere)
- * or -ve (appear as if viewing from the inside of a cylinder/sphere).
- *
- * It can be a horizontal or vertical (cylindrical) or both (spherical). The AnglePerUnit
- * property provides this functionality as a Vector2.
- *
- * Finally, the carousel's center position can be specified as a Screen coordinate (top-left being
- * the origin).
- *
- * Animatable/Constrainable uniforms:
- * "uRadius" - The radius of the Carousel effect. A positive Radius will bend toward the camera,
- * while a negative Radius will bend away from the camera.
- * "uAnglePerUnit" - The angle deviation of Carousel in degrees per geometric unit for each axis
- For example if you wish for the horizontal angle deviation to vary from +/- 10
- degrees, then a Value of 20.0f / stageWidth for the X component should be specified.
- * "uCenter" - The center point of the carousel (in screen coordinates) this is where the peek of the carousel should appear.
- * Defaults value is top-left corner (0.0f, 0.0f).
- *
- * @return A handle to a newly allocated ShaderEffect
- */
-inline ShaderEffect CreateCarouselEffect()
-{
- // append the default version
- std::string vertexShader(
- "uniform float uRadius;\n"
- "uniform mediump vec2 uCenter;\n"
- "uniform mediump vec2 uAnglePerUnit;\n"
- "\n"
- "void main()\n"
- "{\n"
- " mediump vec4 world = uModelView * vec4(aPosition, 1.0);\n"
- " mediump vec2 d = (world.xy - uCenter) * uAnglePerUnit;\n"
- " mediump float a = length(d);\n"
- " mediump float cs = cos(radians(a));\n"
- " world.z -= cs * uRadius;\n"
- " gl_Position = uProjection * world;\n"
- " \n"
- " vTexCoord = mix( sTextureRect.xy, sTextureRect.zw, aTexCoord );\n"
- "}\n");
-
- ShaderEffect shaderEffect = ShaderEffect::New(
- vertexShader,
- "",
- ShaderEffect::GeometryHints( ShaderEffect::HINT_GRID | ShaderEffect::HINT_DEPTH_BUFFER ));
-
-
- shaderEffect.SetUniform( "uRadius", 0.0f );
- shaderEffect.SetUniform( "uCenter", Vector2( 0.0f, 0.0f ) );
- shaderEffect.SetUniform( "uAnglePerUnit", Vector2( 0.0f, 0.0f ) );
-
- return shaderEffect;
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // __DALI_TOOLKIT_CAROUSEL_EFFECT_H__
+++ /dev/null
-#ifndef __DALI_TOOLKIT_SHADER_EFFECT_DISPLACEMENT_H__
-#define __DALI_TOOLKIT_SHADER_EFFECT_DISPLACEMENT_H__
-
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/devel-api/shader-effects/shader-effect.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-/**
- * @brief Creates a new displacement effect
- *
- * Two state displacement effect shader that works on a per object basis. By passing a height-normal map as an effect image, the user can create
- * various styles of buttons on an image actor. The shader requires two height-normal maps in one image, one for each state.
- *
- * The normals and height information for the two states of the button should be strictly specified in this format:
- * ______________
- * | State 0 |
- * | |
- * | | --> Unpressed button normals in rgb and height in a
- * | Map |
- * |______________|
- * | State 1 |
- * | |
- * | | --> Pressed button normals in rgb and height in a
- * | Map |
- * |______________|
- *
- * The RGB values should contain the surface normals and the alpha should contian the height map. For a better effect keep the highest point (alpha value) in
- * the combined map as 1.0 and the lowest posint as 0.0 and 0.5 for any region which doesn't need displacement.
- *
- * For the supplied Normal map the Y-Axis should be down, Meaning (0,0) is in the top left. As the shader inverts the Y axis for lighting calculation.
- *
- * Limitations: Can be applied to ImageActor only, And doesn't provide support for specular color.
- *
- * Usage example:-
- *
- * // Create shader used for doing soft button\n
- * ShaderEffect buttonEffect = CreateDisplacementEffect();
- * buttonEffect.SetEffectImage(Image::New( FANCY_BUTTON_HEIGHT_MAP_IMAGE_PATH ););
- *
- * // set shader to the soft button\n
- * ImageActor fancyButton = ImageActor::New( ... );\n
- * fancyButton.SetShaderEffect( buttonEffect );
- *
- * // animate a button push, using e.g. AlphaFunction::BOUNCE. With these values the button pushes in and out (animates to and fro between the two states)
- *
- *
- * Animation animation = Animation::New( ... );\n
- * animation.AnimateTo( Property(buttonEffect, "uState"), 1.0f, AlphaFunction::BOUNCE, ... );\n
- * animation.Play();\n
- *
- * Animatable/Constrainable uniforms:
- * "uLightDirection" - The light direction is used in the lighting calculation. The angle of incidence directly affects the amount of light reflected.
- * Default (0.0f, 0.7070168f, 0.7071068f), i.e angled at the surface from in front and above.
- * "uAmbientLightColor" - The ambient light is used in the lighting calculation. Care must be taken to not saturate the image by setting this value too high,
- * or the indentation will not look correct. Default 0.15.
- * "uDiffuseLightColor" - The diffuse light is used in the lighting calculation. Default is (1.0f, 1.0f, 1.0f).
- * "uLightMultiplier" - The ambient and diffuse lighting is multiplied by this factor. Since a diffuse light at an angle will cause the whole image to darken,
- * this property can be used to scale the image back up closer to the pixel values of the original diffuse texture. Care must be taken
- * to not saturate the image,or the indentation will not look correct. Default 1.0
- * "uState" - The shader can have a maximum of two end states 0 or 1, Animate between these two values to do the transitions
- * between states. Default 0.0
- * "uHightScale" - The height displacement is multiplied by this factor. Tweak this to get the required level of depth. Default 0.1
- * "uFixedNormal" - The Fixed normal will be used for the light calculation. Tweak this to get the required level of light.
- * Only applicable for the FIXED type shader and not for DISPLACED type
- *
- * @param type The type of the effect, can be either DISPLACED, or FIXED.
- * @return A handle to a newly allocated ShaderEffect
- *
- */
-
-typedef enum
-{
- DISPLACEMENT_EFFECT_DISPLACED = 0, /// Image gets displaced
- DISPLACEMENT_EFFECT_FIXED /// Image does not displace. Useful for matching lighting between areas that do not displace and those that do, e.g for backgrounds which are visible between buttons.
-}DisplacementEffectType;
-
-inline ShaderEffect CreateDisplacementEffect(DisplacementEffectType type)
-{
- std::string fragmentSourceFixed;
- fragmentSourceFixed = "precision mediump float;\n"
- "uniform vec3 uLightDirection;\n"
- "uniform vec3 uAmbientLightColor;\n"
- "uniform vec3 uDiffuseLightColor;\n"
- "uniform float uLightMultiplier;\n"
- "uniform float uState;\n"
- "uniform float uHightScale;\n"
- "uniform vec3 uFixedNormal;\n"
-
- "void main()\n"
- "{\n"
- " vec4 col = texture2D(sTexture, vTexCoord);\n"
- // calc lighting
- " float intensity = dot(uLightDirection, uFixedNormal);"
- " vec3 lighting = (intensity * uDiffuseLightColor) + uAmbientLightColor;\n"
- " lighting *= uLightMultiplier;\n"
- // output col = image * light
- " gl_FragColor = vec4(col.rgb * lighting * uColor.rgb, col.a * uColor.a);\n"
- "}\n";
-
-
-
- std::string fragmentSourceDisplaced(
- "precision mediump float;\n"
- "uniform vec3 uLightDirection;\n"
- "uniform vec3 uAmbientLightColor;\n"
- "uniform vec3 uDiffuseLightColor;\n"
- "uniform float uLightMultiplier;\n"
- "uniform float uState;\n"
- "uniform float uHightScale;\n"
- "void main()\n"
- "{\n"
- " highp vec4 displacementMap1 = texture2D(sEffect, vec2(vTexCoord.s, vTexCoord.t/2.0));\n"
- " highp vec4 displacementMap2 = texture2D(sEffect, vec2(vTexCoord.s, 0.5+vTexCoord.t/2.0));\n"
- " highp vec4 displacementMap = mix(displacementMap1, displacementMap2, uState);\n"
-
- " vec3 normalAdjusted = normalize(displacementMap.rgb*2.0-1.0);\n"
- " float height = uHightScale * (displacementMap.a*2.0 - 1.0);\n"
- " vec2 displacement = vec2(0.0);\n"
- " displacement += (vec2(0.5)-vTexCoord.st)*height;\n"
- " vec2 newCoord = vTexCoord.st + displacement.xy;\n"
-
- " vec4 col = texture2D(sTexture, newCoord);\n"
- // Y-Axis for the normal map is taken as in Y-Down format, So inverting it for GL
- " float intensity = dot(uLightDirection, vec3(1.0,-1.0, 1.0) * normalAdjusted);"
- " vec3 lighting = (intensity * uDiffuseLightColor) + uAmbientLightColor;\n"
- " lighting *= uLightMultiplier;\n"
- " vec3 color = col.rgb * lighting * uColor.rgb;\n"
- " gl_FragColor = vec4(color, col.a * uColor.a);\n"
- "}\n");
-
- //////////////////////////////////////
- // Create shader effect
- //
- //
-
- ShaderEffect shaderEffect;
- switch(type)
- {
- case DISPLACEMENT_EFFECT_DISPLACED:
- shaderEffect = ShaderEffect::New( "", fragmentSourceDisplaced);
- break;
-
- case DISPLACEMENT_EFFECT_FIXED:
- default:
- shaderEffect = ShaderEffect::New( "", fragmentSourceFixed);
- break;
- }
-
-
- //////////////////////////////////////
- // Register uniform properties
- //
- //
- // factors that scale the look, defaults
- shaderEffect.SetUniform("uLightDirection",Vector3(0.0, 0.7070168f, 0.7071068f));
- shaderEffect.SetUniform("uAmbientLightColor",Vector3(0.15f, 0.15f, 0.15f));
- shaderEffect.SetUniform("uDiffuseLightColor",Vector3(1.0f, 1.0f, 1.0f));
- shaderEffect.SetUniform("uLightMultiplier",1.0f);
- shaderEffect.SetUniform("uState",0.0f);
- shaderEffect.SetUniform("uHightScale",0.1f);
-
- if(type == DISPLACEMENT_EFFECT_FIXED)
- {
- shaderEffect.SetUniform("uFixedNormal",Vector3(0.0f, 0.0f, 1.0f) );
- }
-
- return shaderEffect;
-}
-
-}
-
-}
-
-#endif //#ifndef __DALI_TOOLKIT_SHADER_EFFECT_DISPLACEMENT_H__
+++ /dev/null
-#ifndef __DALI_TOOLKIT_SHADER_EFFECT_LOCAL_DISSOLVE_H__
-#define __DALI_TOOLKIT_SHADER_EFFECT_LOCAL_DISSOLVE_H__
-
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/devel-api/shader-effects/shader-effect.h>
-#include <sstream>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-/**
- * @brief Create a new DissolveLocalEffect
- *
- * DissolveLocalEffect is a custom shader effect to achieve Dissolve effects in multiple small areas of Image actors
- *
- * Animatable/Constrainable uniforms:
- * "uTransparency"
- * "uCenter" - The center positions of each dimples
- * "uRadius" - The propagation radius of each dimple
- * "uPercentage" - The distortion applied to the effect texture. A value of zero means no distortion
- *
- * @param[in] numberOfDimples The number of dimples
- * @return A handle to a newly allocated ShaderEffect
- */
-inline ShaderEffect CreateDissolveLocalEffect( unsigned int numberOfDimples )
-{
- std::ostringstream vertexShaderStringStream;
- vertexShaderStringStream << "#define NUMBER_OF_DIMPLE "<< numberOfDimples << "\n";
- std::string vertexShader(
- "precision highp float;\n"
- "uniform vec2 uCenter[ NUMBER_OF_DIMPLE ];\n"
- "uniform float uRadius[ NUMBER_OF_DIMPLE ]; \n"
- "uniform float uPercentage[ NUMBER_OF_DIMPLE ]; \n"
- "varying float vPercentage;\n"
- "void main()\n"
- "{\n"
- " vec4 position = uModelView * vec4( aPosition, 1.0 );\n"
- " float percentage = 0.0;\n"
- " for( int i=0; i<NUMBER_OF_DIMPLE; ++i )\n"
- " {\n"
- " float distance = distance(uCenter[i], position.xy);\n"
- " percentage = max(percentage, uPercentage[i] * cos(clamp( distance/uRadius[i], 0.0, 1.0 )*1.57) );"
- " }\n"
- " vPercentage = clamp( percentage, 0.0, 1.0 );\n"
- " gl_Position = uProjection * position;\n"
- " vTexCoord = mix( sTextureRect.xy, sTextureRect.zw, aTexCoord );\n"
- "}\n");
- vertexShaderStringStream << vertexShader;
-
- std::string fragmentShader(
- "precision highp float;\n"
- "uniform float uTransparency;\n"
- "varying float vPercentage;\n"
- "float rand(vec2 co) \n"
- "{\n"
- " return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); \n"
- "}\n"
- "void main()\n"
- "{\n"
- //Calculate the randomness
- " float offsetS = rand( vTexCoord * vPercentage ); \n"
- " float offsetT = rand( vec2(vTexCoord.t*vPercentage, vTexCoord.s * vPercentage) ); \n"
- " vec2 lookupCoord = vTexCoord + vec2(offsetS, offsetT) * vPercentage; \n"
- " gl_FragColor = texture2D( sTexture, lookupCoord ) * uColor; \n"
- " gl_FragColor.a *= 1.0 - uTransparency*vPercentage; \n"
- "}\n");
-
- ShaderEffect shaderEffect = ShaderEffect::New(
- vertexShaderStringStream.str(), fragmentShader,
- ShaderEffect::GeometryHints( ShaderEffect::HINT_GRID | ShaderEffect::HINT_BLENDING ) );
-
- //Register uniform properties
- std::ostringstream oss;
- for( unsigned int i = 0; i < numberOfDimples; i++ )
- {
- oss.str("");
- oss<< "uCenter["<< i << "]";
- shaderEffect.SetUniform(oss.str(), Vector2(0.f,0.f));
-
- oss.str("");
- oss<< "uRadius["<< i << "]";
- shaderEffect.SetUniform(oss.str(), 0.f);
-
- oss.str("");
- oss<< "uPercentage["<< i << "]";
- shaderEffect.SetUniform( oss.str(), 0.f );
- }
-
- shaderEffect.SetProperty( ShaderEffect::Property::GRID_DENSITY, Dali::Property::Value(5.f) );
- shaderEffect.SetUniform( "uTransparency", 0.5f );
-
- return shaderEffect;
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // __DALI_TOOLKIT_SHADER_EFFECT_LOCAL_DISSOLVE_H__
#include <dali/public-api/object/property-map.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/devel-api/visual-factory/devel-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
namespace Dali
{
* "uBottomRight" - The bottom-right corner of the image region. The coordinates are in percentage,
* (0,0) being the top-left and (1,1) the bottom right of the original image
*
- * @return A handle to a newly allocated ShaderEffect
+ * @return A property map of the required shader
*/
inline Property::Map CreateImageRegionEffect()
{
Property::Map customShader;
customShader[ Visual::Shader::Property::VERTEX_SHADER ] = vertexShader;
- map[ VisualProperty::SHADER ] = customShader;
+ map[ DevelVisual::Property::SHADER ] = customShader;
return map;
}
+++ /dev/null
-#ifndef __DALI_TOOLKIT_SHADER_EFFECT_IRIS_H__
-#define __DALI_TOOLKIT_SHADER_EFFECT_IRIS_H__
-
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/devel-api/shader-effects/shader-effect.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-/**
- * @brief Creates a new IrisEffect
- *
- * IrisEffect is a custom shader effect to achieve iris effects in Image actors
- *
- * Animatable/Constrainable uniforms:
- *
- * "uRadius" - The radius of the iris effect in texture coordinate distance,
- * i.e. 0.0 (no circle) to 1.0 (complete circle), to > 1.0 (extending outside of texture).
- * @note For Atlas Textures results may be unpredictable.
- *
- * "uBlendFactor" - The blend factor of the iris effect. The lower the value, the larger the blending portion
- * (between Opaque & Transparent). Blending will account for 1 / blendFactor of the radius
- * of the texture.
- *
- * "uCenter" - The center point of the iris (in texture coordinates)
- *
- * @return A handle to a newly allocated ShaderEffect
- */
-inline ShaderEffect CreateIrisEffect()
-{
- // append the default version
- std::string vertexShader(
- "uniform mediump vec2 uCenter;\n"
- "varying mediump vec2 vRelativePosition;\n"
- "\n"
- "void main()\n"
- "{\n"
- " mediump vec4 world = uModelView * vec4(aPosition, 1.0);\n"
- " gl_Position = uProjection * world;\n"
- " \n"
- " vTexCoord = mix( sTextureRect.xy, sTextureRect.zw, aTexCoord );\n"
- " vRelativePosition = vTexCoord - uCenter;\n"
- "}\n");
-
- std::string fragmentShader(
- "uniform mediump float uRadius; \n"
- "uniform mediump float uBlendFactor; \n"
- "varying mediump vec2 vRelativePosition; \n"
- "void main() \n"
- "{ \n"
- " mediump float delta = (length(vRelativePosition) - uRadius); \n"
- " delta = clamp(0.0 - delta * uBlendFactor, 0.0, 1.0); \n"
- " gl_FragColor = texture2D(sTexture, vTexCoord) * uColor; \n"
- " gl_FragColor.a *= delta; \n"
- "} \n"
- );
-
- Dali::ShaderEffect shaderEffect = Dali::ShaderEffect::New(
- vertexShader,
- fragmentShader,
- ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING ));
-
- shaderEffect.SetUniform( "uRadius", 0.0f );
- shaderEffect.SetUniform( "uBlendFactor", 100.0f );
- shaderEffect.SetUniform( "uCenter", Vector2(0.5f, 0.5f) );
-
- return shaderEffect;
-}
-
-}
-}
-
-#endif
+++ /dev/null
-#ifndef __DALI_TOOLKIT_MASK_EFFECT_H__
-#define __DALI_TOOLKIT_MASK_EFFECT_H__
-
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/images/image.h>
-#include <dali/devel-api/shader-effects/shader-effect.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-/**
- * @brief Creates a new MaskEffect
- *
- * MaskEffect is used to control which parts of an image are visible, using the alpha channel of a separate mask image.
- *
- * Typically mask images should be the same size as the main image being viewed, but this isn't essential.
- *
- * Usage example:
- *
- * ImageActor actor = ImageActor::New( Image( EXAMPLE_IMAGE_PATH ) );
- * ShaderEffect maskEffect = CreateMaskEffect( Image::New( MASK_IMAGE_PATH ) );
- * actor.SetShaderEffect( maskEffect );
- *
- * @param[in] maskImage The image to use as a mask
- * @return A handle to a newly allocated ShaderEffect
- */
-inline ShaderEffect CreateMaskEffect(Image maskImage)
-{
- const char* ALPHA_MASK_FRAGMENT_SHADER_SOURCE =
- "void main() \n"
- "{ \n"
- " highp vec4 mask = texture2D(sEffect, vTexCoord); \n"
- " gl_FragColor = texture2D(sTexture, vTexCoord) * uColor * vec4(1,1,1,mask.a); \n"
- "} \n";
-
- ShaderEffect shaderEffect = ShaderEffect::New(
- "", // Use default
- ALPHA_MASK_FRAGMENT_SHADER_SOURCE,
- ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING ) );
-
- shaderEffect.SetEffectImage( maskImage );
-
- return shaderEffect;
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // __DALI_TOOLKIT_MASK_EFFECT_H__
+++ /dev/null
-#ifndef __DALI_TOOLKIT_MIRROR_EFFECT_H__
-#define __DALI_TOOLKIT_MIRROR_EFFECT_H__
-
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/devel-api/shader-effects/shader-effect.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-/**
- * @brief Creates a new MirrorEffect
- *
- * MirrorEffect is a custom shader effect to achieve square effects in Image actors
- *
- * Animatable/Constrainable uniforms:
- * "uDepth" - The depth of the mirror effect. Default value 0.5
- * "uAlpha" - The alpha of the mirror effect. Default value 1.0
- *
- * @return A handle to a newly allocated ShaderEffect
- */
-inline ShaderEffect CreateMirrorEffect()
-{
- std::string vertexShader(
- "void main() \n"
- "{ \n"
- " mediump vec3 pos = aPosition; \n"
- " pos.y = pos.y * 3.0; \n"
- " mediump vec4 world = uModelView * vec4(pos,1.0); \n"
- " gl_Position = uProjection * world; \n"
- " vTexCoord = mix( sTextureRect.xy, sTextureRect.zw, aTexCoord ); \n"
- "} \n" );
-
- std::string fragmentShader(
- "uniform mediump float uDepth; \n"
- "uniform mediump float uAlpha; \n"
- "void main() \n"
- "{ \n"
- " if(vTexCoord.y < 1.0 / 3.0) \n"
- " { \n"
- " gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); \n"
- " } \n"
- " else if(vTexCoord.y < 2.0 / 3.0) \n"
- " { \n"
- " gl_FragColor = texture2D(sTexture, vec2(vTexCoord.x, vTexCoord.y * 3.0 - 1.0)) * uColor; \n"
- " gl_FragColor.a *= uAlpha; \n"
- " } \n"
- " else \n"
- " { \n"
- " highp float darkness = 3.0 - vTexCoord.y * 3.0; \n"
- " darkness = (1.0 - 1.0 / uDepth + darkness * 1.0/ uDepth) * 0.65; \n"
- " highp vec4 color = texture2D(sTexture, vec2(vTexCoord.x, -vTexCoord.y *3.0 + 3.0)) * uColor; \n"
- " color.a *= uAlpha; \n"
- " gl_FragColor = color * vec4(darkness, darkness, darkness, darkness); \n"
- " } \n"
- "} \n" );
-
- Dali::ShaderEffect shaderEffect = Dali::ShaderEffect::New(
- vertexShader,
- fragmentShader,
- ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING ));
-
- shaderEffect.SetUniform("uAlpha", 1.0f);
- shaderEffect.SetUniform("uDepth", 0.5f);
-
- return shaderEffect;
-}
-
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // __DALI_TOOLKIT_MIRROR_EFFECT_H__
+++ /dev/null
-#ifndef __DALI_TOOLKIT_OVERLAY_EFFECT_H__
-#define __DALI_TOOLKIT_OVERLAY_EFFECT_H__
-
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/images/image.h>
-#include <dali/devel-api/shader-effects/shader-effect.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-/**
- * @brief Creates a new OverlayEffect
- *
- * OverlayEffect is used to apply an overlay image to the actor.
- * Typically overlay images should be the same size as the main image being viewed, but this isn't essential.
- *
- * Usage example:
- *
- * ImageActor actor = ImageActor::New( Image( EXAMPLE_IMAGE_PATH ) );
- * ShaderEffect overlayEffect = CreateOverlayEffect( Image::New( OVERLAY_IMAGE_PATH ) );
- * actor.SetShaderEffect( overlayEffect );
- *
- * @param[in] overlayImage The image to overlay on top of the actor
- * @return A handle to a newly allocated ShaderEffect
- */
-inline ShaderEffect CreateOverlayEffect(Image overlayImage)
-{
- // (Target > 0.5) * (1 - (1-2*(Target-0.5)) * (1-Blend)) + (Target <= 0.5) * ((2*Target) * Blend)
- const char* OVERLAY_FRAGMENT_SHADER_SOURCE =
- "void main()\n"
- "{\n"
- " lowp vec4 target = texture2D(sTexture, vTexCoord);\n"
- " lowp vec4 overlay = texture2D(sEffect, vTexCoord);\n"
- " if ( length( target.rgb ) > 0.5 )\n"
- " {\n"
- " gl_FragColor = vec4( mix( target.rgb, 1.0 - ( 1.0 - 2.0 * ( target.rgb - 0.5 ) ) * ( 1.0 - overlay.rgb ), overlay.a ), min( 1.0, target.a + overlay.a ) );\n"
- " }\n"
- " else\n"
- " {\n"
- " gl_FragColor = vec4( mix( target.rgb, 2.0 * target.rgb * overlay.rgb, overlay.a ), target.a + overlay.a );\n"
- " }\n"
- "}\n";
-
- ShaderEffect shaderEffect = ShaderEffect::New(
- "", // Use default
- OVERLAY_FRAGMENT_SHADER_SOURCE,
- ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING ) );
-
- shaderEffect.SetEffectImage( overlayImage );
-
- return shaderEffect;
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // __DALI_TOOLKIT_OVERLAY_EFFECT_H__
+++ /dev/null
-#ifndef __DALI_TOOLKIT_QUADRATIC_BEZIER_H__
-#define __DALI_TOOLKIT_QUADRATIC_BEZIER_H__
-
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/devel-api/shader-effects/shader-effect.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-/**
- * @brief Creates a new QuadraticBezier shader effect
- *
- * QuadraticBezier is a custom shader to render quadratic bezier curves and bounded regions.
- *
- * Implementation based on the paper "Resolution Independent Curve Rendering using Programmable Graphics Hardware"
- * by Charles Loop and Jim Blinn.
- *
- * The coordinates of the control points is passed to the shader via uniforms.
- * aNormal attribute is used to pass the coefficients of each control point (xy coordinates) as well as the vertex ID (z coordinate).
- * A quadratic curve should have as normal for the first control point (0.0,0.0), (0.5,0.0) for the second and (1.0,1.0) for the third.
- * Triangles that do not contain curves should have coordinates (0.0,1.0) for each control point in order to be filled properly.
- *
- * Animatable/Constrainable uniforms:
- * "uPoint" - Position coordinates for the points in the curve
- * "uColor" - The color of the curve or bounded region
- * "uLineWidth" - The width of the path. Only for not filled curves
- *
- * @param[in] pointCount The maximum number of vertices
- * @param[in] filled Specify whether the the bounded region should be filled or not
- * @return A handle to a newly allocated ShaderEffect
- */
-inline ShaderEffect CreateQuadraticBezier(unsigned int pointCount, bool filled)
-{
- std::string vertexShader = DALI_COMPOSE_SHADER
- (
- uniform mediump vec3 uPoint[MAX_POINT_COUNT];\n
- varying highp vec2 vCoefficient;
- void main()\n
- {\n
- int vertexId = int(aNormal.z);\n
- gl_Position = uMvpMatrix * vec4(uPoint[vertexId], 1.0);\n
- vCoefficient = aNormal.xy;\n
- }\n
- );
-
- std::string fragmentShader;
-
- if( filled )
- {
- fragmentShader = DALI_COMPOSE_SHADER
- (
- varying highp vec2 vCoefficient;\n
-
- void main()\n
- {\n
- highp float C = (vCoefficient.x*vCoefficient.x-vCoefficient.y);\n
- highp float Cdx = dFdx(C);\n
- highp float Cdy = dFdy(C);\n
-
- highp float distance = float(C / sqrt(Cdx*Cdx + Cdy*Cdy));\n
-
- gl_FragColor = uColor;\n
- highp float alpha = 0.5 - distance;\n
- if( alpha < 0.0 )\n
- discard;\n
-
- gl_FragColor.w = alpha;\n
- }\n
- );
- }
- else
- {
- fragmentShader = DALI_COMPOSE_SHADER
- (
- varying highp vec2 vCoefficient;\n
- uniform lowp float uLineWidth;\n
-
- void main()\n
- {\n
- highp float C = (vCoefficient.x*vCoefficient.x-vCoefficient.y);\n
- highp float Cdx = dFdx(C);\n
- highp float Cdy = dFdy(C);\n
- highp float distance = abs(float(C / sqrt(Cdx*Cdx + Cdy*Cdy)));\n
- gl_FragColor = uColor*(uLineWidth-distance);\n
- }\n
- );
- }
-
- std::ostringstream vertexShaderPrefix;
- vertexShaderPrefix << "#define MAX_POINT_COUNT "<< pointCount << "\n";
-
- Dali::ShaderEffect shaderEffect = Dali::ShaderEffect::NewWithPrefix(
- vertexShaderPrefix.str(),vertexShader,
- "#extension GL_OES_standard_derivatives:enable\n", fragmentShader );
-
- //Set default uniform values
- shaderEffect.SetUniform( "uColor", Vector4(1.0f,1.0f,1.0f,1.0f) );
- if( !filled )
- {
- //Set default line widht to 1 pixel
- shaderEffect.SetUniform( "uLineWidth", 1.0f );
- }
-
- return shaderEffect;
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // __DALI_TOOLKIT_IMAGE_REGION_EFFECT_H__
+++ /dev/null
-#ifndef __DALI_TOOLKIT_SHADER_EFFECT_RIPPLE_H__
-#define __DALI_TOOLKIT_SHADER_EFFECT_RIPPLE_H__
-
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/devel-api/shader-effects/shader-effect.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-/**
- * @brief Creates a new RippleEffect
- *
- * RippleEffect is a custom shader effect to achieve ripple effects on Image actors.
- *
- * Animatable/Constrainable uniforms:
- * "uAmplitude" - The amplitude of the effect
- * "uCenter" - The center point of the effect as screen coordinates
- * "uTime" - The time duration for the ripple
- *
- * @return A handle to a newly allocated ShaderEffect
- */
-inline ShaderEffect CreateRippleEffect()
-{
- std::string vertexShader(
- "precision mediump float;\n"
- "uniform mediump vec2 uCenter;\n"
- "uniform mediump float uTime;\n"
- "uniform mediump float uAmplitude;\n"
- "varying mediump float vLight;\n"
- "varying mediump float vShade;\n"
- "void main()\n"
- "{\n"
- "float lighting = uAmplitude * 0.02;\n"
- "float waveLength = uAmplitude * 0.0016;\n"
- "vec4 world = uModelView * vec4(aPosition, 1.0);\n"
- "vec2 d = vec2(world.x - uCenter.x, world.y - uCenter.y);\n"
- "float dist = length(d);\n"
- "float amplitude = cos(uTime - dist*waveLength);\n"
- "float slope = sin(uTime - dist*waveLength);\n"
- "world.z += amplitude * uAmplitude;\n"
- "gl_Position = uProjection * world;\n"
- "vec2 lightDirection = vec2(-0.707,0.707);\n"
- "float dot = 0.0;\n"
- "if(dist > 0.0)\n"
- "{\n"
- " dot = dot(normalize(d),lightDirection) * lighting;\n"
- "}\n"
- "vShade = 1.0 - (dot * slope);\n"
- "vLight = max(0.0, dot * -slope);\n"
- "vTexCoord = mix( sTextureRect.xy, sTextureRect.zw, aTexCoord );\n"
- "}" );
-
- // append the default version
- std::string imageFragmentShader(
- "precision mediump float;\n"
- "varying mediump float vLight;\n"
- "varying mediump float vShade;\n"
- "void main()\n"
- "{\n"
- " gl_FragColor = texture2D(sTexture, vTexCoord) * uColor * vec4(vShade,vShade,vShade,1.0) + vec4(vLight, vLight, vLight,0.0);\n"
- "}" );
-
-
- Dali::ShaderEffect shaderEffect = Dali::ShaderEffect::New(
- vertexShader, imageFragmentShader,
- ShaderEffect::GeometryHints(ShaderEffect::HINT_GRID) );
-
-
- shaderEffect.SetUniform( "uAmplitude", 0.0f );
- shaderEffect.SetUniform( "uCenter", Vector2(0.0f, 0.0f));
- shaderEffect.SetUniform( "uTime", 0.0f );
-
- return shaderEffect;
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // __DALI_TOOLKIT_SHADER_EFFECT_RIPPLE_H__
+++ /dev/null
-#ifndef __DALI_TOOLKIT_SHADER_EFFECT_RIPPLE2D_H__
-#define __DALI_TOOLKIT_SHADER_EFFECT_RIPPLE2D_H__
-
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/devel-api/shader-effects/shader-effect.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-/**
- * @brief Creates a new Ripple2DEffect
- *
- * Ripple2DEffect is a custom shader effect to achieve 2d ripple effects on Image actors.
- *
- * Animatable/Constrainable uniforms:
- * "uTime" - The time duration for the 2d ripple
- * "uAmplitude" - The amplitude of the 2d ripple
- *
- * @return A handle to a newly allocated ShaderEffect
- */
-inline ShaderEffect CreateRipple2DEffect()
-{
- // append the default version
- std::string fragmentShader(
- "precision mediump float;\n"
- "uniform float uAmplitude;\n"
- "uniform float uTime;\n"
- "void main()\n"
- "{\n"
- " highp vec2 textureSize = sTextureRect.zw - sTextureRect.xy;\n"
- " highp vec2 pos = -1.0 + 2.0 * vTexCoord.st/textureSize;\n"
- " highp float len = length(pos);\n"
- " highp vec2 texCoord = vTexCoord.st/textureSize + pos/len * sin( len * 12.0 - uTime * 4.0 ) * uAmplitude;\n"
- " gl_FragColor = texture2D(sTexture, texCoord) * uColor;\n"
- "}" );
-
- Dali::ShaderEffect shaderEffect = Dali::ShaderEffect::New(
- "", fragmentShader,
- ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING | ShaderEffect::HINT_GRID ));
-
-
-
- shaderEffect.SetUniform( "uTextureSize", Vector2(0.0f, 0.0f) ); //@note: Is this needed?
- shaderEffect.SetUniform( "uAmplitude", 0.0f );
- shaderEffect.SetUniform( "uTime", 0.0f );
-
- return shaderEffect;
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // __DALI_TOOLKIT_SHADER_EFFECT_RIPPLE2D_H__
+++ /dev/null
-#ifndef __DALI_TOOLKIT_SHEAR_EFFECT_H__
-#define __DALI_TOOLKIT_SHEAR_EFFECT_H__
-
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/devel-api/shader-effects/shader-effect.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-/**
- * @brief Creates a new ShearEffect
- *
- * ShearEffect is a custom shader effect to achieve shear effects in Image actors
- *
- * Animatable/Constrainable uniforms:
- * "uCenter" - The center point of the shear effect in screen coordinates
- * "uAngleXAxis" - The angle of the shear effect in the X axis
- * "uAngleYAxis" - The angle of the shear effect in the Y axis
- *
- * @return A handle to a newly allocated ShaderEffect
- */
-inline ShaderEffect CreateShearEffect()
-{
- // append the default version
- std::string vertexShader(
- "uniform mediump vec2 uCenter;\n"
- "uniform mediump float uAngleXAxis;\n"
- "uniform mediump float uAngleYAxis;\n"
- "\n"
- "void main()\n"
- "{\n"
- "mediump vec4 world = uModelView * vec4(aPosition, 1.0);\n"
- "\n"
- "world.x = world.x + tan(radians(uAngleXAxis)) * (world.y - uCenter.y * world.w);\n"
- "world.y = world.y + tan(radians(uAngleYAxis)) * (world.x - uCenter.x * world.w);\n"
- "\n"
- "gl_Position = uProjection * world;\n"
- "\n"
- "vTexCoord = mix( sTextureRect.xy, sTextureRect.zw, aTexCoord );\n"
- "}" );
-
- // Create the implementation, temporarily owned on stack,
- ShaderEffect shaderEffect = Dali::ShaderEffect::New(
- vertexShader,
- "",
- ShaderEffect::GeometryHints( ShaderEffect::HINT_GRID ));
-
-
- shaderEffect.SetUniform( "uCenter", Vector2(0.0f, 0.0f), ShaderEffect::COORDINATE_TYPE_VIEWPORT_POSITION );
- shaderEffect.SetUniform( "uAngleXAxis", 0.0f);
- shaderEffect.SetUniform( "uAngleYAxis", 0.0f);
-
- return shaderEffect;
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // __DALI_TOOLKIT_SHEAR_EFFECT_H__
+++ /dev/null
-#ifndef __DALI_TOOLKIT_SHADER_EFFECT_SOFT_BUTTON_H__
-#define __DALI_TOOLKIT_SHADER_EFFECT_SOFT_BUTTON_H__
-
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/devel-api/shader-effects/shader-effect.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-/**
- * @brief Creates a new soft button shader effect
- *
- * Soft button shader effect works on a per object basis. Using animatable parameters user can create
- * effect of button pushing in / out. Can be applied to ImageActor only.
- *
- * Usage example:-
- *
- * // Create shader used for doing soft button\n
- * ShaderEffect softButtonEffect = CreateSoftButtonEffect();
- *
- * // set image actor shader to the soft button one\n
- * ImageActor imageActor = ImageActor::New( ... );\n
- * imageActor.SetShaderEffect( softButtonEffect );
- *
- * // animate a button push, using e.g. AlphaFunction::BOUNCE. With these values the button pushes in and pops out slightly at the end\n
- * Animation animation = Animation::New( ... );\n
- * animation.AnimateTo( Property(softButtonEffect, "uLightingIndentationAmount), 0.25f, AlphaFunction::BOUNCE, ... );\n
- * animation.AnimateTo( Property(softButtonEffect, "uLightingIndentationAmount"), -0.05f, AlphaFunction::BOUNCE, ... );\n
- * animation.AnimateTo( Property(softButtonEffect, "uTextureDistortAmount"), 0.25f, AlphaFunction::BOUNCE, ... );\n
- * animation.AnimateTo( Property(softButtonEffect, "uTextureDistortAmount"), -0.05f, AlphaFunction::BOUNCE, ... );\n
- * animation.Play();\n
- *
- * Animatable/Constrainable uniforms:
- *
- * "uLightingIndentationAmount" - This property changes the lighting, to make it look like the button is pushed in. User should animate
- * this in conjunction with texture distortion. Allowable values range from [-1..1], higher values give
- * more change in lighting. Default 0.0 (no lighting change).
- * "uTextureDistortAmount" - This property changes the distortion, to make it look like the button is pushed in. User should animate
- * this in conjunction with lighting indentation. Allowable values range from [-1..1) - note 1.0 is NOT
- * allowed - higher values give more distortion. Default 0.0 (no distortion).
- * "uAmbientLight" - The ambient light is used in the lighting calculation. Care must be taken to not saturate the image by
- * setting this value too high, or the indentation will not look correct. Default 0.15
- * "uDiffuseLight" - The diffuse light is used in the lighting calculation. Default is (0.0, 0.7070168, 0.7070168),
- * i.e. a light angled at the surface from in front and above. Note that you need to Normalize()
- * the Vector3 that you set with this property
- * "uLightMultiplier" - The ambient and diffuse lighting is multiplied by this factor. Since a diffuse light at an angle will
- * cause the whole image to darken, even outside the soft button indentation, this property can be used
- * to scale the image back up closer to the pixel values of the original diffuse texture. Care must be
- * taken to not saturate the image,or the indentation will not look correct. Default 1.2.
- * "uInsideCircleSizeScale" - The SoftButtonEffect consists of two shapes, one inside the other. The outside shape fits exactly to
- * the actor, touching its edges but completely contained. The inside shape size is given by a multiplier
- * of the outside shape size. For example a value of 0.5 means that the inside shape is half the size of
- * the outside one. Allowable values are in the range (0.0 - 1.0), note that 0.0 and 1.0 themselves are
- * not allowed. Default 0.75.
- * "uOutsideCircleDepth" - The SoftButtonEffect consists of two shapes, one inside the other. The depth of the indentation at the
- * transition between the inside and outside shapes is controlled by this property. The values lies in the
- * range [0.0 - 1.0]. A value of 0.0 means the outside shape has no depth (and is thus invisible), value of
- * 1.0 means the outside shape has maximum depth (and the inside shape is thus invisible). Default 0.05
- * "uEffectRegion" - The soft button effect is applied within the supplied rect region of the texture. Default values for this
- * is (0.0, 0.0, 1.0, 1.0) which is the entire image with 0,0 being the top left and 1.0, 1.0 being the bottom
- * right. If the image texture is split between multiple ImageActors then the developer should specify the pixel
- * area of the texture the effect should be applied with. Example, If the Image is split among two ImageActors
- * side by side, with the left one using left half of the texture and right one using the right half of the
- * texture then the pixel area value for the left ImageActor will be (0.0, 0.0, 0.5, 1.0) and the pixel area for
- * the right will be (0.5,0.0,1.0,1.0).
- * "uRectangleSizeScale" - This property can be used to set the mix between proportion of rectangle and proportion of ellipse - the
- * result is a rectangle with rounded corners. If the value is 0.0, the shape is an ellipse. If the value is
- * close to 1.0, the shape is close to a rectangle. The value lies in the range [0.0 - 1.0). Note that a value
- * of 1.0 is NOT allowed.Default 0.5.
- *
- * @param type The type of the soft button, can be either ELLIPTICAL, RECTANGULAR, or FIXED.
- * @return A handle to a newly allocated ShaderEffect
- */
-typedef enum
-{
- SOFT_BUTTON_ELLIPTICAL = 0, /// Button is elliptical
- SOFT_BUTTON_RECTANGULAR, /// Button is rectangular
- SOFT_BUTTON_FIXED /// Button does not indent (move). Useful for matching lighting between areas that do not indent (which can thus use a cheaper shader) and those that do indent.
-}SoftButtonEffectType;
-
-static void InverseConstraint( float& current, const PropertyInputContainer& inputs )
-{
- current = 1.0f / inputs[0]->GetFloat();
-}
-
-inline ShaderEffect CreateSoftButtonEffect(SoftButtonEffectType type)
-{
- std::string vertexSource;
- vertexSource = "precision mediump float;\n"
- "uniform vec3 uDiffuseLight;\n"
- "uniform float uAmbientLight;\n"
- "uniform float uLightMultiplier;\n"
- "uniform vec4 uEffectRegion;\n"
- "varying vec2 vCentredCoord;\n"
-
- "const vec3 norm = vec3(0.0, 0.0, 1.0);\n"
-
- "void main()\n"
- "{\n"
- " vTexCoord = mix( sTextureRect.xy, sTextureRect.zw, aTexCoord );\n"
- // Get the rect coords of the effect region in -1..1 range, i.e. circle centred around the center of the rect
- // Done in the vertex shader itself to make use of gl interpolation for varying.
- " vCentredCoord = vec2( ( (vTexCoord.x - uEffectRegion.x)/(uEffectRegion.z - uEffectRegion.x) * 2.0 - 1.0 ), ( (vTexCoord.y - uEffectRegion.y)/(uEffectRegion.w - uEffectRegion.y) * 2.0 - 1.0 ) );\n"
- " gl_Position = uMvpMatrix * vec4(aPosition, 1.0);\n"
- "}\n";
-
- std::string fragmentSourceFixed;
- fragmentSourceFixed = "precision mediump float;\n"
-
- "uniform vec3 uDiffuseLight;\n"
- "uniform float uAmbientLight;\n"
- "uniform float uLightMultiplier;\n"
- "varying vec2 vCentredCoord;\n"
-
- "const vec3 norm = vec3(0.0, 0.0, 1.0);\n"
-
- "void main()\n"
- "{\n"
- " vec4 col = texture2D(sTexture, vTexCoord);\n"
- // calc lighting
- " float lighting = (dot(uDiffuseLight, norm) + uAmbientLight) * uLightMultiplier;\n"
- // output col = image * light
- // use the lighting value for colors only
- " gl_FragColor = vec4(col.rgb * uColor.rgb * lighting, col.a * uColor.a);\n"
- "}\n";
-
- std::string fragmentSourceElliptical;
- fragmentSourceElliptical = "precision mediump float;\n"
-
- "uniform float uLightingIndentationAmount;\n"
- "uniform float uTextureDistortAmount;\n"
- "uniform vec3 uDiffuseLight;\n"
- "uniform float uAmbientLight;\n"
- "uniform float uLightMultiplier;\n"
- "uniform float uInsideCircleSizeScale;\n"
- "uniform float uRecipInsideCircleSizeScale;\n"
- "uniform float uOutsideCircleDepth;\n"
- "uniform vec4 uEffectRegion;\n"
- "varying vec2 vCentredCoord;\n"
-
- "const float PI = 3.1415927;\n"
-
- "void main()\n"
- "{\n"
- // Apply distortion only if the pixel is within the rect specified
- "if( (vTexCoord.x > uEffectRegion.x) && (vTexCoord.x < uEffectRegion.z) && (vTexCoord.y > uEffectRegion.y) && (vTexCoord.y < uEffectRegion.w) )\n"
- "{\n"
- " vec2 coord = vCentredCoord;\n"
-
- // find a coordinate representing distance from circle centre, such that we split into inside / outside circles that can have different gradients / normals
- " float realDistFromCentre = length(coord);\n"
- " realDistFromCentre = min(1.0, realDistFromCentre);\n" // clamp corners of square to vertical normal
- " float distFromCentre;\n"
- " if(realDistFromCentre <= uInsideCircleSizeScale)\n"
- " {\n"
- " distFromCentre = realDistFromCentre * uRecipInsideCircleSizeScale * (1.0 - uOutsideCircleDepth);\n" // inside circle indent, up to outline depth
- " }\n"
- " else \n"
- " {\n"
- " distFromCentre = mix(1.0 - uOutsideCircleDepth, 1.0, (realDistFromCentre - ( uInsideCircleSizeScale)) / (1.0 - uInsideCircleSizeScale));\n" // outside circle
- " }\n"
-
- // get coords in -PI..PI range, i.e. scale the circle for use by trig functions
- " coord *= PI;\n"
-
- // get a z value for the distorted surface in 0..1 range, using cos for a smooth curve (note, we ignore inside / outside circles since the difference isn't noticeable visually)
- " vec2 cosThetaCoord = (cos(coord) * 0.5) + 0.5;\n"
- " float z = cosThetaCoord.x * cosThetaCoord.y;\n"
-
- // get the normal for the distorted surface, using the fact that the derivative of cos is -sin, finding tangent vector from slope and then normal by cross product...
- " float sinThetaCoord = sin(distFromCentre*PI) * uLightingIndentationAmount;\n" // slope, so tangent vec is (1.0, -sin)
- // ...2D normal vector along distFromCentre vec is (sin, 1.0), convert to components in 3D.
- " vec3 norm = normalize(vec3(coord.x * sinThetaCoord, coord.y * sinThetaCoord, 1.0));\n"
-
- // form surface z and project texture onto it.
- " float indentAmount = 1.0 / (1.0 - (z * uTextureDistortAmount));\n"
- " vec2 distortedCoord = vCentredCoord * indentAmount;\n"
-
- // Convert the rect coordinates in -1 to 1 range back to the original coordinates
- " vec2 texCoord = vec2( ( (distortedCoord.x + 1.0)*(0.5) * (uEffectRegion.z - uEffectRegion.x) + uEffectRegion.x ), ( (distortedCoord.y + 1.0)*(0.5) * (uEffectRegion.w - uEffectRegion.y) + uEffectRegion.y ) ); \n"
- " vec4 col = texture2D(sTexture, texCoord);\n"
-
- // calc lighting
- " float lighting = (dot(uDiffuseLight, norm) + uAmbientLight) * uLightMultiplier;\n"
- " gl_FragColor = vec4(col.rgb * uColor.rgb * lighting, col.a * uColor.a);\n"
- "}\n"
- "else\n"
- "{\n"
- " vec4 col = texture2D(sTexture, vTexCoord);\n"
- " float lighting = (dot(uDiffuseLight, vec3(0.0, 0.0, 1.0)) + uAmbientLight) * uLightMultiplier;\n"
- " gl_FragColor = vec4(col.rgb * uColor.rgb * lighting, col.a * uColor.a);\n"
- "}\n"
- "}\n";
-
- std::string fragmentSourceRectangular;
- fragmentSourceRectangular = "precision mediump float;\n"
-
- "uniform float uLightingIndentationAmount;\n"
- "uniform float uTextureDistortAmount;\n"
- "uniform vec3 uDiffuseLight;\n"
- "uniform float uAmbientLight;\n"
- "uniform float uLightMultiplier;\n"
- "uniform float uInsideCircleSizeScale;\n"
- "uniform float uRecipInsideCircleSizeScale;\n"
- "uniform float uOutsideCircleDepth;\n"
- "uniform float uRectangleSizeScale;\n"
- "uniform vec4 uEffectRegion;\n"
- "varying vec2 vCentredCoord;\n"
-
- "const float PI = 3.1415927;\n"
-
- "void main()\n"
- "{\n"
- // Apply distortion only if the pixel is within the rect specified
- "if( (vTexCoord.x > uEffectRegion.x) && (vTexCoord.x < uEffectRegion.z) && (vTexCoord.y > uEffectRegion.y) && (vTexCoord.y < uEffectRegion.w) )\n"
- "{ \n"
- // get the rect coords to -1..1 range, i.e. circle centred around the center of the rect
- " vec2 centredCoord = vCentredCoord;\n"
- // clamp coords such that the circle is split into 4 pieces that lie in the corners of the actor. uRectangleScale is the distance along each axis from the centre
- // of the actor, e.g. 0.5 is half way along an axis from centre to actor edge.
- " vec2 clampedCoord;\n"
- " if(centredCoord.x > 0.0)\n"
- " {\n"
- " if(centredCoord.x < uRectangleSizeScale)\n"
- " {\n"
- // we are in a rectangular region along this axis, clamp coord to be same as centre pixel
- " clampedCoord.x = 0.0;\n"
- " }\n"
- " else\n"
- " {\n"
- // we are outside rectangular region along this axis, so we want curvature.
- " clampedCoord.x = smoothstep(0.0, 1.0, (centredCoord.x - uRectangleSizeScale) / (1.0 - uRectangleSizeScale));\n"
- " }\n"
- " }\n"
- " else\n"
- " {\n"
- " if(centredCoord.x > -uRectangleSizeScale)\n"
- " {\n"
- // we are in a rectangular region along this axis, clamp coord to be same as centre pixel
- " clampedCoord.x = 0.0;\n"
- " }\n"
- " else\n"
- " {\n"
- // we are outside rectangular region along this axis, so we want curvature.
- " clampedCoord.x = -smoothstep(0.0, 1.0, (centredCoord.x + uRectangleSizeScale) / (uRectangleSizeScale - 1.0));\n"
- " }\n"
- " }\n"
- " if(centredCoord.y > 0.0)\n"
- " {\n"
- " if(centredCoord.y < uRectangleSizeScale)\n"
- " {\n"
- // we are in a rectangular region along this axis, clamp coord to be same as centre pixel
- " clampedCoord.y = 0.0;\n"
- " }\n"
- " else\n"
- " {\n"
- // we are outside rectangular region along this axis, so we want curvature.
- " clampedCoord.y = smoothstep(0.0, 1.0, (centredCoord.y - uRectangleSizeScale) / (1.0 - uRectangleSizeScale));\n"
- " }\n"
- " }\n"
- " else\n"
- " {\n"
- " if(centredCoord.y > -uRectangleSizeScale)\n"
- " {\n"
- // we are in a rectangular region along this axis, clamp coord to be same as centre pixel
- " clampedCoord.y = 0.0;\n"
- " }\n"
- " else\n"
- " {\n"
- // we are outside rectangular region along this axis, so we want curvature.
- " clampedCoord.y = -smoothstep(0.0, 1.0, (centredCoord.y + uRectangleSizeScale) / (uRectangleSizeScale - 1.0));\n"
- " }\n"
- " }\n"
- // get coords in -PI..PI range, i.e. scale above circle for use by trig functions
- " vec2 thetaCoord = clampedCoord * PI;\n"
- // get a z value for the distorted surface in 0..1 range, using cos for a smooth curve (note, we ignore inside / outside circles since the difference isn't noticeable visually)
- " vec2 cosThetaCoord = (cos(thetaCoord) * 0.5) + 0.5;\n"
- " float z = cosThetaCoord.x * cosThetaCoord.y;\n"
- // find a coordinate representing distance from circle centre, such that we split into inside / outside circles that can have different gradients / normals
- " float realDistFromCentre = length(thetaCoord);\n"
- " realDistFromCentre = min(PI, realDistFromCentre);\n" // clamp corners of square to vertical normal
- " float distFromCentre;\n"
- " if(realDistFromCentre <= PI * uInsideCircleSizeScale)\n"
- " {\n"
- " distFromCentre = realDistFromCentre * uRecipInsideCircleSizeScale * (PI - (uOutsideCircleDepth * PI)) / PI;\n" // inside circle indent, up to outline depth
- " }\n"
- " else\n"
- " {\n"
- " distFromCentre = mix(PI - (uOutsideCircleDepth * PI), PI, (realDistFromCentre - ( PI * uInsideCircleSizeScale)) / (PI - (PI * uInsideCircleSizeScale)));\n" // outside circle
- " }\n"
- // get the normal for the distorted surface, using the fact that the derivative of cos is -sin, finding tangent vector from slope and then normal by cross product...
- " float sinThetaCoord = sin(distFromCentre) * uLightingIndentationAmount;\n" // slope, so tangent vec is (1.0, -sin)
- // ...2D normal vector along distFromCentre vec is (sin, 1.0), convert to components in 3D.
- " vec3 norm = normalize(vec3(thetaCoord.x * sinThetaCoord, thetaCoord.y * sinThetaCoord, 1.0));\n"
- // form surface z and project texture onto it.
- " float indentAmount = 1.0 / (1.0 - (z * uTextureDistortAmount));\n"
- " vec2 distortedCoord = centredCoord * indentAmount;\n"
- // Convert the rect coordinates in -1 to 1 range back to the original coordinates
- " vec2 texCoord = vec2( ( (distortedCoord.x + 1.0)/(2.0) * (uEffectRegion.z - uEffectRegion.x) + uEffectRegion.x ), ( (distortedCoord.y + 1.0)/(2.0) * (uEffectRegion.w - uEffectRegion.y) + uEffectRegion.y ) );\n"
- " vec4 col = texture2D(sTexture, texCoord);\n"
- // calc lighting
- " float lighting = (dot(uDiffuseLight, norm) + uAmbientLight) * uLightMultiplier;\n"
- // output col = image * light
- // use the lighting value for colors only
- " gl_FragColor = vec4(col.rgb * uColor.rgb * lighting, col.a * uColor.a);\n"
-
- "}\n"
- "else\n"
- "{\n"
- " vec4 col = texture2D(sTexture, vTexCoord);\n"
- " float lighting = (dot(uDiffuseLight, vec3(0.0, 0.0, 1.0)) + uAmbientLight) * uLightMultiplier;\n"
- " gl_FragColor = vec4(col.rgb * uColor.rgb * lighting, col.a * uColor.a);\n"
- "} \n"
- "}\n";
-
-
- //////////////////////////////////////
- // Create shader effectCreateSoftButtonEffect
- //
- //
-
- ShaderEffect shader;
- switch(type)
- {
- case SOFT_BUTTON_RECTANGULAR:
- shader = ShaderEffect::New( vertexSource, fragmentSourceRectangular, ShaderEffect::GeometryHints( ShaderEffect::HINT_NONE ));
- break;
-
- case SOFT_BUTTON_ELLIPTICAL:
- shader = ShaderEffect::New( vertexSource, fragmentSourceElliptical, ShaderEffect::GeometryHints( ShaderEffect::HINT_NONE ));
- break;
-
- case SOFT_BUTTON_FIXED:
- default:
- shader = ShaderEffect::New( vertexSource, fragmentSourceFixed, ShaderEffect::GeometryHints( ShaderEffect::HINT_NONE ));
- break;
- }
-
- //////////////////////////////////////
- // Register uniform properties
- //
- //
- static const float SOFT_BUTTON_LIGHTING_INDENTATION_AMOUNT_DEFAULT = 0.0f;
- static const float SOFT_BUTTON_TEXTURE_DISTORTION_AMOUNT_DEFAULT = 0.0f;
- static const float SOFT_BUTTON_AMBIENT_LIGHT_AMOUNT_DEFAULT = 0.15f;
- static const Vector3 SOFT_BUTTON_DIFFUSE_LIGHT_DEFAULT = Vector3(0.0f, 0.7070168f, 0.7071068f);
- static const float SOFT_BUTTON_LIGHTING_MULTIPLIER_DEFAULT = 1.2f;
- static const float SOFT_BUTTON_INSIDE_SHAPE_SIZE_SCALE_DEFAULT = 0.75f;
- static const float SOFT_BUTTON_OUTSIDE_SHAPE_DEPTH_DEFAULT = Math::PI * 0.05f;
- static const Vector4 SOFT_BUTTON_EFFECT_PIXEL_AREA_DEFAULT = Vector4(0.0f, 0.0f, 1.0f, 1.0f);
- static const float SOFT_BUTTON_RECTANGLE_SIZE_SCALE_DEFAULT = 0.5f;
-
- // factors that scale the look, defaults
- shader.SetUniform("uAmbientLight", SOFT_BUTTON_AMBIENT_LIGHT_AMOUNT_DEFAULT);
- shader.SetUniform("uDiffuseLight", SOFT_BUTTON_DIFFUSE_LIGHT_DEFAULT);
- shader.SetUniform("uLightMultiplier", SOFT_BUTTON_LIGHTING_MULTIPLIER_DEFAULT);
- if(SOFT_BUTTON_FIXED != type)
- {
- shader.SetUniform("uLightingIndentationAmount", SOFT_BUTTON_LIGHTING_INDENTATION_AMOUNT_DEFAULT);
- shader.SetUniform("uTextureDistortAmount", SOFT_BUTTON_TEXTURE_DISTORTION_AMOUNT_DEFAULT);
- shader.SetUniform("uInsideCircleSizeScale", SOFT_BUTTON_INSIDE_SHAPE_SIZE_SCALE_DEFAULT);
- shader.SetUniform("uRecipInsideCircleSizeScale", 1.0f / SOFT_BUTTON_INSIDE_SHAPE_SIZE_SCALE_DEFAULT);
- shader.SetUniform("uOutsideCircleDepth", SOFT_BUTTON_OUTSIDE_SHAPE_DEPTH_DEFAULT);
- shader.SetUniform("uEffectRegion", SOFT_BUTTON_EFFECT_PIXEL_AREA_DEFAULT);
- if(SOFT_BUTTON_RECTANGULAR == type)
- {
- shader.SetUniform("uRectangleSizeScale", SOFT_BUTTON_RECTANGLE_SIZE_SCALE_DEFAULT);
- }
-
- // precalc 1.0 / uInsideCircleSizeScale on CPU to save shader insns, using constraint to tie to the normal property
- Dali::Property::Index insideCircleSizeScalePropertyIndex = shader.GetPropertyIndex("uInsideCircleSizeScale");
- Dali::Property::Index recipInsideCircleSizeScalePropertyIndex = shader.GetPropertyIndex("uRecipInsideCircleSizeScale");
- Constraint constraint = Constraint::New<float>( shader, recipInsideCircleSizeScalePropertyIndex, InverseConstraint );
- constraint.AddSource( LocalSource(insideCircleSizeScalePropertyIndex) );
- constraint.Apply();
- }
-
- return shader;
-}
-
-}
-
-}
-
-#endif //#ifndef __DALI_TOOLKIT_SHADER_EFFECT_SOFT_BUTTON_H__
+++ /dev/null
-#ifndef __DALI_TOOLKIT_SHADER_EFFECT_SPOT_H__
-#define __DALI_TOOLKIT_SHADER_EFFECT_SPOT_H__
-
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/devel-api/shader-effects/shader-effect.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-/**
- * @brief Creates a new SpotEffect
- *
- * SpotEffect is a custom shader effect to achieve spot effects on Image actors
- *
- * Animatable/Constrainable uniforms:
- * "uCenter" - The center of the spot. Default value (0.0,0.0)
- * "uRadius" - The radius of the spot. Default value 0.0
- *
- * @return A handle to a newly allocated ShaderEffect
- */
-inline ShaderEffect CreateSpotEffect()
-{
- // append the default version
- std::string vertexShader(
- "uniform mediump vec2 uCenter;\n"
- "uniform mediump float uRadius;\n"
- "varying mediump float vRange;\n"
- "\n"
- "void main()\n"
- "{\n"
- " mediump vec4 world = vec4(aPosition, 1.0);\n"
- " \n"
- " mediump vec2 d = vec2(world.xy - uCenter);\n"
- " mediump float dist = length(d);\n"
- " \n"
- " mediump float range = (uRadius - dist) / (uRadius);\n"
- " vRange = max(0.1, range);\n"
- " \n"
- " gl_Position = uMvpMatrix * world;\n"
- " vTexCoord = mix( sTextureRect.xy, sTextureRect.zw, aTexCoord );\n"
- "}");
-
- std::string fragmentShader(
- "varying mediump float vRange;\n"
- "\n"
- "void main()\n"
- "{\n"
- " gl_FragColor = texture2D(sTexture, vTexCoord) * vec4(vRange, vRange, vRange, 1.0) * uColor;\n"
- "}" );
-
- Dali::ShaderEffect shaderEffect = Dali::ShaderEffect::New(
- vertexShader, fragmentShader,
- ShaderEffect::GeometryHints( ShaderEffect::HINT_GRID ));
-
- shaderEffect.SetUniform( "uCenter", Vector2(0.0f, 0.0f) );
- shaderEffect.SetUniform( "uRadius", 0.0f );
-
- return shaderEffect;
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // __DALI_TOOLKIT_SHADER_EFFECT_SPOT_H__
+++ /dev/null
-#ifndef __DALI_TOOLKIT_SHADER_EFFECT_SQUARE_H__
-#define __DALI_TOOLKIT_SHADER_EFFECT_SQUARE_H__
-
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/devel-api/shader-effects/shader-effect.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-/**
- * @brief Creates a new SquareDissolveEffect
- *
- * SquareDissolveEffect is a custom shader effect to achieve square effects in Image actors
- *
- * Animatable/Constrainable uniforms:
- * "uStep" - The step of the square effect
- * "uRows" - The rows of the square dissolve effect
- * "uColumns" - The columns of the square dissolve effect
- * "uTextureSize"- The texture size of the square dissolve
- *
- * @return A handle to a newly allocated ShaderEffect
- */
-inline ShaderEffect CreateSquareDissolveEffect()
-{
- // variable "uStep" range scope : [0.0, 1.0]
- std::string fragmentShader(
- "uniform mediump vec2 uTextureSize;\n"
- "uniform mediump float uStep;\n"
- "uniform mediump float uRows;\n"
- "uniform mediump float uColumns;\n"
- "void main()\n"
- "{\n"
- " mediump vec2 mosaicSize = vec2(1.0 / uRows, 1.0 / uColumns); \n"
- " mediump vec2 intXY = vec2(vTexCoord.x * uTextureSize.x, vTexCoord.y * uTextureSize.y); \n"
- " mediump vec2 XYMosaic = vec2(floor(intXY.x / mosaicSize.x) * mosaicSize.x, floor(intXY.y / mosaicSize.y) * mosaicSize.y); \n"
- " mediump vec2 UVMosaic = vec2(XYMosaic.x /uTextureSize.x, XYMosaic.y / uTextureSize.y); \n"
- " mediump vec4 noiseVec = texture2D(sEffect, UVMosaic); \n"
- " mediump float intensity = (noiseVec[0] + noiseVec[1] + noiseVec[2] + noiseVec[3]) / 4.0; \n"
- " if(intensity < uStep) \n"
- " gl_FragColor = vec4(0.1, 0.1, 0.1, 1.0); \n"
- " else \n"
- " gl_FragColor = texture2D(sTexture, vTexCoord); \n"
- " gl_FragColor *= uColor; \n"
- "} \n" );
-
- Dali::ShaderEffect shaderEffect = Dali::ShaderEffect::New(
- "",
- fragmentShader,
- ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING | ShaderEffect::HINT_GRID ));
-
- shaderEffect.SetUniform( "uTextureSize", Vector2(1.0f, 1.0f) );//COORDINATE_TYPE_DEFAULT
- shaderEffect.SetUniform( "uStep", 0.1f);
- shaderEffect.SetUniform( "uRows", 25.0f);
- shaderEffect.SetUniform( "uColumns", 25.0f);
-
- return shaderEffect;
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // __DALI_TOOLKIT_SHADER_EFFECT_SQUARE_H__
+++ /dev/null
-#ifndef __DALI_TOOLKIT_SHADER_EFFECT_SWIRL_H__
-#define __DALI_TOOLKIT_SHADER_EFFECT_SWIRL_H__
-
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/devel-api/shader-effects/shader-effect.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-/**
- * @brief Creates a new SwirlEffect
- *
- * SwirlEffect is a custom shader effect to achieve swirl effects in Image actors.
- *
- * Animatable/Constrainable uniforms:
- * "uAngle" - The angle of the swirl
- * "uCenter" - The center of the swirl
- * "uRadius" - The radius of the swirl
- *
- * @param[in] warp True if the effect should warp
- * @return A handle to a newly allocated ShaderEffect
- */
-inline ShaderEffect CreateSwirlEffect( bool warp )
-{
- // append the default version
- std::string fragmentShader(
- "uniform mediump vec2 uTextureSize;\n"
- "uniform highp float uRadius;\n"
- "uniform highp float uAngle;\n"
- "uniform mediump vec2 uCenter;\n"
- "void main()\n"
- "{\n"
- " highp vec2 textureCenter = (sTextureRect.xy + sTextureRect.zw) * 0.5;\n"
- " textureCenter = vTexCoord.st - textureCenter;\n"
- " highp float distance = length(textureCenter);\n"
- " if (distance >= uRadius)\n"
- " discard;\n"
- " highp float percent = (uRadius - distance) / uRadius;\n"
- " highp float theta = percent * percent * uAngle * 4.0;\n"
- " highp float sinTheta = sin(theta);\n"
- " highp float cosTheta = cos(theta);\n" );
- // if warp, loose the sign from sin
- if( warp )
- {
- fragmentShader.append(
- " textureCenter = vec2( dot( textureCenter, vec2(cosTheta, sinTheta) ), "
- " dot( textureCenter, vec2(sinTheta, cosTheta) ) );\n" );
- }
- else
- {
- fragmentShader.append(
- " textureCenter = vec2( dot( textureCenter, vec2(cosTheta, -sinTheta) ), "
- " dot( textureCenter, vec2(sinTheta, cosTheta) ) );\n" );
- }
- fragmentShader.append(
- " textureCenter += uCenter;\n"
- " gl_FragColor = texture2D( sTexture, textureCenter ) * uColor;\n"
- "}" );
-
- Dali::ShaderEffect shaderEffect = Dali::ShaderEffect::New(
- "",
- fragmentShader,
- ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING | ShaderEffect::HINT_GRID ));
-
- shaderEffect.SetUniform( "uAngle", 0.0f );
- shaderEffect.SetUniform( "uCenter", Vector2(0.5f, 0.5f) );
- shaderEffect.SetUniform( "uRadius", 1.0f );
-
- return shaderEffect;
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // __DALI_TOOLKIT_SHADER_EFFECT_SWIRL_H__
+++ /dev/null
-#ifndef DALI_TOOLKIT_DEVEL_VISUAL_PROPERTIES_H
-#define DALI_TOOLKIT_DEVEL_VISUAL_PROPERTIES_H
-
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/toolkit-property-index-ranges.h>
-#include <dali-toolkit/public-api/visuals/visual-properties.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Visual
-{
-
-// Mirror of public API Property namespace with addition of enums that are not yet
-// public. A namespace alias is used below to reduce implementation cruft.
-
-namespace DevelProperty
-{
-
-enum Type
-{
- TYPE = Dali::Toolkit::Visual::Property::TYPE,
- SHADER = Dali::Toolkit::Visual::Property::SHADER,
-
- /**
- * @brief The transform used by the visual.
- * @details Name "transform", type Property::Map.
-
- * @note Optional.
- * @see DevelProperty::Transform::Property
- */
- TRANSFORM = SHADER+1//Dali::Toolkit::Visual::Property::SHADER+1
-};
-
-namespace Transform
-{
-
-namespace Property
-{
-
-enum Type
-{
- /**
- * @brief Offset of the visual. It can be either relative (percentage of the parent)
- * or absolute (in world units).
- * @details Name "offset", type Property::VECTOR2
- */
- OFFSET,
-
- /**
- * @brief Size of the visual. It can be either relative (percentage of the parent)
- * or absolute (in world units).
- * @details Name "size", type Property::VECTOR2
- */
- SIZE,
-
- /**
- * @brief The origin of the visual within its control area.
- * @details Name "origin", type Align::Type (Property::INTEGER) or Property::STRING.
- * @see Toolkit::Align
- */
- ORIGIN,
-
- /**
- * @brief The anchor-point of the visual
- * @details Name "anchorPoint", type Align::Type (Property::INTEGER) or Property::STRING.
- * @see Toolkit::Align
- */
- ANCHOR_POINT,
-
- /**
- * @brief Indicates which components of the offset and size are relative
- * (percentage of the parent) or absolute (in world units).
- * 0 indicates the component is relative, and 1 absolute.
- * @details Name "offsetSizeMode", type Property::VECTOR4
- */
- OFFSET_SIZE_MODE
-};
-
-} //namespace Property
-
-} //namespace Transform
-
-} // namespace DevelProperty
-
-} // namespace Visual
-
-namespace VisualProperty = Visual::DevelProperty;
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-
-#endif // DALI_TOOLKIT_DEVEL_VISUAL_PROPERTIES_H
-#ifndef DALI_TOOLKIT_VISUAL_PROPERTIES_DEVEL_H
-#define DALI_TOOLKIT_VISUAL_PROPERTIES_DEVEL_H
+#ifndef DALI_TOOLKIT_DEVEL_API_VISUALS_VISUAL_PROPERTIES_DEVEL_H
+#define DALI_TOOLKIT_DEVEL_API_VISUALS_VISUAL_PROPERTIES_DEVEL_H
/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd.
*/
enum Type
{
- BORDER = Dali::Toolkit::Visual::BORDER,
- COLOR = Dali::Toolkit::Visual::COLOR,
- GRADIENT = Dali::Toolkit::Visual::GRADIENT,
- IMAGE = Dali::Toolkit::Visual::IMAGE,
- MESH = Dali::Toolkit::Visual::MESH,
+ BORDER = Dali::Toolkit::Visual::BORDER,
+ COLOR = Dali::Toolkit::Visual::COLOR,
+ GRADIENT = Dali::Toolkit::Visual::GRADIENT,
+ IMAGE = Dali::Toolkit::Visual::IMAGE,
+ MESH = Dali::Toolkit::Visual::MESH,
PRIMITIVE = Dali::Toolkit::Visual::PRIMITIVE,
WIREFRAME = Dali::Toolkit::Visual::WIREFRAME,
- TEXT = Dali::Toolkit::Visual::WIREFRAME + 1, ///< Renders text.
+
+ TEXT = WIREFRAME + 1, ///< Renders text.
+};
+
+namespace Property
+{
+
+enum Type
+{
+ TYPE = Dali::Toolkit::Visual::Property::TYPE,
+ SHADER = Dali::Toolkit::Visual::Property::SHADER,
+
+ /**
+ * @brief The transform used by the visual.
+ * @details Name "transform", type Property::Map.
+
+ * @note Optional.
+ * @see DevelVisual::Transform::Property
+ */
+ TRANSFORM = SHADER+1//Dali::Toolkit::Visual::Property::SHADER+1
+};
+
+} //namespace Property
+
+namespace Transform
+{
+
+namespace Property
+{
+
+enum Type
+{
+ /**
+ * @brief Offset of the visual. It can be either relative (percentage of the parent)
+ * or absolute (in world units).
+ * @details Name "offset", type Property::VECTOR2
+ */
+ OFFSET,
+
+ /**
+ * @brief Size of the visual. It can be either relative (percentage of the parent)
+ * or absolute (in world units).
+ * @details Name "size", type Property::VECTOR2
+ */
+ SIZE,
+
+ /**
+ * @brief The origin of the visual within its control area.
+ * @details Name "origin", type Align::Type (Property::INTEGER) or Property::STRING.
+ * @see Toolkit::Align
+ */
+ ORIGIN,
+
+ /**
+ * @brief The anchor-point of the visual
+ * @details Name "anchorPoint", type Align::Type (Property::INTEGER) or Property::STRING.
+ * @see Toolkit::Align
+ */
+ ANCHOR_POINT,
+
+ /**
+ * @brief Indicates which components of the offset and size are relative
+ * (percentage of the parent) or absolute (in world units).
+ * 0 indicates the component is relative, and 1 absolute.
+ * @details Name "offsetSizeMode", type Property::VECTOR4
+ */
+ OFFSET_SIZE_MODE
};
+} //namespace Property
+
+} // namespace Transform
+
} // namespace DevelVisual
} // namespace Toolkit
} // namespace Dali
-#endif // DALI_TOOLKIT_VISUAL_PROPERTIES_DEVEL_H
+#endif // DALI_TOOLKIT_DEVEL_API_VISUALS_VISUAL_PROPERTIES_DEVEL_H
// INTERNAL INCLUDES
#include <dali-toolkit/devel-api/controls/gaussian-blur-view/gaussian-blur-view.h>
#include <dali-toolkit/devel-api/controls/bloom-view/bloom-view.h>
-#include <dali-toolkit/devel-api/visual-factory/devel-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali-toolkit/internal/controls/gaussian-blur-view/gaussian-blur-view-impl.h>
namespace Dali
Property::Map customShader;
customShader[ Toolkit::Visual::Shader::Property::FRAGMENT_SHADER ] = BLOOM_EXTRACT_FRAGMENT_SOURCE;
Property::Map visualMap;
- visualMap.Insert( Toolkit::VisualProperty::SHADER, customShader );
+ visualMap.Insert( Toolkit::DevelVisual::Property::SHADER, customShader );
mBloomExtractImageView.SetProperty( Toolkit::ImageView::Property::IMAGE, visualMap );
// set GaussianBlurView to blur our extracted bloom
mCompositeImageView.SetImage( mRenderTargetForRenderingChildren );
// Create shader used to composite bloom and original image to output render target
customShader[ Toolkit::Visual::Shader::Property::FRAGMENT_SHADER ] = COMPOSITE_FRAGMENT_SOURCE;
- visualMap[ Toolkit::VisualProperty::SHADER ] = customShader;
+ visualMap[ Toolkit::DevelVisual::Property::SHADER ] = customShader;
mCompositeImageView.SetProperty( Toolkit::ImageView::Property::IMAGE, visualMap );
TextureSet textureSet = mCompositeImageView.GetRendererAt(0).GetTextures();
TextureSetImage( textureSet, 1u, mBlurExtractTarget );
+++ /dev/null
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "bubble-actor.h"
-
-// EXTERNAL INCLUDES
-#include <cmath>
-#include <sstream>
-
-// INTERNAL INCLUDES
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal
-{
-
-BubbleActor::BubbleActor( unsigned int numberOfBubble,
- const Vector2& movementArea)
-: mActor(),
- mRenderer(),
- mMovementArea( movementArea ),
- mIndicesOffset(),
- mIndiceStartEndPos(),
- mIndicesPercentage(),
- mIndexGravity( Property::INVALID_INDEX ),
- mIndexDynamicScale( Property::INVALID_INDEX ),
- mIndexInvertedMovementArea( Property::INVALID_INDEX ),
- mNumBubble( numberOfBubble ),
- mRandomSeed( 0 )
-{
- mActor = Actor::New();
-}
-
-void BubbleActor::MakeRenderable( Geometry geometry, TextureSet textureSet, Shader shader )
-{
- if( mRenderer )
- {
- // This function is supposed to be called once
- return;
- }
-
- mRenderer = Renderer::New( geometry, shader );
- mRenderer.SetTextures( textureSet );
-
- mActor.AddRenderer( mRenderer );
- mActor.SetSize( mMovementArea );
- mActor.SetParentOrigin(ParentOrigin::TOP_LEFT);
-
- // register uniforms
- mIndexGravity = mActor.RegisterProperty( "uGravity", 50.f );
- mIndexDynamicScale = mActor.RegisterProperty( "uDynamicScale", 1.f );
-
- mIndexInvertedMovementArea = mActor.RegisterProperty( "uInvertedMovementArea", Vector2(1.f,1.f) / mMovementArea );
-
- mIndicesOffset.resize(9);
- int offset = mMovementArea.Length() / 10.f;
-
- mRandomSeed = time( NULL );
-
- mIndicesOffset[0] = mActor.RegisterProperty( "uOffset[0]", Vector2( 0.f,0.f ) );
- mIndicesOffset[1] = mActor.RegisterProperty( "uOffset[1]", Vector2( rand_r( &mRandomSeed ) % offset, rand_r( &mRandomSeed ) % offset ) );
- mIndicesOffset[2] = mActor.RegisterProperty( "uOffset[2]", Vector2( rand_r( &mRandomSeed ) % offset, -rand_r( &mRandomSeed ) % offset ) );
- mIndicesOffset[3] = mActor.RegisterProperty( "uOffset[3]", Vector2(-rand_r( &mRandomSeed ) % offset, rand_r( &mRandomSeed ) % offset ) );
- mIndicesOffset[4] = mActor.RegisterProperty( "uOffset[4]", Vector2(-rand_r( &mRandomSeed ) % offset, -rand_r( &mRandomSeed ) % offset ) );
- mIndicesOffset[5] = mActor.RegisterProperty( "uOffset[5]", Vector2( rand_r( &mRandomSeed ) % offset, 0.f ) );
- mIndicesOffset[6] = mActor.RegisterProperty( "uOffset[6]", Vector2(-rand_r( &mRandomSeed ) % offset, 0.f ) );
- mIndicesOffset[7] = mActor.RegisterProperty( "uOffset[7]", Vector2( 0.f, rand_r( &mRandomSeed ) % offset ) );
- mIndicesOffset[8] = mActor.RegisterProperty( "uOffset[8]", Vector2( 0.f, -rand_r( &mRandomSeed ) % offset ) );
-
- Vector4 zeroVector;
- mIndiceStartEndPos.resize( mNumBubble );
- mIndicesPercentage.resize( mNumBubble );
- for( unsigned int i=0; i<mNumBubble; i++ )
- {
- std::ostringstream ossProperty;
- ossProperty<< "uStartEndPosition["<< i << "]";
- mIndiceStartEndPos[i] = mActor.RegisterProperty( ossProperty.str(), zeroVector );
-
- ossProperty.str("");
- ossProperty<< "uPercentage["<< i << "]";
- mIndicesPercentage[i] = mActor.RegisterProperty( ossProperty.str(), 0.f );
- }
-}
-
-Actor BubbleActor::GetMeshActor()
-{
- return mActor;
-}
-
-void BubbleActor::SetGeometry( Geometry geometry )
-{
- mRenderer.SetGeometry( geometry );
-}
-
-void BubbleActor::SetMovementArea( const Vector2& movementArea )
-{
- if( movementArea == mMovementArea)
- {
- return;
- }
-
- mMovementArea = movementArea;
- mActor.SetSize( mMovementArea );
- mActor.SetProperty( mIndexInvertedMovementArea, Vector2(1.f,1.f) / mMovementArea );
-
- int offset = mMovementArea.Length() / 10.f;
-
- mActor.SetProperty( mIndicesOffset[1], Vector2( rand_r( &mRandomSeed ) % offset, rand_r( &mRandomSeed ) % offset ) );
- mActor.SetProperty( mIndicesOffset[2], Vector2( rand_r( &mRandomSeed ) % offset, -rand_r( &mRandomSeed ) % offset ) );
- mActor.SetProperty( mIndicesOffset[3], Vector2(-rand_r( &mRandomSeed ) % offset, rand_r( &mRandomSeed ) % offset ) );
- mActor.SetProperty( mIndicesOffset[4], Vector2(-rand_r( &mRandomSeed ) % offset, -rand_r( &mRandomSeed ) % offset ) );
- mActor.SetProperty( mIndicesOffset[5], Vector2( rand_r( &mRandomSeed ) % offset, 0.f ) );
- mActor.SetProperty( mIndicesOffset[6], Vector2(-rand_r( &mRandomSeed ) % offset, 0.f ) );
- mActor.SetProperty( mIndicesOffset[7], Vector2( 0.f, rand_r( &mRandomSeed ) % offset ) );
- mActor.SetProperty( mIndicesOffset[8], Vector2( 0.f, -rand_r( &mRandomSeed ) % offset ) );
-}
-
-void BubbleActor::SetStartAndEndPosition( unsigned int index, const Vector4& startAndEndPosition )
-{
- mActor.SetProperty( mIndiceStartEndPos[index], startAndEndPosition );
-}
-
-void BubbleActor::SetPercentage( unsigned int index, float percentage )
-{
- mActor.SetProperty( mIndicesPercentage[index], percentage );
-}
-
-void BubbleActor::SetGravity( float gravity )
-{
- mActor.SetProperty( mIndexGravity, gravity );
-}
-
-void BubbleActor::SetDynamicScale( float scale )
-{
- mActor.SetProperty( mIndexDynamicScale, scale );
-}
-
-Property BubbleActor::GetPercentageProperty( unsigned int index )
-{
- return Property( mActor, mIndicesPercentage[index] );
-}
-
-void BubbleActor::ResetProperties()
-{
- Vector4 zeroVector;
- for( unsigned int i=0; i<mNumBubble; i++ )
- {
- SetPercentage( i, 0.f);
- SetStartAndEndPosition( i, zeroVector );
- }
-}
-
-} // namespace Internal
-
-} // namespace Toolkit
-
-} // namespace Dali
vTexCoord = aTexCoord;\n
vPercentage = percentage;\n
// Use the emit position color for the bubble
- vEffectTexCoord = startAndEnd.xy * uInvertedMovementArea;\n
+ vEffectTexCoord = startAndEnd.xy * uInvertedMovementArea + vec2(0.5);\n
}\n
);
// EXTERNAL INCLUDES
#include <dali/public-api/animation/animation.h>
#include <dali/public-api/render-tasks/render-task-list.h>
-#include <dali/public-api/images/resource-image.h>
-#include <dali/devel-api/images/texture-set-image.h>
+#include <dali/public-api/rendering/texture.h>
+#include <dali/public-api/rendering/shader.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/internal/controls/bubble-effect/bubble-actor.h>
-#include <dali-toolkit/internal/controls/bubble-effect/color-adjuster.h>
#include <dali-toolkit/internal/controls/bubble-effect/bubble-effect.h>
-#include <dali-toolkit/public-api/controls/image-view/image-view.h>
-
+#include <dali-toolkit/internal/controls/bubble-effect/bubble-renderer.h>
namespace
{
return f0 + (rand_r( &seed ) & 0xfff) * (f1-f0) * (1.0f/4095.0f);
}
+const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
+ attribute mediump vec2 aPosition;\n
+ attribute mediump vec2 aTexCoord;\n
+ uniform mediump vec3 uSize;\n
+ uniform mediump mat4 uMvpMatrix;\n
+ varying mediump vec2 vTexCoord;\n
+ \n
+
+ void main()\n
+ {\n
+ gl_Position = uMvpMatrix * vec4(aPosition*uSize.xy,0.0,1.0);
+ vTexCoord = aTexCoord;\n
+ }\n
+);
+
+const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
+ precision highp float;\n
+ uniform vec3 uHSVDelta;\n
+ varying mediump vec2 vTexCoord;\n
+ uniform sampler2D sTexture;\n
+ float rand(vec2 co) \n
+ {\n
+ return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); \n}
+ \n
+ vec3 rgb2hsv(vec3 c)\n
+ {\n
+ vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\n
+ vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));\n
+ vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));\n
+ \n
+ float d = q.x - min(q.w, q.y);\n
+ float e = 1.0e-10;\n
+ return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);\n
+ }\n
+ vec3 hsv2rgb(vec3 c)\n
+ {\n
+ vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\n
+ vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);\n
+ return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);\n
+ }\n
+ void main() {\n
+ vec4 color = texture2D(sTexture, vTexCoord); \n
+ vec3 hsvColor = rgb2hsv( color.rgb );\n
+ // modify the hsv Value
+ hsvColor += uHSVDelta * rand(vTexCoord); \n
+ // if the new vale exceeds one, then decrease it
+ hsvColor -= max(hsvColor*2.0 - vec3(2.0), 0.0);\n
+ // if the new vale drops below zero, then increase it
+ hsvColor -= min(hsvColor*2.0, 0.0);\n
+ color = vec4( hsv2rgb( hsvColor ), 1.0 ); \n
+ gl_FragColor = color; \n
+ }\n
+ );
+
+Dali::Geometry CreateTexturedQuad()
+{
+ struct Vertex
+ {
+ Dali::Vector2 position;
+ Dali::Vector2 texCoord;
+ };
+
+ static const Vertex data[] = {{ Dali::Vector2( -0.5f, -0.5f ), Dali::Vector2( 0.0f, 0.0f ) },
+ { Dali::Vector2( 0.5f, -0.5f ), Dali::Vector2( 1.0f, 0.0f ) },
+ { Dali::Vector2( -0.5f, 0.5f ), Dali::Vector2( 0.0f, 1.0f ) },
+ { Dali::Vector2( 0.5f, 0.5f ), Dali::Vector2( 1.0f, 1.0f ) }};
+
+ //Create a vertex buffer for vertex positions and texture coordinates
+ Dali::PropertyBuffer vertexBuffer = Dali::PropertyBuffer::New( Dali::Property::Map()
+ .Add( "aPosition", Dali::Property::VECTOR2 )
+ .Add( "aTexCoord", Dali::Property::VECTOR2 ) );
+ vertexBuffer.SetData( data, 4u );
+
+ //Create the geometry
+ Dali::Geometry geometry = Dali::Geometry::New();
+ geometry.AddVertexBuffer( vertexBuffer );
+ geometry.SetType(Dali::Geometry::TRIANGLE_STRIP );
+
+ return geometry;
+}
+
}
namespace Dali
namespace Internal
{
BubbleEmitter::BubbleEmitter( const Vector2& movementArea,
- Image shapeImage,
+ Texture shapeTexture,
unsigned int maximumNumberOfBubble,
const Vector2& bubbleSizeRange )
: Control( ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ),
- mShapeImage( shapeImage ),
+ mShapeTexture( shapeTexture ),
mMovementArea( movementArea ),
mBubbleSizeRange( bubbleSizeRange ),
mDensity( 5 ),
// Calculate how many shaders are required
if( mTotalNumOfBubble>100 )
{
- mNumBubblePerActor = 100;
- mNumActor = mTotalNumOfBubble / 100;
- if( mNumActor*mNumBubblePerActor < mTotalNumOfBubble )
+ mNumBubblePerRenderer = 100;
+ mNumRenderer = mTotalNumOfBubble / 100;
+ if( mNumRenderer*mNumBubblePerRenderer < mTotalNumOfBubble )
{
- mNumActor++;
- mNumBubblePerActor = mTotalNumOfBubble / mNumActor+1;
- mTotalNumOfBubble = mNumActor * mNumBubblePerActor;
+ mNumRenderer++;
+ mNumBubblePerRenderer = mTotalNumOfBubble / mNumRenderer+1;
+ mTotalNumOfBubble = mNumRenderer * mNumBubblePerRenderer;
}
}
else
{
- mNumBubblePerActor = mTotalNumOfBubble;
- mNumActor = 1;
+ mNumBubblePerRenderer = mTotalNumOfBubble;
+ mNumRenderer = 1;
}
mRandomSeed = time( NULL );
}
Toolkit::BubbleEmitter BubbleEmitter::New( const Vector2& winSize,
- Image shapeImage,
+ Texture shapeTexture,
unsigned int maximumNumberOfBubble,
const Vector2& bubbleSizeRange )
{
// Create the implementation
- IntrusivePtr<BubbleEmitter> internalBubbleEmitter ( new BubbleEmitter( winSize, shapeImage,
+ IntrusivePtr<BubbleEmitter> internalBubbleEmitter ( new BubbleEmitter( winSize, shapeTexture,
maximumNumberOfBubble,bubbleSizeRange ) );
// Pass ownership to Toolkit::BubbleEmitter handle
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 );
+ // Prepare the frame buffer to store the color adjusted background texture
+ Vector2 imageSize = Vector2( mMovementArea.width/4.f, mMovementArea.height/4.f );
+ mFrameBuffer = FrameBuffer::New( imageSize.x, imageSize.y, 0 );
+ mEffectTexture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, imageSize.x, imageSize.y );
+ mFrameBuffer.AttachColorTexture( mEffectTexture );
// Generate the geometry, which is used by all bubbleActors
- mMeshGeometry = CreateGeometry( mNumBubblePerActor*mDensity );
+ mMeshGeometry = CreateGeometry( mNumBubblePerRenderer*mDensity );
- Shader bubbleShader = CreateBubbleShader (mNumBubblePerActor );
+ Shader bubbleShader = CreateBubbleShader( mNumBubblePerRenderer );
mTextureSet = TextureSet::New();
- TextureSetImage( mTextureSet, 0u, mEffectImage );
- TextureSetImage( mTextureSet, 1u, mShapeImage );
-
- mBubbleActors.resize( mNumActor );
+ mTextureSet.SetTexture( 0u, mEffectTexture );
+ mTextureSet.SetTexture( 1u, mShapeTexture );
- // Create the meshActor group and bubbleEffect group to emit bubbles following the given track, such as finger touch track.
- for(unsigned int i=0; i < mNumActor; i++ )
+ // Create the renderers to render the bubbles
+ mBubbleRenderers.resize( mNumRenderer );
+ for(unsigned int i=0; i < mNumRenderer; i++ )
{
- mBubbleActors[i] = new BubbleActor( mNumBubblePerActor, mMovementArea );
- (mBubbleActors[i])->MakeRenderable( mMeshGeometry, mTextureSet, bubbleShader );
- mBubbleRoot.Add( (mBubbleActors[i])->GetMeshActor() );
+ mBubbleRenderers[i].Initialize( mNumBubblePerRenderer, mMovementArea, mMeshGeometry, mTextureSet, bubbleShader );
+ mBubbleRoot.AddRenderer( mBubbleRenderers[i].GetRenderer() );
}
// Create a cameraActor for the off screen render task.
return mBubbleRoot;
}
-void BubbleEmitter::SetBackground( Image bgImage, const Vector3& hsvDelta )
+void BubbleEmitter::SetBackground( Texture bgTexture, const Vector3& hsvDelta )
{
- mBackgroundImage = bgImage;
+ mBackgroundTexture = bgTexture;
mHSVDelta = hsvDelta;
- Toolkit::ImageView sourceActor = Toolkit::ImageView::New(bgImage);
+ //Create RenderTask source actor
+ Actor sourceActor = Actor::New();
sourceActor.SetSize( mMovementArea );
sourceActor.SetParentOrigin(ParentOrigin::CENTER);
-
- Property::Map colorAdjuster = CreateColorAdjuster();
- sourceActor.SetProperty( Toolkit::ImageView::Property::IMAGE, colorAdjuster);
- SetColorAdjusterProperties( sourceActor, hsvDelta, true /*ignore alpha to make bubble color always*/ );
-
+ sourceActor.RegisterProperty( "uHSVDelta", hsvDelta );
Stage::GetCurrent().Add( sourceActor );
+ //Create renderer
+ Dali::Geometry geometry = CreateTexturedQuad();
+ Shader shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
+ Renderer renderer = Renderer::New( geometry, shader );
+ TextureSet textureSet = TextureSet::New();
+ textureSet.SetTexture(0u, bgTexture );
+ renderer.SetTextures( textureSet );
+ sourceActor.AddRenderer( renderer );
+
RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
RenderTask task = taskList.CreateTask();
task.SetRefreshRate( RenderTask::REFRESH_ONCE );
task.SetExclusive(true);
task.SetCameraActor(mCameraActor);
task.GetCameraActor().SetInvertYAxis(true);
- task.SetTargetFrameBuffer( mEffectImage );
+ task.SetFrameBuffer( mFrameBuffer );
task.FinishedSignal().Connect(this, &BubbleEmitter::OnRenderFinished);
mRenderTaskRunning = true;
}
-void BubbleEmitter::SetShapeImage( Image shapeImage )
+void BubbleEmitter::SetBubbleShape( Texture shapeTexture )
{
- TextureSetImage( mTextureSet, 1, shapeImage );
+ mTextureSet.SetTexture( 1, shapeTexture );
}
void BubbleEmitter::SetBubbleScale( float scale )
{
- for(unsigned int i=0; i < mNumActor; i++ )
+ for(unsigned int i=0; i < mNumRenderer; i++ )
{
- (mBubbleActors[i])->SetDynamicScale( scale );
+ mBubbleRenderers[i].SetDynamicScale( scale );
}
}
else
{
mDensity = density;
- mMeshGeometry = CreateGeometry( mNumBubblePerActor*mDensity );
- for(unsigned int i=0; i < mNumActor; i++ )
+ mMeshGeometry = CreateGeometry( mNumBubblePerRenderer*mDensity );
+ for(unsigned int i=0; i < mNumRenderer; i++ )
{
- (mBubbleActors[i])->SetGeometry( mMeshGeometry );
+ mBubbleRenderers[i].SetGeometry( mMeshGeometry );
}
}
}
// and trigger re-draw if not already running
if( ! mRenderTaskRunning )
{
- SetBackground( mBackgroundImage, mHSVDelta );
+ SetBackground( mBackgroundTexture, mHSVDelta );
}
}
void BubbleEmitter::EmitBubble( Animation& animation, const Vector2& emitPosition, const Vector2& direction, const Vector2& displacement )
{
- unsigned int curUniform = mCurrentBubble % mNumBubblePerActor;
- unsigned int groupIdx = mCurrentBubble / mNumBubblePerActor;
- SetBubbleParameter( mBubbleActors[groupIdx], curUniform, emitPosition, direction, displacement);
- animation.AnimateTo( (mBubbleActors[groupIdx])->GetPercentageProperty(curUniform),
+ unsigned int curUniform = mCurrentBubble % mNumBubblePerRenderer;
+ unsigned int groupIdx = mCurrentBubble / mNumBubblePerRenderer;
+ SetBubbleParameter( mBubbleRenderers[groupIdx], curUniform, emitPosition - Vector2(mMovementArea.x*0.5f,mMovementArea.y*0.5f), direction, displacement);
+ animation.AnimateTo( mBubbleRenderers[groupIdx].GetPercentageProperty(curUniform),
1.f, AlphaFunction::LINEAR );
mCurrentBubble = (mCurrentBubble + 1) % mTotalNumOfBubble;
void BubbleEmitter::Restore()
{
- for(unsigned int i=0; i < mNumActor; i++ )
+ for(unsigned int i=0; i < mNumRenderer; i++ )
{
- (mBubbleActors[i])->ResetProperties();
+ mBubbleRenderers[i].ResetProperties();
}
}
Geometry BubbleEmitter::CreateGeometry( unsigned int numOfPatch )
{
unsigned int numVertex = numOfPatch*4u;
- std::vector<Vertex> vertexData;
- vertexData.reserve( numVertex );
+ Vector<Vertex> vertexData;
+ vertexData.Reserve( numVertex );
unsigned int numIndex = numOfPatch*6u;
Vector<unsigned short> indexData;
for(unsigned int i = 0; i < numOfPatch; i++)
{
- float curSize = RandomRange(mBubbleSizeRange.x, mBubbleSizeRange.y, mRandomSeed);
+ float halfSize = RandomRange(mBubbleSizeRange.x, mBubbleSizeRange.y, mRandomSeed) * 0.5f;
float index = static_cast<float>( i );
- vertexData.push_back( Vertex( index, Vector2(0.f,0.f), Vector2(0.f,0.f) ) );
- vertexData.push_back( Vertex( index, Vector2(0.f,curSize), Vector2(0.f,1.f) ) );
- vertexData.push_back( Vertex( index, Vector2(curSize,curSize), Vector2(1.f,1.f) ) );
- vertexData.push_back( Vertex( index, Vector2(curSize,0.f), Vector2(1.f,0.f) ) );
+ vertexData.PushBack( Vertex( index, Vector2(-halfSize,-halfSize),Vector2(0.f,0.f) ) );
+ vertexData.PushBack( Vertex( index, Vector2(-halfSize, halfSize), Vector2(0.f,1.f) ) );
+ vertexData.PushBack( Vertex( index, Vector2( halfSize, halfSize), Vector2(1.f,1.f) ) );
+ vertexData.PushBack( Vertex( index, Vector2( halfSize,-halfSize), Vector2(1.f,0.f) ) );
unsigned short idx = index * 4;
indexData.PushBack( idx );
return geometry;
}
-void BubbleEmitter::SetBubbleParameter( BubbleActorPtr bubbleActor, unsigned int curUniform,
+void BubbleEmitter::SetBubbleParameter( BubbleRenderer& bubbleRenderer, unsigned int curUniform,
const Vector2& emitPosition, const Vector2& direction, const Vector2& displacement )
{
Vector2 dir(direction);
randomVec.y *= 0.33f;
}
Vector4 startAndEndPos( emitPosition.x, emitPosition.y, emitPosition.x+randomVec.x, emitPosition.y+randomVec.y );
- bubbleActor->SetStartAndEndPosition( curUniform, startAndEndPos );
+ bubbleRenderer.SetStartAndEndPosition( curUniform, startAndEndPos );
- bubbleActor->SetPercentage( curUniform, 0.f);
+ bubbleRenderer.SetPercentage( curUniform, 0.f);
}
} // namespace Internal
// EXTERNAL INCLUDES
#include <dali/public-api/actors/camera-actor.h>
#include <dali/public-api/common/stage.h>
-#include <dali/public-api/images/frame-buffer-image.h>
+#include <dali/public-api/rendering/frame-buffer.h>
#include <dali/public-api/render-tasks/render-task.h>
#include <dali/public-api/rendering/geometry.h>
#include <dali/public-api/rendering/property-buffer.h>
namespace Internal
{
-class BubbleActor;
-typedef IntrusivePtr<BubbleActor> BubbleActorPtr;
+class BubbleRenderer;
/**
* BubbleEmitter implementation class.
* @copydoc Toolkit::BubbleEmitter::New
*/
static Toolkit::BubbleEmitter New( const Vector2& winSize,
- Image shapeImage,
+ Texture shapeTexture,
unsigned int maximumNumberOfBubble,
const Vector2& bubbleSizeRange );
/**
* @copydoc Toolkit::BubbleEmitter::SetBackground
*/
- void SetBackground( Image bgImage, const Vector3& hsvDelta );
+ void SetBackground( Texture bgTexture, const Vector3& hsvDelta );
/**
- * @copydoc Toolkit::BubbleEmitter::SetShapeImage
+ * @copydoc Toolkit::BubbleEmitter::SetShape
*/
- void SetShapeImage( Image shapeImage );
+ void SetBubbleShape( Texture shapeTexture );
/**
* @copydoc Toolkit::BubbleEmiter::SetBubbleScale
/**
* 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] shapeTexture 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,
+ Texture shapeTexture,
unsigned int maximumNumberOfBubble,
const Vector2& bubbleSizeRange );
/**
* 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.
+ * @param[in] source The render task used to create the color adjusted background texture.
*/
void OnRenderFinished(RenderTask& source);
/**
* Set the uniform values to the shader effect to emit a bubble
- * @param[in] bubbleActor The BubbleActor to render the current bubble
+ * @param[in] bubbleRenderer The BubbleRenderer
* @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( BubbleActorPtr bubbleActor, unsigned int curUniform,
+ void SetBubbleParameter( BubbleRenderer& bubbleRenderer, unsigned int curUniform,
const Vector2& emitPosition, const Vector2& direction, const Vector2& displacement );
private:
Actor mBubbleRoot; ///<The bubble root actor. Need to add it to stage to get the bubbles rendered.
- Image mShapeImage; ///< The alpha channnel of this texture defines the bubble shape.
- 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.
+ Texture mShapeTexture; ///< The alpha channnel of this texture defines the bubble shape.
+ Texture mBackgroundTexture; ///< The original background texture
+ Texture mEffectTexture; ///< Texture which stores the adjusted color of the background image.The bubbles pick color from this image.
+ FrameBuffer mFrameBuffer; ///< FrameBuffer used for offscreen rendering
CameraActor mCameraActor; ///< The render task views the scene from the perspective of this actor.
Geometry mMeshGeometry; ///< The mesh geometry which contains the vertices and indices data
TextureSet mTextureSet; ///< The texture set which controls the bubble display
- std::vector<BubbleActorPtr> mBubbleActors; ///< The meshActor vector, its size is mNumShader.
+ std::vector<BubbleRenderer> mBubbleRenderers; ///< The BubbleRenderer vector, its size is mNumShader.
Vector2 mMovementArea; ///< The size of the bubble moving area, usually the same size as the background.
Vector2 mBubbleSizeRange; ///< The size range of the bubbles; x component is the low bound, and y component is the up bound.
Vector3 mHSVDelta; ///< The HSV difference used to adjust the background image color.
- unsigned int mNumBubblePerActor; ///< How many bubbles for each BubbleActor.
- unsigned int mNumActor; ///< How many BubbleActors are used.
+ unsigned int mNumBubblePerRenderer; ///< How many bubbles for each BubbleRenderer.
+ unsigned int mNumRenderer; ///< How many BubbleRenderers are used.
unsigned int mDensity; ///< How many bubbles will emit at each time, they are controlled by same uniforms in the shader.
unsigned int mTotalNumOfBubble; ///< mNumBubblePerShader*mNumShader.
unsigned int mCurrentBubble; ///< Keep track of the index for the newly emitted bubble
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "bubble-renderer.h"
+
+// EXTERNAL INCLUDES
+#include <cmath>
+#include <sstream>
+
+// INTERNAL INCLUDES
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+BubbleRenderer::BubbleRenderer()
+: mRenderer(),
+ mIndicesOffset(),
+ mIndiceStartEndPos(),
+ mIndicesPercentage(),
+ mIndexGravity( Property::INVALID_INDEX ),
+ mIndexDynamicScale( Property::INVALID_INDEX ),
+ mIndexInvertedMovementArea( Property::INVALID_INDEX )
+{
+}
+
+void BubbleRenderer::Initialize( unsigned int numberOfBubble, const Vector2& movementArea, Geometry geometry, TextureSet textureSet, Shader shader )
+{
+ if( mRenderer )
+ {
+ // This function is supposed to be called once
+ return;
+ }
+
+ mRenderer = Renderer::New( geometry, shader );
+ mRenderer.SetTextures( textureSet );
+
+ // register uniforms
+ mIndexGravity = mRenderer.RegisterProperty( "uGravity", 50.f );
+ mIndexDynamicScale = mRenderer.RegisterProperty( "uDynamicScale", 1.f );
+
+ mIndexInvertedMovementArea = mRenderer.RegisterProperty( "uInvertedMovementArea", Vector2(1.f,1.f) / movementArea );
+
+ mIndicesOffset.resize(9);
+ int offset = movementArea.Length() / 10.f;
+
+ unsigned int seed = time( NULL );
+
+ mIndicesOffset[0] = mRenderer.RegisterProperty( "uOffset[0]", Vector2( 0.f,0.f ) );
+ mIndicesOffset[1] = mRenderer.RegisterProperty( "uOffset[1]", Vector2( rand_r( &seed ) % offset, rand_r( &seed ) % offset ) );
+ mIndicesOffset[2] = mRenderer.RegisterProperty( "uOffset[2]", Vector2( rand_r( &seed ) % offset, -rand_r( &seed ) % offset ) );
+ mIndicesOffset[3] = mRenderer.RegisterProperty( "uOffset[3]", Vector2(-rand_r( &seed ) % offset, rand_r( &seed ) % offset ) );
+ mIndicesOffset[4] = mRenderer.RegisterProperty( "uOffset[4]", Vector2(-rand_r( &seed ) % offset, -rand_r( &seed ) % offset ) );
+ mIndicesOffset[5] = mRenderer.RegisterProperty( "uOffset[5]", Vector2( rand_r( &seed ) % offset, 0.f ) );
+ mIndicesOffset[6] = mRenderer.RegisterProperty( "uOffset[6]", Vector2(-rand_r( &seed ) % offset, 0.f ) );
+ mIndicesOffset[7] = mRenderer.RegisterProperty( "uOffset[7]", Vector2( 0.f, rand_r( &seed ) % offset ) );
+ mIndicesOffset[8] = mRenderer.RegisterProperty( "uOffset[8]", Vector2( 0.f, -rand_r( &seed ) % offset ) );
+
+ Vector4 zeroVector;
+ mIndiceStartEndPos.resize( numberOfBubble );
+ mIndicesPercentage.resize( numberOfBubble );
+ for( unsigned int i=0; i<numberOfBubble; i++ )
+ {
+ std::ostringstream ossProperty;
+ ossProperty<< "uStartEndPosition["<< i << "]";
+ mIndiceStartEndPos[i] = mRenderer.RegisterProperty( ossProperty.str(), zeroVector );
+
+ ossProperty.str("");
+ ossProperty<< "uPercentage["<< i << "]";
+ mIndicesPercentage[i] = mRenderer.RegisterProperty( ossProperty.str(), 0.f );
+ }
+}
+
+Renderer& BubbleRenderer::GetRenderer()
+{
+ return mRenderer;
+}
+
+void BubbleRenderer::SetGeometry( Geometry geometry )
+{
+ mRenderer.SetGeometry( geometry );
+}
+
+void BubbleRenderer::SetStartAndEndPosition( unsigned int index, const Vector4& startAndEndPosition )
+{
+ mRenderer.SetProperty( mIndiceStartEndPos[index], startAndEndPosition );
+}
+
+void BubbleRenderer::SetPercentage( unsigned int index, float percentage )
+{
+ mRenderer.SetProperty( mIndicesPercentage[index], percentage );
+}
+
+void BubbleRenderer::SetGravity( float gravity )
+{
+ mRenderer.SetProperty( mIndexGravity, gravity );
+}
+
+void BubbleRenderer::SetDynamicScale( float scale )
+{
+ mRenderer.SetProperty( mIndexDynamicScale, scale );
+}
+
+Property BubbleRenderer::GetPercentageProperty( unsigned int index )
+{
+ return Property( mRenderer, mIndicesPercentage[index] );
+}
+
+void BubbleRenderer::ResetProperties()
+{
+ Vector4 zeroVector;
+ for( unsigned int i=0; i<mIndicesPercentage.size(); i++ )
+ {
+ SetPercentage( i, 0.f);
+ SetStartAndEndPosition( i, zeroVector );
+ }
+}
+
+} // namespace Internal
+
+} // namespace Toolkit
+
+} // namespace Dali
-#ifndef DALI_TOOLKIT_INTERNAL_BUBBLE_ACTOR_H
-#define DALI_TOOLKIT_INTERNAL_BUBBLE_ACTOR_H
+#ifndef DALI_TOOLKIT_INTERNAL_BUBBLE_RENDERER_H
+#define DALI_TOOLKIT_INTERNAL_BUBBLE_RENDERER_H
/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd.
{
/**
- * BubbleActor is a group of bubbles.Each bubble can be moved separately.
+ * BubbleRenderer renders a group of bubbles.Each bubble can be moved separately.
* Its custom shader achieves similar effect of particle system by applying on a specially created mesh
* Each bubble is rendered on a patch with two triangles; and each mesh can contain multiple such patches, thus a group.
*/
-class BubbleActor : public RefObject
+class BubbleRenderer
{
public:
/**
- * Constructor
- * @param[in] numberOfBubble How many groups of uniforms are used to control the bubble movement.
- * Note: Limited by the maximum available uniforms, this parameter cannot be bigger than 100.
- * Ideally use one group of uniform to control one bubble.
- * If the num of patches in the MeshActor is more than groups of uniforms,
- * the uniform values will be shared by multiple bubbles. Allow up to 9 times.
- * @param[in] movementArea The size of the bubble moving area, usually the same size as the background.
+ * Constructor *
* @return A newly allocated object.
*/
- BubbleActor( unsigned int numberOfBubble,
- const Vector2& movementArea);
+ BubbleRenderer();
/**
* @brief Destructor
*/
- ~BubbleActor(){}
+ ~BubbleRenderer(){}
/**
- * Prepare for the rendering: create and add renderer, and register properties
+ * Prepare for the rendering: create the renderer, and register properties
+ * @param[in] numberOfBubble How many groups of uniforms are used to control the bubble movement.
+ * Note: Limited by the maximum available uniforms, this parameter cannot be bigger than 100.
+ * Ideally use one group of uniform to control one bubble.
+ * If the num of patches in the MeshActor is more than groups of uniforms,
+ * the uniform values will be shared by multiple bubbles. Allow up to 9 times.
+ * @param[in] movementArea The size of the bubble moving area, usually the same size as the background.
* @param[in] geometry The geometry to be used by the renderer
* @param[in] textureSet The texture set to be used by the renderer
- * @param[in] textureSet The shader set to be used by the renderer
+ * @param[in] shader The shader set to be used by the renderer
*/
- void MakeRenderable( Geometry geometry, TextureSet textureSet, Shader shader );
+ void Initialize( unsigned int numberOfBubble, const Vector2& movementArea, Geometry geometry, TextureSet textureSet, Shader shader );
/**
* Return the mesh actor which is used to display the bubbles
*/
- Actor GetMeshActor();
+ Renderer& GetRenderer();
/**
* Sets the geometry to be used by the renderer
void SetGeometry( Geometry geometry );
/**
- * Set the bubble movement area for the BubbleEffect
- * @param[in] movementArea The size of bubble movement area; by default, it is the stage size
- */
- void SetMovementArea( const Vector2& movementArea );
-
- /**
* Set the start and end positions of the index-th bubble's movement.
* @param[in] index Indicate which bubble these properties are applied on.
* @param[in] startAndEndPosition The start and the end position of movement.
private:
- Actor mActor;
Renderer mRenderer;
- Vector2 mMovementArea; ///< The size of the bubble moving area, usually the same size as the background.
-
//properties mapped as uniforms
std::vector<Property::Index> mIndicesOffset; ///< Indices of the properties mapping to uniform array 'uOffset'
std::vector<Property::Index> mIndiceStartEndPos; ///< Indices of the properties mapping to uniform array 'uStartAndEndPos'
Property::Index mIndexGravity; ///< Index of the property mapping to uniform 'uGravity'
Property::Index mIndexDynamicScale; ///< Index of the property mapping to uniform 'uDynamicScale'
Property::Index mIndexInvertedMovementArea; ///< Index of the property mapping to uniform 'uInvertedMovementArea'
-
- unsigned int mNumBubble; ///< How many groups of uniforms are used to control the bubble movement.
- unsigned int mRandomSeed; ///< Seed to generate random number.
};
} // namespace Internal
} // namespace Dali
-#endif // DALI_TOOLKIT_INTERNAL_BUBBLE_ACTOR_H
+#endif // DALI_TOOLKIT_INTERNAL_BUBBLE_RENDERER_H
#include <dali/public-api/object/property-map.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/devel-api/visual-factory/devel-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#define DALI_COMPOSE_SHADER(STR) #STR
customShader[ Toolkit::Visual::Shader::Property::FRAGMENT_SHADER ] = fragmentShader;
Property::Map map;
- map[ Toolkit::VisualProperty::SHADER ] = customShader;
+ map[ Toolkit::DevelVisual::Property::SHADER ] = customShader;
return map;
}
#include <dali-toolkit/public-api/controls/text-controls/text-label.h>
#include <dali-toolkit/public-api/controls/image-view/image-view.h>
#include <dali-toolkit/public-api/visuals/color-visual-properties.h>
-#include <dali-toolkit/devel-api/visual-factory/devel-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
Toolkit::Visual::Base visual;
Property::Map map;
- map[ Toolkit::VisualProperty::TYPE ] = Toolkit::Visual::COLOR;
+ map[ Toolkit::DevelVisual::Property::TYPE ] = Toolkit::Visual::COLOR;
map[ Toolkit::ColorVisual::Property::MIX_COLOR ] = color;
visual = visualFactory.CreateVisual( map );
// EXTERNAL INCLUDES
#include <dali/public-api/common/dali-vector.h>
-#include <dali/devel-api/shader-effects/shader-effect.h>
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/buttons/check-box-button.h>
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/devel-api/visual-factory/devel-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
// TODO:
// pixel format / size - set from JSON
horizFragmentShaderStringStream << GAUSSIAN_BLUR_FRAGMENT_SOURCE;
Property::Map source;
source[ Toolkit::Visual::Shader::Property::FRAGMENT_SHADER ] = horizFragmentShaderStringStream.str();
- mCustomShader[ Toolkit::VisualProperty::SHADER ] = source;
+ mCustomShader[ Toolkit::DevelVisual::Property::SHADER ] = source;
//////////////////////////////////////////////////////
// Create actors
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/image-view/image-view.h>
-#include <dali-toolkit/devel-api/visual-factory/devel-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
#include <dali-toolkit/internal/visuals/visual-string-constants.h>
#include <dali-toolkit/internal/visuals/visual-base-impl.h>
DALI_ANIMATABLE_PROPERTY_REGISTRATION_WITH_DEFAULT( Toolkit, ImageView, "pixelArea", Vector4(0.f, 0.f, 1.f, 1.f), PIXEL_AREA )
DALI_TYPE_REGISTRATION_END()
-
-void SetDefaultTransformMap( Property::Map& transformMap )
-{
- transformMap.Clear();
- transformMap
- .Add( Toolkit::Visual::DevelProperty::Transform::Property::OFFSET, Vector2(0.0f, 0.0f) )
- .Add( Toolkit::Visual::DevelProperty::Transform::Property::SIZE, Vector2(1.0f, 1.0f) )
- .Add( Toolkit::Visual::DevelProperty::Transform::Property::ORIGIN, Toolkit::Align::CENTER )
- .Add( Toolkit::Visual::DevelProperty::Transform::Property::ANCHOR_POINT, Toolkit::Align::CENTER )
- .Add( Toolkit::Visual::DevelProperty::Transform::Property::OFFSET_SIZE_MODE, Vector4::ZERO );
-
-}
-
} // anonymous namespace
using namespace Dali;
mVisual = Toolkit::VisualFactory::Get().CreateVisual( url, size );
RegisterVisual( Toolkit::ImageView::Property::IMAGE, mVisual );
- // This transform fills the control
- // Should provide a transform that handles aspect ratio according to image size
- Property::Map transformMap;
- SetDefaultTransformMap( transformMap );
- mVisual.SetTransformAndSize( transformMap, mSizeSet );
-
RelayoutRequest();
}
}
}
}
-
-///////////////////////////////////////////////////////////
-//
-// Private methods
-//
-
-void ImageView::OnSizeSet( const Vector3& targetSize )
+void ImageView::OnRelayout( const Vector2& size, RelayoutContainer& container )
{
- Control::OnSizeSet( targetSize );
- mSizeSet = targetSize;
+ Control::OnRelayout( size, container );
if( mVisual )
{
- Vector2 size( targetSize );
-
- // This transform fills the control
+ // Pass in an empty map which uses default transform values meaning our visual fills the control
// Should provide a transform that handles aspect ratio according to image size
- Property::Map transformMap;
- SetDefaultTransformMap( transformMap );
- mVisual.SetTransformAndSize( transformMap, size );
+ mVisual.SetTransformAndSize( Property::Map(), size );
}
}
case Toolkit::ImageView::Property::IMAGE:
{
std::string imageUrl;
- Property::Map map;
+ Property::Map* map;
if( value.Get( imageUrl ) )
{
impl.SetImage( imageUrl, ImageDimensions() );
}
// if its not a string then get a Property::Map from the property if possible.
- else if( value.Get( map ) )
+ else
{
- Property::Value* shaderValue = map.Find( Toolkit::VisualProperty::SHADER, CUSTOM_SHADER );
- // set image only if property map contains image information other than custom shader
- if( map.Count() > 1u || !shaderValue )
+ map = value.GetMap();
+ if( map )
{
- impl.SetImage( map );
- }
- // the property map contains only the custom shader
- else if( impl.mVisual && map.Count() == 1u && shaderValue )
- {
- Property::Map shaderMap;
- if( shaderValue->Get( shaderMap ) )
+ Property::Value* shaderValue = map->Find( Toolkit::DevelVisual::Property::SHADER, CUSTOM_SHADER );
+ // set image only if property map contains image information other than custom shader
+ if( map->Count() > 1u || !shaderValue )
+ {
+ impl.SetImage( *map );
+ }
+ // the property map contains only the custom shader
+ else if( ( impl.mVisual )&&( map->Count() == 1u )&&( shaderValue ) )
{
- Internal::Visual::Base& visual = Toolkit::GetImplementation( impl.mVisual );
- visual.SetCustomShader( shaderMap );
- if( imageView.OnStage() )
+ Property::Map* shaderMap = shaderValue->GetMap();
+ if( shaderMap )
{
- // force to create new core renderer to use the newly set shader
- visual.SetOffStage( imageView );
- visual.SetOnStage( imageView );
+ Internal::Visual::Base& visual = Toolkit::GetImplementation( impl.mVisual );
+ visual.SetCustomShader( *shaderMap );
+ if( imageView.OnStage() )
+ {
+ // force to create new core renderer to use the newly set shader
+ visual.SetOffStage( imageView );
+ visual.SetOnStage( imageView );
+ }
}
}
}
#define __DALI_TOOLKIT_INTERNAL_IMAGE_VIEW_H__
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
private: // From Control
/**
- * @copydoc Toolkit::Control::OnSizeSet()
- */
- virtual void OnSizeSet( const Vector3& targetSize );
-
- /**
* @copydoc Toolkit::Control::GetNaturalSize
*/
virtual Vector3 GetNaturalSize();
*/
virtual float GetWidthForHeight( float height );
+ /**
+ * @copydoc Toolkit::Control::OnRelayout()
+ */
+ virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
+
private:
// Undefined
ImageView( const ImageView& );
private:
Toolkit::Visual::Base mVisual;
ImageDimensions mImageSize;
- Vector2 mSizeSet;
std::string mUrl; ///< the url for the image if the image came from a URL, empty otherwise
Image mImage; ///< the Image if the image came from a Image, null otherwise
#include <dali-toolkit/public-api/visuals/border-visual-properties.h>
#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
#include <dali-toolkit/internal/visuals/visual-factory-impl.h>
-#include <dali-toolkit/devel-api/visual-factory/devel-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
namespace Dali
{
Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
Property::Map map;
- map[ Toolkit::VisualProperty::TYPE ] = Toolkit::Visual::BORDER;
+ map[ Toolkit::DevelVisual::Property::TYPE ] = Toolkit::Visual::BORDER;
map[ Toolkit::BorderVisual::Property::COLOR ] = Color::WHITE;
map[ Toolkit::BorderVisual::Property::SIZE ] = IMAGE_BORDER_INDENT;
Toolkit::Visual::Base borderVisual = visualFactory.CreateVisual( map );
*/
// INTERNAL INCLUDES
-#include <dali-toolkit/devel-api/visual-factory/devel-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#define DALI_COMPOSE_SHADER(STR) #STR
customShader[ Toolkit::Visual::Shader::Property::VERTEX_SHADER ] = vertexSource;
customShader[ Toolkit::Visual::Shader::Property::FRAGMENT_SHADER ] = fragmentSource;
- map[ Toolkit::VisualProperty::SHADER ] = customShader;
+ map[ Toolkit::DevelVisual::Property::SHADER ] = customShader;
return map;
}
#include <dali/public-api/object/property-map.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/devel-api/visual-factory/devel-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali-toolkit/internal/controls/page-turn-view/page-turn-effect.h>
using namespace Dali;
customShader[ Toolkit::Visual::Shader::Property::SUBDIVIDE_GRID_X ] = 20;
customShader[ Toolkit::Visual::Shader::Property::SUBDIVIDE_GRID_Y ] = 20;
- map[ Toolkit::VisualProperty::SHADER ] = customShader;
+ map[ Toolkit::DevelVisual::Property::SHADER ] = customShader;
return map;
}
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/devel-api/visual-factory/devel-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali-toolkit/internal/controls/page-turn-view/page-turn-effect.h>
#include <dali-toolkit/internal/controls/page-turn-view/page-turn-book-spine-effect.h>
#include <dali-toolkit/internal/visuals/visual-factory-cache.h>
Shader PageTurnView::CreateShader( const Property::Map& shaderMap )
{
Shader shader;
- Property::Value* shaderValue = shaderMap.Find( Toolkit::VisualProperty::SHADER, CUSTOM_SHADER );
+ Property::Value* shaderValue = shaderMap.Find( Toolkit::DevelVisual::Property::SHADER, CUSTOM_SHADER );
Property::Map shaderSource;
if( shaderValue && shaderValue->Get( shaderSource ) )
{
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/devel-api/visual-factory/devel-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali-toolkit/internal/controls/shadow-view/shadow-view-impl.h>
#include <dali-toolkit/internal/filters/blur-two-pass-filter.h>
customShader[ Toolkit::Visual::Shader::Property::HINTS ] = Shader::Hint::OUTPUT_IS_TRANSPARENT;
- mShadowVisualMap[ Toolkit::VisualProperty::SHADER ] = customShader;
+ mShadowVisualMap[ Toolkit::DevelVisual::Property::SHADER ] = customShader;
// Create render targets needed for rendering from light's point of view
mSceneFromLightRenderTarget = FrameBufferImage::New( stageSize.width, stageSize.height, Pixel::RGBA8888 );
$(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/bubble-effect/bubble-actor.cpp \
+ $(toolkit_src_dir)/controls/bubble-effect/bubble-renderer.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 \
#include <dali/devel-api/images/texture-set-image.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/devel-api/visual-factory/devel-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
namespace Dali
{
Property::Map customShader;
customShader[ Toolkit::Visual::Shader::Property::FRAGMENT_SHADER ] = fragmentSource.str();
Property::Map visualMap;
- visualMap.Insert( Toolkit::VisualProperty::SHADER, customShader );
+ visualMap.Insert( Toolkit::DevelVisual::Property::SHADER, customShader );
mActorForInput.SetProperty( Toolkit::ImageView::Property::IMAGE, visualMap );
mActorForHorz.SetProperty( Toolkit::ImageView::Property::IMAGE, visualMap );
// Set up blend-two-image custom shader
customShader[ Toolkit::Visual::Shader::Property::FRAGMENT_SHADER ] = BLEND_TWO_IMAGES_FRAGMENT_SOURCE;
- visualMap[ Toolkit::VisualProperty::SHADER ] = customShader;
+ visualMap[ Toolkit::DevelVisual::Property::SHADER ] = customShader;
mActorForBlending.SetProperty( Toolkit::ImageView::Property::IMAGE, visualMap );
mRootActor.Add( mActorForInput );
// INTERNAL INCLUDES
#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
-#include <dali-toolkit/devel-api/visual-factory/devel-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali-toolkit/internal/visuals/visual-base-impl.h>
#include <dali-toolkit/internal/visuals/visual-factory-impl.h>
Property::Map customShader;
customShader[ Toolkit::Visual::Shader::Property::FRAGMENT_SHADER ] = EMBOSS_FRAGMENT_SOURCE;
Property::Map visualMap;
- visualMap.Insert( Toolkit::VisualProperty::SHADER, customShader );
+ visualMap.Insert( Toolkit::DevelVisual::Property::SHADER, customShader );
// create actor to render input with applied emboss effect
mActorForInput1 = Toolkit::ImageView::New(mInputImage);
#include <dali/public-api/render-tasks/render-task-list.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/devel-api/visual-factory/devel-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
namespace Dali
{
Property::Map customShader;
customShader[ Toolkit::Visual::Shader::Property::FRAGMENT_SHADER ] = SPREAD_FRAGMENT_SOURCE;
Property::Map visualMap;
- visualMap.Insert( Toolkit::VisualProperty::SHADER, customShader );
+ visualMap.Insert( Toolkit::DevelVisual::Property::SHADER, customShader );
// set SPREAD custom shader
mActorForInput.SetProperty( Toolkit::ImageView::Property::IMAGE, visualMap );
// EXTERNAL INCLUDES
#include <dali/integration-api/debug.h>
+#include <dali/devel-api/object/handle-devel.h>
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/visuals/border-visual-properties.h>
-#include <dali-toolkit/devel-api/visual-factory/devel-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali-toolkit/internal/visuals/visual-factory-impl.h>
#include <dali-toolkit/internal/visuals/visual-factory-cache.h>
#include <dali-toolkit/internal/visuals/visual-string-constants.h>
{
InitializeRenderer();
- mBorderColorIndex = (mImpl->mRenderer).RegisterProperty( Toolkit::BorderVisual::Property::COLOR, COLOR_NAME, mBorderColor );
+ mBorderColorIndex = DevelHandle::RegisterProperty( mImpl->mRenderer, Toolkit::BorderVisual::Property::COLOR, COLOR_NAME, mBorderColor );
if( mBorderColor.a < 1.f || mAntiAliasing)
{
mImpl->mRenderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON );
}
- mBorderSizeIndex = (mImpl->mRenderer).RegisterProperty( Toolkit::BorderVisual::Property::SIZE, SIZE_NAME, mBorderSize );
+ mBorderSizeIndex = DevelHandle::RegisterProperty( mImpl->mRenderer, Toolkit::BorderVisual::Property::SIZE, SIZE_NAME, mBorderSize );
actor.AddRenderer( mImpl->mRenderer );
}
void BorderVisual::DoCreatePropertyMap( Property::Map& map ) const
{
map.Clear();
- map.Insert( VisualProperty::TYPE, Toolkit::Visual::BORDER );
+ map.Insert( DevelVisual::Property::TYPE, Toolkit::Visual::BORDER );
map.Insert( Toolkit::BorderVisual::Property::COLOR, mBorderColor );
map.Insert( Toolkit::BorderVisual::Property::SIZE, mBorderSize );
map.Insert( Toolkit::BorderVisual::Property::ANTI_ALIASING, mAntiAliasing );
// EXTERNAL INCLUDES
#include <dali/integration-api/debug.h>
+#include <dali/devel-api/object/handle-devel.h>
//INTERNAL INCLUDES
#include <dali-toolkit/public-api/visuals/color-visual-properties.h>
-#include <dali-toolkit/devel-api/visual-factory/devel-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali-toolkit/internal/visuals/visual-factory-impl.h>
#include <dali-toolkit/internal/visuals/visual-factory-cache.h>
#include <dali-toolkit/internal/visuals/visual-string-constants.h>
void ColorVisual::DoCreatePropertyMap( Property::Map& map ) const
{
map.Clear();
- map.Insert( Toolkit::VisualProperty::TYPE, Toolkit::Visual::COLOR );
+ map.Insert( Toolkit::DevelVisual::Property::TYPE, Toolkit::Visual::COLOR );
map.Insert( Toolkit::ColorVisual::Property::MIX_COLOR, mMixColor );
}
mImpl->mRenderer = Renderer::New( geometry, shader );
- mMixColorIndex = mImpl->mRenderer.RegisterProperty( Toolkit::ColorVisual::Property::MIX_COLOR, COLOR_NAME, mMixColor );
+ mMixColorIndex = DevelHandle::RegisterProperty( mImpl->mRenderer, Toolkit::ColorVisual::Property::MIX_COLOR, COLOR_NAME, mMixColor );
if( mMixColor.a < 1.f )
{
mImpl->mRenderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON );
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/visuals/gradient-visual-properties.h>
-#include <dali-toolkit/devel-api/visual-factory/devel-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali-toolkit/internal/visuals/visual-factory-impl.h>
#include <dali-toolkit/internal/visuals/visual-factory-cache.h>
#include <dali-toolkit/internal/visuals/visual-string-constants.h>
void GradientVisual::DoCreatePropertyMap( Property::Map& map ) const
{
map.Clear();
- map.Insert( Toolkit::VisualProperty::TYPE, Toolkit::Visual::GRADIENT );
+ map.Insert( Toolkit::DevelVisual::Property::TYPE, Toolkit::Visual::GRADIENT );
map.Insert( Toolkit::GradientVisual::Property::UNITS, mGradient->GetGradientUnits() );
map.Insert( Toolkit::GradientVisual::Property::SPREAD_METHOD, mGradient->GetSpreadMethod() );
#include <dali/public-api/images/native-image.h>
#include <dali/integration-api/debug.h>
#include <dali/devel-api/adaptor-framework/bitmap-loader.h>
+#include <dali/devel-api/rendering/renderer-devel.h>
#include <dali/public-api/images/pixel-data.h>
#include <dali/public-api/rendering/texture.h>
#include <dali/public-api/rendering/texture-set.h>
// INTERNAL HEADER
#include <dali-toolkit/public-api/visuals/image-visual-properties.h>
-#include <dali-toolkit/devel-api/visual-factory/devel-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali-toolkit/internal/visuals/visual-factory-impl.h>
#include <dali-toolkit/internal/visuals/visual-factory-cache.h>
#include <dali-toolkit/internal/visuals/visual-base-impl.h>
mImpl->mRenderer.SetTextures( textureSet );
// Turn batching on, to send message it must be on stage.
- mImpl->mRenderer.SetProperty( Dali::Renderer::Property::BATCHING_ENABLED, true );
+ mImpl->mRenderer.SetProperty( Dali::DevelRenderer::Property::BATCHING_ENABLED, true );
}
mImpl->mFlags |= Impl::IS_FROM_CACHE;
}
InitializeRenderer( mImageUrl );
}
// Turn batching on, to send message it must be on stage
- mImpl->mRenderer.SetProperty( Dali::Renderer::Property::BATCHING_ENABLED, true );
+ mImpl->mRenderer.SetProperty( Dali::DevelRenderer::Property::BATCHING_ENABLED, true );
actor.AddRenderer( mImpl->mRenderer );
}
void BatchImageVisual::DoCreatePropertyMap( Property::Map& map ) const
{
map.Clear();
- map.Insert( Toolkit::VisualProperty::TYPE, Toolkit::Visual::IMAGE );
+ map.Insert( Toolkit::DevelVisual::Property::TYPE, Toolkit::Visual::IMAGE );
if( !mImageUrl.empty() )
{
// INTERNAL HEADER
#include <dali-toolkit/public-api/visuals/image-visual-properties.h>
-#include <dali-toolkit/devel-api/visual-factory/devel-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali-toolkit/internal/visuals/visual-string-constants.h>
#include <dali-toolkit/internal/visuals/visual-factory-impl.h>
#include <dali-toolkit/internal/visuals/visual-factory-cache.h>
void ImageVisual::DoCreatePropertyMap( Property::Map& map ) const
{
map.Clear();
- map.Insert( Toolkit::VisualProperty::TYPE, Toolkit::Visual::IMAGE );
+ map.Insert( Toolkit::DevelVisual::Property::TYPE, Toolkit::Visual::IMAGE );
bool sync = IsSynchronousResourceLoading();
map.Insert( SYNCHRONOUS_LOADING, sync );
#include <fstream>
//INTERNAL INCLUDES
-#include <dali-toolkit/devel-api/visual-factory/devel-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
#include <dali-toolkit/internal/visuals/visual-string-constants.h>
void MeshVisual::DoCreatePropertyMap( Property::Map& map ) const
{
map.Clear();
- map.Insert( Toolkit::VisualProperty::TYPE, Toolkit::Visual::MESH );
+ map.Insert( Toolkit::DevelVisual::Property::TYPE, Toolkit::Visual::MESH );
map.Insert( Toolkit::MeshVisual::Property::OBJECT_URL, mObjectUrl );
map.Insert( Toolkit::MeshVisual::Property::MATERIAL_URL, mMaterialUrl );
map.Insert( Toolkit::MeshVisual::Property::TEXTURES_PATH, mTexturesPath );
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/visuals/image-visual-properties.h>
-#include <dali-toolkit/devel-api/visual-factory/devel-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali-toolkit/internal/visuals/npatch-loader.h>
#include <dali-toolkit/internal/visuals/visual-factory-impl.h>
#include <dali-toolkit/internal/visuals/visual-factory-cache.h>
void NPatchVisual::DoCreatePropertyMap( Property::Map& map ) const
{
map.Clear();
- map.Insert( Toolkit::VisualProperty::TYPE, Toolkit::Visual::IMAGE );
+ map.Insert( Toolkit::DevelVisual::Property::TYPE, Toolkit::Visual::IMAGE );
map.Insert( Toolkit::ImageVisual::Property::URL, mImageUrl );
map.Insert( Toolkit::ImageVisual::Property::BORDER_ONLY, mBorderOnly );
}
#include <dali/integration-api/debug.h>
#include <dali/public-api/common/stage.h>
#include <dali/public-api/common/constants.h>
+#include <dali/devel-api/object/handle-devel.h>
#include <dali/devel-api/scripting/enum-helper.h>
#include <dali/devel-api/scripting/scripting.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/devel-api/visual-factory/devel-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
#include <dali-toolkit/internal/visuals/visual-string-constants.h>
void PrimitiveVisual::DoCreatePropertyMap( Property::Map& map ) const
{
map.Clear();
- map.Insert( Toolkit::VisualProperty::TYPE, Toolkit::Visual::PRIMITIVE );
+ map.Insert( Toolkit::DevelVisual::Property::TYPE, Toolkit::Visual::PRIMITIVE );
map.Insert( Toolkit::PrimitiveVisual::Property::SHAPE, mPrimitiveType );
map.Insert( Toolkit::PrimitiveVisual::Property::MIX_COLOR, mColor );
map.Insert( Toolkit::PrimitiveVisual::Property::SLICES, mSlices );
mShader.RegisterProperty( STAGE_OFFSET_UNIFORM_NAME, Vector2( width, height ) / 2.0f );
mShader.RegisterProperty( LIGHT_POSITION_UNIFORM_NAME, mLightPosition );
mShader.RegisterProperty( OBJECT_MATRIX_UNIFORM_NAME, scaleMatrix );
- mShader.RegisterProperty( Toolkit::PrimitiveVisual::Property::MIX_COLOR, COLOR_UNIFORM_NAME, mColor );
+ DevelHandle::RegisterProperty( mShader, Toolkit::PrimitiveVisual::Property::MIX_COLOR, COLOR_UNIFORM_NAME, mColor );
mShader.RegisterProperty( OBJECT_DIMENSIONS_UNIFORM_NAME, mObjectDimensions );
}
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/visuals/image-visual-properties.h>
-#include <dali-toolkit/devel-api/visual-factory/devel-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali-toolkit/third-party/nanosvg/nanosvg.h>
#include <dali-toolkit/internal/visuals/svg/svg-rasterize-thread.h>
#include <dali-toolkit/internal/visuals/image/image-visual.h>
void SvgVisual::DoCreatePropertyMap( Property::Map& map ) const
{
map.Clear();
- map.Insert( Toolkit::VisualProperty::TYPE, Toolkit::Visual::IMAGE );
+ map.Insert( Toolkit::DevelVisual::Property::TYPE, Toolkit::Visual::IMAGE );
if( !mImageUrl.empty() )
{
map.Insert( Toolkit::ImageVisual::Property::URL, mImageUrl );
#include <dali-toolkit/internal/visuals/text/text-visual.h>
// INTERNAL HEADER
-#include <dali-toolkit/devel-api/visual-factory/devel-visual-properties.h>
#include <dali-toolkit/devel-api/visuals/text-visual-properties.h>
#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
Property::Value value;
map.Clear();
- map.Insert( Toolkit::VisualProperty::TYPE, Toolkit::DevelVisual::TEXT );
+ map.Insert( Toolkit::DevelVisual::Property::TYPE, Toolkit::DevelVisual::TEXT );
std::string text;
mController->GetText( text );
{
case Property::Key::INDEX:
{
- if( Toolkit::VisualProperty::TYPE != keyValue.first.indexKey ) // Toolkit::VisualProperty::TYPE is not a TextVisual's property.
- {
- DoSetProperty( keyValue.first.indexKey, keyValue.second );
- }
+ DoSetProperty( keyValue.first.indexKey, keyValue.second );
break;
}
case Property::Key::STRING:
{
mControl = actor;
- CreateRenderer();
+ Geometry geometry = mFactoryCache.GetGeometry( VisualFactoryCache::QUAD_GEOMETRY );
+ if( !geometry )
+ {
+ geometry = VisualFactoryCache::CreateQuadGeometry();
+ mFactoryCache.SaveGeometry( VisualFactoryCache::QUAD_GEOMETRY , geometry );
+ }
+
+ Shader shader = mFactoryCache.GetShader( VisualFactoryCache::IMAGE_SHADER_ATLAS_DEFAULT_WRAP );
+ if( !shader )
+ {
+ shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER_ATLAS_CLAMP );
+ mFactoryCache.SaveShader( VisualFactoryCache::IMAGE_SHADER_ATLAS_DEFAULT_WRAP, shader );
+ }
+ shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
+
+ mImpl->mRenderer = Renderer::New( geometry, shader );
+ mImpl->mRenderer.SetProperty( Dali::Renderer::Property::DEPTH_INDEX, Toolkit::DepthIndex::TEXT );
+
+ UpdateRenderer();
}
void TextVisual::DoSetOffStage( Actor& actor )
// Removes the renderer from the actor.
actor.RemoveRenderer( mImpl->mRenderer );
- DestroyRenderer();
+ RemoveTextureSet();
+
+ // Resets the renderer.
+ mImpl->mRenderer.Reset();
}
// Resets the control handle.
mControl.Reset();
}
+void TextVisual::OnSetTransform()
+{
+ UpdateRenderer();
+}
+
void TextVisual::DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue )
{
switch( index )
{
+ case Toolkit::TextVisual::Property::ENABLE_MARKUP:
+ {
+ const bool enableMarkup = propertyValue.Get<bool>();
+ mController->SetMarkupProcessorEnabled( enableMarkup );
+ break;
+ }
case Toolkit::TextVisual::Property::TEXT:
{
mController->SetText( propertyValue.Get<std::string>() );
case Toolkit::TextVisual::Property::POINT_SIZE:
{
const float pointSize = propertyValue.Get<float>();
-
if( !Equals( mController->GetDefaultPointSize(), pointSize ) )
{
mController->SetDefaultPointSize( pointSize );
}
break;
}
- case Toolkit::TextVisual::Property::ENABLE_MARKUP:
- {
- const bool enableMarkup = propertyValue.Get<bool>();
- mController->SetMarkupProcessorEnabled( enableMarkup );
- break;
- }
- default:
- {
- // Should not arrive here.
- DALI_ASSERT_DEBUG( false );
- }
}
}
-void TextVisual::OnSetTransform()
-{
- CreateRenderer();
-}
-
-void TextVisual::CreateRenderer()
+void TextVisual::UpdateRenderer()
{
Actor control = mControl.GetHandle();
if( !control )
if( ( fabsf( relayoutSize.width ) < Math::MACHINE_EPSILON_1000 ) || ( fabsf( relayoutSize.height ) < Math::MACHINE_EPSILON_1000 ) )
{
+ // Removes the texture set.
+ RemoveTextureSet();
+
// Remove any renderer previously set.
if( mImpl->mRenderer )
{
control.RemoveRenderer( mImpl->mRenderer );
-
- DestroyRenderer();
}
// Nothing else to do if the relayout size is zero.
if( Text::Controller::NONE_UPDATED != ( Text::Controller::MODEL_UPDATED & updateTextType ) )
{
+ // Removes the texture set.
+ RemoveTextureSet();
+
// Remove any renderer previously set.
if( mImpl->mRenderer )
{
control.RemoveRenderer( mImpl->mRenderer );
-
- DestroyRenderer();
}
if( ( relayoutSize.width > Math::MACHINE_EPSILON_1000 ) &&
{
PixelData data = mTypesetter->Render( relayoutSize );
- Geometry geometry;
- Shader shader;
- TextureSet textureSet;
+ Vector4 atlasRect = FULL_TEXTURE_RECT;
+ TextureSet textureSet = mFactoryCache.GetAtlasManager()->Add( atlasRect, data );
- Vector4 atlasRect;
+ if( textureSet )
+ {
+ mImpl->mFlags |= Impl::IS_ATLASING_APPLIED;
+ }
+ else
+ {
+ // It may happen the image atlas can't handle a pixel data it exceeds the maximum size.
+ // In that case, create a texture. TODO: should tile the text.
- textureSet = mFactoryCache.GetAtlasManager()->Add( atlasRect, data );
- mImpl->mFlags |= Impl::IS_ATLASING_APPLIED;
+ Texture texture = Texture::New( Dali::TextureType::TEXTURE_2D,
+ data.GetPixelFormat(),
+ data.GetWidth(),
+ data.GetHeight() );
- // Filter mode needs to be set to nearest to avoid blurry text.
- Sampler sampler = Sampler::New();
- sampler.SetFilterMode( FilterMode::NEAREST, FilterMode::NEAREST );
- textureSet.SetSampler( 0u, sampler );
+ texture.Upload( data );
- geometry = mFactoryCache.GetGeometry( VisualFactoryCache::QUAD_GEOMETRY );
- if( !geometry )
- {
- geometry = VisualFactoryCache::CreateQuadGeometry();
- mFactoryCache.SaveGeometry( VisualFactoryCache::QUAD_GEOMETRY , geometry );
- }
+ textureSet = TextureSet::New();
+ textureSet.SetTexture( 0u, texture );
- shader = mFactoryCache.GetShader( VisualFactoryCache::IMAGE_SHADER_ATLAS_DEFAULT_WRAP );
- if( !shader )
- {
- shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER_ATLAS_CLAMP );
- mFactoryCache.SaveShader( VisualFactoryCache::IMAGE_SHADER_ATLAS_DEFAULT_WRAP, shader );
+ mImpl->mFlags &= ~Impl::IS_ATLASING_APPLIED;
}
- shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
- mImpl->mRenderer = Renderer::New( geometry, shader );
- mImpl->mRenderer.SetProperty( Dali::Renderer::Property::DEPTH_INDEX, Toolkit::DepthIndex::TEXT );
mImpl->mRenderer.RegisterProperty( ATLAS_RECT_UNIFORM_NAME, atlasRect );
- mImpl->mRenderer.SetTextures( textureSet );
-
- control.AddRenderer( mImpl->mRenderer );
-
//Register transform properties
mImpl->mTransform.RegisterUniforms( mImpl->mRenderer, Direction::LEFT_TO_RIGHT );
- mImpl->mFlags |= Impl::IS_FROM_CACHE;
+ // Filter mode needs to be set to nearest to avoid blurry text.
+ Sampler sampler = Sampler::New();
+ sampler.SetFilterMode( FilterMode::NEAREST, FilterMode::NEAREST );
+ textureSet.SetSampler( 0u, sampler );
+
+ mImpl->mRenderer.SetTextures( textureSet );
+
+ control.AddRenderer( mImpl->mRenderer );
}
}
}
-void TextVisual::DestroyRenderer()
+void TextVisual::RemoveTextureSet()
{
- // Removes the text's image from the texture atlas.
- Vector4 atlasRect;
-
- const Property::Index index = mImpl->mRenderer.GetPropertyIndex( ATLAS_RECT_UNIFORM_NAME );
- if( index != Property::INVALID_INDEX )
+ if( mImpl->mFlags & Impl::IS_ATLASING_APPLIED )
{
- const Property::Value& atlasRectValue = mImpl->mRenderer.GetProperty( index );
- atlasRectValue.Get( atlasRect );
+ // Removes the text's image from the texture atlas.
+ Vector4 atlasRect;
- const TextureSet& textureSet = mImpl->mRenderer.GetTextures();
- mFactoryCache.GetAtlasManager()->Remove( textureSet, atlasRect );
- }
+ const Property::Index index = mImpl->mRenderer.GetPropertyIndex( ATLAS_RECT_UNIFORM_NAME );
+ if( index != Property::INVALID_INDEX )
+ {
+ const Property::Value& atlasRectValue = mImpl->mRenderer.GetProperty( index );
+ atlasRectValue.Get( atlasRect );
- // Resets the renderer.
- mImpl->mRenderer.Reset();
+ const TextureSet& textureSet = mImpl->mRenderer.GetTextures();
+ mFactoryCache.GetAtlasManager()->Remove( textureSet, atlasRect );
+ }
+ }
}
} // namespace Internal
virtual void OnSetTransform();
private:
-
/**
- * Set the individual property to the given value
- * @param[in] index The index key used to reference this value within the initial
- * property map.
- * @param[in] propertyValue The value to set
+ * @brief Set the individual property to the given value.
+ *
+ * @param[in] index The index key used to reference this value within the initial property map.
+ *
+ * @param[in] propertyValue The value to set.
*/
void DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue );
/**
- * @brief Creates the text's renderer.
+ * @brief Updates the text's renderer.
*/
- void CreateRenderer();
+ void UpdateRenderer();
/**
- * @brief Destroys the text's renderer.
+ * @brief Removes the texture set from the renderer.
*/
- void DestroyRenderer();
+ void RemoveTextureSet();
private:
Text::ControllerPtr mController; ///< The text's controller.
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/devel-api/visual-factory/devel-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali-toolkit/internal/visuals/visual-string-constants.h>
namespace Dali
customShader.Insert( Toolkit::Visual::Shader::Property::HINTS, static_cast< int >( mHints ) );
}
- map.Insert( Toolkit::VisualProperty::SHADER, customShader );
+ map.Insert( Toolkit::DevelVisual::Property::SHADER, customShader );
}
}
for( Property::Map::SizeType i(0); i<map.Count(); ++i )
{
KeyValuePair keyValue = map.GetKeyValue( i );
- if( keyValue.first == Toolkit::Visual::DevelProperty::Transform::Property::OFFSET )
+ if( keyValue.first == Toolkit::DevelVisual::Transform::Property::OFFSET )
{
keyValue.second.Get( mOffset );
}
- else if( keyValue.first == Toolkit::Visual::DevelProperty::Transform::Property::SIZE )
+ else if( keyValue.first == Toolkit::DevelVisual::Transform::Property::SIZE )
{
keyValue.second.Get( mSize );
}
- else if( keyValue.first == Toolkit::Visual::DevelProperty::Transform::Property::ORIGIN )
+ else if( keyValue.first == Toolkit::DevelVisual::Transform::Property::ORIGIN )
{
Toolkit::Align::Type align(Toolkit::Align::CENTER);
if( Scripting::GetEnumerationProperty< Toolkit::Align::Type >( keyValue.second, ALIGN_TABLE, ALIGN_TABLE_COUNT, align ) )
mOrigin = align;
}
}
- else if( keyValue.first == Toolkit::Visual::DevelProperty::Transform::Property::ANCHOR_POINT )
+ else if( keyValue.first == Toolkit::DevelVisual::Transform::Property::ANCHOR_POINT )
{
Toolkit::Align::Type align(Toolkit::Align::CENTER);
if( Scripting::GetEnumerationProperty< Toolkit::Align::Type >( keyValue.second, ALIGN_TABLE, ALIGN_TABLE_COUNT, align ) )
mAnchorPoint = align;
}
}
- else if( keyValue.first == Toolkit::Visual::DevelProperty::Transform::Property::OFFSET_SIZE_MODE )
+ else if( keyValue.first == Toolkit::DevelVisual::Transform::Property::OFFSET_SIZE_MODE )
{
keyValue.second.Get( mOffsetSizeMode );
}
void Internal::Visual::Base::Impl::Transform::GetPropertyMap( Property::Map& map ) const
{
map.Clear();
- map.Add( Toolkit::Visual::DevelProperty::Transform::Property::OFFSET, mOffset )
- .Add( Toolkit::Visual::DevelProperty::Transform::Property::SIZE, mSize )
- .Add( Toolkit::Visual::DevelProperty::Transform::Property::ORIGIN, mOrigin )
- .Add( Toolkit::Visual::DevelProperty::Transform::Property::ANCHOR_POINT, mAnchorPoint )
- .Add( Toolkit::Visual::DevelProperty::Transform::Property::OFFSET_SIZE_MODE, mOffsetSizeMode );
+ map.Add( Toolkit::DevelVisual::Transform::Property::OFFSET, mOffset )
+ .Add( Toolkit::DevelVisual::Transform::Property::SIZE, mSize )
+ .Add( Toolkit::DevelVisual::Transform::Property::ORIGIN, mOrigin )
+ .Add( Toolkit::DevelVisual::Transform::Property::ANCHOR_POINT, mAnchorPoint )
+ .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_SIZE_MODE, mOffsetSizeMode );
}
void Internal::Visual::Base::Impl::Transform::RegisterUniforms( Dali::Renderer renderer, Toolkit::Direction::Type direction )
#include <dali/integration-api/debug.h>
//INTERNAL HEARDER
-#include <dali-toolkit/devel-api/visual-factory/devel-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
#include <dali-toolkit/internal/visuals/visual-string-constants.h>
void Visual::Base::SetProperties( const Property::Map& propertyMap )
{
- Property::Value* customShaderValue = propertyMap.Find( VisualProperty::SHADER, CUSTOM_SHADER );
+ Property::Value* customShaderValue = propertyMap.Find( DevelVisual::Property::SHADER, CUSTOM_SHADER );
if( customShaderValue )
{
Property::Map shaderMap;
}
}
- Property::Value* transform = propertyMap.Find( Toolkit::Visual::DevelProperty::TRANSFORM, TRANSFORM );
+ Property::Value* transform = propertyMap.Find( DevelVisual::Property::TRANSFORM, TRANSFORM );
if( transform )
{
Property::Map map;
Property::Map transform;
mImpl->mTransform.GetPropertyMap( transform );
- map.Insert( Toolkit::Visual::DevelProperty::TRANSFORM, transform );
+ map.Insert( DevelVisual::Property::TRANSFORM, transform );
}
void Visual::Base::EnablePreMultipliedAlpha( bool preMultipled )
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/visuals/image-visual-properties.h>
-#include <dali-toolkit/devel-api/visual-factory/devel-visual-properties.h>
#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali-toolkit/internal/visuals/border/border-visual.h>
#include <dali-toolkit/internal/visuals/color/color-visual.h>
}
else
{
- Property::Value* typeValue = propertyMap.Find( Toolkit::VisualProperty::TYPE, VISUAL_TYPE );
+ Property::Value* typeValue = propertyMap.Find( Toolkit::DevelVisual::Property::TYPE, VISUAL_TYPE );
Toolkit::DevelVisual::Type visualType = Toolkit::DevelVisual::IMAGE; // Default to IMAGE type.
if( typeValue )
{
#include "wireframe-visual.h"
// INTERNAL INCLUDES
-#include <dali-toolkit/devel-api/visual-factory/devel-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali-toolkit/internal/visuals/visual-factory-impl.h>
#include <dali-toolkit/internal/visuals/visual-factory-cache.h>
#include <dali-toolkit/internal/visuals/visual-string-constants.h>
void WireframeVisual::DoCreatePropertyMap( Property::Map& map ) const
{
map.Clear();
- map.Insert( Toolkit::VisualProperty::TYPE, Toolkit::Visual::WIREFRAME );
+ map.Insert( Toolkit::DevelVisual::Property::TYPE, Toolkit::Visual::WIREFRAME );
}
void WireframeVisual::InitializeRenderer()
#include <dali/public-api/rendering/renderer.h>
#include <dali/public-api/size-negotiation/relayout-container.h>
#include <dali/devel-api/common/owner-container.h>
+#include <dali/devel-api/object/handle-devel.h>
#include <dali/devel-api/scripting/scripting.h>
#include <dali/integration-api/debug.h>
#include <dali-toolkit/public-api/styling/style-manager.h>
#include <dali-toolkit/public-api/visuals/color-visual-properties.h>
#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
-#include <dali-toolkit/devel-api/visual-factory/devel-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
#include <dali-toolkit/devel-api/focus-manager/keyinput-focus-manager.h>
#include <dali-toolkit/internal/styling/style-manager-impl.h>
if( iter != visuals.End() )
{
Actor self = controlImpl.Self();
- Property::Index index = self.GetPropertyIndex( propertyKey );
+ Property::Index index = DevelHandle::GetPropertyIndex( self, propertyKey );
if( index != Property::INVALID_INDEX )
{
// It's an actor property:
{
// @todo Need to use correct renderer index
Renderer renderer = self.GetRendererAt(0);
- Property::Index index = renderer.GetPropertyIndex( propertyKey );
+ Property::Index index = DevelHandle::GetPropertyIndex( renderer, propertyKey );
if( index != Property::INVALID_INDEX )
{
// It's a renderer property:
{
propertyMap.Clear();
propertyMap
- .Add( Toolkit::Visual::DevelProperty::Transform::Property::OFFSET, Vector2(0.0f, 0.0f) )
- .Add( Toolkit::Visual::DevelProperty::Transform::Property::SIZE, Vector2(1.0f, 1.0f) )
- .Add( Toolkit::Visual::DevelProperty::Transform::Property::ORIGIN, Toolkit::Align::CENTER )
- .Add( Toolkit::Visual::DevelProperty::Transform::Property::ANCHOR_POINT, Toolkit::Align::CENTER )
- .Add( Toolkit::Visual::DevelProperty::Transform::Property::OFFSET_SIZE_MODE, Vector4::ZERO );
+ .Add( Toolkit::DevelVisual::Transform::Property::OFFSET, Vector2(0.0f, 0.0f) )
+ .Add( Toolkit::DevelVisual::Transform::Property::SIZE, Vector2(1.0f, 1.0f) )
+ .Add( Toolkit::DevelVisual::Transform::Property::ORIGIN, Toolkit::Align::CENTER )
+ .Add( Toolkit::DevelVisual::Transform::Property::ANCHOR_POINT, Toolkit::Align::CENTER )
+ .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_SIZE_MODE, Vector4::ZERO );
}
/**
case Toolkit::Control::Property::BACKGROUND:
{
+ std::string url;
const Property::Map* map = value.GetMap();
if( map && !map->Empty() )
{
controlImpl.SetBackground( *map );
}
+ else if( value.Get( url ) )
+ {
+ // don't know the size to load
+ Toolkit::Visual::Base visual = Toolkit::VisualFactory::Get().CreateVisual( url, ImageDimensions() );
+ if( visual )
+ {
+ controlImpl.RegisterVisual( Toolkit::Control::Property::BACKGROUND, visual );
+ visual.SetDepthIndex( DepthIndex::BACKGROUND );
+ }
+ }
else
{
// The background is an empty property map, so we should clear the background
return handle;
}
-Control::~Control()
-{
- delete mImpl;
-}
-
void Control::SetStyleName( const std::string& styleName )
{
if( styleName != mImpl->mStyleName )
{
mImpl->mBackgroundColor = color;
Property::Map map;
- map[ Toolkit::VisualProperty::TYPE ] = Toolkit::Visual::COLOR;
+ map[ Toolkit::DevelVisual::Property::TYPE ] = Toolkit::Visual::COLOR;
map[ Toolkit::ColorVisual::Property::MIX_COLOR ] = color;
SetBackground( map );
{
RegisterVisual( Toolkit::Control::Property::BACKGROUND, visual );
visual.SetDepthIndex( DepthIndex::BACKGROUND );
+
+ // Trigger a size negotiation request that may be needed by the new visual to relayout its contents.
+ RelayoutRequest();
}
}
{
UnregisterVisual( Toolkit::Control::Property::BACKGROUND );
mImpl->mBackgroundColor = Color::TRANSPARENT;
+
+ // Trigger a size negotiation request that may be needed when unregistering a visual.
+ RelayoutRequest();
}
void Control::EnableGestureDetection(Gesture::Type type)
Actor child = Self().FindChildByName( animator->objectName );
if( child )
{
- Property::Index propertyIndex = child.GetPropertyIndex( animator->propertyKey );
+ Property::Index propertyIndex = DevelHandle::GetPropertyIndex( child, animator->propertyKey );
handleIndex = HandleIndex( child, propertyIndex );
}
else
mImpl->mFlags = behaviourFlags;
}
+Control::~Control()
+{
+ delete mImpl;
+}
+
void Control::Initialize()
{
// Call deriving classes so initialised before styling is applied to them.
*/
static Toolkit::Control New();
- /**
- * @brief Virtual destructor.
- * @SINCE_1_0.0
- */
- virtual ~Control();
-
// Styling
/**
Control( ControlBehaviour behaviourFlags );
/**
+ * @brief Virtual destructor.
+ * @SINCE_1_0.0
+ */
+ virtual ~Control();
+
+ /**
* @brief Second phase initialization.
* @SINCE_1_0.0
*/
*/
KEY_INPUT_FOCUS,
/**
- * @brief name "background", mutually exclusive with BACKGROUND_COLOR & BACKGROUND_IMAGE, type Map
+ * @brief name "background", mutually exclusive with BACKGROUND_COLOR & BACKGROUND_IMAGE, type Map or std::string for URL
* @SINCE_1_1.3
*/
BACKGROUND,
const unsigned int TOOLKIT_MAJOR_VERSION = 1;
const unsigned int TOOLKIT_MINOR_VERSION = 2;
-const unsigned int TOOLKIT_MICRO_VERSION = 15;
+const unsigned int TOOLKIT_MICRO_VERSION = 16;
const char * const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__;
#ifdef DEBUG_ENABLED
*
* @brief DALi Toolkit provides UI components and various effects on top of the DALi Core.
*
- * @section dali_core_overview Overview
+ * @section dali_toolkit_overview Overview
*
* DALi Toolkit consists of the following groups of API:
*
+ [Equal To Constraint](@ref constraints-equal-to)
+ [Relative To Constraint](@ref constraints-relative-to)
+ [Multi-threading Notes](@ref animation-multi-threading-notes)
- + [Shader Animation](@ref animation-shader)
+ [Styling](@ref styling)
### Resources
+++ /dev/null
-/*! \page animation-shader Shader Effect Animation
- *
-
-The uniforms of a shader can be animated using the Animation::AnimateTo functions.
-
-For example, to animate the center point of the Bendy shader effect:
-@code
-Dali::Animation animation = Dali::Animation::New( 1.0f );
-//...
-Vector2 newPosition( 0.0f, 0.0f );
-animation.AnimateTo( Property(shaderEffect, shaderEffect.GetPositionPropertyName()), newPosition );
-@endcode
-
-To animate a uniform of a custom shader effect, the developer must use the name of the uniform:
-@code
-Dali::Animation animation = Dali::Animation::New( 1.0f );
-//...
-// Set the initial value for the uniform
-shaderEffect.SetUniform( "myUniform", -0.5f );
-//...
-// Animate the uniform to a value
-animation.AnimateTo( Property(shaderEffect, "myUniform"), 0.5f );
-@endcode
-
- *
- */
| Kind | Description | Start Index | End Index |
|:----------------------|:--------------------------------------------------------------------------------------------------|:----------------------------------------------------------------------------------------------------------:|:----------------------------------------------------------------------------------------------------------------------------------:|
-| Default | Properties defined within DALi Core, e.g. Dali::Actor, Dali::ShaderEffect default properties etc. | \link Dali::DEFAULT_OBJECT_PROPERTY_START_INDEX DEFAULT_OBJECT_PROPERTY_START_INDEX\endlink | \link Dali::DEFAULT_PROPERTY_MAX_COUNT DEFAULT_PROPERTY_MAX_COUNT\endlink (9999999) |
+| Default | Properties defined within DALi Core, e.g. Dali::Actor default properties etc. | \link Dali::DEFAULT_OBJECT_PROPERTY_START_INDEX DEFAULT_OBJECT_PROPERTY_START_INDEX\endlink | \link Dali::DEFAULT_PROPERTY_MAX_COUNT DEFAULT_PROPERTY_MAX_COUNT\endlink (9999999) |
| Registered | Properties registered using Dali::PropertyRegistration | \link Dali::PROPERTY_REGISTRATION_START_INDEX PROPERTY_REGISTRATION_START_INDEX\endlink (10000000) | \link Dali::PROPERTY_REGISTRATION_MAX_INDEX PROPERTY_REGISTRATION_MAX_INDEX\endlink (19999999) |
| Control | Property range reserved by Dali::Toolkit::Control | \link Dali::Toolkit::Control::CONTROL_PROPERTY_START_INDEX CONTROL_PROPERTY_START_INDEX\endlink (10000000) | \link Dali::Toolkit::Control::CONTROL_PROPERTY_END_INDEX CONTROL_PROPERTY_END_INDEX\endlink (10001000) |
| Derived Control | Property range for control deriving directly from Dali::Toolkit::Control | 10001001 | \link Dali::PROPERTY_REGISTRATION_MAX_INDEX PROPERTY_REGISTRATION_MAX_INDEX\endlink (19999999) |
dali.stage.add( imageView );
@endcode
-For a more detailed example see the ShaderEffect example in the JavaScript documentation.
-
<br>
<hr>
@section property-use-example-json Property use in JSON
on the attached renderer, and then on the attached shader object.
The actor property names and shader uniform names must not clash for the
-uniform to animate correctly. The convention in DALi is to prepend
-uniforms with 'u'.
+uniform to animate correctly.
+
+The actor needs to register the uniform properties as custom animatable
+properties.
~~~
- { \\
- "animations": \\ Animation library
- { \\
- "rotate": \\ An Animation named rotate
- { \\
- "duration": 10, \\
- "properties": \\ Properties changed in this animation
- [ \\
- {
- "actor":"image", \\ Actor found by name from the stage
- "property":"uTranslate", \\ Uniform name specified as if it is a
- \\ property of the object.
- "value":[10, 20],
- ...
- },
- ...
- ]
- },
- "shaderEffects":
- {
- "myshader1":
- {
- \\ Shader program with uniform
- "program": {...} \\ "uTranslate"
- }
- },
- "actors":
- [
- {
- "name": "image",
- "effect": "myshader1" \\ Actor using shader effect instance
- \\ "myshader1"
- }
- ]
+{
+ "animations":
+ {
+ "rotate": \\ An Animation named rotate
+ {
+ "properties": \\ Properties changed in this animation
+ [
+ {
+ "actor": "image", \\ Actor found by name from the stage
+ "property": "uTranslate", \\ Uniform name specified as if it is a property of the object
+ "value": [10, 20], \\ Target value of uniform
+ ...
+ }
+ ]
+ },
+ ...
+ },
+ "stage":
+ [
+ {
+ "type": "ImageView",
+ "name": "image", \\ Name of the actor
+ ...
+ "image":
+ {
+ ...
+ "shader": \\ ImageView has a shader property where we can set a custom shader
+ {
+ "vertexShader": "..." \\ Vertex shader with uniform "uTranslate"
+ }
+ },
+ "animatableProperties": \\ Custom properties that the actor needs to register
+ {
+ "uTranslate": [0, 0] \\ The name should match the uniform we want to animate
+ },
+ ...
},
+ ...
+ ]
+}
~~~
## Stage {#stage}
- **Templates** actor & control tree creation
- **Styles** used to style actor & control trees
- **Animations**
-- **Instances** of objects for path, shaderEffects, renderTasks, frameBuffers
+- **Instances** of objects for path, renderTasks, frameBuffers
- **Stage**. A list of actors / controls that can be added to the stage
- **Constants** (e.g. positions / colors, that can be references by other parts of the JSON file);
- **Actions**
Name: dali-addon
Summary: DALi module for Node.JS
-Version: 1.2.15
+Version: 1.2.16
Release: 1
Group: Development/Libraries
License: Apache License, Version 2.0
Name: NDalic
Summary: dali wrapper
-Version: 1.2.15
+Version: 1.2.16
Release: 1
Group: uifw/graphic
License: TO_BE_FILLED_IN
Name: dali-toolkit
Summary: The OpenGLES Canvas Core Library Toolkit
-Version: 1.2.15
+Version: 1.2.16
Release: 1
Group: System/Libraries
License: Apache-2.0 and BSD-2-Clause and MIT
# then call our property-wrapper to inject DALi property getters / setters
$(BUILT_SOURCES): SWIG/*.i
rm -f automatic/csharp/*.cs
+ mkdir -p automatic/csharp
$(SWIG) -csharp -c++ -outdir automatic/csharp \
$(DALI_CFLAGS) $(DALICORE_CFLAGS) $(DALIADAPTOR_CFLAGS) $(DALITOOLKIT_CFLAGS) -namespace Dali -o automatic/cpp/dali_wrap.cpp SWIG/dali.i
./property-wrapper.rb
public void Initialize(object source, AUIApplicationInitEventArgs e)
{
Stage stage = Stage.GetCurrent();
- stage.SetBackgroundColor( NDalic.WHITE );
+ stage.BackgroundColor = Color.White;
// Create a container to layout the rows of image and rating vertically
FlexContainer container = new FlexContainer();
int myPropertyIndex2 = handle.RegisterProperty("myProperty2", new Property.Value(new Size(5.0f, 5.0f)), Property.AccessMode.READ_WRITE);
Size myProperty2 = new Size(0.0f, 0.0f);
handle.GetProperty(myPropertyIndex2).Get(myProperty2);
- Console.WriteLine( "myProperty2 value: " + myProperty2.x + ", " + myProperty2.y );
+ Console.WriteLine( "myProperty2 value: " + myProperty2.W + ", " + myProperty2.H );
Actor actor = new Actor();
actor.Size = new Position(200.0f, 200.0f, 0.0f);
Console.WriteLine("Actor name: " + actor.Name);
Stage stage = Stage.GetCurrent();
- stage.BackgroundColor = new Color(Colors.White) ;
+ stage.BackgroundColor = Color.White;
Size stageSize = stage.Size;
- Console.WriteLine("Stage size: " + stageSize.x + ", " + stageSize.y);
+ Console.WriteLine("Stage size: " + stageSize.W + ", " + stageSize.H);
stage.Add(actor);
TextLabel text = new TextLabel("Hello Mono World");
Console.WriteLine( " *************************" );
Size Size = new Size(100, 50);
Console.WriteLine( " Created " + Size );
- Console.WriteLine( " Size x = " + Size.x + ", y = " + Size.y );
+ Console.WriteLine( " Size x = " + Size.W + ", y = " + Size.H );
Size += new Size(20, 20);
- Console.WriteLine( " Size x = " + Size[0] + ", y = " + Size[1] );
- Size.x += 10;
- Size.y += 10;
- Console.WriteLine( " Size width = " + Size.width + ", height = " + Size.height );
- Size += new Size(15, 15);
- Console.WriteLine( " Size width = " + Size[0] + ", height = " + Size[1] );
+ Console.WriteLine( " Size x = " + Size.W + ", y = " + Size.H );
+ Size.W += 10;
+ Size.H += 10;
+ Console.WriteLine( " Size width = " + Size.W + ", height = " + Size.H );
Console.WriteLine( " *************************" );
Position Position = new Position(20, 100, 50);
Console.WriteLine( " Created " + Position );
- Console.WriteLine( " Position x = " + Position.x + ", y = " + Position.y + ", z = " + Position.z );
+ Console.WriteLine( " Position x = " + Position.X + ", y = " + Position.Y + ", z = " + Position.Z );
Position += new Position(20, 20, 20);
- Console.WriteLine( " Position x = " + Position[0] + ", y = " + Position[1] + ", z = " + Position[2] );
- Position.x += 10;
- Position.y += 10;
- Position.z += 10;
- Console.WriteLine( " Position width = " + Position.width + ", height = " + Position.height + ", depth = " + Position.depth );
+ Console.WriteLine( " Position x = " + Position.X + ", y = " + Position.Y + ", z = " + Position.Z );
+ Position.X += 10;
+ Position.Y += 10;
+ Position.Z += 10;
+ Console.WriteLine( " Position width = " + Position.X + ", height = " + Position.Y + ", depth = " + Position.Z );
Position parentOrigin = new Dali.Position(NDalic.ParentOriginBottomRight);
- Console.WriteLine( " parentOrigin x = " + parentOrigin.x + ", y = " + parentOrigin.y + ", z = " + parentOrigin.z );
+ Console.WriteLine( " parentOrigin x = " + parentOrigin.X + ", y = " + parentOrigin.Y + ", z = " + parentOrigin.Z );
Console.WriteLine( " *************************" );
- Color Color = new Color(20, 100, 50, 200);
- Console.WriteLine( " Created " + Color );
- Console.WriteLine( " Color x = " + Color.x + ", y = " + Color.y + ", z = " + Color.z + ", w = " + Color.w );
- Color += new Color(20, 20, 20, 20);
- Console.WriteLine( " Color x = " + Color[0] + ", y = " + Color[1] + ", z = " + Color[2] + ", w = " + Color[3] );
- Color.x += 10;
- Color.y += 10;
- Color.z += 10;
- Color.w += 10;
- Console.WriteLine( " Color r = " + Color.r + ", g = " + Color.g + ", b = " + Color.b + ", a = " + Color.a );
+ Color color = new Color(20, 100, 50, 200);
+ Console.WriteLine( " Created " + color );
+ Console.WriteLine( " Color R = " + color.R + ", G = " + color.G + ", B = " + color.B + ", A = " + color.A );
+ color += new Color(20, 20, 20, 20);
+ Console.WriteLine( " Color R = " + color.R + ", G = " + color.G + ", B = " + color.B + ", A = " + color.A );
+ color.R += 10;
+ color.G += 10;
+ color.B += 10;
+ color.A += 10;
+ Console.WriteLine( " Color r = " + color.R + ", g = " + color.G + ", b = " + color.B + ", a = " + color.A );
}
{
Console.WriteLine("Customized Application Initialize event handler");
Stage stage = Stage.GetCurrent();
- stage.BackgroundColor = new Color("white");
+ stage.BackgroundColor = Color.Green;
stage.Touched += OnStageTouched;
private void CreateScrollView()
{
Stage stage = Stage.GetCurrent();
- stage.BackgroundColor = new Color("white");
+ stage.BackgroundColor = Color.White;
// Create a scroll view
_scrollView = new ScrollView();
Size stageSize = stage.Size;
- _scrollView.Size = new Position(stageSize.x, stageSize.y, 0.0f);
+ _scrollView.Size = new Position(stageSize.W, stageSize.H, 0.0f);
_scrollView.ParentOrigin = NDalic.ParentOriginCenter;
_scrollView.AnchorPoint = NDalic.AnchorPointCenter;
stage.Add(_scrollView);
pageActor.SetResizePolicy(ResizePolicyType.FILL_TO_PARENT, DimensionType.ALL_DIMENSIONS);
pageActor.ParentOrigin = NDalic.ParentOriginCenter;
pageActor.AnchorPoint = NDalic.AnchorPointCenter;
- pageActor.Position = new Position(pageColumn * stageSize.x, pageRow * stageSize.y, 0.0f);
+ pageActor.Position = new Position(pageColumn * stageSize.W, pageRow * stageSize.H, 0.0f);
// Add images in a 3x4 grid layout for each page
int imageRows = 4;
int imageColumns = 3;
float margin = 10.0f;
- Position imageSize = new Position((stageSize.x / imageColumns) - margin, (stageSize.y / imageRows) - margin, 0.0f);
+ Position imageSize = new Position((stageSize.W / imageColumns) - margin, (stageSize.H / imageRows) - margin, 0.0f);
for(int row = 0; row < imageRows; row++)
{
imageView.ParentOrigin = NDalic.ParentOriginCenter;
imageView.AnchorPoint = NDalic.AnchorPointCenter;
imageView.Size = imageSize;
- imageView.Position = new Position( margin * 0.5f + (imageSize.x + margin) * column - stageSize.x * 0.5f + imageSize.x * 0.5f,
- margin * 0.5f + (imageSize.y + margin) * row - stageSize.y * 0.5f + imageSize.y * 0.5f, 0.0f );
+ imageView.Position = new Position( margin * 0.5f + (imageSize.X + margin) * column - stageSize.W * 0.5f + imageSize.X * 0.5f,
+ margin * 0.5f + (imageSize.Y + margin) * row - stageSize.H * 0.5f + imageSize.Y * 0.5f, 0.0f );
pageActor.Add(imageView);
}
}
// Set scroll view to have 3 pages in X axis and allow page snapping,
// and also disable scrolling in Y axis.
- RulerPtr scrollRulerX = new RulerPtr(new FixedRuler(stageSize.width));
+ RulerPtr scrollRulerX = new RulerPtr(new FixedRuler(stageSize.W));
RulerPtr scrollRulerY = new RulerPtr(new DefaultRuler());
- scrollRulerX.SetDomain(new RulerDomain(0.0f, stageSize.width * pageColumns, true));
+ scrollRulerX.SetDomain(new RulerDomain(0.0f, stageSize.W * pageColumns, true));
scrollRulerY.Disable();
_scrollView.SetRulerX(scrollRulerX);
_scrollView.SetRulerY(scrollRulerY);
_scrollBar.AnchorPoint = NDalic.AnchorPointTopLeft;
_scrollBar.SetResizePolicy(ResizePolicyType.FIT_TO_CHILDREN, DimensionType.WIDTH);
_scrollBar.SetResizePolicy(ResizePolicyType.FILL_TO_PARENT, DimensionType.HEIGHT);
- _scrollBar.Orientation = new Quaternion( new Radian( new Degree( 270.0f ) ), Position.ZAXIS );
+ _scrollBar.Orientation = new Quaternion( new Radian( new Degree( 270.0f ) ), Vector3.ZAXIS );
_scrollBar.SetScrollDirection(ScrollBar.Direction.Horizontal);
_scrollView.Add(_scrollBar);
_animation = new Animation(1.0f); // 1 second of duration
- _animation.AnimateTo(new Property(_text, Actor.Property.ORIENTATION), new Property.Value(new Quaternion( new Radian( new Degree( 180.0f ) ), Position.XAXIS )), new AlphaFunction(AlphaFunction.BuiltinFunction.LINEAR), new TimePeriod(0.0f, 0.5f));
- _animation.AnimateTo(new Property(_text, Actor.Property.ORIENTATION), new Property.Value(new Quaternion( new Radian( new Degree( 0.0f ) ), Position.XAXIS )), new AlphaFunction(AlphaFunction.BuiltinFunction.LINEAR), new TimePeriod(0.5f, 0.5f));
+ _animation.AnimateTo(new Property(_text, Actor.Property.ORIENTATION), new Property.Value(new Quaternion( new Radian( new Degree( 180.0f ) ), Vector3.XAXIS )), new AlphaFunction(AlphaFunction.BuiltinFunction.LINEAR), new TimePeriod(0.0f, 0.5f));
+ _animation.AnimateTo(new Property(_text, Actor.Property.ORIENTATION), new Property.Value(new Quaternion( new Radian( new Degree( 0.0f ) ), Vector3.XAXIS )), new AlphaFunction(AlphaFunction.BuiltinFunction.LINEAR), new TimePeriod(0.5f, 0.5f));
// Connect the signal callback for animaiton finished signal
_animation.Finished += AnimationFinished;
private string _fontFamily;
private string _fontStyle;
private int _pointSize;
- private Vector4 _textColor;
- private Vector4 _textBackgroundColor;
+ private Color _textColor;
+ private Color _textBackgroundColor;
private int _maxTextLength;
public Spin() : base(ViewWrapperImpl.CustomViewBehaviour.REQUIRES_KEYBOARD_NAVIGATION_SUPPORT | ViewWrapperImpl.CustomViewBehaviour.DISABLE_STYLE_CHANGE_SIGNALS)
{
// Initialize the properties
_arrowImage = "./images/arrow.png";
- _textBackgroundColor = new Vector4(0.6f, 0.6f, 0.6f, 1.0f);
+ _textBackgroundColor = new Color(0.6f, 0.6f, 0.6f, 1.0f);
_currentValue = 0;
_minValue = 0;
_maxValue = 0;
}
}
- // TextColor property of type Vector4:
- public Vector4 TextColor
+ // TextColor property of type Color:
+ public Color TextColor
{
get
{
public void Initialize(object source, AUIApplicationInitEventArgs e)
{
Stage stage = Stage.GetCurrent();
- stage.SetBackgroundColor( NDalic.WHITE );
+ stage.BackgroundColor = Color.White;
// Create a container for the spins
_container = new FlexContainer();
_spinYear.Step = 1;
_spinYear.MaxTextLength = 4;
_spinYear.TextPointSize = 26;
- _spinYear.TextColor = NDalic.WHITE;
+ _spinYear.TextColor = Color.White;
_spinYear.SetKeyboardFocusable(true);
_spinYear.Name = "_spinYear";
_spinMonth.Step = 1;
_spinMonth.MaxTextLength = 2;
_spinMonth.TextPointSize = 26;
- _spinMonth.TextColor = NDalic.WHITE;
+ _spinMonth.TextColor = Color.White;
_spinMonth.SetKeyboardFocusable(true);
_spinMonth.Name = "_spinMonth";
_spinDay.Step = 1;
_spinDay.MaxTextLength = 2;
_spinDay.TextPointSize = 26;
- _spinDay.TextColor = NDalic.WHITE;
+ _spinDay.TextColor = Color.White;
_spinDay.SetKeyboardFocusable(true);
_spinDay.Name = "_spinDay";
-namespace Dali {
+namespace Dali
+{
+ using System;
-using System;
+ public enum Colors
+ {
+ Red,
+ White,
+ Blue,
+ Green,
+ Black,
+ Yellow,
+ Magenta,
+ Cyan
+ }
-public enum Colors
-{
- Red,
- White,
- Blue,
- Green,
- Black,
- Grey,
- Yellow,
- Azure,
- Rose
-}
+ public class Color
+ {
+
+ private float r;
+ private float g;
+ private float b;
+ private float a;
+
+ /**
+ * @brief constructor
+ *
+ * @since 1.0.0
+ */
+ public Color()
+ {
+ r = 0.0f;
+ g = 0.0f;
+ b = 0.0f;
+ a = 0.0f;
+ }
+
+ /**
+ * @brief constructor
+ *
+ * @since 1.0.0
+ * @param [in] red The Color r.
+ * @param [in] green The Color g.
+ * @param [in] blue The Color b.
+ * @param [in] alpha The Color a.
+ */
+ public Color(float red, float green, float blue, float alpha)
+ {
+ r = red;
+ g = green;
+ b = blue;
+ a = alpha;
+ }
+
+ /**
+ * @brief constructor
+ *
+ * @since 1.0.0
+ * @param [in] o The Vector4 having r g b a components
+ */
+ public Color(Vector4 o)
+ {
+ r = o.r;
+ g = o.g;
+ b = o.b;
+ a = o.a;
+ }
+
+
+ /**
+ * @brief constructor
+ *
+ * @since 1.0.0
+ * @param [in] color as enum Colors.
+ */
+ public Color(Colors color)
+ {
+ switch (color)
+ {
+ case Colors.Red:
+ SetColor(1.0f, 0.0f, 0.0f, 1.0f);
+ break;
+ case Colors.White:
+ SetColor(1.0f, 1.0f, 1.0f, 1.0f);
+ break;
+ case Colors.Blue:
+ SetColor(0.0f, 0.0f, 1.0f, 1.0f);
+ break;
+ case Colors.Green:
+ SetColor(0.0f, 1.0f, 0.0f, 1.0f);
+ break;
+ case Colors.Black:
+ SetColor(0.0f, 0.0f, 0.0f, 1.0f);
+ break;
+ case Colors.Yellow:
+ SetColor(1.0f, 1.0f, 0.0f, 1.0f);
+ break;
+ case Colors.Cyan:
+ SetColor(0.0f, 1.0f, 1.0f, 1.0f);
+ break;
+ case Colors.Magenta:
+ SetColor(1.0f, 0.0f, 1.0f, 1.0f);
+ break;
+ }
+ }
+
+
+ /**
+ * @brief SetColor
+ *
+ * @since 1.0.0
+ * @param [in] red The Color r.
+ * @param [in] green The Color g.
+ * @param [in] blue The Color b.
+ * @param [in] alpha The Color a.
+ */
+ public void SetColor(float red, float green, float blue, float alpha)
+ {
+ r = red;
+ g = green;
+ b = blue;
+ a = alpha;
+ }
+
+ /**
+ * @brief name "R", type float (Color's Red component)
+ * @SINCE_1_0.0
+ */
+
+ public float R
+ {
+ get { return r; }
+ set { r = value; }
+ }
+
+ /**
+ * @brief name "G", type float (Color's Green component)
+ * @SINCE_1_0.0
+ */
+ public float G
+ {
+ get { return g; }
+ set { g = value; }
+ }
+
+ /**
+ * @brief name "B", type float (Color's Blue component)
+ * @SINCE_1_0.0
+ */
+ public float B
+ {
+ get { return b; }
+ set { b = value; }
+ }
+
+ /**
+ * @brief name "A", type float (Color's Alpha value)
+ * @SINCE_1_0.0
+ */
+ public float A
+ {
+ get { return a; }
+ set { a = value; }
+ }
+
+ /**
+ * @brief operator+
+ *
+ * @since 1.0.0
+ * @param [in] l The Color to add.
+ * @param [in] r The Color to add
+ * @return A reference to this
+ */
+ public static Color operator +(Color l, Color r)
+ {
+ return new Color(l.R + r.R, l.G + r.G, l.B + r.B, l.A + r.A);
+ }
+
+ /**
+ * @brief operator-
+ *
+ * @since 1.0.0
+ * @param [in] l The Color to substract.
+ * @param [in] r The Color to substract
+ * @return A reference to this
+ */
+ public static Color operator -(Color l, Color r)
+ {
+ return new Color(l.R - r.R, l.G - r.G, l.B - r.B, l.A - r.A);
+ }
+
+ /**
+ * @brief operator*
+ *
+ * @since 1.0.0
+ * @param [in] a The Color to multiply.
+ * @param [in] b The constant double to multiply.
+ * @return A reference to this
+ */
+ public static Color operator *(Color a, double b)
+ {
+ return new Color((float)(a.R * b), (float)(a.G * b), (float)(a.B * b), (float)(a.A * b));
+ }
+
+ /**
+ * @brief operator/
+ *
+ * @since 1.0.0
+ * @param [in] a The Color to divide.
+ * @param [in] b The Color to divide
+ * @return float value of division operation
+ */
+ public static float operator /(Color a, Color b)
+ {
+ return (float)System.Math.Sqrt((a.R / b.R) * (a.G / b.G) * (a.B / b.B) * (a.A / b.A));
+ }
+
+ /**
+ * @brief Operator ==
+ *
+ * @since 1.0.0
+ * @param [in] x The Color object to compare.
+ * @param [in] y The Color object to compare.
+ * @return bool, whether colors are equal or not
+ */
+ public static bool operator == (Color x, Color y)
+ {
+ return x.R == y.R && x.G == y.G && x.B == y.B && x.A == y.A;
+ }
+
+ /**
+ * @brief Operator !=
+ *
+ * @since 1.0.0
+ * @param [in] x The Color object to compare.
+ * @param [in] y The Color object to compare.
+ * @return bool, whether colors are equal or not
+ */
+ public static bool operator != (Color x, Color y)
+ {
+ return x.R != y.R || x.G != y.G || x.B != y.B || x.A != y.A;
+ }
+
+ /**
+ * @brief GetHashCode
+ *
+ * @since 1.0.0
+ * @return int, hascode of Color
+ */
+ public override int GetHashCode()
+ {
+ return base.GetHashCode();
+ }
+
+ /**
+ * @brief Clone
+ *
+ * @since 1.0.0
+ * @return Color object
+ */
+ public Color Clone()
+ {
+ Color copy = new Color(R, G, B, A);
+ return copy;
+ }
+
+ // Create a color for RGBA values ranging from 0..255, useful when dealing with HTML colors
+ static Color FromRgbaByte( byte red, byte green, byte blue, byte alpha )
+ {
+ return new Color ( red / 255, green / 255, blue / 255, alpha / 255 );
+ }
+
+ // User-defined conversion from Color to Vector4
+ public static implicit operator Vector4(Color color)
+ {
+ return new Vector4(color.r, color.g, color.b, color.a);
+ }
+
+ public static implicit operator Color(Vector4 vec)
+ {
+ return new Color(vec.r, vec.g, vec.b, vec.a);
+ }
+
+ /**
+ * @brief name "White", type Color (White Color object)
+ * @SINCE_1_0.0
+ */
+ public static Color White
+ {
+ get
+ {
+ return new Color(Colors.White);
+ }
+ }
+
+ /**
+ * @brief name "Black", type Color (Black Color object)
+ * @SINCE_1_0.0
+ */
+ public static Color Black
+ {
+ get
+ {
+ return new Color(Colors.Black);
+ }
+ }
+
+ /**
+ * @brief name "Red", type Color (Red Color object)
+ * @SINCE_1_0.0
+ */
+ public static Color Red
+ {
+ get
+ {
+ return new Color(Colors.Red);
+ }
+ }
+
+ /**
+ * @brief name "Green", type Color (Green Color object)
+ * @SINCE_1_0.0
+ */
+ public static Color Green
+ {
+ get
+ {
+ return new Color(Colors.Green);
+ }
+ }
+ /**
+ * @brief name "Blue", type Color (Blue Color object)
+ * @SINCE_1_0.0
+ */
+ public static Color Blue
+ {
+ get
+ {
+ return new Color(Colors.Blue);
+ }
+ }
+ /**
+ * @brief name "Yellow", type Color (Yellow Color object)
+ * @SINCE_1_0.0
+ */
+ public static Color Yellow
+ {
+ get
+ {
+ return new Color(Colors.Yellow);
+ }
+ }
-public class Color : Vector4
- {
- /**
- * @brief constructor
- *
- * @since 1.0.0
- */
- public Color()
- : base()
- { }
- /**
- * @brief constructor
- *
- * @since 1.0.0
- * @param [in] red The Color r.
- * @param [in] green The Color g.
- * @param [in] blue The Color b.
- * @param [in] alpha The Color a.
- */
- public Color(float red, float green, float blue, float alpha)
- : base(red, green, blue, alpha)
- { }
-
- /**
- * @brief constructor
- *
- * @since 1.0.0
- * @param [in] o The Vector4 having r g b a components
- */
- public Color(Vector4 o)
- : base(o.x, o.y, o.z, o.w)
- {
-
- }
-
- /**
- * @brief constructor
- *
- * @since 1.0.0
- * @param [in] color as string.
- */
- public Color(string color)
- : base(0, 0, 0, 0)
- {
- switch (color)
- {
- case "red":
- SetColor(255, 0, 0, 255);
- break;
- case "white":
- SetColor(255, 255, 255, 255);
- break;
- case "blue":
- SetColor(0, 0, 255, 255);
- break;
- case "green":
- SetColor(0, 255, 0, 255);
- break;
- case "black":
- SetColor(0, 0, 0, 255);
- break;
- case "grey":
- SetColor(128, 128, 128, 255);
- break;
- case "yellow":
- SetColor(255, 255, 0, 255);
- break;
- case "azure":
- SetColor(0, 255, 255, 255);
- break;
- case "rose":
- SetColor(255, 0, 255, 255);
- break;
- }
- }
-
-
- /**
- * @brief constructor
- *
- * @since 1.0.0
- * @param [in] color as enum Colors.
- */
- public Color(Colors color)
- : base(0, 0, 0, 0)
- {
- switch (color)
- {
- case Colors.Red:
- SetColor(255, 0, 0, 255);
- break;
- case Colors.White:
- SetColor(255, 255, 255, 255);
- break;
- case Colors.Blue:
- SetColor(0, 0, 255, 255);
- break;
- case Colors.Green:
- SetColor(0, 255, 0, 255);
- break;
- case Colors.Black:
- SetColor(0, 0, 0, 255);
- break;
- case Colors.Grey:
- SetColor(128, 128, 128, 255);
- break;
- case Colors.Yellow:
- SetColor(255, 255, 0, 255);
- break;
- case Colors.Azure:
- SetColor(0, 255, 255, 255);
- break;
- case Colors.Rose:
- SetColor(255, 0, 255, 255);
- break;
- }
- }
-
-
- /**
- * @brief SetColor
- *
- * @since 1.0.0
- * @param [in] red The Color r.
- * @param [in] green The Color g.
- * @param [in] blue The Color b.
- * @param [in] alpha The Color a.
- */
- public void SetColor(float red, float green, float blue, float alpha)
- {
- r = red;
- g = green;
- b = blue;
- a = alpha;
- }
-
- /**
- * @brief name "R", type float (Color's Red component)
- * @SINCE_1_0.0
- */
-
- public float R
- {
- get { return r; }
- set { r = value; }
- }
-
- /**
- * @brief name "G", type float (Color's Green component)
- * @SINCE_1_0.0
- */
- public float G
- {
- get { return g; }
- set { g = value; }
- }
-
- /**
- * @brief name "B", type float (Color's Blue component)
- * @SINCE_1_0.0
- */
- public float B
- {
- get { return b; }
- set { b = value; }
- }
-
- /**
- * @brief name "A", type float (Color's Alpha value)
- * @SINCE_1_0.0
- */
- public float A
- {
- get { return a; }
- set { a = value; }
- }
-
- /**
- * @brief operator+
- *
- * @since 1.0.0
- * @param [in] l The Color to add.
- * @param [in] r The Color to add
- * @return A reference to this
- */
- public static Color operator +(Color l, Color r)
- {
- return new Color(l.R + r.R, l.G + r.G, l.B + r.B, l.A + r.A);
- }
-
- /**
- * @brief operator-
- *
- * @since 1.0.0
- * @param [in] l The Color to substract.
- * @param [in] r The Color to substract
- * @return A reference to this
- */
- public static Color operator -(Color l, Color r)
- {
- return new Color(l.R - r.R, l.G - r.G, l.B - r.B, l.A - r.A);
- }
-
- /**
- * @brief operator*
- *
- * @since 1.0.0
- * @param [in] a The Color to multiply.
- * @param [in] b The Color to multiply
- * @return A reference to this
- */
- public static Color operator *(Color a, double b)
- {
- return new Color((int)(a.R * b), (int)(a.G * b), (int)(a.B * b), (int)(a.A * b));
- }
-
- /**
- * @brief operator/
- *
- * @since 1.0.0
- * @param [in] a The Color to divide.
- * @param [in] b The Color to divide
- * @return float value of division operation
- */
- public static float operator /(Color a, Color b)
- {
- return (float)System.Math.Sqrt((a.R / b.R) * (a.G / b.G) * (a.B / b.B) * (a.A / b.A));
- }
-
- /**
- * @brief Equals
- *
- * @since 1.0.0
- * @param [in] o The Color object to compare.
- * @param [in] r The Color to add
- * @return bool, whether object equal or not
- */
- public override bool Equals(object obj)
- {
- Color l = this;
- Color r = obj as Color;
- if (r == null)
- {
- return false;
- }
- return l.R == r.R && l.G == r.G && l.B == r.B && l.A == r.A;
- }
-
- /**
- * @brief GetHashCode
- *
- * @since 1.0.0
- * @return int, hascode of Color
- */
- public override int GetHashCode()
- {
- return base.GetHashCode();
- }
-
- /**
- * @brief Clone
- *
- * @since 1.0.0
- * @return Color object
- */
- public Color Clone()
- {
- Color copy = new Color(R, G, B, A);
- return copy;
- }
- }
+ /**
+ * @brief name "Magenta", type Color (Magenta Color object)
+ * @SINCE_1_0.0
+ */
+ public static Color Magenta
+ {
+ get
+ {
+ return new Color(Colors.Magenta);
+ }
+ }
+ /**
+ * @brief name "Cyan", type Color (Cyan Color object)
+ * @SINCE_1_0.0
+ */
+ public static Color Cyan
+ {
+ get
+ {
+ return new Color(Colors.Cyan);
+ }
+ }
+ }
}
-namespace Dali {
-
-using System;
-
-public class Position : Vector3
- {
-
- /**
- * @brief constructor
- *
- * @since 1.0.0
- */
- public Position()
- : base()
- {
- }
-
- /**
- * @brief constructor
- *
- * @since 1.0.0
- * @param [in] a The Position X.
- * @param [in] b The Position Y.
- * @param [in] c The Position Z.
- */
- public Position(float a, float b, float c)
- : base(a, b, c)
- {
- }
-
- /**
- * @brief constructor
- *
- * @since 1.0.0
- * @param [in] o The Vector Position X, Y, Z.
- */
- public Position(Vector3 o)
- : base(o.x, o.y, o.z)
- {
- }
-
- ///< name "X", type float (Position X value)
- //@since 1.0.0
- public float X
- {
- get { return width; }
- set { width = value; }
- }
-
- ///< name "Y", type float (Position Y value)
- //@since 1.0.0
- public float Y
- {
- get { return height; }
- set { height = value; }
- }
-
- ///< name "Z", type float (Position Z value)
- //@since 1.0.0
- public float Z
- {
- get { return depth; }
- set { depth = value; }
- }
-
- /**
- * @brief operator+
- *
- * @since 1.0.0
- * @param [in] l The Position to add.
- * @param [in] r The Position to add
- * @return A reference to this
- */
- public static Position operator +(Position l, Position r)
- {
- return new Position(l.X + r.X, l.Y + r.Y, l.Z + r.Z);
- }
-
- /**
- * @brief operator-
- *
- * @since 1.0.0
- * @param [in] l The Position to substract.
- * @param [in] r The Position to substract
- * @return A reference to this
- */
- public static Position operator -(Position l, Position r)
- {
- return new Position(l.X - r.X, l.Y - r.Y, l.Z - r.Z);
- }
-
- /**
- * @brief operator*
- *
- * @since 1.0.0
- * @param [in] a The Position to multiply.
- * @param [in] b The Position to multiply
- * @return A reference to this
- */
- public static Position operator *(Position a, double b)
- {
- return new Position((int)(a.X * b), (int)(a.Y * b), (int)(a.Z * b));
- }
-
- /**
- * @brief operator/
- *
- * @since 1.0.0
- * @param [in] a The Position to divide.
- * @param [in] b The Position to divide
- * @return float value of division operation
- */
- public static float operator /(Position a, Position b)
- {
- return (float)System.Math.Sqrt((a.X / b.X) * (a.Y / b.Y) * (a.Z / b.Z));
- }
-
- /**
- * @brief Equals
- *
- * @since 1.0.0
- * @param [in] o The Position object to compare.
- * @return bool, whether object equal or not
- */
- public override bool Equals(object obj)
- {
- Position r = obj as Position;
- if (r == null)
- {
- return false;
- }
- return this.X == r.X && this.Y == r.Y && this.Z == r.Z;
- }
-
- /**
- * @brief GetHashCode
- *
- * @since 1.0.0
- * @return int, hascode of position
- */
- public override int GetHashCode()
- {
- return base.GetHashCode();
- }
-
- /**
- * @brief Clone
- *
- * @since 1.0.0
- * @return Position object
- */
- public Position Clone()
- {
- Position copy = new Position(X, Y, Z);
- return copy;
- }
- }
+namespace Dali
+{
+ using System;
+ public class Position
+ {
+
+ private float x;
+ private float y;
+ private float z;
+
+ /**
+ * @brief constructor
+ *
+ * @since 1.0.0
+ */
+ public Position()
+ {
+ x = 0.0f;
+ y = 0.0f;
+ z = 0.0f;
+ }
+
+ /**
+ * @brief constructor
+ *
+ * @since 1.0.0
+ * @param [in] a The Position X.
+ * @param [in] b The Position Y.
+ * @param [in] c The Position Z.
+ */
+ public Position(float a, float b, float c)
+ {
+ x = a;
+ y = b;
+ z = c;
+ }
+
+ /**
+ * @brief constructor
+ *
+ * @since 1.0.0
+ * @param [in] o The Vector Position X, Y, Z.
+ */
+ public Position(Vector3 o)
+ {
+ x = o.x;
+ y = o.y;
+ z = o.z;
+ }
+
+ ///< name "X", type float (Position X value)
+ //@since 1.0.0
+ public float X
+ {
+ get { return x; }
+ set { x = value; }
+ }
+
+ ///< name "Y", type float (Position Y value)
+ //@since 1.0.0
+ public float Y
+ {
+ get { return y; }
+ set { y = value; }
+ }
+
+ ///< name "Z", type float (Position Z value)
+ //@since 1.0.0
+ public float Z
+ {
+ get { return z; }
+ set { z = value; }
+ }
+
+ /**
+ * @brief operator+
+ *
+ * @since 1.0.0
+ * @param [in] l The Position to add.
+ * @param [in] r The Position to add
+ * @return A reference to this
+ */
+ public static Position operator +(Position l, Position r)
+ {
+ return new Position(l.X + r.X, l.Y + r.Y, l.Z + r.Z);
+ }
+
+ /**
+ * @brief operator-
+ *
+ * @since 1.0.0
+ * @param [in] l The Position to substract.
+ * @param [in] r The Position to substract
+ * @return A reference to this
+ */
+ public static Position operator -(Position l, Position r)
+ {
+ return new Position(l.X - r.X, l.Y - r.Y, l.Z - r.Z);
+ }
+
+ /**
+ * @brief operator*
+ *
+ * @since 1.0.0
+ * @param [in] a The Position to multiply.
+ * @param [in] b The constant to multiply of type double.
+ * @return A reference to this
+ */
+ public static Position operator *(Position a, double b)
+ {
+ return new Position((int)(a.X * b), (int)(a.Y * b), (int)(a.Z * b));
+ }
+
+ /**
+ * @brief operator/
+ *
+ * @since 1.0.0
+ * @param [in] a The Position to divide.
+ * @param [in] b The Position to divide
+ * @return float value of division operation
+ */
+ public static float operator /(Position a, Position b)
+ {
+ return (float)System.Math.Sqrt((a.X / b.X) * (a.Y / b.Y) * (a.Z / b.Z));
+ }
+
+ /**
+ * @brief Operator ==
+ *
+ * @since 1.0.0
+ * @param [in] a The Position object to compare.
+ * @param [in] b The Position object to compare.
+ * @return bool, whether Position are equal or not
+ */
+ public static bool operator == (Position a, Position b)
+ {
+ return a.X == b.X && a.Y == b.Y && a.Z == b.Z;
+ }
+
+ /**
+ * @brief Operator !=
+ *
+ * @since 1.0.0
+ * @param [in] a The Position object to compare.
+ * @param [in] b The Position object to compare.
+ * @return bool, whether Position are equal or not
+ */
+ public static bool operator != (Position a, Position b)
+ {
+ return a.X != b.X || a.Y != b.Y || a.Z == b.Z;
+ }
+
+ /**
+ * @brief GetHashCode
+ *
+ * @since 1.0.0
+ * @return int, hascode of position
+ */
+ public override int GetHashCode()
+ {
+ return base.GetHashCode();
+ }
+
+ /**
+ * @brief Clone
+ *
+ * @since 1.0.0
+ * @return Position object
+ */
+ public Position Clone()
+ {
+ Position copy = new Position(X, Y, Z);
+ return copy;
+ }
+
+ // User-defined conversion from Position to Vector3
+ public static implicit operator Vector3(Position pos)
+ {
+ return new Vector3(pos.x, pos.y, pos.z);
+ }
+
+ public static implicit operator Position(Vector3 vec)
+ {
+ return new Position(vec.x, vec.y, vec.z);
+ }
+ }
}
-namespace Dali {
-
-using System;
-
-public class Size : Vector2
- {
-
- /**
- * @brief constructor
- *
- * @since 1.0.0
- * @param [in] a Width value .
- * @param [in] b Height value.
- */
- public Size(float a, float b)
- : base(a, b)
- {
- }
- /**
- * @brief default constructor
- *
- * @since 1.0.0
- */
- public Size()
- : base()
- {
- }
-
- /**
- * @brief constructor with base class object
- *
- * @since 1.0.0
- * @param [in] o The Vector2 with Width, Height values.
- */
- public Size(Vector2 o)
- : base(o.x, o.y)
- {
-
- }
-
- /**
- * @brief Copy constructor
- *
- * @since 1.0.0
- * @param [in] o The Size having Width & Y.
- */
- public Size(Size a)
- : base(a.width, a.height)
- {
- }
-
- ///< name "W", type float (Size Width value)
- //@since 1.0.0
- public float W
- {
- get { return width; }
- set { width = value; }
- }
-
- ///< name "H", type float (Size Height value)
- //@since 1.0.0
- public float H
- {
- get { return height; }
- set { height = value; }
- }
-
- /**
- * @brief operator+
- *
- * @since 1.0.0
- * @param [in] l The Size to add.
- * @param [in] r The Size to add
- * @return A reference to this
- */
- public static Size operator +(Size l, Size r)
- {
- return new Size(l.W + r.W, l.H + r.H);
- }
-
- /**
- * @brief operator-
- *
- * @since 1.0.0
- * @param [in] l The Size to substract.
- * @param [in] r The Size to substract
- * @return A reference to this
- */
- public static Size operator -(Size l, Size r)
- {
- return new Size(l.W - r.W, l.H - r.H);
- }
-
- /**
- * @brief operator*
- *
- * @since 1.0.0
- * @param [in] a The Size to multiply
- * @param [in] b The Size to multiply
- * @return A reference to this
- */
- public static Size operator *(Size a, double b)
- {
- return new Size((int)(a.W * b), (int)(a.H * b));
- }
-
- /**
- * @brief operator/
- *
- * @since 1.0.0
- * @param [in] a The Size to divide.
- * @param [in] b The Size to divide
- * @return float of the size division
- */
- public static float operator /(Size a, Size b)
- {
- return (float)System.Math.Sqrt((a.W / b.W) * (a.H / b.H));
- }
-
- /**
- * @brief Equals
- *
- * @since 1.0.0
- * @param [in] obj The Size object to compare.
- * @return bool, whether object equal or not
- */
- public override bool Equals(object obj)
- {
- Size that = obj as Size;
- if (that == null)
- {
- return false;
- }
- return this.W == that.W && this.H == that.H;
- }
-
- /**
- * @brief GetHashCode
- *
- * @since 1.0.0
- * @return int, hascode of Size
- */
- public override int GetHashCode()
- {
- return (int)(W + H);
- }
-
- /**
- * @brief Clone
- *
- * @since 1.0.0
- * @return returns a copy of Size object
- */
- public Size Clone()
- {
- Size copy = new Size(W, H);
- return copy;
- }
- }
+namespace Dali
+{
+ using System;
+
+ public class Size
+ {
+ private float width;
+ private float height;
+
+ /**
+ * @brief constructor
+ *
+ * @since 1.0.0
+ * @param [in] a Width value .
+ * @param [in] b Height value.
+ */
+ public Size(float a, float b)
+ {
+ width = a;
+ height = b;
+ }
+ /**
+ * @brief default constructor
+ *
+ * @since 1.0.0
+ */
+ public Size()
+ {
+ width = 0.0f;
+ height = 0.0f;
+ }
+
+ /**
+ * @brief constructor with base class object
+ *
+ * @since 1.0.0
+ * @param [in] o The Vector2 with Width, Height values.
+ */
+ public Size(Vector2 o)
+ {
+ width = o.x;
+ height = o.y;
+ }
+
+ /**
+ * @brief Copy constructor
+ *
+ * @since 1.0.0
+ * @param [in] o The Size having Width & Y.
+ */
+ public Size(Size a)
+ {
+ width = a.width;
+ height = a.height;
+ }
+
+ ///< name "W", type float (Size Width value)
+ //@since 1.0.0
+ public float W
+ {
+ get { return width; }
+ set { width = value; }
+ }
+
+ ///< name "H", type float (Size Height value)
+ //@since 1.0.0
+ public float H
+ {
+ get { return height; }
+ set { height = value; }
+ }
+
+ /**
+ * @brief operator+
+ *
+ * @since 1.0.0
+ * @param [in] l The Size to add.
+ * @param [in] r The Size to add
+ * @return A reference to this
+ */
+ public static Size operator +(Size l, Size r)
+ {
+ return new Size(l.W + r.W, l.H + r.H);
+ }
+
+ /**
+ * @brief operator-
+ *
+ * @since 1.0.0
+ * @param [in] l The Size to substract.
+ * @param [in] r The Size to substract
+ * @return A reference to this
+ */
+ public static Size operator -(Size l, Size r)
+ {
+ return new Size(l.W - r.W, l.H - r.H);
+ }
+
+ /**
+ * @brief operator*
+ *
+ * @since 1.0.0
+ * @param [in] a The Size to multiply
+ * @param [in] b The constant to multiply of type double.
+ * @return A reference to this
+ */
+ public static Size operator *(Size a, double b)
+ {
+ return new Size((float)(a.W * b), (float)(a.H * b));
+ }
+
+ /**
+ * @brief operator/
+ *
+ * @since 1.0.0
+ * @param [in] a The Size to divide.
+ * @param [in] b The Size to divide
+ * @return float of the size division
+ */
+ public static float operator /(Size a, Size b)
+ {
+ return (float)System.Math.Sqrt((a.W / b.W) * (a.H / b.H));
+ }
+
+ /**
+ * @brief Operator ==
+ *
+ * @since 1.0.0
+ * @param [in] a The Size object to compare.
+ * @param [in] b The Size object to compare.
+ * @return bool, whether Size are equal or not
+ */
+ public static bool operator == (Size a, Size b)
+ {
+ return a.W == b.W && a.H == b.H ;
+ }
+
+ /**
+ * @brief Operator !=
+ *
+ * @since 1.0.0
+ * @param [in] a The Size object to compare.
+ * @param [in] b The Size object to compare.
+ * @return bool, whether Size are equal or not
+ */
+ public static bool operator != (Size a, Size b)
+ {
+ return a.W != b.W || a.H != b.H;
+ }
+
+ /**
+ * @brief GetHashCode
+ *
+ * @since 1.0.0
+ * @return int, hascode of Size
+ */
+ public override int GetHashCode()
+ {
+ return (int)(W + H);
+ }
+
+ /**
+ * @brief Clone
+ *
+ * @since 1.0.0
+ * @return returns a copy of Size object
+ */
+ public Size Clone()
+ {
+ Size copy = new Size(W, H);
+ return copy;
+ }
+
+ // User-defined conversion from Position to Vector3
+ public static implicit operator Vector2(Size size)
+ {
+ return new Vector2(size.width, size.height);
+ }
+
+ public static implicit operator Size(Vector2 vec)
+ {
+ return new Size(vec.x, vec.y);
+ }
+ }
}