Merge "TextVisual - Renderer life cycle." into devel/master
authorDavid Steele <david.steele@samsung.com>
Tue, 29 Nov 2016 16:08:11 +0000 (08:08 -0800)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Tue, 29 Nov 2016 16:08:11 +0000 (08:08 -0800)
18 files changed:
automated-tests/src/dali-toolkit/utc-Dali-BubbleEmitter.cpp
dali-toolkit/devel-api/controls/bubble-effect/bubble-emitter.cpp
dali-toolkit/devel-api/controls/bubble-effect/bubble-emitter.h
dali-toolkit/internal/controls/bubble-effect/bubble-actor.cpp [deleted file]
dali-toolkit/internal/controls/bubble-effect/bubble-effect.h
dali-toolkit/internal/controls/bubble-effect/bubble-emitter-impl.cpp
dali-toolkit/internal/controls/bubble-effect/bubble-emitter-impl.h
dali-toolkit/internal/controls/bubble-effect/bubble-renderer.cpp [new file with mode: 0644]
dali-toolkit/internal/controls/bubble-effect/bubble-renderer.h [moved from dali-toolkit/internal/controls/bubble-effect/bubble-actor.h with 79% similarity]
dali-toolkit/internal/file.list
plugins/dali-swig/examples/custom-control.cs
plugins/dali-swig/examples/dali-test.cs
plugins/dali-swig/examples/hello-world.cs
plugins/dali-swig/examples/scroll-view.cs
plugins/dali-swig/examples/spin-control.cs
plugins/dali-swig/manual/csharp/Color.cs
plugins/dali-swig/manual/csharp/Position.cs
plugins/dali-swig/manual/csharp/Size.cs

index 4c711f3..a4575fc 100644 (file)
@@ -75,30 +75,10 @@ static int Wait(ToolkitTestApplication& application, int duration = 0)
   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
 
@@ -114,7 +94,7 @@ int UtcDaliBubbleEmitterNew(void)
   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 );
 
@@ -146,7 +126,7 @@ int UtcDaliBubbleEmitterDownCast01(void)
 
   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);
@@ -172,12 +152,12 @@ int UtcDaliBubbleEmitterGetRootActor(void)
   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;
 }
 
@@ -186,13 +166,13 @@ int UtcDaliBubbleEmitterSetBackground(void)
   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 );
@@ -213,7 +193,7 @@ int UtcDaliBubbleEmitterSetBubbleScale(void)
   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();
@@ -248,7 +228,7 @@ int UtcDaliBubbleEmitterSetBubbleDensity01(void)
   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
@@ -269,7 +249,7 @@ int UtcDaliBubbleEmitterSetBubbleDensity02(void)
   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
@@ -289,39 +269,39 @@ int UtcDaliBubbleEmitterEmitBubble(void)
   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;
@@ -332,16 +312,16 @@ int UtcDaliBubbleEmitterRestore(void)
   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();
@@ -358,8 +338,8 @@ int UtcDaliBubbleEmitterRestore(void)
   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);
@@ -369,8 +349,8 @@ int UtcDaliBubbleEmitterRestore(void)
   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();
index 16faba4..506e12d 100644 (file)
@@ -48,11 +48,11 @@ BubbleEmitter::BubbleEmitter(Dali::Internal::CustomActor* internal)
 }
 
 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 )
@@ -79,14 +79,14 @@ Actor BubbleEmitter::GetRootActor()
   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 )
index a9a5c3a..3bbdce9 100644 (file)
@@ -20,6 +20,7 @@
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/controls/control.h>
+#include <dali/public-api/rendering/texture.h>
 
 namespace Dali
 {
@@ -58,13 +59,13 @@ public:
    * @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 );
 
@@ -107,19 +108,19 @@ public:
    * @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.
diff --git a/dali-toolkit/internal/controls/bubble-effect/bubble-actor.cpp b/dali-toolkit/internal/controls/bubble-effect/bubble-actor.cpp
deleted file mode 100644 (file)
index f42b72b..0000000
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * 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
index 6e265f6..65b485f 100644 (file)
@@ -92,7 +92,7 @@ inline Shader CreateBubbleShader( unsigned int numBubble )
     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
   );
 
index 6244694..d4c46ea 100644 (file)
 // 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
 {
@@ -62,6 +59,87 @@ float RandomRange(float f0, float f1, unsigned int& seed)
   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
@@ -73,11 +151,11 @@ namespace Toolkit
 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 ),
@@ -89,19 +167,19 @@ BubbleEmitter::BubbleEmitter( const Vector2& movementArea,
   // 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 );
@@ -112,12 +190,12 @@ BubbleEmitter::~BubbleEmitter()
 }
 
 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
@@ -135,26 +213,27 @@ void BubbleEmitter::OnInitialize()
   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.
@@ -172,21 +251,27 @@ Actor BubbleEmitter::GetRootActor()
   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 );
@@ -194,21 +279,21 @@ void BubbleEmitter::SetBackground( Image bgImage, const Vector3& hsvDelta )
   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 );
   }
 }
 
@@ -223,10 +308,10 @@ void BubbleEmitter::SetBubbleDensity( unsigned int density )
   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 );
     }
   }
 }
@@ -247,16 +332,16 @@ void BubbleEmitter::OnContextRegained()
   // 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;
@@ -264,17 +349,17 @@ void BubbleEmitter::EmitBubble( Animation& animation, const Vector2& emitPositio
 
 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;
@@ -282,13 +367,13 @@ Geometry BubbleEmitter::CreateGeometry( unsigned int numOfPatch )
 
   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 );
@@ -313,7 +398,7 @@ Geometry BubbleEmitter::CreateGeometry( unsigned int numOfPatch )
   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);
@@ -330,9 +415,9 @@ void BubbleEmitter::SetBubbleParameter( BubbleActorPtr bubbleActor, unsigned int
     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
index fecbd85..e6879ae 100644 (file)
@@ -21,7 +21,7 @@
 // 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>
@@ -42,8 +42,7 @@ namespace Toolkit
 namespace Internal
 {
 
-class BubbleActor;
-typedef IntrusivePtr<BubbleActor> BubbleActorPtr;
+class BubbleRenderer;
 
 /**
  * BubbleEmitter implementation class.
@@ -61,7 +60,7 @@ public:
    * @copydoc Toolkit::BubbleEmitter::New
    */
   static Toolkit::BubbleEmitter New( const Vector2& winSize,
-                                     Image shapeImage,
+                                     Texture shapeTexture,
                                      unsigned int maximumNumberOfBubble,
                                      const Vector2& bubbleSizeRange );
 
@@ -73,12 +72,12 @@ public:
   /**
    * @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
@@ -105,12 +104,12 @@ private:
   /**
    * Construct a new BubbleEmitter object.
    * @param[in] movementArea The size of the bubble moving area
-   * @param[in] shapeImage The alpha channnel of this texture defines the bubble shape.
+   * @param[in] 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 );
 
@@ -129,7 +128,7 @@ private:
 
   /**
    * 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);
 
@@ -140,33 +139,34 @@ private:
 
   /**
    * 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
diff --git a/dali-toolkit/internal/controls/bubble-effect/bubble-renderer.cpp b/dali-toolkit/internal/controls/bubble-effect/bubble-renderer.cpp
new file mode 100644 (file)
index 0000000..88b1a85
--- /dev/null
@@ -0,0 +1,143 @@
+/*
+ * 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
@@ -1,5 +1,5 @@
-#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.
@@ -34,44 +34,43 @@ namespace Internal
 {
 
 /**
- * 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
@@ -80,12 +79,6 @@ public:
   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.
@@ -128,11 +121,8 @@ public:
 
 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'
@@ -140,9 +130,6 @@ private:
   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
@@ -151,4 +138,4 @@ private:
 
 } // namespace Dali
 
-#endif // DALI_TOOLKIT_INTERNAL_BUBBLE_ACTOR_H
+#endif // DALI_TOOLKIT_INTERNAL_BUBBLE_RENDERER_H
index 994faaf..c8c98ad 100644 (file)
@@ -36,7 +36,7 @@ toolkit_src_files = \
    $(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 \
index 9dde85e..92b0610 100644 (file)
@@ -166,7 +166,7 @@ namespace MyCSharpExample
         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();
index d13b4ea..b6396f7 100644 (file)
@@ -51,7 +51,7 @@ namespace MyCSharpExample
       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);
@@ -62,10 +62,10 @@ namespace MyCSharpExample
       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");
@@ -130,39 +130,37 @@ namespace MyCSharpExample
       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 );
     }
 
 
index 7853ce3..be7a11b 100755 (executable)
@@ -38,7 +38,7 @@ namespace MyCSharpExample
         {
             Console.WriteLine("Customized Application Initialize event handler");
             Stage stage = Stage.GetCurrent();
-            stage.BackgroundColor = new Color("white");
+            stage.BackgroundColor = Color.Green;
 
            stage.Touched += OnStageTouched;
 
index 342c82b..4e7c3ac 100644 (file)
@@ -50,12 +50,12 @@ namespace MyCSharpExample
     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);
@@ -71,13 +71,13 @@ namespace MyCSharpExample
           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++)
           {
@@ -88,8 +88,8 @@ namespace MyCSharpExample
               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);
             }
           }
@@ -102,9 +102,9 @@ namespace MyCSharpExample
 
       // 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);
@@ -115,7 +115,7 @@ namespace MyCSharpExample
       _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);
 
@@ -166,8 +166,8 @@ namespace MyCSharpExample
 
         _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;
index 15b0d8b..af74f1e 100644 (file)
@@ -36,8 +36,8 @@ namespace MyCSharpExample
         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)
@@ -48,7 +48,7 @@ namespace MyCSharpExample
         {
             // 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;
@@ -229,8 +229,8 @@ namespace MyCSharpExample
             }
         }
 
-        // TextColor property of type Vector4:
-        public Vector4 TextColor
+        // TextColor property of type Color:
+        public Color TextColor
         {
             get
             {
@@ -305,7 +305,7 @@ namespace MyCSharpExample
         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();
@@ -331,7 +331,7 @@ namespace MyCSharpExample
             _spinYear.Step = 1;
             _spinYear.MaxTextLength = 4;
             _spinYear.TextPointSize = 26;
-            _spinYear.TextColor = NDalic.WHITE;
+            _spinYear.TextColor = Color.White;
             _spinYear.SetKeyboardFocusable(true);
             _spinYear.Name = "_spinYear";
 
@@ -349,7 +349,7 @@ namespace MyCSharpExample
             _spinMonth.Step = 1;
             _spinMonth.MaxTextLength = 2;
             _spinMonth.TextPointSize = 26;
-            _spinMonth.TextColor = NDalic.WHITE;
+            _spinMonth.TextColor = Color.White;
             _spinMonth.SetKeyboardFocusable(true);
             _spinMonth.Name = "_spinMonth";
 
@@ -367,7 +367,7 @@ namespace MyCSharpExample
             _spinDay.Step = 1;
             _spinDay.MaxTextLength = 2;
             _spinDay.TextPointSize = 26;
-            _spinDay.TextColor = NDalic.WHITE;
+            _spinDay.TextColor = Color.White;
             _spinDay.SetKeyboardFocusable(true);
             _spinDay.Name = "_spinDay";
 
index 3115a71..abcb020 100644 (file)
-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);
+      }
+    }
+  }
 }
index d56c414..2e58ab4 100644 (file)
-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);
+    }
+  }
 }
index 07934ff..f89172a 100644 (file)
-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);
+    }
+  }
 }