}
/**
- * @copydoc PlatformAbstraction::GetDefaultFontDescription()
- */
-void TestPlatformAbstraction::GetDefaultFontDescription( std::string& family, std::string& style ) const
-{
- // TODO
-}
-
-/**
* @copydoc PlatformAbstraction::GetDefaultFontSize()
*/
int TestPlatformAbstraction::GetDefaultFontSize() const
virtual bool IsLoading();
/**
- * @copydoc PlatformAbstraction::GetDefaultFontDescription()
- */
- virtual void GetDefaultFontDescription( std::string& family, std::string& style ) const;
-
- /**
* @copydoc PlatformAbstraction::GetDefaultFontSize()
*/
virtual int GetDefaultFontSize() const;
using namespace Dali;
using namespace Dali::Toolkit;
+namespace
+{
+const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg";
+const char* TEST_NPATCH_FILE_NAME = "gallery_image_01.9.jpg";
+}
+
void dali_control_renderer_startup(void)
{
test_return_value = TET_UNDEF;
END_TEST;
}
-int UtcDaliControlRendererSetOnStage(void)
+int UtcDaliControlRendererSetOnOffStage(void)
{
ToolkitTestApplication application;
tet_infoline( "UtcDaliControlRendererSetDepthIndex" );
DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
controlRenderer.SetOnStage( actor );
-
application.SendNotification();
application.Render(0);
DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+ controlRenderer.SetOffStage( actor );
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+
+ END_TEST;
+}
+
+int UtcDaliControlRendererGetPropertyMap1(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliControlRendererGetPropertyMap1: ColorRenderer" );
+
+ RendererFactory factory = RendererFactory::Get();
+ Property::Map propertyMap;
+ propertyMap.Insert("renderer-type", "color-renderer");
+ propertyMap.Insert("blend-color", Color::BLUE);
+ ControlRenderer colorRenderer = factory.GetControlRenderer( propertyMap );
+
+ Property::Map resultMap;
+ colorRenderer.CreatePropertyMap( resultMap );
+
+ Property::Value* typeValue = resultMap.Find( "renderer-type", Property::STRING );
+ DALI_TEST_CHECK( typeValue );
+ DALI_TEST_CHECK( typeValue->Get<std::string>() == "color-renderer" );
+
+ Property::Value* colorValue = resultMap.Find( "blend-color", Property::VECTOR4 );
+ DALI_TEST_CHECK( colorValue );
+ DALI_TEST_CHECK( colorValue->Get<Vector4>() == Color::BLUE );
+
+ // change the blend color
+ factory.ResetRenderer( colorRenderer, Color::CYAN );
+ colorRenderer.CreatePropertyMap( resultMap );
+
+ colorValue = resultMap.Find( "blend-color", Property::VECTOR4 );
+ DALI_TEST_CHECK( colorValue );
+ DALI_TEST_CHECK( colorValue->Get<Vector4>() == Color::CYAN );
+
+ END_TEST;
+}
+
+int UtcDaliControlRendererGetPropertyMap2(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliControlRendererGetPropertyMap2: BorderRenderer" );
+
+ RendererFactory factory = RendererFactory::Get();
+ Property::Map propertyMap;
+ propertyMap.Insert("renderer-type", "border-renderer");
+ propertyMap.Insert("border-color", Color::BLUE);
+ propertyMap.Insert("border-size", 5.f);
+ ControlRenderer borderRenderer = factory.GetControlRenderer( propertyMap );
+
+ Property::Map resultMap;
+ borderRenderer.CreatePropertyMap( resultMap );
+
+ // check the property values from the returned map from control renderer
+ Property::Value* typeValue = resultMap.Find( "renderer-type", Property::STRING );
+ DALI_TEST_CHECK( typeValue );
+ DALI_TEST_CHECK( typeValue->Get<std::string>() == "border-renderer" );
+
+ Property::Value* colorValue = resultMap.Find( "border-color", Property::VECTOR4 );
+ DALI_TEST_CHECK( colorValue );
+ DALI_TEST_CHECK( colorValue->Get<Vector4>() == Color::BLUE );
+
+ Property::Value* sizeValue = resultMap.Find( "border-size", Property::FLOAT );
+ DALI_TEST_CHECK( sizeValue );
+ DALI_TEST_CHECK( sizeValue->Get<float>() == 5.f );
+
+ borderRenderer = factory.GetControlRenderer( 10.f, Color::CYAN );
+ borderRenderer.CreatePropertyMap( resultMap );
+
+ typeValue = resultMap.Find( "renderer-type", Property::STRING );
+ DALI_TEST_CHECK( typeValue );
+ DALI_TEST_CHECK( typeValue->Get<std::string>() == "border-renderer" );
+
+ colorValue = resultMap.Find( "border-color", Property::VECTOR4 );
+ DALI_TEST_CHECK( colorValue );
+ DALI_TEST_CHECK( colorValue->Get<Vector4>() == Color::CYAN );
+
+ colorValue = resultMap.Find( "border-size", Property::FLOAT );
+ DALI_TEST_CHECK( colorValue );
+ DALI_TEST_CHECK( colorValue->Get<float>() == 10.f );
+
+ END_TEST;
+}
+
+int UtcDaliControlRendererGetPropertyMap3(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliControlRendererGetPropertyMap3: linear GradientRenderer" );
+
+ RendererFactory factory = RendererFactory::Get();
+ DALI_TEST_CHECK( factory );
+
+ Property::Map propertyMap;
+ propertyMap.Insert("renderer-type", "gradient-renderer");
+
+ Vector2 start(-1.f, -1.f);
+ Vector2 end(1.f, 1.f);
+ propertyMap.Insert("gradient-start-position", start);
+ propertyMap.Insert("gradient-end-position", end);
+ propertyMap.Insert("gradient-spread-method", "repeat");
+
+ propertyMap.Insert("gradient-stop-offset", Vector2(0.2f, 0.8f));
+
+ Property::Array stopColors;
+ stopColors.PushBack( Color::RED );
+ stopColors.PushBack( Color::GREEN );
+ propertyMap.Insert("gradient-stop-color", stopColors);
+
+ ControlRenderer gradientRenderer = factory.GetControlRenderer(propertyMap);
+
+ Property::Map resultMap;
+ gradientRenderer.CreatePropertyMap( resultMap );
+
+ // check the property values from the returned map from control renderer
+ Property::Value* value = resultMap.Find( "renderer-type", Property::STRING );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<std::string>() == "gradient-renderer" );
+
+ value = resultMap.Find( "gradient-units", Property::STRING );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<std::string>() == "object-bounding-box" );
+
+ value = resultMap.Find( "gradient-spread-method", Property::STRING );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<std::string>() == "repeat" );
+
+ value = resultMap.Find( "gradient-start-position", Property::VECTOR2 );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get<Vector2>(), start , Math::MACHINE_EPSILON_100, TEST_LOCATION );
+
+ value = resultMap.Find( "gradient-end-position", Property::VECTOR2 );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get<Vector2>(), end , Math::MACHINE_EPSILON_100, TEST_LOCATION );
+
+ value = resultMap.Find( "gradient-stop-offset", Property::ARRAY );
+ DALI_TEST_CHECK( value );
+ Property::Array* offsetArray = value->GetArray();
+ DALI_TEST_CHECK( offsetArray->Count() == 2 );
+ DALI_TEST_EQUALS( offsetArray->GetElementAt(0).Get<float>(), 0.2f , Math::MACHINE_EPSILON_100, TEST_LOCATION );
+ DALI_TEST_EQUALS( offsetArray->GetElementAt(1).Get<float>(), 0.8f , Math::MACHINE_EPSILON_100, TEST_LOCATION );
+
+ value = resultMap.Find( "gradient-stop-color", Property::ARRAY );
+ DALI_TEST_CHECK( value );
+ Property::Array* colorArray = value->GetArray();
+ DALI_TEST_CHECK( colorArray->Count() == 2 );
+ DALI_TEST_EQUALS( colorArray->GetElementAt(0).Get<Vector4>(), Color::RED , Math::MACHINE_EPSILON_100, TEST_LOCATION );
+ DALI_TEST_EQUALS( colorArray->GetElementAt(1).Get<Vector4>(), Color::GREEN , Math::MACHINE_EPSILON_100, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliControlRendererGetPropertyMap4(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliControlRendererGetPropertyMap4: radial GradientRenderer" );
+
+ RendererFactory factory = RendererFactory::Get();
+ DALI_TEST_CHECK( factory );
+
+ Property::Map propertyMap;
+ propertyMap.Insert("renderer-type", "gradient-renderer");
+
+ Vector2 center(100.f, 100.f);
+ float radius = 100.f;
+ propertyMap.Insert("gradient-units", "user-space");
+ propertyMap.Insert("gradient-center", center);
+ propertyMap.Insert("gradient-radius", radius);
+ propertyMap.Insert("gradient-stop-offset", Vector3(0.1f, 0.3f, 1.1f));
+
+ Property::Array stopColors;
+ stopColors.PushBack( Color::RED );
+ stopColors.PushBack( Color::BLACK );
+ stopColors.PushBack( Color::GREEN );
+ propertyMap.Insert("gradient-stop-color", stopColors);
+
+ ControlRenderer gradientRenderer = factory.GetControlRenderer(propertyMap);
+ DALI_TEST_CHECK( gradientRenderer );
+
+ Property::Map resultMap;
+ gradientRenderer.CreatePropertyMap( resultMap );
+
+ // check the property values from the returned map from control renderer
+ Property::Value* value = resultMap.Find( "renderer-type", Property::STRING );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<std::string>() == "gradient-renderer" );
+
+ value = resultMap.Find( "gradient-units", Property::STRING );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<std::string>() == "user-space" );
+
+ value = resultMap.Find( "gradient-spread-method", Property::STRING );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<std::string>() == "pad" );
+
+ value = resultMap.Find( "gradient-center", Property::VECTOR2 );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get<Vector2>(), center , Math::MACHINE_EPSILON_100, TEST_LOCATION );
+
+ value = resultMap.Find( "gradient-radius", Property::FLOAT );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get<float>(), radius , Math::MACHINE_EPSILON_100, TEST_LOCATION );
+
+ value = resultMap.Find( "gradient-stop-offset", Property::ARRAY );
+ DALI_TEST_CHECK( value );
+ Property::Array* offsetArray = value->GetArray();
+ DALI_TEST_CHECK( offsetArray->Count() == 3 );
+ DALI_TEST_EQUALS( offsetArray->GetElementAt(0).Get<float>(), 0.1f , Math::MACHINE_EPSILON_100, TEST_LOCATION );
+ DALI_TEST_EQUALS( offsetArray->GetElementAt(1).Get<float>(), 0.3f , Math::MACHINE_EPSILON_100, TEST_LOCATION );
+ // any stop value will be clamped to [0.0, 1.0];
+ DALI_TEST_EQUALS( offsetArray->GetElementAt(2).Get<float>(), 1.0f , Math::MACHINE_EPSILON_100, TEST_LOCATION );
+
+ value = resultMap.Find( "gradient-stop-color", Property::ARRAY );
+ DALI_TEST_CHECK( value );
+ Property::Array* colorArray = value->GetArray();
+ DALI_TEST_CHECK( colorArray->Count() == 3 );
+ DALI_TEST_EQUALS( colorArray->GetElementAt(0).Get<Vector4>(), Color::RED , Math::MACHINE_EPSILON_100, TEST_LOCATION );
+ DALI_TEST_EQUALS( colorArray->GetElementAt(1).Get<Vector4>(), Color::BLACK , Math::MACHINE_EPSILON_100, TEST_LOCATION );
+ DALI_TEST_EQUALS( colorArray->GetElementAt(2).Get<Vector4>(), Color::GREEN , Math::MACHINE_EPSILON_100, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliControlRendererGetPropertyMap5(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliControlRendererGetPropertyMap5: ImageRenderer" );
+
+ RendererFactory factory = RendererFactory::Get();
+ Property::Map propertyMap;
+ propertyMap.Insert( "renderer-type", "image-renderer" );
+ propertyMap.Insert( "image-url", TEST_IMAGE_FILE_NAME );
+ propertyMap.Insert( "image-desired-width", 20 );
+ propertyMap.Insert( "image-desired-height", 30 );
+ propertyMap.Insert( "image-fitting-mode", "fit-height" );
+ propertyMap.Insert( "image-sampling-mode", "box-then-nearest" );
+
+ ControlRenderer imageRenderer = factory.GetControlRenderer(propertyMap);
+ DALI_TEST_CHECK( imageRenderer );
+
+ Property::Map resultMap;
+ imageRenderer.CreatePropertyMap( resultMap );
+
+ // check the property values from the returned map from control renderer
+ Property::Value* value = resultMap.Find( "renderer-type", Property::STRING );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<std::string>() == "image-renderer" );
+
+ value = resultMap.Find( "image-url", Property::STRING );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<std::string>() == TEST_IMAGE_FILE_NAME );
+
+ value = resultMap.Find( "image-fitting-mode", Property::STRING );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<std::string>() == "fit-height" );
+
+ value = resultMap.Find( "image-sampling-mode", Property::STRING );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<std::string>() == "box-then-nearest" );
+
+ value = resultMap.Find( "image-desired-width", Property::INTEGER );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<int>() == 20 );
+
+ value = resultMap.Find( "image-desired-height", Property::INTEGER );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<int>() == 30 );
+
+ // Get an image renderer with an image handle, and test the default property values
+ Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME, ImageDimensions(100, 200));
+ imageRenderer = factory.GetControlRenderer(image);
+ imageRenderer.CreatePropertyMap( resultMap );
+
+ value = resultMap.Find( "renderer-type", Property::STRING );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<std::string>() == "image-renderer" );
+
+ value = resultMap.Find( "image-url", Property::STRING );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<std::string>() == TEST_IMAGE_FILE_NAME );
+
+ value = resultMap.Find( "image-fitting-mode", Property::STRING );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<std::string>() == "shrink-to-fit" );
+
+ value = resultMap.Find( "image-sampling-mode", Property::STRING );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<std::string>() == "box" );
+
+ value = resultMap.Find( "image-desired-width", Property::INTEGER );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<int>() == 100 );
+
+ value = resultMap.Find( "image-desired-height", Property::INTEGER );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<int>() == 200 );
+
+ END_TEST;
+}
+
+int UtcDaliControlRendererGetPropertyMap6(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliControlRendererGetPropertyMap6: NPatchRenderer" );
+
+ RendererFactory factory = RendererFactory::Get();
+ Property::Map propertyMap;
+ propertyMap.Insert( "renderer-type", "n-patch-renderer" );
+ propertyMap.Insert( "image-url", TEST_NPATCH_FILE_NAME );
+ propertyMap.Insert( "border-only", true );
+ ControlRenderer nPatchRenderer = factory.GetControlRenderer( propertyMap );
+
+ Property::Map resultMap;
+ nPatchRenderer.CreatePropertyMap( resultMap );
+
+ // check the property values from the returned map from control renderer
+ Property::Value* value = resultMap.Find( "renderer-type", Property::STRING );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<std::string>() == "n-patch-renderer" );
+
+ value = resultMap.Find( "image-url", Property::STRING );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<std::string>() == TEST_NPATCH_FILE_NAME );
+
+ value = resultMap.Find( "border-only", Property::BOOLEAN );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<bool>() );
+
END_TEST;
}
#include <dali-toolkit-test-suite-utils.h>
#include <dali-toolkit/dali-toolkit.h>
+#include <dali/devel-api/scripting/scripting.h>
using namespace Dali;
using namespace Toolkit;
namespace
{
const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg";
+const char* TEST_IMAGE_FILE_NAME2 = "gallery_image_02.jpg";
+
+void TestImage( ImageView imageView, BufferImage image )
+{
+ Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
+
+ Property::Map map;
+ DALI_TEST_CHECK( value.Get( map ) );
+
+ DALI_TEST_CHECK( map.Find( "width" ) );
+ DALI_TEST_CHECK( map.Find( "height" ) );
+ DALI_TEST_CHECK( map.Find( "type" ) );
+
+ int width = 0;
+ DALI_TEST_CHECK( map[ "width" ].Get( width ) );
+ DALI_TEST_EQUALS( width, image.GetWidth(), TEST_LOCATION );
+
+ int height = 0;
+ DALI_TEST_CHECK( map[ "height" ].Get( height ) );
+ DALI_TEST_EQUALS( height, image.GetHeight(), TEST_LOCATION );
+
+ std::string type;
+ DALI_TEST_CHECK( map[ "type" ].Get( type ) );
+ DALI_TEST_EQUALS( type, "BufferImage", TEST_LOCATION );
+}
+
+void TestImage( ImageView imageView, ResourceImage image )
+{
+ Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
+
+ Property::Map map;
+ DALI_TEST_CHECK( value.Get( map ) );
+
+ if( map.Find( "width" ) )
+ {
+ int width = 0;
+ DALI_TEST_CHECK( map[ "width" ].Get( width ) );
+ DALI_TEST_EQUALS( width, image.GetWidth(), TEST_LOCATION );
+ }
+
+ if( map.Find( "height" ) )
+ {
+ int height = 0;
+ DALI_TEST_CHECK( map[ "height" ].Get( height ) );
+ DALI_TEST_EQUALS( height, image.GetHeight(), TEST_LOCATION );
+ }
+
+ DALI_TEST_CHECK( map.Find( "type" ) );
+
+ std::string type;
+ DALI_TEST_CHECK( map[ "type" ].Get( type ) );
+ DALI_TEST_EQUALS( type, "ResourceImage", TEST_LOCATION );
+
+ std::string filename;
+ DALI_TEST_CHECK( map[ "filename" ].Get( filename ) );
+ DALI_TEST_EQUALS( filename, image.GetUrl(), TEST_LOCATION );
+}
+
+void TestUrl( ImageView imageView, const std::string url )
+{
+ Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
+
+ std::string urlActual;
+ DALI_TEST_CHECK( value.Get( urlActual ) );
+ DALI_TEST_EQUALS( urlActual, url, TEST_LOCATION );
+}
+
} // namespace
int UtcDaliImageViewNewP(void)
{
TestApplication application;
- Image image = CreateBufferImage( 100, 200, Vector4( 1.f, 1.f, 1.f, 1.f ) );
+ BufferImage image = CreateBufferImage( 100, 200, Vector4( 1.f, 1.f, 1.f, 1.f ) );
ImageView imageView = ImageView::New( image );
DALI_TEST_CHECK( imageView );
- DALI_TEST_EQUALS( image, imageView.GetImage(), TEST_LOCATION );
+ TestImage( imageView, image );
END_TEST;
}
ImageView imageView = ImageView::New( TEST_IMAGE_FILE_NAME );
DALI_TEST_CHECK( imageView );
- DALI_TEST_CHECK( imageView.GetImage() );
-
- Property::Value val = imageView.GetProperty( imageView.GetPropertyIndex( "resource-url" ) );
- std::string resource_url;
- DALI_TEST_CHECK( val.Get( resource_url ) );
- DALI_TEST_EQUALS( resource_url, TEST_IMAGE_FILE_NAME, TEST_LOCATION );
- Image image = imageView.GetImage();
- DALI_TEST_CHECK( image );
-
- ResourceImage resourceImage = ResourceImage::DownCast( image );
- DALI_TEST_CHECK( resourceImage );
- DALI_TEST_EQUALS( resourceImage.GetUrl(), TEST_IMAGE_FILE_NAME, TEST_LOCATION );
+ TestUrl( imageView, TEST_IMAGE_FILE_NAME );
END_TEST;
}
END_TEST;
}
-int UtcDaliImageViewSetGetProperty(void)
+int UtcDaliImageViewSetGetProperty01(void)
{
ToolkitTestApplication application;
ImageView imageView = ImageView::New();
- Property::Index idx = imageView.GetPropertyIndex( "resource-url" );
- DALI_TEST_EQUALS( idx, ImageView::Property::RESOURCE_URL, TEST_LOCATION );
+ Property::Index idx = imageView.GetPropertyIndex( "image" );
+ DALI_TEST_EQUALS( idx, ImageView::Property::IMAGE, TEST_LOCATION );
imageView.SetProperty( idx, TEST_IMAGE_FILE_NAME );
- Property::Value val = imageView.GetProperty( idx );
- std::string resource_url;
- DALI_TEST_CHECK( val.Get( resource_url ) );
- DALI_TEST_EQUALS( resource_url, TEST_IMAGE_FILE_NAME, TEST_LOCATION );
-
- Image image = imageView.GetImage();
- DALI_TEST_CHECK( image );
-
- ResourceImage resourceImage = ResourceImage::DownCast( image );
- DALI_TEST_CHECK( resourceImage );
- DALI_TEST_EQUALS( resourceImage.GetUrl(), TEST_IMAGE_FILE_NAME, TEST_LOCATION );
+ TestUrl( imageView, TEST_IMAGE_FILE_NAME );
END_TEST;
}
{
ToolkitTestApplication application;
- int width = 300;
- int height = 400;
- Image image = CreateBufferImage( width, height, Vector4( 1.f, 1.f, 1.f, 1.f ) );
+ int width1 = 300;
+ int height1 = 400;
+ BufferImage image1 = CreateBufferImage( width1, height1, Vector4( 1.f, 1.f, 1.f, 1.f ) );
ImageView imageView = ImageView::New();
- imageView.SetImage( image );
+ imageView.SetImage( image1 );
- std::string resource_url;
- Property::Value val = imageView.GetProperty( imageView.GetPropertyIndex( "resource-url" ) );
- DALI_TEST_CHECK( val.Get( resource_url ) );
- DALI_TEST_CHECK( resource_url.empty() );
+ TestImage( imageView, image1 );
+
+ int width2 = 600;
+ int height2 = 500;
+ BufferImage image2 = CreateBufferImage( width2, height2, Vector4( 1.f, 1.f, 1.f, 1.f ) );
+ imageView.SetImage( image2 );
+
+ TestImage( imageView, image2 );
END_TEST;
}
-int UtcDaliImageViewSetResourceImage(void)
+int UtcDaliImageViewSetImageUrl(void)
{
ToolkitTestApplication application;
- Image image = ResourceImage::New( TEST_IMAGE_FILE_NAME );
ImageView imageView = ImageView::New();
- imageView.SetImage( image );
+ imageView.SetImage( TEST_IMAGE_FILE_NAME );
+ TestUrl( imageView, TEST_IMAGE_FILE_NAME );
- std::string resource_url;
- Property::Value val = imageView.GetProperty( imageView.GetPropertyIndex( "resource-url" ) );
- DALI_TEST_CHECK( val.Get( resource_url ) );
- DALI_TEST_EQUALS( resource_url, TEST_IMAGE_FILE_NAME, TEST_LOCATION );
+
+ imageView.SetImage( TEST_IMAGE_FILE_NAME2 );
+ TestUrl( imageView, TEST_IMAGE_FILE_NAME2 );
END_TEST;
}
application.SendNotification();
application.Render();
- Image image1 = ResourceImage::New( TEST_IMAGE_FILE_NAME );
+ ResourceImage image1 = ResourceImage::New( TEST_IMAGE_FILE_NAME );
imageView.SetImage( image1 );
-
- Image image2 = imageView.GetImage();
- DALI_TEST_EQUALS( image1, image2, TEST_LOCATION );
+ TestImage( imageView, image1 );
int width = 300;
int height = 400;
- Image image3 = CreateBufferImage( width, height, Vector4( 1.f, 1.f, 1.f, 1.f ) );
- imageView.SetImage( image3 );
-
- Image image4 = imageView.GetImage();
- DALI_TEST_EQUALS( image3, image4, TEST_LOCATION );
+ BufferImage image2 = CreateBufferImage( width, height, Vector4( 1.f, 1.f, 1.f, 1.f ) );
+ imageView.SetImage( image2 );
+ TestImage( imageView, image2 );
END_TEST;
}
application.SendNotification();
application.Render();
- Image image1 = ResourceImage::New( TEST_IMAGE_FILE_NAME );
+ ResourceImage image1 = ResourceImage::New( TEST_IMAGE_FILE_NAME );
imageView.SetImage( image1 );
+ TestImage( imageView, image1 );
+
+ Image image2;
+ imageView.SetImage( image2 );
- Image image2 = imageView.GetImage();
- DALI_TEST_EQUALS( image1, image2, TEST_LOCATION );
+ Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
- Image image3;
- imageView.SetImage( image3 );
+ //the value should be empty
+ std::string url;
+ DALI_TEST_CHECK( !value.Get( url ) );
- Image image4 = imageView.GetImage();
- DALI_TEST_CHECK( !image4 );
+ Property::Map map;
+ DALI_TEST_CHECK( !value.Get( map ) );
END_TEST;
}
application.Render();
Stage::GetCurrent().Remove( imageView );
- Image image1 = ResourceImage::New( TEST_IMAGE_FILE_NAME );
+ ResourceImage image1 = ResourceImage::New( TEST_IMAGE_FILE_NAME );
imageView.SetImage( image1 );
-
- Image image2 = imageView.GetImage();
- DALI_TEST_EQUALS( image1, image2, TEST_LOCATION );
+ TestImage( imageView, image1 );
int width = 300;
int height = 400;
- Image image3 = CreateBufferImage( width, height, Vector4( 1.f, 1.f, 1.f, 1.f ) );
- imageView.SetImage( image3 );
-
- Image image4 = imageView.GetImage();
- DALI_TEST_EQUALS( image3, image4, TEST_LOCATION );
+ BufferImage image2 = CreateBufferImage( width, height, Vector4( 1.f, 1.f, 1.f, 1.f ) );
+ imageView.SetImage( image2 );
+ TestImage( imageView, image2 );
END_TEST;
}
application.Render();
Stage::GetCurrent().Remove( imageView );
- Image image1 = ResourceImage::New( TEST_IMAGE_FILE_NAME );
+ ResourceImage image1 = ResourceImage::New( TEST_IMAGE_FILE_NAME );
imageView.SetImage( image1 );
+ TestImage( imageView, image1 );
+
+ Image image2;
+ imageView.SetImage( image2 );
- Image image2 = imageView.GetImage();
- DALI_TEST_EQUALS( image1, image2, TEST_LOCATION );
+ Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
- Image image3;
- imageView.SetImage( image3 );
+ //the value should be empty
+ std::string url;
+ DALI_TEST_CHECK( !value.Get( url ) );
- Image image4 = imageView.GetImage();
- DALI_TEST_CHECK( !image4 );
+ Property::Map map;
+ DALI_TEST_CHECK( !value.Get( map ) );
END_TEST;
}
ImageView imageView = ImageView::New();
imageView.SetImage( image1 );
- Image image2 = imageView.GetImage();
- DALI_TEST_CHECK( !image2 );
+ Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
+
+ //the value should be empty
+ std::string url;
+ DALI_TEST_CHECK( !value.Get( url ) );
+
+ Property::Map map;
+ DALI_TEST_CHECK( !value.Get( map ) );
std::string resource_url;
- Property::Value val = imageView.GetProperty( imageView.GetPropertyIndex( "resource-url" ) );
- DALI_TEST_CHECK( val.Get( resource_url ) );
- DALI_TEST_CHECK( resource_url.empty() );
+ Property::Value val = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
+ DALI_TEST_CHECK( !val.Get( resource_url ) );
END_TEST;
}
actor.SetParentOrigin( ParentOrigin::CENTER );
actor.SetAnchorPoint( AnchorPoint::CENTER );
+ ImageActor backPageActor = CreateSolidColorImageActor(mApplication, Color::BLUE,IMAGE_WIDTH,IMAGE_HEIGHT);
+ backPageActor.SetParentOrigin( ParentOrigin::CENTER );
+ backPageActor.SetAnchorPoint( AnchorPoint::CENTER );
+ actor.Add( backPageActor );
+
mSourceActors[pageId] = actor;
}
registry.ObjectCreatedSignal().Connect( &TestCallback );
{
TestPageFactory factory(application);
- PageTurnView PortraitView = PageTurnPortraitView::New( factory, PAGE_SIZE );
+ PageTurnView portraitView = PageTurnPortraitView::New( factory, PAGE_SIZE );
}
DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
handleView = portraitView;
PageTurnView downCastView = PageTurnView::DownCast( handleView );
DALI_TEST_CHECK( downCastView );
+
END_TEST;
}
END_TEST;
}
+int UtcDaliPageTurnPortraitViewCopyConstructorAndAssignment(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline(" UtcDaliPageTurnPortraitViewCopyConstructorAndAssignment ");
+
+ // Test default constructor
+ PageTurnPortraitView portraitView;
+ DALI_TEST_CHECK( !portraitView );
+
+ // Test object creation
+ TestPageFactory factory(application);
+ portraitView = PageTurnPortraitView::New( factory, PAGE_SIZE );
+ DALI_TEST_CHECK( portraitView );
+
+ // Test copy constructor
+ PageTurnPortraitView viewCopy( portraitView );
+ DALI_TEST_CHECK( viewCopy );
+
+ // Test assignment
+ PageTurnPortraitView portraitView2;
+ portraitView2 = portraitView;
+ DALI_TEST_CHECK( portraitView2 );
+ DALI_TEST_CHECK( portraitView == portraitView2);
+
+ // Test down cast
+ Handle handleView;
+ handleView = portraitView;
+ PageTurnPortraitView downCastView = PageTurnPortraitView::DownCast( handleView );
+ DALI_TEST_CHECK( downCastView );
+
+ END_TEST;
+}
+
+int UtcDaliPageTurnLandscapeViewCopyConstructorAndAssignment(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline(" UtcDaliPageTurnLandscapeViewCopyConstructorAndAssignment ");
+
+ // Test default constructor
+ PageTurnLandscapeView landscapeView;
+ DALI_TEST_CHECK( !landscapeView );
+
+ // Test object creation
+ TestPageFactory factory(application);
+ landscapeView = PageTurnLandscapeView::New( factory, PAGE_SIZE );
+ DALI_TEST_CHECK( landscapeView );
+
+ // Test copy constructor
+ PageTurnLandscapeView viewCopy( landscapeView );
+ DALI_TEST_CHECK( viewCopy );
+
+ // Test assignment
+ PageTurnLandscapeView landscapeView2;
+ landscapeView2 = landscapeView;
+ DALI_TEST_CHECK( landscapeView2 );
+ DALI_TEST_CHECK( landscapeView == landscapeView2);
+
+ // Test down cast
+ Handle handleView;
+ handleView = landscapeView;
+ PageTurnLandscapeView downCastView = PageTurnLandscapeView::DownCast( handleView );
+ DALI_TEST_CHECK( downCastView );
+
+ END_TEST;
+}
+
int UtcDaliPageTurnViewSetGetProperty(void)
{
ToolkitTestApplication application;
END_TEST;
}
-int UtcDaliPageTurnViewSignals(void)
+int UtcDaliPageTurnPortraitViewSignals(void)
{
ToolkitTestApplication application;
- tet_infoline(" UtcDaliPageTurnViewSignals ");
+ tet_infoline(" UtcDaliPageTurnPortraitViewSignals ");
application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE );
Wait(application, 1000);
DALI_TEST_CHECK( callbackTurnFinished.mSignalVerified );
- // the page is turn over
+ // the page is turned over
DALI_TEST_EQUALS( portraitView.GetProperty(PageTurnView::Property::CURRENT_PAGE_ID).Get<int>(), pageIndex+1, TEST_LOCATION );
//---Test 2: pan from position( size*0.5f ) to position( size.width, size.height*0.5f ) to position( size * 0.75f ), page 1 will bent then slid back---
DALI_TEST_EQUALS( portraitView.GetProperty(PageTurnView::Property::CURRENT_PAGE_ID).Get<int>(), 9, TEST_LOCATION );
END_TEST;
}
+
+int UtcDaliPageTurnLanscapeViewSignals(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline(" UtcDaliPageTurnLanscapeViewSignals ");
+
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE );
+
+ /***
+ * -----------------
+ * | |
+ * |---------------|
+ * |bookboo|bookboo|
+ * |kbookbo|kbookbo|
+ * |okbookb|okbookb|
+ * |ookbook|ookbook|
+ * |bookboo|bookboo|
+ * |---------------|
+ * | |
+ * ----------------
+ */
+
+ TestPageFactory factory(application);
+ Vector2 stageSize = Stage::GetCurrent().GetSize();
+ PageTurnView landscapeView = PageTurnLandscapeView::New( factory, Vector2(stageSize.x*0.5f, stageSize.x*0.8f) );
+ landscapeView.SetPositionInheritanceMode( USE_PARENT_POSITION );;
+ Stage::GetCurrent().Add( landscapeView );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render(RENDER_FRAME_INTERVAL);
+
+ // [0]: testing PageTurnStartedSignal; [1]: testing PageTurnFinishedSignal
+ // [2]: testing PagePanStartedSignal; [3]: testing PagePanFinishedSignal
+ bool signalVerified[4] = {false, false, false, false};
+ PageTurnView currentView;
+ unsigned int pageIndex;
+ bool isTurningForwards;
+
+ PageSignalCallback callbackTurnStarted( signalVerified[0], currentView, pageIndex, isTurningForwards );
+ landscapeView.PageTurnStartedSignal().Connect( &callbackTurnStarted, &PageSignalCallback::PageTurnSignalCallback );
+
+ PageSignalCallback callbackTurnFinished( signalVerified[1], currentView, pageIndex, isTurningForwards );
+ landscapeView.PageTurnFinishedSignal().Connect( &callbackTurnFinished, &PageSignalCallback::PageTurnSignalCallback );
+
+ PageSignalCallback callbackPanStarted( signalVerified[2], currentView, pageIndex, isTurningForwards );
+ landscapeView.PagePanStartedSignal().Connect( &callbackPanStarted, &PageSignalCallback::PagePanSignalCallback );
+
+ PageSignalCallback callbackPanFinished( signalVerified[3], currentView, pageIndex, isTurningForwards );
+ landscapeView.PagePanFinishedSignal().Connect( &callbackPanFinished, &PageSignalCallback::PagePanSignalCallback );
+
+ DALI_TEST_CHECK( !callbackTurnStarted.mSignalVerified );
+ DALI_TEST_CHECK( !callbackTurnFinished.mSignalVerified );
+ DALI_TEST_CHECK( !callbackPanStarted.mSignalVerified );
+ DALI_TEST_CHECK( !callbackPanFinished.mSignalVerified );
+
+ currentView = landscapeView;
+
+ //-----Test 1: pan 10 frames from position(stageSize.x * 0.85f, stageSize.y*0.5) to position(stageSize.x * 0.45f, stageSize.y*0.5-stageSize.x * 0.3f), page 0 will be turned forward----
+ pageIndex = 0;
+ isTurningForwards = true;
+ // Do a pan to the left.
+ Vector2 start = Vector2(stageSize.x * 0.85f, stageSize.y*0.5);
+ Vector2 direction = Vector2(-stageSize.x*0.04f, -stageSize.x*0.03f);
+
+ DALI_TEST_EQUALS( landscapeView.GetProperty(PageTurnView::Property::CURRENT_PAGE_ID).Get<int>(), 0, TEST_LOCATION );
+ PerformGestureDiagonalSwipe( application, start, direction, 5, true, false);
+ DALI_TEST_CHECK( callbackTurnStarted.mSignalVerified );
+ DALI_TEST_CHECK( !callbackTurnFinished.mSignalVerified );
+ DALI_TEST_CHECK( callbackPanStarted.mSignalVerified );
+ DALI_TEST_CHECK( !callbackPanFinished.mSignalVerified );
+
+ PerformGestureDiagonalSwipe( application, start+direction*5.f, direction, 5, false, true);
+ DALI_TEST_CHECK( !callbackTurnFinished.mSignalVerified );
+ DALI_TEST_CHECK( callbackPanFinished.mSignalVerified );
+
+ Wait(application, 1000);
+ DALI_TEST_CHECK( callbackTurnFinished.mSignalVerified );
+ // the page is turned over
+ DALI_TEST_EQUALS( landscapeView.GetProperty(PageTurnView::Property::CURRENT_PAGE_ID).Get<int>(), pageIndex+1, TEST_LOCATION );
+
+ //---Test 2: pan from position(stageSize.x * 0.15f, stageSize.y*0.5) to position(stageSize.x * 0.45f, stageSize.y*0.5) page 4 will be turned back---
+ callbackTurnStarted.Reset();
+ callbackTurnFinished.Reset();
+ callbackPanStarted.Reset();
+ callbackPanFinished.Reset();
+ isTurningForwards = false;
+
+ //pan 10 frames from position( size.width, size.height*0.5f ) to position( size * 0.75f )
+ start = Vector2( stageSize.x * 0.15f, stageSize.y*0.5f );
+ direction = Vector2(stageSize.x * 0.03f, 0.f);
+ PerformGestureDiagonalSwipe( application, start, direction, 5, true, false);
+ DALI_TEST_CHECK( callbackPanStarted.mSignalVerified );
+ DALI_TEST_CHECK( callbackTurnStarted.mSignalVerified );
+ DALI_TEST_CHECK( !callbackTurnFinished.mSignalVerified );
+ DALI_TEST_CHECK( !callbackPanFinished.mSignalVerified );
+
+ PerformGestureDiagonalSwipe( application, start + direction*5.f , direction, 5, false, true);
+ DALI_TEST_CHECK( !callbackTurnFinished.mSignalVerified );
+ DALI_TEST_CHECK( callbackPanFinished.mSignalVerified );
+
+ Wait(application, 1000);
+ DALI_TEST_CHECK( callbackTurnFinished.mSignalVerified );
+ DALI_TEST_EQUALS( landscapeView.GetProperty(PageTurnView::Property::CURRENT_PAGE_ID).Get<int>(), 0, TEST_LOCATION ); // the first page is turned back
+
+ // ----Test 3: pan 10 frames from position( size*0.55f ) to position( size.width*0.8f, size.height*0.5f ), no page turn will be started---
+ callbackTurnStarted.Reset();
+ callbackTurnFinished.Reset();
+ callbackPanStarted.Reset();
+ callbackPanFinished.Reset();
+ isTurningForwards = false;
+ start = stageSize*0.55f;
+ direction = Vector2(stageSize.x*0.025f, 0.f);
+ PerformGestureDiagonalSwipe( application, start, direction, 5, true, false);
+ DALI_TEST_CHECK( callbackPanStarted.mSignalVerified );
+ DALI_TEST_CHECK( !callbackTurnStarted.mSignalVerified );
+ DALI_TEST_CHECK( !callbackTurnFinished.mSignalVerified );
+ DALI_TEST_CHECK( !callbackPanFinished.mSignalVerified );
+
+ PerformGestureDiagonalSwipe( application, start+direction*5.f, direction, 5, false, true);
+ DALI_TEST_CHECK( !callbackTurnStarted.mSignalVerified );
+ DALI_TEST_CHECK( callbackPanFinished.mSignalVerified );
+ DALI_TEST_CHECK( !callbackTurnFinished.mSignalVerified );
+
+ Wait( application, 1000 );
+
+ DALI_TEST_CHECK( !callbackTurnFinished.mSignalVerified );
+ DALI_TEST_EQUALS( landscapeView.GetProperty(PageTurnView::Property::CURRENT_PAGE_ID).Get<int>(), 0, TEST_LOCATION );
+ END_TEST;
+}
namespace
{
const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg";
+const char* TEST_NPATCH_FILE_NAME = "gallery_image_01.9.jpg";
+
+Integration::Bitmap* CreateBitmap( unsigned int imageWidth, unsigned int imageHeight, unsigned int initialColor, Pixel::Format pixelFormat )
+{
+ Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
+ Integration::PixelBuffer* pixbuffer = bitmap->GetPackedPixelsProfile()->ReserveBuffer( pixelFormat, imageWidth, imageHeight, imageWidth, imageHeight );
+ unsigned int bytesPerPixel = GetBytesPerPixel( pixelFormat );
+
+ memset( pixbuffer, initialColor, imageHeight * imageWidth * bytesPerPixel );
+
+ return bitmap;
+}
+
+void InitialiseRegionsToZeroAlpha( Integration::Bitmap* image, unsigned int imageWidth, unsigned int imageHeight, Pixel::Format pixelFormat )
+{
+ PixelBuffer* pixbuffer = image->GetBuffer();
+ unsigned int bytesPerPixel = GetBytesPerPixel( pixelFormat );
+
+ for( unsigned int row = 0; row < imageWidth; ++row )
+ {
+ unsigned int pixelOffset = row * bytesPerPixel;
+ pixbuffer[ pixelOffset + 3 ] = 0x00;
+ pixelOffset += ( imageHeight - 1 ) * imageWidth * bytesPerPixel;
+ pixbuffer[ pixelOffset + 3 ] = 0x00;
+ }
+
+ for ( unsigned int column = 0; column < imageHeight; ++column )
+ {
+ unsigned int pixelOffset = column * imageWidth * bytesPerPixel;
+ pixbuffer[ pixelOffset + 3 ] = 0x00;
+ pixelOffset += ( imageWidth -1 ) * bytesPerPixel;
+ pixbuffer[ pixelOffset + 3 ] = 0x00;
+ }
+}
+
+void AddStretchRegionsToImage( Integration::Bitmap* image, unsigned int imageWidth, unsigned int imageHeight, const Vector4& requiredStretchBorder, Pixel::Format pixelFormat )
+{
+ PixelBuffer* pixbuffer = image->GetBuffer();
+ unsigned int bytesPerPixel = GetBytesPerPixel( pixelFormat );
+
+ for( unsigned int column = requiredStretchBorder.x; column < imageWidth - requiredStretchBorder.z; ++column )
+ {
+ unsigned int pixelOffset = column * bytesPerPixel;
+ pixbuffer[ pixelOffset ] = 0x00;
+ pixbuffer[ pixelOffset + 1 ] = 0x00;
+ pixbuffer[ pixelOffset + 2 ] = 0x00;
+ pixbuffer[ pixelOffset + 3 ] = 0xFF;
+ }
+
+ for( unsigned int row = requiredStretchBorder.y; row < imageHeight - requiredStretchBorder.w; ++row )
+ {
+ unsigned int pixelOffset = row * imageWidth * bytesPerPixel;
+ pixbuffer[ pixelOffset ] = 0x00;
+ pixbuffer[ pixelOffset + 1 ] = 0x00;
+ pixbuffer[ pixelOffset + 2 ] = 0x00;
+ pixbuffer[ pixelOffset + 3 ] = 0xFF;
+ }
+}
+
+void AddChildRegionsToImage( Integration::Bitmap* image, unsigned int imageWidth, unsigned int imageHeight, const Vector4& requiredChildRegion, Pixel::Format pixelFormat )
+{
+ PixelBuffer* pixbuffer = image->GetBuffer();
+ unsigned int bytesPerPixel = GetBytesPerPixel( pixelFormat );
+
+ Integration::Bitmap::PackedPixelsProfile* srcProfile = image->GetPackedPixelsProfile();
+ unsigned int bufferStride = srcProfile->GetBufferStride();
+
+ // Add bottom child region
+ for( unsigned int column = requiredChildRegion.x; column < imageWidth - requiredChildRegion.z; ++column )
+ {
+ unsigned int pixelOffset = column * bytesPerPixel;
+ pixelOffset += ( imageHeight - 1 ) * bufferStride;
+ pixbuffer[ pixelOffset ] = 0x00;
+ pixbuffer[ pixelOffset + 1 ] = 0x00;
+ pixbuffer[ pixelOffset + 2 ] = 0x00;
+ pixbuffer[ pixelOffset + 3 ] = 0xFF;
+ }
+
+ // Add right child region
+ for ( unsigned int row = requiredChildRegion.y; row < imageHeight - requiredChildRegion.w; ++row )
+ {
+ unsigned int pixelOffset = row * bufferStride + ( imageWidth - 1 ) * bytesPerPixel;
+ pixbuffer[ pixelOffset ] = 0x00;
+ pixbuffer[ pixelOffset + 1 ] = 0x00;
+ pixbuffer[ pixelOffset + 2 ] = 0x00;
+ pixbuffer[ pixelOffset + 3 ] = 0xFF;
+ }
+}
+
+Integration::ResourcePointer CustomizeNinePatch( TestApplication& application,
+ unsigned int ninePatchImageWidth,
+ unsigned int ninePatchImageHeight,
+ const Vector4& requiredStretchBorder,
+ bool addChildRegion = false,
+ Vector4 requiredChildRegion = Vector4::ZERO )
+{
+ TestPlatformAbstraction& platform = application.GetPlatform();
+
+ Pixel::Format pixelFormat = Pixel::RGBA8888;
+
+ tet_infoline("Create Bitmap");
+ platform.SetClosestImageSize(Vector2( ninePatchImageWidth, ninePatchImageHeight));
+ Integration::Bitmap* bitmap = CreateBitmap( ninePatchImageWidth, ninePatchImageHeight, 0xFF, pixelFormat );
+
+ tet_infoline("Clear border regions");
+ InitialiseRegionsToZeroAlpha( bitmap, ninePatchImageWidth, ninePatchImageHeight, pixelFormat );
+
+ tet_infoline("Add Stretch regions to Bitmap");
+ AddStretchRegionsToImage( bitmap, ninePatchImageWidth, ninePatchImageHeight, requiredStretchBorder, pixelFormat );
+
+ if( addChildRegion )
+ {
+ tet_infoline("Add Child regions to Bitmap");
+ AddChildRegionsToImage( bitmap, ninePatchImageWidth, ninePatchImageHeight, requiredChildRegion, pixelFormat );
+ }
+
+ tet_infoline("Getting resource");
+ Integration::ResourcePointer resourcePtr(bitmap);
+ platform.SetResourceLoaded( 0, Dali::Integration::ResourceBitmap, resourcePtr );
+
+ return resourcePtr;
+}
+
} // namespace
DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uBlendColor", actualValue ) );
DALI_TEST_EQUALS( actualValue, testColor, TEST_LOCATION );
+ controlRenderer.SetOffStage( actor );
+ DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+
END_TEST;
}
+int UtcDaliRendererFactoryGetBorderRenderer1(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliRendererFactoryGetBorderRenderer1: Request border renderer with a Property::Map" );
+
+ RendererFactory factory = RendererFactory::Get();
+ DALI_TEST_CHECK( factory );
+
+ Property::Map propertyMap;
+ Vector4 testColor( 1.f, 0.5f, 0.3f, 0.2f );
+ float testSize = 5.f;
+ propertyMap.Insert("renderer-type", "border-renderer");
+ propertyMap.Insert("border-color", testColor);
+ propertyMap.Insert("border-size", testSize);
+
+ ControlRenderer controlRenderer = factory.GetControlRenderer(propertyMap);
+ DALI_TEST_CHECK( controlRenderer );
+
+ Actor actor = Actor::New();
+ actor.SetSize(200.f, 200.f);
+ Stage::GetCurrent().Add( actor );
+ controlRenderer.SetSize(Vector2(200.f, 200.f));
+ controlRenderer.SetOnStage( actor );
+
+ DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+
+ application.SendNotification();
+ application.Render(0);
+
+ Vector4 actualColor(Vector4::ZERO);
+ DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uBorderColor", actualColor ) );
+ DALI_TEST_EQUALS( actualColor, testColor, TEST_LOCATION );
+
+ float actualSize = 0.f;
+ DALI_TEST_CHECK( gl.GetUniformValue<float>( "uBorderSize", actualSize ) );
+ DALI_TEST_EQUALS( actualSize, testSize, TEST_LOCATION );
+
+ controlRenderer.SetOffStage( actor );
+ DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+
+ END_TEST;
+}
+
+int UtcDaliRendererFactoryGetBorderRenderer2(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliRendererFactoryGetBorderRenderer2: Request border renderer with a borderSize and a borderColor" );
+
+ RendererFactory factory = RendererFactory::Get();
+ DALI_TEST_CHECK( factory );
+
+ Vector4 testColor( 1.f, 0.5f, 0.3f, 0.2f );
+ float testSize = 5.f;
+
+ ControlRenderer controlRenderer = factory.GetControlRenderer(testSize, testColor);
+ DALI_TEST_CHECK( controlRenderer );
+
+ Actor actor = Actor::New();
+ actor.SetSize(200.f, 200.f);
+ Stage::GetCurrent().Add( actor );
+ controlRenderer.SetSize(Vector2(200.f, 200.f));
+ controlRenderer.SetOnStage( actor );
+
+ DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+
+ application.SendNotification();
+ application.Render(0);
+
+ Vector4 actualColor(Vector4::ZERO);
+ DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uBorderColor", actualColor ) );
+ DALI_TEST_EQUALS( actualColor, testColor, TEST_LOCATION );
+
+ float actualSize = 0.f;
+ DALI_TEST_CHECK( gl.GetUniformValue<float>( "uBorderSize", actualSize ) );
+ DALI_TEST_EQUALS( actualSize, testSize, TEST_LOCATION );
+
+ END_TEST;
+}
+
+
int UtcDaliRendererFactoryGetLinearGradientRenderer(void)
{
ToolkitTestApplication application;
application.SendNotification();
application.Render(0);
+ controlRenderer.SetOffStage( actor );
+ DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+
END_TEST;
}
DALI_TEST_CHECK( gl.GetUniformValue< int >( "sTexture", textureUnit ) );
DALI_TEST_EQUALS( textureUnit, 0, TEST_LOCATION );
+ controlRenderer.SetOffStage( actor );
+ DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+
END_TEST;
}
END_TEST;
}
+int UtcDaliRendererFactoryGetNPatchRenderer1(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliRendererFactoryGetNPatchRenderer1: Request n-patch renderer with a Property::Map" );
+
+ RendererFactory factory = RendererFactory::Get();
+ DALI_TEST_CHECK( factory );
+
+ const unsigned int ninePatchImageHeight = 18;
+ const unsigned int ninePatchImageWidth = 28;
+ const Vector4 requiredStretchBorder( 3, 4, 5, 6 );
+ Integration::ResourcePointer ninePatchResource = CustomizeNinePatch( application, ninePatchImageWidth, ninePatchImageHeight, requiredStretchBorder );
+
+ Property::Map propertyMap;
+ propertyMap.Insert( "renderer-type", "n-patch-renderer" );
+ propertyMap.Insert( "image-url", TEST_NPATCH_FILE_NAME );
+
+ ControlRenderer controlRenderer = factory.GetControlRenderer( propertyMap );
+ DALI_TEST_CHECK( controlRenderer );
+
+ Actor actor = Actor::New();
+ actor.SetSize( 200.f, 200.f );
+ Stage::GetCurrent().Add( actor );
+ controlRenderer.SetSize( Vector2(200.f, 200.f) );
+ controlRenderer.SetOnStage( actor );
+
+ DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+ DALI_TEST_CHECK( actor.GetRendererAt(0u).GetMaterial().GetNumberOfSamplers() == 1u );
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ application.SendNotification();
+ application.Render();
+
+ Integration::ResourceRequest* request = application.GetPlatform().GetRequest();
+ if(request)
+ {
+ application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, ninePatchResource );
+ }
+
+ application.Render();
+ application.SendNotification();
+
+ DALI_TEST_CHECK(application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc));
+
+ DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+
+ int textureUnit = -1;
+ DALI_TEST_CHECK( gl.GetUniformValue< int >( "sTexture", textureUnit ) );
+ DALI_TEST_EQUALS( textureUnit, 0, TEST_LOCATION );
+
+ controlRenderer.SetOffStage( actor );
+ DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+
+ END_TEST;
+}
+
+int UtcDaliRendererFactoryGetNPatchRenderer2(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliRendererFactoryGetNPatchRenderer2: Request n-patch renderer with an image url" );
+
+ RendererFactory factory = RendererFactory::Get();
+ DALI_TEST_CHECK( factory );
+
+ const unsigned int ninePatchImageHeight = 18;
+ const unsigned int ninePatchImageWidth = 28;
+ const Vector4 requiredStretchBorder( 3, 4, 5, 6 );
+ Integration::ResourcePointer ninePatchResource = CustomizeNinePatch( application, ninePatchImageWidth, ninePatchImageHeight, requiredStretchBorder );
+
+ ControlRenderer controlRenderer = factory.GetControlRenderer( TEST_NPATCH_FILE_NAME );
+ DALI_TEST_CHECK( controlRenderer );
+
+ Actor actor = Actor::New();
+ actor.SetSize( 200.f, 200.f );
+ Stage::GetCurrent().Add( actor );
+ controlRenderer.SetSize( Vector2(200.f, 200.f) );
+ controlRenderer.SetOnStage( actor );
+
+ DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+ DALI_TEST_CHECK( actor.GetRendererAt(0u).GetMaterial().GetNumberOfSamplers() == 1u );
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ application.SendNotification();
+ application.Render();
+
+ Integration::ResourceRequest* request = application.GetPlatform().GetRequest();
+ if(request)
+ {
+ application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, ninePatchResource );
+ }
+
+ application.Render();
+ application.SendNotification();
+
+ DALI_TEST_CHECK(application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc));
+
+ int textureUnit = -1;
+ DALI_TEST_CHECK( gl.GetUniformValue< int >( "sTexture", textureUnit ) );
+ DALI_TEST_EQUALS( textureUnit, 0, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliRendererFactoryGetNPatchRendererN1(void)
+{
+ //This should still load but display an error image
+
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliRendererFactoryGetNPatchRendererN: Request n-patch renderer with an invalid image url" );
+
+ RendererFactory factory = RendererFactory::Get();
+ DALI_TEST_CHECK( factory );
+
+ ControlRenderer controlRenderer = factory.GetControlRenderer( "ERROR.9.jpg" );
+ DALI_TEST_CHECK( controlRenderer );
+
+ Actor actor = Actor::New();
+ actor.SetSize( 200.f, 200.f );
+ Stage::GetCurrent().Add( actor );
+ controlRenderer.SetSize( Vector2(200.f, 200.f) );
+ controlRenderer.SetOnStage( actor );
+
+ DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+ DALI_TEST_CHECK( actor.GetRendererAt(0u).GetMaterial().GetNumberOfSamplers() == 1u );
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ application.SendNotification();
+ application.Render();
+
+ int textureUnit = -1;
+ DALI_TEST_CHECK( gl.GetUniformValue< int >( "sTexture", textureUnit ) );
+ DALI_TEST_EQUALS( textureUnit, 0, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliRendererFactoryGetNPatchRendererN2(void)
+{
+ //This should still load but display an error image
+
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliRendererFactoryGetNPatchRendererN: Request n-patch renderer with an invalid Property::Map" );
+
+ RendererFactory factory = RendererFactory::Get();
+ DALI_TEST_CHECK( factory );
+
+ Property::Map propertyMap;
+ propertyMap.Insert( "renderer-type", "n-patch-renderer" );
+ propertyMap.Insert( "image-url", 111 );
+
+ ControlRenderer controlRenderer = factory.GetControlRenderer( propertyMap );
+ DALI_TEST_CHECK( controlRenderer );
+
+ Actor actor = Actor::New();
+ actor.SetSize( 200.f, 200.f );
+ Stage::GetCurrent().Add( actor );
+ controlRenderer.SetSize( Vector2(200.f, 200.f) );
+ controlRenderer.SetOnStage( actor );
+
+ DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+ DALI_TEST_CHECK( actor.GetRendererAt(0u).GetMaterial().GetNumberOfSamplers() == 1u );
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ application.SendNotification();
+ application.Render();
+
+ int textureUnit = -1;
+ DALI_TEST_CHECK( gl.GetUniformValue< int >( "sTexture", textureUnit ) );
+ DALI_TEST_EQUALS( textureUnit, 0, TEST_LOCATION );
+
+ END_TEST;
+}
+
int UtcDaliRendererFactoryResetRenderer1(void)
{
ToolkitTestApplication application;
application.SendNotification();
application.Render();
- // Cursor position should be the same than position2.
- Vector3 position6 = cursor.GetCurrentPosition();
-
- DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
-
// Should not be renderer.
DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 1u, TEST_LOCATION ); // The camera actor only.
@prefix@/include/dali/doc/dali-core-doc.h \
@prefix@/include/dali/doc/dali-adaptor-doc.h \
../../../../dali-toolkit/doc/dali-toolkit-doc.h \
- @prefix@/include/dali \
+ @prefix@/include/dali/public-api \
../../../../dali-toolkit/dali-toolkit/public-api \
../../../automated-tests/README.md
GetImplementation( *this ).SetOnStage(actor);
}
+void ControlRenderer::SetOffStage( Actor& actor )
+{
+ GetImplementation( *this ).SetOffStage(actor);
+}
+
+void ControlRenderer::CreatePropertyMap( Property::Map& map ) const
+{
+ GetImplementation( *this ).CreatePropertyMap( map );
+}
+
} // namespace Toolkit
} // namespace Dali
}
/**
- * ControlRenderer provides renderer for rendering the controls. A control may have multiple ControlRenders.
+ * @brief ControlRenderer provides renderer for rendering the controls. A control may have multiple ControlRenders.
+ *
* ControlRenderers reuses geometry, shader etc. across controls and manages the renderer and material to exist only when control is on-stage.
* It also responds to actor size and color change, and provides the clipping at the renderer level.
* Note: The control renderer responds to the the Actor::COLOR by blending it with the 'Multiply' operator.
ControlRenderer& operator=( const ControlRenderer& handle );
/**
- * Set the size of the painting area.
+ * @brief Set the size of the painting area.
*
* @param[in] size The size of the painting area.
*/
void SetSize( const Vector2& size );
/**
- * Set the depth index of this renderer.
+ * @brief Set the depth index of this renderer.
+ *
* Depth-index controls draw-order for overlapping renderers.
* Renderer with higher depth indices are rendered in front of other renderer with smaller values
*
void SetDepthIndex( float index );
/**
- * Renderer only exists when control is on stage.
+ * @brief Renderer only exists when control is on stage.
+ *
* This function should be called when the control put on stage.
*
* @param[in] actor The actor applying this renderer.
*/
void SetOnStage( Actor& actor );
+ /**
+ * @brief Renderer is destroyed when control is off stage.
+ *
+ * This function should be called when the control removes from stage
+ *
+ * @param[in] actor The actor applying this renderer.
+ */
+ void SetOffStage( Actor& actor );
+
+ /**
+ * @brief Create the property map representing this renderer.
+ *
+ * @param[out] map The renderer property map.
+ */
+ void CreatePropertyMap( Property::Map& map ) const;
+
public: // Not intended for application developers
explicit DALI_INTERNAL ControlRenderer(Internal::ControlRenderer *impl);
return GetImplementation( *this ).ResetRenderer( renderer, color );
}
+ControlRenderer RendererFactory::GetControlRenderer( float borderSize, const Vector4& borderColor )
+{
+ return GetImplementation( *this ).GetControlRenderer( borderSize, borderColor );
+}
+
ControlRenderer RendererFactory::GetControlRenderer( const Image& image )
{
return GetImplementation( *this ).GetControlRenderer( image );
return GetImplementation( *this ).ResetRenderer( renderer, image );
}
+ControlRenderer RendererFactory::GetControlRenderer( const std::string& url )
+{
+ return GetImplementation( *this ).GetControlRenderer( url );
+}
+
+bool RendererFactory::ResetRenderer( ControlRenderer& renderer, const std::string& url )
+{
+ return GetImplementation( *this ).ResetRenderer( renderer, url );
+}
+
} // namespace Toolkit
} // namespace Dali
}
/**
- * RendererFactory is a singleton object that provides and shares renderers for controls
+ * @brief RendererFactory is a singleton object that provides and shares renderers for controls
*
* The renderer type is required in the property map for requesting a control renderer.
*
* if the current renderer is a handle to an internal color renderer, set this color to it,
* else the renderer would be a handle to a newly created internal color renderer.
*
+ * @param[in] renderer The ControlRenderer to reset
+ * @param[in] color The color to be rendered.
* @return Whether a new internal control renderer is created.
*/
bool ResetRenderer( ControlRenderer& renderer, const Vector4& color );
/**
+ * @brief Request the control renderer to renderer the border with the given size and color.
+ *
+ * @param[in] borderSize The size of the border. Border size is the same along all edges.
+ * @param[in] borderColor The color of the border.
+ * @return The pointer pointing to the control renderer
+ */
+ ControlRenderer GetControlRenderer( float borderSize, const Vector4& borderColor );
+
+ /**
* @brief Request the control renderer to render the image.
*
* @param[in] image The image to be rendered.
* if the current renderer is a handle to an internal image renderer, set this image to it,
* else the renderer would be a handle to a newly created internal image renderer.
*
+ * @param[in] renderer The ControlRenderer to reset
+ * @param[in] image The Image to be rendered.
* @return Whether a new internal control renderer is created.
*/
bool ResetRenderer( ControlRenderer& renderer, const Image& image );
+ /**
+ * @brief Request the control renderer to render the given resource at the url.
+ *
+ * @param[in] url The URL to the resource to be rendered.
+ * @return The pointer pointing to the control renderer
+ */
+ ControlRenderer GetControlRenderer( const std::string& url );
+
+ /**
+ * @brief Request the current control renderer to render the given resource at the url
+ *
+ * if the current renderer is a handle to an internal image renderer, set this image to it,
+ * else the renderer would be a handle to a newly created internal image renderer.
+ *
+ * @param[in] renderer The ControlRenderer to reset
+ * @param[in] url The URL to the resource to be rendered.
+ * @return Whether a new internal control renderer is created.
+ */
+ bool ResetRenderer( ControlRenderer& renderer, const std::string& url );
+
private:
explicit DALI_INTERNAL RendererFactory(Internal::RendererFactory *impl);
{
enum
{
- MAX_SIZE = PROPERTY_START_INDEX ///< name "max-size", The maximum size the Popup can be, type VECTOR2
+ MAX_SIZE = PROPERTY_START_INDEX, ///< name "max-size", The maximum size the Popup can be, type VECTOR2
+ ENABLE_OVERSHOOT, ///< name "enable-overshoot", Whether the overshoot image is enabled, type BOOLEAN
};
};
// CLASS HEADER
#include "image-view-impl.h"
-// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/controls/image-view/image-view.h>
-
// EXTERNAL INCLUDES
#include <dali/public-api/images/resource-image.h>
#include <dali/public-api/object/type-registry.h>
#include <dali/devel-api/object/type-registry-helper.h>
#include <dali/devel-api/scripting/scripting.h>
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/controls/image-view/image-view.h>
+#include <dali-toolkit/devel-api/controls/renderer-factory/renderer-factory.h>
+#include <dali-toolkit/internal/controls/renderers/image/image-renderer.h>
+
namespace Dali
{
namespace
{
-#define MAKE_SHADER(A)#A
-
-const char* VERTEX_SHADER = MAKE_SHADER(
- attribute mediump vec2 aPosition;
- attribute highp vec2 aTexCoord;
- varying mediump vec2 vTexCoord;
- uniform mediump mat4 uMvpMatrix;
- uniform mediump vec3 uSize;
-
- void main()
- {
- mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);
- vertexPosition.xyz *= uSize;
- vertexPosition = uMvpMatrix * vertexPosition;
-
- vTexCoord = aTexCoord;
- gl_Position = vertexPosition;
- }
-);
-
-const char* FRAGMENT_SHADER = MAKE_SHADER(
- varying mediump vec2 vTexCoord;
- uniform sampler2D sTexture;
- uniform lowp vec4 uColor;
-
- void main()
- {
- gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;
- }
-);
-
-//TODO: remove when RendererFactory is implemented, so if there are multiple images that render as quads we only end up with one instance of geometry
-Geometry CreateGeometry( int width, int height )
-{
- // Create vertices
- const float halfWidth = 0.5f;
- const float halfHeight = 0.5f;
- struct TexturedQuadVertex { Vector2 position; Vector2 textureCoordinates; };
- TexturedQuadVertex texturedQuadVertexData[4] = { { Vector2(-halfWidth, -halfHeight), Vector2(0.f, 0.f) },
- { Vector2( halfWidth, -halfHeight), Vector2(1.f, 0.f) },
- { Vector2(-halfWidth, halfHeight), Vector2(0.f, 1.f) },
- { Vector2( halfWidth, halfHeight), Vector2(1.f, 1.f) } };
-
- Property::Map texturedQuadVertexFormat;
- texturedQuadVertexFormat["aPosition"] = Property::VECTOR2;
- texturedQuadVertexFormat["aTexCoord"] = Property::VECTOR2;
- PropertyBuffer texturedQuadVertices = PropertyBuffer::New( texturedQuadVertexFormat, 4 );
- texturedQuadVertices.SetData(texturedQuadVertexData);
-
- // Create indices
- //TODO: replace with triangle strip when Geometry supports it
- unsigned int indexData[6] = { 0, 3, 1, 0, 2, 3 };
- Property::Map indexFormat;
- indexFormat["indices"] = Property::INTEGER;
- PropertyBuffer indices = PropertyBuffer::New( indexFormat, 6 );
- indices.SetData(indexData);
-
- // Create the geometry object
- Geometry texturedQuadGeometry = Geometry::New();
- texturedQuadGeometry.AddVertexBuffer( texturedQuadVertices );
- texturedQuadGeometry.SetIndexBuffer( indices );
-
- return texturedQuadGeometry;
-}
-
BaseHandle Create()
{
return Toolkit::ImageView::New();
// Setup properties, signals and actions using the type-registry.
DALI_TYPE_REGISTRATION_BEGIN( Toolkit::ImageView, Toolkit::Control, Create );
-DALI_PROPERTY_REGISTRATION( Toolkit, ImageView, "resource-url", STRING, RESOURCE_URL )
+DALI_PROPERTY_REGISTRATION( Toolkit, ImageView, "image", MAP, IMAGE )
DALI_TYPE_REGISTRATION_END()
} // anonymous namespace
{
ImageView* impl = new ImageView();
- Dali::Toolkit::ImageView handle = Dali::Toolkit::ImageView( *impl );
+ Toolkit::ImageView handle = Toolkit::ImageView( *impl );
// Second-phase init of the implementation
// This can only be done after the CustomActor connection has been made...
void ImageView::SetImage( Image image )
{
- mImage = image;
+ if( mImage != image )
+ {
+ mUrl.clear();
+ mPropertyMap.Clear();
- ResourceImage resourceImage = ResourceImage::DownCast( mImage );
- if( resourceImage )
+ mImage = image;
+
+ bool newRendererCreated = false;
+ if( mRenderer )
+ {
+ newRendererCreated = Toolkit::RendererFactory::Get().ResetRenderer( mRenderer, image );
+ }
+ else
+ {
+ mRenderer = Toolkit::RendererFactory::Get().GetControlRenderer( image );
+ newRendererCreated = true;
+ }
+
+ //we need to inform any newly created renderers if it is on stage
+ if( newRendererCreated && Self().OnStage() )
+ {
+ CustomActor self = Self();
+ mRenderer.SetOnStage( self );
+ }
+
+ mImageSize = image ? ImageDimensions( image.GetWidth(), image.GetHeight() ) : ImageDimensions( 0, 0 );
+ }
+}
+
+void ImageView::SetImage( Property::Map map )
+{
+ mImage.Reset();
+ mUrl.clear();
+ mPropertyMap = map;
+
+ mRenderer = Toolkit::RendererFactory::Get().GetControlRenderer( mPropertyMap );
+
+ //we need to inform any newly created renderers if it is on stage
+ if( Self().OnStage() )
{
- mImageUrl = resourceImage.GetUrl();
+ CustomActor self = Self();
+ mRenderer.SetOnStage( self );
}
- else
+
+ int width = 0;
+ Property::Value* widthValue = mPropertyMap.Find( "width" );
+ if( widthValue )
{
- mImageUrl.clear();
+ widthValue->Get( width );
}
- if( mImage )
+ int height = 0;
+ Property::Value* heightValue = mPropertyMap.Find( "height" );
+ if( heightValue )
{
- if( Self().OnStage() )
- {
- AttachImage();
- }
- RelayoutRequest();
+ heightValue->Get( height );
}
- else
+
+ mImageSize = ImageDimensions( width, height );
+}
+
+void ImageView::SetImage( const std::string& url )
+{
+ if( mUrl != url )
{
+ mImage.Reset();
+ mPropertyMap.Clear();
+
+ mUrl = url;
+
+ bool newRendererCreated = false;
if( mRenderer )
{
- Self().RemoveRenderer( mRenderer );
+ newRendererCreated = Toolkit::RendererFactory::Get().ResetRenderer( mRenderer, mUrl );
+ }
+ else
+ {
+ mRenderer = Toolkit::RendererFactory::Get().GetControlRenderer( mUrl );
+ newRendererCreated = true;
}
- mSampler.Reset();
- mMaterial.Reset();
- mMesh.Reset();
- mRenderer.Reset();
- }
-}
-Image ImageView::GetImage() const
-{
- return mImage;
+ //we need to inform any newly created renderers if it is on stage
+ if( newRendererCreated && Self().OnStage() )
+ {
+ CustomActor self = Self();
+ mRenderer.SetOnStage( self );
+ }
+
+ mImageSize = ResourceImage::GetImageSize( mUrl );
+ }
}
Vector3 ImageView::GetNaturalSize()
{
- // if no image then use Control's natural size
Vector3 size;
- if( mImage )
+ size.x = mImageSize.GetWidth();
+ size.y = mImageSize.GetHeight();
+ size.z = std::min(size.x, size.y);
+
+ if( size.x > 0 && size.x > 0 )
{
- size.x = mImage.GetWidth();
- size.y = mImage.GetHeight();
- size.z = std::min(size.x, size.y);
+ return size;
}
else
{
- size = Control::GetNaturalSize();
+ // if no image then use Control's natural size
+ return Control::GetNaturalSize();
}
- return size;
}
float ImageView::GetHeightForWidth( float width )
{
- if( mImage )
+ if( mImageSize.GetWidth() > 0 && mImageSize.GetHeight() > 0 )
{
return GetHeightForWidthBase( width );
}
float ImageView::GetWidthForHeight( float height )
{
- if( mImage )
+ if( mImageSize.GetWidth() > 0 && mImageSize.GetHeight() > 0 )
{
return GetWidthForHeightBase( height );
}
// Private methods
//
-void ImageView::AttachImage()
-{
- if( !mRenderer )
- {
- Shader shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
- mMaterial = Material::New( shader );
-
- mSampler = Sampler::New( mImage, "sTexture" );
- mMaterial.AddSampler( mSampler );
-
- Vector3 size = Self().GetCurrentSize();
- mMesh = CreateGeometry( size.width, size.height );
- mRenderer = Renderer::New( mMesh, mMaterial );
- Self().AddRenderer( mRenderer );
- }
- else
- {
- mSampler.SetImage( mImage );
- }
-}
-
-void ImageView::OnRelayout( const Vector2& size, RelayoutContainer& container )
-{
- Control::OnRelayout( size, container );
-
- if( mRenderer )
- {
- mMesh = CreateGeometry( size.width, size.height );
- mRenderer.SetGeometry( mMesh );
- }
-}
-
void ImageView::OnStageConnection( int depth )
{
- if( mImage )
+ if( mRenderer )
{
- AttachImage();
+ CustomActor self = Self();
+ mRenderer.SetOnStage( self );
}
}
{
switch ( index )
{
- case Toolkit::ImageView::Property::RESOURCE_URL:
+ case Toolkit::ImageView::Property::IMAGE:
{
std::string imageUrl;
if( value.Get( imageUrl ) )
{
ImageView& impl = GetImpl( imageView );
- impl.mImageUrl = imageUrl;
+ impl.SetImage( imageUrl );
+ }
- Image image = ResourceImage::New( imageUrl );
- impl.SetImage( image );
+ // if its not a string then get a Property::Map from the property if possible.
+ Property::Map map;
+ if( value.Get( map ) )
+ {
+ ImageView& impl = GetImpl( imageView );
+ impl.SetImage( map );
}
+
break;
}
}
{
switch ( propertyIndex )
{
- case Toolkit::ImageView::Property::RESOURCE_URL:
+ case Toolkit::ImageView::Property::IMAGE:
{
- value = GetImpl( imageview ).mImageUrl;
+ ImageView& impl = GetImpl( imageview );
+ if ( !impl.mUrl.empty() )
+ {
+ value = impl.mUrl;
+ }
+ else if( impl.mImage )
+ {
+ Property::Map map;
+ Scripting::CreatePropertyMap( impl.mImage, map );
+ value = map;
+ }
+ else if( !impl.mPropertyMap.Empty() )
+ {
+ value = impl.mPropertyMap;
+ }
break;
}
}
*/
// EXTERNAL INCLUDES
-#include <dali/devel-api/rendering/renderer.h>
+#include <dali/public-api/object/property-map.h>
// INTERNAL INCLUDES
+#include <dali-toolkit/internal/controls/renderers/image/image-renderer.h>
#include <dali-toolkit/public-api/controls/control-impl.h>
#include <dali-toolkit/public-api/controls/image-view/image-view.h>
*/
virtual ~ImageView();
+
+
public:
/**
* Create a new ImageView.
static Toolkit::ImageView New();
/**
- * @copydoc Dali::Toolkit::SetImage( Image image )
+ * @copydoc Dali::Toolkit::SetImage
*/
void SetImage( Image image );
/**
- * @copydoc Dali::Toolkit::Image GetImage() const
+ * @brief Sets this ImageView from an Dali::Property::Map
+ *
+ * If the handle is empty, ImageView will display nothing
+ * @param[in] map The Dali::Property::Map to use for to display.
+ */
+ void SetImage( Dali::Property::Map map );
+
+ /**
+ * @copydoc Dali::Toolkit::SetImage
*/
- Image GetImage() const;
+ void SetImage( const std::string& imageUrl );
// Properties
/**
private: // From Control
/**
- * @copydoc Toolkit::Control::OnRelayout()
- */
- virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
-
- /**
* @copydoc Toolkit::Control::OnStageConnect()
*/
virtual void OnStageConnection( int depth );
void AttachImage();
private:
+ // Undefined
+ ImageView( const ImageView& );
+ ImageView& operator=( const ImageView& );
+
+private:
+ Toolkit::ControlRenderer mRenderer;
+ ImageDimensions mImageSize;
- Sampler mSampler;
- Material mMaterial;
- Geometry mMesh;
- Renderer mRenderer;
- Image mImage;
- std::string mImageUrl;
+ std::string mUrl; ///< the url for the image if the image came from a URL, empty otherwise
+ Image mImage; ///< the Image if the image came from a Image, null otherwise
+ Property::Map mPropertyMap; ///< the Property::Map if the image came from a Property::Map, empty otherwise
};
} // namespace Internal
#include <dali/public-api/object/type-registry.h>
#include <dali/devel-api/object/type-registry-helper.h>
+// INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/controls/renderer-factory/renderer-factory.h>
+
namespace Dali
{
DALI_TYPE_REGISTRATION_END()
-const char* DEFAULT_FRAME_IMAGE_PATH = DALI_IMAGE_DIR "magnifier-image-frame.png";
-
-const float IMAGE_BORDER_INDENT = 14.0f; ///< Indent of border in pixels.
+const float IMAGE_BORDER_INDENT = 5.0f; ///< Indent of border in pixels.
struct CameraActorPositionConstraint
{
{
Actor self(Self());
- Image image = ResourceImage::New( DEFAULT_FRAME_IMAGE_PATH );
- mFrame = ImageActor::New( image );
- mFrame.SetStyle( ImageActor::STYLE_NINE_PATCH );
+ mFrame = Actor::New( );
mFrame.SetPositionInheritanceMode(DONT_INHERIT_POSITION);
mFrame.SetInheritScale(true);
mFrame.SetResizePolicy( ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT, Dimension::ALL_DIMENSIONS );
Vector3 sizeOffset(IMAGE_BORDER_INDENT*2.f - 2.f, IMAGE_BORDER_INDENT*2.f - 2.f, 0.0f);
mFrame.SetSizeModeFactor( sizeOffset );
+ //TODO Set the renderer onto the control self when Actor::RemoveRenderer is supported
+ Toolkit::RendererFactory rendererFactory = Toolkit::RendererFactory::Get();
+ Toolkit::ControlRenderer borderRenderer = rendererFactory.GetControlRenderer(IMAGE_BORDER_INDENT, Color::WHITE);
+ borderRenderer.SetOnStage( mFrame );
+
Constraint constraint = Constraint::New<Vector3>( mFrame, Actor::Property::POSITION, EqualToConstraint() );
constraint.AddSource( ParentSource( Actor::Property::WORLD_POSITION ) );
constraint.Apply();
- mFrame.SetNinePatchBorder( Vector4::ONE * IMAGE_BORDER_INDENT );
self.Add(mFrame);
}
else if(!visible && mFrame)
RenderTask mTask; ///< Render Task to render the source actor contents.
CameraActor mCameraActor; ///< CameraActor attached to RenderTask
- ImageActor mFrame; ///< The Magnifier Frame
+ Actor mFrame; ///< The Magnifier Frame
Actor mSourceActor; ///< Source Delegate Actor represents the source position to read.
float mDefaultCameraDistance; ///< Default RenderTask's camera distance from target.
Vector3 mActorSize; ///< The Actor size
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "border-renderer.h"
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+
+//INTERNAL INCLUDES
+#include <dali-toolkit/internal/controls/renderers/renderer-factory-impl.h>
+#include <dali-toolkit/internal/controls/renderers/renderer-factory-cache.h>
+#include <dali-toolkit/internal/controls/renderers/control-renderer-data-impl.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+namespace
+{
+const char * const RENDERER_TYPE("renderer-type");
+const char * const RENDERER_TYPE_VALUE("border-renderer");
+
+const char * const COLOR_NAME("border-color");
+const char * const COLOR_UNIFORM_NAME("uBorderColor");
+const char * const SIZE_NAME("border-size");
+const char * const SIZE_UNIFORM_NAME("uBorderSize");
+
+const char * const POSITION_ATTRIBUTE_NAME("aPosition");
+const char * const DRIFT_ATTRIBUTE_NAME("aDrift");
+const char * const INDEX_NAME("indices");
+
+
+const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
+ attribute mediump vec2 aPosition;\n
+ attribute mediump vec2 aDrift;\n
+ uniform mediump mat4 uMvpMatrix;\n
+ uniform mediump vec3 uSize;\n
+ uniform mediump float uBorderSize;\n
+ \n
+ void main()\n
+ {\n
+ vec2 position = aPosition*uSize.xy + aDrift*uBorderSize;\n
+ gl_Position = uMvpMatrix * vec4(position, 0.0, 1.0);\n
+ }\n
+);
+
+const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
+ uniform lowp vec4 uColor;\n
+ uniform lowp vec4 uBorderColor;\n
+ \n
+ void main()\n
+ {\n
+ gl_FragColor = uBorderColor*uColor;\n
+ }\n
+);
+}
+
+BorderRenderer::BorderRenderer()
+: ControlRenderer(),
+ mBorderColor( Color::TRANSPARENT ),
+ mBorderSize( 0.f ),
+ mBorderColorIndex( Property::INVALID_INDEX ),
+ mBorderSizeIndex( Property::INVALID_INDEX )
+{
+}
+
+BorderRenderer::~BorderRenderer()
+{
+}
+
+void BorderRenderer::Initialize( RendererFactoryCache& factoryCache, const Property::Map& propertyMap )
+{
+ Initialize( factoryCache );
+
+ Property::Value* color = propertyMap.Find( COLOR_NAME );
+ if( !( color && color->Get(mBorderColor) ) )
+ {
+ DALI_LOG_ERROR( "Fail to provide a border color to the BorderRenderer object" );
+ }
+
+ Property::Value* size = propertyMap.Find( SIZE_NAME );
+ if( !( size && size->Get(mBorderSize) ) )
+ {
+ DALI_LOG_ERROR( "Fail to provide a border size to the BorderRenderer object" );
+ }
+}
+
+void BorderRenderer::SetClipRect( const Rect<int>& clipRect )
+{
+ ControlRenderer::SetClipRect( clipRect );
+
+ //ToDo: renderer responds to the clipRect change
+}
+
+void BorderRenderer::DoSetOnStage( Actor& actor )
+{
+ mBorderColorIndex = (mImpl->mRenderer).RegisterProperty( COLOR_UNIFORM_NAME, mBorderColor );
+ if( mBorderColor.a < 1.f )
+ {
+ (mImpl->mRenderer).GetMaterial().SetBlendMode( BlendingMode::ON );
+ }
+ mBorderSizeIndex = (mImpl->mRenderer).RegisterProperty( SIZE_UNIFORM_NAME, mBorderSize );
+}
+
+void BorderRenderer::CreatePropertyMap( Property::Map& map ) const
+{
+ map.Clear();
+ map.Insert( RENDERER_TYPE, RENDERER_TYPE_VALUE );
+ map.Insert( COLOR_NAME, mBorderColor );
+ map.Insert( SIZE_NAME, mBorderSize );
+}
+
+void BorderRenderer::Initialize( RendererFactoryCache& factoryCache)
+{
+ mImpl->mGeometry = factoryCache.GetGeometry( RendererFactoryCache::BORDER_GEOMETRY );
+ if( !(mImpl->mGeometry) )
+ {
+ mImpl->mGeometry = CreateBorderGeometry();
+ factoryCache.SaveGeometry( RendererFactoryCache::QUAD_GEOMETRY, mImpl->mGeometry );
+ }
+
+ mImpl->mShader = factoryCache.GetShader( RendererFactoryCache::BORDER_SHADER );
+ if( !(mImpl->mShader) )
+ {
+ mImpl->mShader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
+ factoryCache.SaveShader( RendererFactoryCache::COLOR_SHADER, mImpl->mShader );
+ }
+}
+
+void BorderRenderer::SetBorderColor(const Vector4& color)
+{
+ mBorderColor = color;
+
+ if( mImpl->mIsOnStage )
+ {
+ (mImpl->mRenderer).SetProperty( mBorderColorIndex, color );
+ if( color.a < 1.f && (mImpl->mRenderer).GetMaterial().GetBlendMode() != BlendingMode::ON)
+ {
+ (mImpl->mRenderer).GetMaterial().SetBlendMode( BlendingMode::ON );
+ }
+ }
+}
+
+void BorderRenderer::SetBorderSize( float size )
+{
+ mBorderSize = size;
+
+ if( mImpl->mIsOnStage )
+ {
+ (mImpl->mRenderer).SetProperty( mBorderSizeIndex, size );
+ }
+}
+
+/**
+ * Vertices and triangles of the border geometry:
+ *
+ * vertex position = aPosition*uSize.xy + aDrift*uBorderSize;
+ *
+ * 0--1--2--3
+ * | /| /| /|
+ * |/ |/ |/ |
+ * 4--5--6--7
+ * | /| | /|
+ * |/ | |/ |
+ * 8--9--10-11
+ * | /| /| /|
+ * |/ |/ |/ |
+ * 12-13-14-15
+ */
+Geometry BorderRenderer::CreateBorderGeometry()
+{
+ const float halfWidth = 0.5f;
+ const float halfHeight = 0.5f;
+ struct BorderVertex { Vector2 position; Vector2 drift;};
+ BorderVertex borderVertexData[16] =
+ {
+ { Vector2(-halfWidth, -halfHeight), Vector2(0.f, 0.f) },
+ { Vector2(-halfWidth, -halfHeight), Vector2(1.f, 0.f) },
+ { Vector2(halfWidth, -halfHeight), Vector2(-1.f, 0.f) },
+ { Vector2(halfWidth, -halfHeight), Vector2(0.f, 0.f) },
+
+ { Vector2(-halfWidth, -halfHeight), Vector2(0.f, 1.f) },
+ { Vector2(-halfWidth, -halfHeight), Vector2(1.f, 1.f) },
+ { Vector2(halfWidth, -halfHeight), Vector2(-1.f, 1.f) },
+ { Vector2(halfWidth, -halfHeight), Vector2(0.f, 1.f) },
+
+ { Vector2(-halfWidth, halfHeight), Vector2(0.f, -1.f) },
+ { Vector2(-halfWidth, halfHeight), Vector2(1.f, -1.f) },
+ { Vector2(halfWidth, halfHeight), Vector2(-1.f, -1.f) },
+ { Vector2(halfWidth, halfHeight), Vector2(0.f, -1.f) },
+
+ { Vector2(-halfWidth, halfHeight), Vector2(0.f, 0.f) },
+ { Vector2(-halfWidth, halfHeight), Vector2(1.f, 0.f) },
+ { Vector2(halfWidth, halfHeight), Vector2(-1.f, 0.f) },
+ { Vector2(halfWidth, halfHeight), Vector2(0.f, 0.f) },
+ };
+
+ Property::Map borderVertexFormat;
+ borderVertexFormat[POSITION_ATTRIBUTE_NAME] = Property::VECTOR2;
+ borderVertexFormat[DRIFT_ATTRIBUTE_NAME] = Property::VECTOR2;
+ PropertyBuffer borderVertices = PropertyBuffer::New( borderVertexFormat, 16 );
+ borderVertices.SetData(borderVertexData);
+
+ // Create indices
+ unsigned int indexData[48] = { 0, 4, 1, 1, 4, 5, 1, 5, 2, 2, 5, 6, 2, 6,3, 3, 6, 7,
+ 4, 8, 5, 5, 8, 9, 6, 10, 7, 7, 10, 11,
+ 8, 12, 9, 9, 12, 13, 9, 13, 10, 10, 13, 14, 10, 11, 14, 11, 14, 15};
+
+ Property::Map indexFormat;
+ indexFormat[INDEX_NAME] = Property::INTEGER;
+ PropertyBuffer indices = PropertyBuffer::New( indexFormat, 48 );
+ indices.SetData(indexData);
+
+ // Create the geometry object
+ Geometry geometry = Geometry::New();
+ geometry.AddVertexBuffer( borderVertices );
+ geometry.SetIndexBuffer( indices );
+
+ return geometry;
+}
+
+} // namespace Internal
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_TOOLKIT_INTERNAL_BORDER_RENDERER_H__
+#define __DALI_TOOLKIT_INTERNAL_BORDER_RENDERER_H__
+
+/*
+ * 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.
+ *
+ */
+// EXTERNAL INCLUDES
+#include <dali/devel-api/rendering/geometry.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/controls/renderers/control-renderer-impl.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+/**
+ * The renderer which renders a solid color to the control's quad border fixed to a specified size.
+ *
+ * The following properties are required for create a BorderRender
+ *
+ * | %Property Name | Type |
+ * |------------------|-------------|
+ * | border-color | VECTOR4 |
+ * | border-size | FLOAT |
+ */
+
+class BorderRenderer : public ControlRenderer
+{
+public:
+
+ /**
+ * @brief Constructor.
+ */
+ BorderRenderer();
+
+ /**
+ * @brief A reference counted object may only be deleted by calling Unreference().
+ */
+ virtual ~BorderRenderer();
+
+public: // from ControlRenderer
+
+ /**
+ * @copydoc ControlRenderer::Initialize
+ */
+ virtual void Initialize( RendererFactoryCache& factoryCache, const Property::Map& propertyMap );
+
+ /**
+ * @copydoc ControlRenderer::SetClipRect
+ */
+ virtual void SetClipRect( const Rect<int>& clipRect );
+
+protected:
+ /**
+ * @copydoc ControlRenderer::DoSetOnStage
+ */
+ virtual void DoSetOnStage( Actor& actor );
+
+ /**
+ * @copydoc ControlRenderer::CreatePropertyMap
+ */
+ virtual void CreatePropertyMap( Property::Map& map ) const;
+
+public:
+
+ /**
+ * Request the geometry and shader from the cache, if not available, create and save to the cache for sharing.
+ *
+ * @param[in] factoryCache A pointer pointing to the RendererFactoryCache object
+ */
+ void Initialize( RendererFactoryCache& factoryCache );
+
+ /**
+ * Set the color of the border.
+ * @param[in] color The border color.
+ */
+ void SetBorderColor( const Vector4& color);
+
+ /**
+ * Set the size of the border.
+ * @param[in] size The border size.
+ */
+ void SetBorderSize( float size );
+
+private:
+
+ /**
+ * Create the geometry which presents the border.
+ * @return The border geometry
+ */
+ Geometry CreateBorderGeometry();
+
+ // Undefined
+ BorderRenderer( const BorderRenderer& borderRenderer );
+
+ // Undefined
+ BorderRenderer& operator=( const BorderRenderer& borderRenderer );
+
+private:
+
+ Vector4 mBorderColor;
+ float mBorderSize;
+
+ Property::Index mBorderColorIndex;
+ Property::Index mBorderSizeIndex;
+};
+
+} // namespace Internal
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif /* __DALI_TOOLKIT_INTERNAL_BORDER_RENDERER_H__ */
namespace
{
+const char * const RENDERER_TYPE("renderer-type");
+const char * const RENDERER_TYPE_VALUE("color-renderer");
const char * const COLOR_NAME("blend-color");
const char * const COLOR_UNIFORM_NAME("uBlendColor");
//ToDo: renderer applies the offset
}
+void ColorRenderer::CreatePropertyMap( Property::Map& map ) const
+{
+ map.Clear();
+ map.Insert( RENDERER_TYPE, RENDERER_TYPE_VALUE );
+ map.Insert( COLOR_NAME, mBlendColor );
+}
+
void ColorRenderer::DoSetOnStage( Actor& actor )
{
mBlendColorIndex = (mImpl->mRenderer).RegisterProperty( COLOR_UNIFORM_NAME, mBlendColor );
*/
virtual void SetOffset( const Vector2& offset );
+ /**
+ * @copydoc ControlRenderer::CreatePropertyMap
+ */
+ virtual void CreatePropertyMap( Property::Map& map ) const;
+
protected:
/**
* @copydoc ControlRenderer::DoSetOnStage
void SetOnStage( Actor& actor );
/**
- * ToDo: Add this function to Toolkit::ControlRenderer when the Renderer can be removed from actor properly.
- *
- * Renderer is destroyed when control is off stage.
- * This function should be called when the control removes from stage
- *
- * @param[in] actor The actor applying this renderer.
+ * @copydoc Toolkit::ControlRenderer::SetOffStage
*/
void SetOffStage( Actor& actor );
+ /**
+ * @copydoc Toolkit::ControlRenderer::CreatePropertyMap
+ */
+ virtual void CreatePropertyMap( Property::Map& map ) const = 0;
+
protected:
/**
#include "gradient-renderer.h"
// EXTERNAL INCLUDES
+#include <typeinfo>
#include <dali/integration-api/debug.h>
#include <dali/public-api/common/dali-vector.h>
#include <dali/public-api/images/buffer-image.h>
namespace
{
+const char * const RENDERER_TYPE("renderer-type");
+const char * const RENDERER_TYPE_VALUE("gradient-renderer");
+
// properties: linear gradient
const char * const GRADIENT_START_POSITION_NAME("gradient-start-position"); // Property::VECTOR2
const char * const GRADIENT_END_POSITION_NAME("gradient-end-position"); // Property::VECTOR2
// string values
const char * const UNIT_USER_SPACE("user-space");
+const char * const UNIT_BOUNDING_BOX("object-bounding-box");
+const char * const SPREAD_PAD("pad");
const char * const SPREAD_REFLECT("reflect");
const char * const SPREAD_REPEAT("repeat");
//ToDo: renderer applies the offset
}
+void GradientRenderer::CreatePropertyMap( Property::Map& map ) const
+{
+ map.Clear();
+ map.Insert( RENDERER_TYPE, RENDERER_TYPE_VALUE );
+
+ Gradient::GradientUnits units = mGradient->GetGradientUnits();
+ if( units == Gradient::USER_SPACE_ON_USE )
+ {
+ map.Insert( GRADIENT_UNITS_NAME, UNIT_USER_SPACE );
+ }
+ else // if( units == Gradient::OBJECT_BOUNDING_BOX )
+ {
+ map.Insert( GRADIENT_UNITS_NAME, UNIT_BOUNDING_BOX );
+ }
+
+ Gradient::SpreadMethod spread = mGradient->GetSpreadMethod();
+ if( spread == Gradient::PAD )
+ {
+ map.Insert( GRADIENT_SPREAD_METHOD_NAME, SPREAD_PAD );
+ }
+ else if( spread == Gradient::REFLECT )
+ {
+ map.Insert( GRADIENT_SPREAD_METHOD_NAME, SPREAD_REFLECT );
+ }
+ else // if( units == Gradient::REPEAT )
+ {
+ map.Insert( GRADIENT_SPREAD_METHOD_NAME, SPREAD_REPEAT );
+ }
+
+ const Vector<Gradient::GradientStop>& stops( mGradient->GetStops() );
+ Property::Array offsets;
+ Property::Array colors;
+ for( unsigned int i=0; i<stops.Count(); i++ )
+ {
+ offsets.PushBack( stops[i].mOffset );
+ colors.PushBack( stops[i].mStopColor );
+ }
+
+ map.Insert( GRADIENT_STOP_OFFSET_NAME, offsets );
+ map.Insert( GRADIENT_STOP_COLOR_NAME, colors );
+
+ if( &typeid( *mGradient ) == &typeid(LinearGradient) )
+ {
+ LinearGradient* gradient = static_cast<LinearGradient*>( mGradient.Get() );
+ map.Insert( GRADIENT_START_POSITION_NAME, gradient->GetStartPosition() );
+ map.Insert( GRADIENT_END_POSITION_NAME, gradient->GetEndPosition() );
+ }
+ else // if( &typeid( *mGradient ) == &typeid(RadialGradient) )
+ {
+ RadialGradient* gradient = static_cast<RadialGradient*>( mGradient.Get() );
+ map.Insert( GRADIENT_CENTER_NAME, gradient->GetCenter() );
+ map.Insert( GRADIENT_RADIUS_NAME, gradient->GetRadius() );
+ }
+}
+
void GradientRenderer::DoSetOnStage( Actor& actor )
{
mGradientTransformIndex = (mImpl->mRenderer).RegisterProperty( UNIFORM_ALIGNMENT_MATRIX_NAME, mGradientTransform );
Property::Value* stopColorValue = propertyMap.Find( GRADIENT_STOP_COLOR_NAME );
if( stopOffsetValue && stopColorValue )
{
- Property::Array* offsetArray = stopOffsetValue->GetArray();
+ Vector<float> offsetArray;
Property::Array* colorArray = stopColorValue->GetArray();
- if( offsetArray && colorArray )
+ if( colorArray && GetStopOffsets( stopOffsetValue, offsetArray ))
{
- unsigned int numStop = offsetArray->Count() < colorArray->Count() ?
- offsetArray->Count() : colorArray->Count();
- float offset;
+ unsigned int numStop = offsetArray.Count() < colorArray->Count() ?
+ offsetArray.Count() : colorArray->Count();
Vector4 color;
for( unsigned int i=0; i<numStop; i++ )
{
- if( (offsetArray->GetElementAt(i)).Get(offset)
- && (colorArray->GetElementAt(i)).Get(color) )
+ if( (colorArray->GetElementAt(i)).Get(color) )
{
- mGradient->AddStop( offset, color);
+ mGradient->AddStop( offsetArray[i], color);
numValidStop++;
}
}
}
}
+
if( numValidStop < 1u ) // no valid stop
{
return false;
return true;
}
+bool GradientRenderer::GetStopOffsets(const Property::Value* value, Vector<float>& stopOffsets)
+{
+ Vector2 offset2;
+ if( value->Get( offset2 ) )
+ {
+ stopOffsets.PushBack( offset2.x );
+ stopOffsets.PushBack( offset2.y );
+ return true;
+ }
+
+ Vector3 offset3;
+ if( value->Get( offset3 ) )
+ {
+ stopOffsets.PushBack( offset3.x );
+ stopOffsets.PushBack( offset3.y );
+ stopOffsets.PushBack( offset3.z );
+ return true;
+ }
+
+ Vector4 offset4;
+ if( value->Get( offset4 ) )
+ {
+ stopOffsets.PushBack( offset4.x );
+ stopOffsets.PushBack( offset4.y );
+ stopOffsets.PushBack( offset4.z );
+ stopOffsets.PushBack( offset4.w );
+ return true;
+ }
+
+ Property::Array* offsetArray = value->GetArray();
+ if( offsetArray )
+ {
+ unsigned int numStop = offsetArray->Count();
+ float offset;
+ for( unsigned int i=0; i<numStop; i++ )
+ {
+ if( offsetArray->GetElementAt(i).Get(offset) )
+ {
+ stopOffsets.PushBack( offset );
+ }
+ }
+ return true;
+ }
+
+ return false;
+}
+
} // namespace Internal
} // namespace Toolkit
*/
virtual void SetOffset( const Vector2& offset );
+ /**
+ * @copydoc ControlRenderer::CreatePropertyMap
+ */
+ virtual void CreatePropertyMap( Property::Map& map ) const;
+
protected:
/**
* @copydoc ControlRenderer::DoSetOnStage
*/
bool NewGradient(Type gradientType, const Property::Map& propertyMap);
+ /**
+ * Get the stop-offsets from the property.
+ * The valid property type are ARRAY, VECTOR2, VECTOR3, VECTOR4.
+ *
+ * @param[in] value The property value of stop-offsets
+ * @param[out] stopOffsets The vector contains the stop offset values.
+ */
+ static bool GetStopOffsets(const Property::Value* value, Vector<float>& stopOffsets);
+
// Undefined
GradientRenderer( const GradientRenderer& gradientRenderer );
mGradientStops.PushBack( GradientStop( Clamp( offset, 0.f, 1.f ), color) );
}
+const Vector<Gradient::GradientStop>& Gradient::GetStops()
+{
+ return mGradientStops;
+}
+
void Gradient::SetGradientUnits( GradientUnits gradientUnits )
{
mGradientUnits = gradientUnits;
void AddStop(float offset, const Vector4& color);
/**
+ * Get the gradient stops.
+ * @return The vector of gradient stops.
+ */
+ const Vector<GradientStop>& GetStops();
+
+ /**
* Set the coordinate system used by the gradient attributes.
* @param[in] gradientUnits The the attributes are defined using the current user coordinate system or the bounding box of the shape.
*/
namespace
{
+const char * const RENDERER_TYPE("renderer-type");
+const char * const RENDERER_TYPE_VALUE("image-renderer");
+// property names
const char * const IMAGE_URL_NAME("image-url");
const char * const IMAGE_FITTING_MODE("image-fitting-mode");
const char * const IMAGE_SAMPLING_MODE("image-sampling-mode");
const char * const IMAGE_DESIRED_WIDTH("image-desired-width");
const char * const IMAGE_DESIRED_HEIGHT("image-desired-height");
-std::string TEXTURE_UNIFORM_NAME = "sTexture";
+// fitting modes
+const char * const SHRINK_TO_FIT("shrink-to-fit");
+const char * const SCALE_TO_FILL("scale-to-fill");
+const char * const FIT_WIDTH("fit-width");
+const char * const FIT_HEIGHT("fit-height");
+const char * const DEFAULT("default");
+
+// sampling modes
+const char * const BOX("box");
+const char * const NEAREST("nearest");
+const char * const LINEAR("linear");
+const char * const BOX_THEN_NEAREST("box-then-nearest");
+const char * const BOX_THEN_LINEAR("box-then-linear");
+const char * const NO_FILTER("no-filter");
+const char * const DONT_CARE("dont-care");
-#define MAKE_SHADER(A)#A
+std::string TEXTURE_UNIFORM_NAME = "sTexture";
const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
attribute mediump vec2 aPosition;\n
fittingValue->Get( fitting );
mFittingMode = FittingMode::DEFAULT;
- if( fitting == "shrink-to-fit" )
+ if( fitting == SHRINK_TO_FIT )
{
mFittingMode = FittingMode::SHRINK_TO_FIT;
}
- else if( fitting == "scale-to-fill" )
+ else if( fitting == SCALE_TO_FILL )
{
mFittingMode = FittingMode::SCALE_TO_FILL;
}
- else if( fitting == "fit-width" )
+ else if( fitting == FIT_WIDTH )
{
mFittingMode = FittingMode::FIT_WIDTH;
}
- else if( fitting == "fit-height" )
+ else if( fitting == FIT_HEIGHT )
{
mFittingMode = FittingMode::FIT_HEIGHT;
}
- else if( fitting == "default" )
+ else if( fitting == DEFAULT )
{
mFittingMode = FittingMode::DEFAULT;
}
samplingValue->Get( sampling );
mSamplingMode = SamplingMode::DEFAULT;
- if( sampling == "box" )
+ if( sampling == BOX )
{
mSamplingMode = SamplingMode::BOX;
}
- else if( sampling == "nearest" )
+ else if( sampling == NEAREST )
{
mSamplingMode = SamplingMode::NEAREST;
}
- else if( sampling == "linear" )
+ else if( sampling == LINEAR )
{
mSamplingMode = SamplingMode::LINEAR;
}
- else if( sampling == "box-then-nearest" )
+ else if( sampling == BOX_THEN_NEAREST )
{
mSamplingMode = SamplingMode::BOX_THEN_NEAREST;
}
- else if( sampling == "box-then-linear" )
+ else if( sampling == BOX_THEN_LINEAR )
{
mSamplingMode = SamplingMode::BOX_THEN_LINEAR;
}
- else if( sampling == "no-filter" )
+ else if( sampling == NO_FILTER )
{
mSamplingMode = SamplingMode::NO_FILTER;
}
- else if( sampling == "dont-care" )
+ else if( sampling == DONT_CARE )
{
mSamplingMode = SamplingMode::DONT_CARE;
}
- else if( sampling == "default" )
+ else if( sampling == DEFAULT )
{
mSamplingMode = SamplingMode::DEFAULT;
}
{
mImage.Reset();
}
+}
+
+void ImageRenderer::CreatePropertyMap( Property::Map& map ) const
+{
+ map.Clear();
+ map.Insert( RENDERER_TYPE, RENDERER_TYPE_VALUE );
+ if( !mImageUrl.empty() )
+ {
+ map.Insert( IMAGE_URL_NAME, mImageUrl );
+ map.Insert( IMAGE_DESIRED_WIDTH, mDesiredSize.GetWidth() );
+ map.Insert( IMAGE_DESIRED_HEIGHT, mDesiredSize.GetHeight() );
+ }
+ else if( mImage )
+ {
+ map.Insert( IMAGE_DESIRED_WIDTH, static_cast<int>(mImage.GetWidth()) );
+ map.Insert( IMAGE_DESIRED_HEIGHT, static_cast<int>(mImage.GetHeight()) );
+
+ ResourceImage resourceImage = ResourceImage::DownCast(mImage);
+ if( resourceImage )
+ {
+ map.Insert( IMAGE_URL_NAME, resourceImage.GetUrl() );
+ }
+ }
- ControlRenderer::SetOffStage( actor );
+ switch( mFittingMode )
+ {
+ case Dali::FittingMode::FIT_HEIGHT:
+ {
+ map.Insert( IMAGE_FITTING_MODE, FIT_HEIGHT );
+ break;
+ }
+ case Dali::FittingMode::FIT_WIDTH:
+ {
+ map.Insert( IMAGE_FITTING_MODE, FIT_WIDTH );
+ break;
+ }
+ case Dali::FittingMode::SCALE_TO_FILL:
+ {
+ map.Insert( IMAGE_FITTING_MODE, SCALE_TO_FILL );
+ break;
+ }
+ case Dali::FittingMode::SHRINK_TO_FIT:
+ {
+ map.Insert( IMAGE_FITTING_MODE, SHRINK_TO_FIT );
+ break;
+ }
+ default:
+ {
+ map.Insert( IMAGE_FITTING_MODE, DEFAULT );
+ break;
+ }
+ }
+
+ switch( mSamplingMode )
+ {
+ case Dali::SamplingMode::BOX:
+ {
+ map.Insert( IMAGE_SAMPLING_MODE, BOX );
+ break;
+ }
+ case Dali::SamplingMode::NEAREST:
+ {
+ map.Insert( IMAGE_SAMPLING_MODE, NEAREST );
+ break;
+ }
+ case Dali::SamplingMode::LINEAR:
+ {
+ map.Insert( IMAGE_SAMPLING_MODE, LINEAR );
+ break;
+ }
+ case Dali::SamplingMode::BOX_THEN_LINEAR:
+ {
+ map.Insert( IMAGE_SAMPLING_MODE, BOX_THEN_LINEAR );
+ break;
+ }
+ case Dali::SamplingMode::BOX_THEN_NEAREST:
+ {
+ map.Insert( IMAGE_SAMPLING_MODE, BOX_THEN_NEAREST );
+ break;
+ }
+ case Dali::SamplingMode::NO_FILTER:
+ {
+ map.Insert( IMAGE_SAMPLING_MODE, NO_FILTER );
+ break;
+ }
+ case Dali::SamplingMode::DONT_CARE:
+ {
+ map.Insert( IMAGE_SAMPLING_MODE, DONT_CARE );
+ break;
+ }
+ default:
+ {
+ map.Insert( IMAGE_SAMPLING_MODE, DEFAULT );
+ break;
+ }
+ }
}
void ImageRenderer::Initialize( RendererFactoryCache& factoryCache )
}
}
+Image ImageRenderer::GetImage() const
+{
+ return mImage;
+}
+
void ImageRenderer::ApplyImageToSampler()
{
if( mImage )
*/
virtual void SetOffset( const Vector2& offset );
+ /**
+ * @copydoc ControlRenderer::CreatePropertyMap
+ */
+ virtual void CreatePropertyMap( Property::Map& map ) const;
+
protected:
/**
* @copydoc ControlRenderer::DoSetOnStage
*/
void SetImage( Image image );
+ /**
+ * @brief Gets the image this renderer uses
+ *
+ * @return The image this renderer uses, which may be null if the image is set from a URL string and the renderer is not set as onstage
+ */
+ Image GetImage() const;
+
private:
/**
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "npatch-renderer.h"
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/platform-abstraction.h>
+#include <dali/public-api/images/buffer-image.h>
+#include <dali/public-api/images/resource-image.h>
+
+// INTERNAL IINCLUDES
+#include <dali-toolkit/internal/controls/renderers/renderer-factory-impl.h>
+#include <dali-toolkit/internal/controls/renderers/renderer-factory-cache.h>
+#include <dali-toolkit/internal/controls/renderers/control-renderer-impl.h>
+#include <dali-toolkit/internal/controls/renderers/control-renderer-data-impl.h>
+
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+namespace
+{
+const char * const RENDERER_TYPE("renderer-type");
+const char * const RENDERER_TYPE_VALUE("n-patch-renderer");
+
+const char * const IMAGE_URL_NAME("image-url");
+const char * const BORDER_ONLY("border-only");
+
+std::string TEXTURE_UNIFORM_NAME = "sTexture";
+
+const char* VERTEX_SHADER_3X3 = DALI_COMPOSE_SHADER(
+ attribute mediump vec2 aPosition;\n
+ varying mediump vec2 vTexCoord;\n
+ uniform mediump mat4 uModelMatrix;\n
+ uniform mediump mat4 uMvpMatrix;\n
+ uniform mediump vec3 uSize;\n
+ uniform mediump vec2 uFixed[ 3 ];\n
+ uniform mediump vec2 uStretchTotal;\n
+ \n
+ void main()\n
+ {\n
+ mediump vec2 scale = vec2( length( uModelMatrix[ 0 ].xyz ), length( uModelMatrix[ 1 ].xyz ) );\n
+ mediump vec2 size = uSize.xy * scale;\n
+ \n
+ mediump vec2 fixedFactor = vec2( uFixed[ int( ( aPosition.x + 1.0 ) * 0.5 ) ].x, uFixed[ int( ( aPosition.y + 1.0 ) * 0.5 ) ].y );\n
+ mediump vec2 stretch = floor( aPosition * 0.5 );\n
+ mediump vec2 fixedTotal = uFixed[ 2 ];\n
+ \n
+ mediump vec4 vertexPosition = vec4( fixedFactor + ( size - fixedTotal ) * stretch, 0.0, 1.0 );\n
+ vertexPosition.xy -= size * vec2( 0.5, 0.5 );\n
+ vertexPosition.xy = vertexPosition.xy / scale;\n
+ \n
+ vertexPosition = uMvpMatrix * vertexPosition;\n
+ \n
+ vTexCoord = ( fixedFactor + stretch * uStretchTotal ) / ( fixedTotal + uStretchTotal );\n
+ \n
+ gl_Position = vertexPosition;\n
+ }\n
+);
+
+const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
+ varying mediump vec2 vTexCoord;\n
+ uniform sampler2D sTexture;\n
+ uniform lowp vec4 uColor;\n
+ \n
+ void main()\n
+ {\n
+ gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n
+ }\n
+);
+
+/**
+ * @brief Creates the geometry formed from the vertices and indices
+ *
+ * @param[in] vertices The vertices to generate the geometry from
+ * @param[in] indices The indices to generate the geometry from
+ * @return The geometry formed from the vertices and indices
+ */
+Geometry GenerateGeometry( const Vector< Vector2 >& vertices, const Vector< unsigned int >& indices )
+{
+ Property::Map vertexFormat;
+ vertexFormat[ "aPosition" ] = Property::VECTOR2;
+ PropertyBuffer vertexPropertyBuffer = PropertyBuffer::New( vertexFormat, vertices.Size() );
+ if( vertices.Size() > 0 )
+ {
+ vertexPropertyBuffer.SetData( &vertices[ 0 ] );
+ }
+
+ Property::Map indexFormat;
+ indexFormat[ "indices" ] = Property::INTEGER;
+ PropertyBuffer indexPropertyBuffer = PropertyBuffer::New( indexFormat, indices.Size() );
+ if( indices.Size() > 0 )
+ {
+ indexPropertyBuffer.SetData( &indices[ 0 ] );
+ }
+
+ // Create the geometry object
+ Geometry geometry = Geometry::New();
+ geometry.AddVertexBuffer( vertexPropertyBuffer );
+ geometry.SetIndexBuffer( indexPropertyBuffer );
+
+ return geometry;
+}
+
+/**
+ * @brief Adds the indices to form a quad composed off two triangles where the indices are organised in a grid
+ *
+ * @param[out] indices The indices to add to
+ * @param[in] rowIdx The row index to start the quad
+ * @param[in] nextRowIdx The index to the next row
+ */
+void AddQuadIndices( Vector< unsigned int >& indices, unsigned int rowIdx, unsigned int nextRowIdx )
+{
+ indices.PushBack( rowIdx );
+ indices.PushBack( nextRowIdx + 1 );
+ indices.PushBack( rowIdx + 1 );
+
+ indices.PushBack( rowIdx );
+ indices.PushBack( nextRowIdx );
+ indices.PushBack( nextRowIdx + 1 );
+}
+
+void AddVertex( Vector< Vector2 >& vertices, unsigned int x, unsigned int y )
+{
+ vertices.PushBack( Vector2( x, y ) );
+}
+
+} //unnamed namespace
+
+/////////////////NPatchRenderer////////////////
+
+NPatchRenderer::NPatchRenderer()
+: ControlRenderer(),
+ mBorderOnly( false )
+{
+}
+
+NPatchRenderer::~NPatchRenderer()
+{
+}
+
+void NPatchRenderer::Initialize( RendererFactoryCache& factoryCache, const Property::Map& propertyMap )
+{
+ Initialize(factoryCache);
+
+ Property::Value* imageURLValue = propertyMap.Find( IMAGE_URL_NAME );
+ if( imageURLValue )
+ {
+ //Read the border-only property first since InitialiseFromImage relies on mBorderOnly to be properly set
+ Property::Value* borderOnlyValue = propertyMap.Find( BORDER_ONLY );
+ if( borderOnlyValue )
+ {
+ borderOnlyValue->Get( mBorderOnly );
+ }
+
+ if( imageURLValue->Get( mImageUrl ) )
+ {
+ NinePatchImage nPatch = NinePatchImage::New( mImageUrl );
+ InitialiseFromImage( nPatch );
+ }
+ else
+ {
+ CreateErrorImage();
+ DALI_LOG_ERROR( "The property '%s' is not a string\n", IMAGE_URL_NAME );
+ }
+ }
+}
+
+void NPatchRenderer::SetClipRect( const Rect<int>& clipRect )
+{
+ ControlRenderer::SetClipRect( clipRect );
+ //ToDo: renderer responds to the clipRect change
+}
+
+void NPatchRenderer::SetOffset( const Vector2& offset )
+{
+ //ToDo: renderer applies the offset
+}
+
+void NPatchRenderer::DoSetOnStage( Actor& actor )
+{
+ if( !mCroppedImage )
+ {
+ if( !mImageUrl.empty() )
+ {
+ NinePatchImage nPatch = NinePatchImage::New( mImageUrl );
+ InitialiseFromImage( nPatch );
+ }
+ else if( mImage )
+ {
+ InitialiseFromImage( mImage );
+ }
+ }
+
+ if( mCroppedImage )
+ {
+ ApplyImageToSampler();
+ }
+}
+
+void NPatchRenderer::DoSetOffStage( Actor& actor )
+{
+ mCroppedImage.Reset();
+}
+
+void NPatchRenderer::CreatePropertyMap( Property::Map& map ) const
+{
+ map.Clear();
+ map.Insert( RENDERER_TYPE, RENDERER_TYPE_VALUE );
+ if( !mImageUrl.empty() )
+ {
+ map.Insert( IMAGE_URL_NAME, mImageUrl );
+ }
+ else if( mImage )
+ {
+ map.Insert( IMAGE_URL_NAME, mImage.GetUrl() );
+ }
+ map.Insert( BORDER_ONLY, mBorderOnly );
+}
+
+void NPatchRenderer::Initialize( RendererFactoryCache& factoryCache )
+{
+ mNinePatchGeometry = factoryCache.GetGeometry( RendererFactoryCache::NINE_PATCH_GEOMETRY );
+ if( !(mNinePatchGeometry) )
+ {
+ mNinePatchGeometry = CreateGeometry( Uint16Pair( 3, 3 ) );
+ factoryCache.SaveGeometry( RendererFactoryCache::NINE_PATCH_GEOMETRY, mNinePatchGeometry );
+ }
+
+ mNinePatchBorderGeometry = factoryCache.GetGeometry( RendererFactoryCache::NINE_PATCH_BORDER_GEOMETRY );
+ if( !(mNinePatchBorderGeometry) )
+ {
+ mNinePatchBorderGeometry = CreateGeometryBorder( Uint16Pair( 3, 3 ) );
+ factoryCache.SaveGeometry( RendererFactoryCache::NINE_PATCH_BORDER_GEOMETRY, mNinePatchBorderGeometry );
+ }
+
+ mNinePatchShader = factoryCache.GetShader( RendererFactoryCache::NINE_PATCH_SHADER );
+ if( !mNinePatchShader )
+ {
+ mNinePatchShader = Shader::New( VERTEX_SHADER_3X3, FRAGMENT_SHADER );
+ factoryCache.SaveShader( RendererFactoryCache::NINE_PATCH_SHADER, mNinePatchShader );
+ }
+
+ mImpl->mGeometry = mNinePatchGeometry;
+ mImpl->mShader = mNinePatchShader;
+
+ mImageUrl.clear();
+}
+
+void NPatchRenderer::SetImage( const std::string& imageUrl, bool borderOnly )
+{
+ mBorderOnly = borderOnly;
+ mImage.Reset();
+ if( mImageUrl == imageUrl )
+ {
+ return;
+ }
+
+ mImageUrl = imageUrl;
+ NinePatchImage nPatch = NinePatchImage::New( mImageUrl );
+ InitialiseFromImage( nPatch );
+
+ if( mCroppedImage && mImpl->mIsOnStage )
+ {
+ ApplyImageToSampler();
+ }
+}
+
+void NPatchRenderer::SetImage( NinePatchImage image, bool borderOnly )
+{
+ mBorderOnly = borderOnly;
+ mImageUrl.empty();
+ if( mImage == image )
+ {
+ return;
+ }
+
+ mImage = image;
+ InitialiseFromImage( mImage );
+
+ if( mCroppedImage && mImpl->mIsOnStage )
+ {
+ ApplyImageToSampler();
+ }
+}
+
+void NPatchRenderer::InitialiseFromImage( NinePatchImage nPatch )
+{
+ mCroppedImage = nPatch.CreateCroppedBufferImage();
+ if( !mCroppedImage )
+ {
+ DALI_LOG_ERROR("'%s' specify a valid 9 patch image\n", mImageUrl.c_str() );
+ CreateErrorImage();
+ return;
+ }
+
+ mImageSize = ImageDimensions( mCroppedImage.GetWidth(), mCroppedImage.GetHeight() );
+
+ mStretchPixelsX = nPatch.GetStretchPixelsX();
+ mStretchPixelsY = nPatch.GetStretchPixelsY();
+
+ if( mStretchPixelsX.Size() > 0 && mStretchPixelsY.Size() > 0 )
+ {
+ //only 9 patch supported for now
+ mImpl->mGeometry = !mBorderOnly ? mNinePatchGeometry : mNinePatchBorderGeometry;
+ mImpl->mShader = mNinePatchShader;
+ }
+}
+
+void NPatchRenderer::CreateErrorImage()
+{
+ mImageSize = ImageDimensions( 1, 1 );
+
+ BufferImage bufferImage = BufferImage::New( mImageSize.GetWidth(), mImageSize.GetHeight(), Pixel::RGBA8888 );
+ mCroppedImage = bufferImage;
+ PixelBuffer* pixbuf = bufferImage.GetBuffer();
+
+ for( size_t i = 0; i < mImageSize.GetWidth() * mImageSize.GetHeight() * 4u; )
+ {
+ pixbuf[ i++ ] = 0;
+ pixbuf[ i++ ] = 0;
+ pixbuf[ i++ ] = 0;
+ pixbuf[ i++ ] = 255;
+ }
+
+ mStretchPixelsX.Clear();
+ mStretchPixelsX.PushBack( Uint16Pair( 0, mImageSize.GetWidth() ) );
+ mStretchPixelsY.Clear();
+ mStretchPixelsY.PushBack( Uint16Pair( 0, mImageSize.GetHeight() ) );
+
+ mImpl->mGeometry = mNinePatchGeometry;
+ mImpl->mShader = mNinePatchShader;
+}
+
+void NPatchRenderer::ApplyImageToSampler()
+{
+ Material material = mImpl->mRenderer.GetMaterial();
+ if( material )
+ {
+ Sampler sampler;
+ for( std::size_t i = 0; i < material.GetNumberOfSamplers(); ++i )
+ {
+ sampler = material.GetSamplerAt( i );
+ if( sampler.GetUniformName() == TEXTURE_UNIFORM_NAME )
+ {
+ sampler.SetImage( mCroppedImage );
+ break;
+ }
+ }
+ if( !sampler )
+ {
+ sampler = Sampler::New( mCroppedImage, TEXTURE_UNIFORM_NAME );
+ material.AddSampler( sampler );
+ }
+
+ if( mStretchPixelsX.Size() > 0 && mStretchPixelsY.Size() > 0 )
+ {
+ //only 9 patch supported for now
+ Uint16Pair stretchX = mStretchPixelsX[ 0 ];
+ Uint16Pair stretchY = mStretchPixelsY[ 0 ];
+
+ uint16_t stretchWidth = stretchX.GetY() - stretchX.GetX();
+ uint16_t stretchHeight = stretchY.GetY() - stretchY.GetX();
+
+ sampler.RegisterProperty( "uFixed[0]", Vector2::ZERO );
+ sampler.RegisterProperty( "uFixed[1]", Vector2( stretchX.GetX(), stretchY.GetX()) );
+ sampler.RegisterProperty( "uFixed[2]", Vector2( mImageSize.GetWidth() - stretchWidth, mImageSize.GetHeight() - stretchHeight ) );
+ sampler.RegisterProperty( "uStretchTotal", Vector2( stretchWidth, stretchHeight ) );
+ }
+ }
+}
+
+Geometry NPatchRenderer::CreateGeometry( Uint16Pair gridSize )
+{
+ uint16_t gridWidth = gridSize.GetWidth();
+ uint16_t gridHeight = gridSize.GetHeight();
+
+ // Create vertices
+ Vector< Vector2 > vertices;
+ vertices.Reserve( ( gridWidth + 1 ) * ( gridHeight + 1 ) );
+
+ for( int y = 0; y < gridHeight + 1; ++y )
+ {
+ for( int x = 0; x < gridWidth + 1; ++x )
+ {
+ AddVertex( vertices, x, y );
+ }
+ }
+
+ // Create indices
+ //TODO: compare performance with triangle strip when Geometry supports it
+ Vector< unsigned int > indices;
+ indices.Reserve( gridWidth * gridHeight * 6 );
+
+ unsigned int rowIdx = 0;
+ unsigned int nextRowIdx = gridWidth + 1;
+ for( int y = 0; y < gridHeight; ++y, ++nextRowIdx, ++rowIdx )
+ {
+ for( int x = 0; x < gridWidth; ++x, ++nextRowIdx, ++rowIdx )
+ {
+ AddQuadIndices( indices, rowIdx, nextRowIdx );
+ }
+ }
+
+ return GenerateGeometry( vertices, indices );
+}
+
+Geometry NPatchRenderer::CreateGeometryBorder( Uint16Pair gridSize )
+{
+ uint16_t gridWidth = gridSize.GetWidth();
+ uint16_t gridHeight = gridSize.GetHeight();
+
+ // Create vertices
+ Vector< Vector2 > vertices;
+ vertices.Reserve( ( gridWidth + 1 ) * ( gridHeight + 1 ) );
+
+ //top
+ int y = 0;
+ for(; y < 2; ++y)
+ {
+ for( int x = 0; x < gridWidth + 1; ++x )
+ {
+ AddVertex( vertices, x, y );
+ }
+ }
+
+ for(; y < gridHeight - 1; ++y)
+ {
+ //left
+ AddVertex( vertices, 0, y );
+ AddVertex( vertices, 1, y );
+
+ //right
+ AddVertex( vertices, gridWidth - 1, y );
+ AddVertex( vertices, gridWidth, y );
+ }
+
+ //bottom
+ for(; y < gridHeight + 1; ++y)
+ {
+ for( int x = 0; x < gridWidth + 1; ++x )
+ {
+ AddVertex( vertices, x, y );
+ }
+ }
+
+ // Create indices
+ //TODO: compare performance with triangle strip when Geometry supports it
+ Vector< unsigned int > indices;
+ indices.Reserve( gridWidth * gridHeight * 6 );
+
+ //top
+ unsigned int rowIdx = 0 ;
+ unsigned int nextRowIdx = gridWidth + 1;
+ for( int x = 0; x < gridWidth; ++x, ++nextRowIdx, ++rowIdx )
+ {
+ AddQuadIndices( indices, rowIdx, nextRowIdx );
+ }
+
+ if(gridHeight > 2)
+ {
+ rowIdx = gridWidth + 1;
+ nextRowIdx = ( gridWidth + 1 ) * 2;
+
+ unsigned increment = gridWidth - 1;
+ if(gridHeight > 3)
+ {
+ increment = 2;
+ //second row left
+ AddQuadIndices( indices, rowIdx, nextRowIdx );
+
+ rowIdx = gridWidth * 2;
+ nextRowIdx = ( gridWidth + 1 ) * 2 + 2;
+ //second row right
+ AddQuadIndices( indices, rowIdx, nextRowIdx );
+
+ //left and right
+ rowIdx = nextRowIdx - 2;
+ nextRowIdx = rowIdx + 4;
+ for(int y = 2; y < 2*(gridHeight - 3); ++y, rowIdx += 2, nextRowIdx += 2)
+ {
+ AddQuadIndices( indices, rowIdx, nextRowIdx );
+ }
+ }
+
+ //second row left
+ AddQuadIndices( indices, rowIdx, nextRowIdx );
+
+ rowIdx += increment;
+ nextRowIdx += gridWidth - 1;
+ //second row right
+ AddQuadIndices( indices, rowIdx, nextRowIdx );
+ }
+
+ //bottom
+ rowIdx = nextRowIdx - gridWidth + 1;
+ nextRowIdx = rowIdx + gridWidth + 1;
+ for( int x = 0; x < gridWidth; ++x, ++nextRowIdx, ++rowIdx )
+ {
+ AddQuadIndices( indices, rowIdx, nextRowIdx );
+ }
+
+ return GenerateGeometry( vertices, indices );
+}
+
+} // namespace Internal
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_TOOLKIT_INTERNAL_N_PATCH_RENDERER_H__
+#define __DALI_TOOLKIT_INTERNAL_N_PATCH_RENDERER_H__
+
+/*
+ * 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.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/controls/renderers/control-renderer-impl.h>
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/images/image.h>
+#include <dali/public-api/images/nine-patch-image.h>
+#include <dali/public-api/images/image-operations.h>
+#include <dali/devel-api/rendering/geometry.h>
+#include <dali/devel-api/rendering/shader.h>
+#include <dali/devel-api/rendering/sampler.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+/**
+ * The renderer which renders an 9 patch image to the control's quad
+ *
+ * The following properties are optional
+ *
+ * | %Property Name | Type |
+ * |---------------------------|------------------|
+ * | image-url | STRING |
+ * | border-only | BOOLEAN
+ *
+ */
+class NPatchRenderer: public ControlRenderer
+{
+public:
+
+ /**
+ * @brief Constructor.
+ */
+ NPatchRenderer();
+
+ /**
+ * @brief A reference counted object may only be deleted by calling Unreference().
+ */
+ ~NPatchRenderer();
+
+public: // from ControlRenderer
+
+ /**
+ * @copydoc ControlRenderer::Initialize
+ */
+ virtual void Initialize( RendererFactoryCache& factoryCache, const Property::Map& propertyMap );
+
+ /**
+ * @copydoc ControlRenderer::SetClipRect
+ */
+ virtual void SetClipRect( const Rect<int>& clipRect );
+
+ /**
+ * @copydoc ControlRenderer::SetOffset
+ */
+ virtual void SetOffset( const Vector2& offset );
+
+ /**
+ * @copydoc ControlRenderer::CreatePropertyMap
+ */
+ virtual void CreatePropertyMap( Property::Map& map ) const;
+
+protected:
+ /**
+ * @copydoc ControlRenderer::DoSetOnStage
+ */
+ virtual void DoSetOnStage( Actor& actor );
+
+ /**
+ * @copydoc ControlRenderer::DoSetOffStage
+ */
+ virtual void DoSetOffStage( Actor& actor );
+
+public:
+
+ /**
+ * Request the geometry and shader from the cache, if not available, create and save to the cache for sharing.
+ *
+ * @param[in] factoryCache A pointer pointing to the RendererFactoryCache object
+ */
+ void Initialize( RendererFactoryCache& factoryCache );
+
+ /**
+ * @brief Sets the 9 patch image of this renderer to the resource at imageUrl
+ * The renderer will load the image synchronously when the associated actor is put on stage, and destroy the image when it is off stage
+ *
+ * @param[in] imageUrl The URL to 9 patch image resource to use
+ * @param[in] borderOnly A Flag to indicate if the image should omit the centre of the n-patch and only render the border
+ */
+ void SetImage( const std::string& imageUrl, bool borderOnly = false );
+
+ /**
+ * @brief Sets the 9 patch image of this renderer to the 9 patch image
+ *
+ * @param[in] image The NinePatchImage to use
+ * @param[in] borderOnly A Flag to indicate if the image should omit the centre of the n-patch and only render the border
+ */
+ void SetImage( NinePatchImage image, bool borderOnly = false );
+
+private:
+
+ /**
+ * @brief Creates a geometry for the grid size to be used by this renderers' shaders
+ *
+ * @param gridSize The grid size of the solid geometry to create
+ * @return Returns the created geometry for the grid size
+ */
+ Geometry CreateGeometry( Uint16Pair gridSize );
+
+ /**
+ * @brief Creates a geometry with the border only for the grid size to be used by this renderers' shaders
+ * e.g. a 5x4 grid would create a geometry that would look like:
+ *
+ * ---------------------
+ * | /| /| /| /| /|
+ * |/ |/ |/ |/ |/ |
+ * ---------------------
+ * | /| | /|
+ * |/ | |/ |
+ * ----- -----
+ * | /| | /|
+ * |/ | |/ |
+ * ---------------------
+ * | /| /| /| /| /|
+ * |/ |/ |/ |/ |/ |
+ * ---------------------
+ *
+ * @param gridSize The grid size of the solid geometry to create
+ * @return Returns the created geometry for the grid size
+ */
+ Geometry CreateGeometryBorder( Uint16Pair gridSize );
+
+ /**
+ * @brief Creates Image from the image url and parses the image for the stretch borders. Will create a error image if the n patch image is invalid
+ *
+ * @param nPatchImage The NinePatchImage to base our cropped images and stretch borders from
+ */
+ void InitialiseFromImage( NinePatchImage nPatchImage );
+
+ /**
+ * @brief Creates a black Image to indicate that there was an error in either the image url or the parsing of the image
+ *
+ */
+ void CreateErrorImage();
+
+ /**
+ * @brief Applies this renderer's image to the sampler to the material used for this renderer
+ */
+ void ApplyImageToSampler();
+
+private:
+
+ NinePatchImage mImage; ///< The image to render if the renderer was set from an NinePatchImage, empty otherwise
+ Image mCroppedImage;
+ Geometry mNinePatchGeometry;
+ Geometry mNinePatchBorderGeometry;
+ Shader mNinePatchShader;
+
+ std::string mImageUrl; ///< The url to the image resource to render if the renderer was set from an image resource url, empty otherwise
+ NinePatchImage::StretchRanges mStretchPixelsX;
+ NinePatchImage::StretchRanges mStretchPixelsY;
+ ImageDimensions mImageSize;
+ bool mBorderOnly;
+};
+
+} // namespace Internal
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif /* __DALI_TOOLKIT_INTERNAL_N_PATCH_RENDERER_H__ */
return mGeometry[type];
}
-void RendererFactoryCache::SaveGeometry( GeometryType type, Geometry geometry)
+void RendererFactoryCache::SaveGeometry( GeometryType type, Geometry geometry )
{
mGeometry[type] = geometry;
}
GRADIENT_SHADER_LINEAR,
GRADIENT_SHADER_RADIAL,
IMAGE_SHADER,
- N_PATCH_SHADER,
+ NINE_PATCH_SHADER,
SVG_SHADER,
SHADER_TYPE_MAX = SVG_SHADER
};
enum GeometryType
{
QUAD_GEOMETRY,
+ BORDER_GEOMETRY,
NINE_PATCH_GEOMETRY,
- GEOMETRY_TYPE_MAX = NINE_PATCH_GEOMETRY
+ NINE_PATCH_BORDER_GEOMETRY,
+ GEOMETRY_TYPE_MAX = NINE_PATCH_BORDER_GEOMETRY
};
public:
#include <dali/devel-api/object/type-registry-helper.h>
// Internal HEADER
+#include <dali-toolkit/internal/controls/renderers/border/border-renderer.h>
#include <dali-toolkit/internal/controls/renderers/color/color-renderer.h>
#include <dali-toolkit/internal/controls/renderers/gradient/gradient-renderer.h>
+#include <dali-toolkit/internal/controls/renderers/npatch/npatch-renderer.h>
#include <dali-toolkit/internal/controls/renderers/image/image-renderer.h>
#include <dali-toolkit/internal/controls/renderers/renderer-factory-cache.h>
namespace
{
const char * const RENDERER_TYPE_NAME( "renderer-type" );
+
const char * const COLOR_RENDERER("color-renderer");
+const char * const BORDER_RENDERER("border-renderer");
const char * const GRADIENT_RENDERER("gradient-renderer");
const char * const IMAGE_RENDERER("image-renderer");
+const char * const N_PATCH_RENDERER("n-patch-renderer");
}
namespace Dali
{
rendererPtr = new ImageRenderer();
}
+ else if( typeValue == N_PATCH_RENDERER )
+ {
+ rendererPtr = new NPatchRenderer();
+ }
+ else if( typeValue == BORDER_RENDERER )
+ {
+ rendererPtr = new BorderRenderer();
+ }
}
if( rendererPtr )
DALI_LOG_ERROR( "Renderer type unknown" );
}
- return Toolkit::ControlRenderer(rendererPtr);
+ return Toolkit::ControlRenderer( rendererPtr );
}
Toolkit::ControlRenderer RendererFactory::GetControlRenderer( const Vector4& color )
}
rendererPtr->Initialize( *( mFactoryCache.Get() ) );
- rendererPtr->SetColor(color);
+ rendererPtr->SetColor( color );
- return Toolkit::ControlRenderer(rendererPtr);
+ return Toolkit::ControlRenderer( rendererPtr );
}
bool RendererFactory::ResetRenderer( Toolkit::ControlRenderer& renderer, const Vector4& color )
{
- ColorRenderer* rendererPtr = dynamic_cast<ColorRenderer*>(&GetImplementation(renderer));
+ ColorRenderer* rendererPtr = dynamic_cast< ColorRenderer* >( &GetImplementation( renderer ) );
if( rendererPtr )
{
- rendererPtr->SetColor(color);
+ rendererPtr->SetColor( color );
return false;
}
else
{
- renderer = GetControlRenderer(color);
+ renderer = GetControlRenderer( color );
return true;
}
}
-Toolkit::ControlRenderer RendererFactory::GetControlRenderer( const Image& image )
+Toolkit::ControlRenderer RendererFactory::GetControlRenderer( float borderSize, const Vector4& borderColor )
{
- ImageRenderer* rendererPtr = new ImageRenderer();
+ BorderRenderer* rendererPtr = new BorderRenderer();
+
if( !mFactoryCache )
{
mFactoryCache = new RendererFactoryCache();
}
rendererPtr->Initialize( *( mFactoryCache.Get() ) );
- rendererPtr->SetImage( image );
- return Toolkit::ControlRenderer(rendererPtr);
+ rendererPtr->SetBorderSize( borderSize );
+ rendererPtr->SetBorderColor( borderColor );
+
+ return Toolkit::ControlRenderer( rendererPtr );
+}
+
+Toolkit::ControlRenderer RendererFactory::GetControlRenderer( const Image& image )
+{
+ if( !mFactoryCache )
+ {
+ mFactoryCache = new RendererFactoryCache();
+ }
+
+ NinePatchImage npatchImage = NinePatchImage::DownCast( image );
+ if( npatchImage )
+ {
+ NPatchRenderer* rendererPtr = new NPatchRenderer();
+ rendererPtr->Initialize( *( mFactoryCache.Get() ) );
+ rendererPtr->SetImage( npatchImage );
+
+ return Toolkit::ControlRenderer( rendererPtr );
+ }
+ else
+ {
+ ImageRenderer* rendererPtr = new ImageRenderer();
+ rendererPtr->Initialize( *( mFactoryCache.Get() ) );
+ rendererPtr->SetImage( image );
+
+ return Toolkit::ControlRenderer( rendererPtr );
+ }
}
bool RendererFactory::ResetRenderer( Toolkit::ControlRenderer& renderer, const Image& image )
{
- ImageRenderer* rendererPtr = dynamic_cast<ImageRenderer*>(&GetImplementation(renderer));
- if( rendererPtr )
+ NinePatchImage npatchImage = NinePatchImage::DownCast( image );
+ if( npatchImage )
{
- rendererPtr->SetImage(image);
- return false;
+ NPatchRenderer* rendererPtr = dynamic_cast< NPatchRenderer* >( &GetImplementation( renderer ) );
+ if( rendererPtr )
+ {
+ rendererPtr->SetImage( npatchImage );
+ return false;
+ }
+ }
+ else
+ {
+ ImageRenderer* rendererPtr = dynamic_cast< ImageRenderer* >( &GetImplementation( renderer ) );
+ if( rendererPtr )
+ {
+ rendererPtr->SetImage( image );
+ return false;
+ }
+ }
+
+ renderer = GetControlRenderer( image );
+ return true;
+}
+
+Toolkit::ControlRenderer RendererFactory::GetControlRenderer( const std::string& url )
+{
+ if( NinePatchImage::IsNinePatchUrl( url ) )
+ {
+ NPatchRenderer* rendererPtr = new NPatchRenderer();
+ if( !mFactoryCache )
+ {
+ mFactoryCache = new RendererFactoryCache();
+ }
+ rendererPtr->Initialize( *( mFactoryCache.Get() ) );
+ rendererPtr->SetImage( url );
+
+ return Toolkit::ControlRenderer( rendererPtr );
+ }
+ else
+ {
+ ImageRenderer* rendererPtr = new ImageRenderer();
+ if( !mFactoryCache )
+ {
+ mFactoryCache = new RendererFactoryCache();
+ }
+ rendererPtr->Initialize( *( mFactoryCache.Get() ) );
+ rendererPtr->SetImage( url );
+
+ return Toolkit::ControlRenderer( rendererPtr );
+ }
+}
+
+bool RendererFactory::ResetRenderer( Toolkit::ControlRenderer& renderer, const std::string& url )
+{
+ if( NinePatchImage::IsNinePatchUrl( url ) )
+ {
+ NPatchRenderer* rendererPtr = dynamic_cast< NPatchRenderer* >( &GetImplementation( renderer ) );
+ if( rendererPtr )
+ {
+ rendererPtr->SetImage( url );
+ return false;
+ }
}
else
{
- renderer = GetControlRenderer(image);
+ ImageRenderer* rendererPtr = dynamic_cast< ImageRenderer* >( &GetImplementation( renderer ) );
+ if( rendererPtr )
+ {
+ rendererPtr->SetImage( url );
+ return false;
+ }
+ }
+
+ {
+ renderer = GetControlRenderer( url );
return true;
}
}
bool ResetRenderer( Toolkit::ControlRenderer& renderer, const Vector4& color );
/**
+ * @copydoc Toolkit::RenderFactory::GetControlRenderer( float, const Vector4& )
+ */
+ Toolkit::ControlRenderer GetControlRenderer( float borderSize, const Vector4& borderColor );
+
+ /**
* @copydoc Toolkit::RenderFactory::GetControlRenderer( const Image& )
*/
Toolkit::ControlRenderer GetControlRenderer( const Image& image );
*/
bool ResetRenderer( Toolkit::ControlRenderer& renderer, const Image& image );
+ /**
+ * @copydoc Toolkit::RenderFactory::GetControlRenderer( const std::string& )
+ */
+ Toolkit::ControlRenderer GetControlRenderer( const std::string& image );
+
+ /**
+ * @copydoc Toolkit::RendererFactory::ResetRenderer( Toolkit::ControlRenderer&, const std::string& )
+ */
+ bool ResetRenderer( Toolkit::ControlRenderer& renderer, const std::string& image );
+
protected:
/**
{
const std::string fontFamily = value.Get< std::string >();
DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str() );
-
- if( impl.mController->GetDefaultFontFamily() != fontFamily )
- {
- impl.mController->SetDefaultFontFamily( fontFamily, true ); // "true" as SetProperty means user defined font so don't change when system font changes.
- }
+ impl.mController->SetDefaultFontFamily( fontFamily );
}
break;
}
const std::string fontFamily = value.Get< std::string >();
DALI_LOG_INFO( gLogFilter, Debug::General, "TextLabel::SetProperty Property::FONT_FAMILY newFont(%s)\n", fontFamily.c_str() );
- if( impl.mController->GetDefaultFontFamily() != fontFamily )
- {
- impl.mController->SetDefaultFontFamily( fontFamily, true );
- }
+ impl.mController->SetDefaultFontFamily( fontFamily );
}
break;
}
DALI_TYPE_REGISTRATION_BEGIN( Toolkit::TextSelectionToolbar, Toolkit::Control, Create );
DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionToolbar, "max-size", VECTOR2, MAX_SIZE )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionToolbar, "enable-overshoot", BOOLEAN, ENABLE_OVERSHOOT )
DALI_TYPE_REGISTRATION_END()
impl.SetPopupMaxSize( value.Get< Vector2 >() );
break;
}
-
+ case Toolkit::TextSelectionToolbar::Property::ENABLE_OVERSHOOT:
+ {
+ impl.mScrollView.SetOvershootEnabled( value.Get< bool >() );
+ break;
+ }
} // switch
} // TextSelectionToolbar
}
value = impl.GetPopupMaxSize();
break;
}
+ case Toolkit::TextSelectionToolbar::Property::ENABLE_OVERSHOOT:
+ {
+ value = impl.mScrollView.IsOvershootEnabled();
+ break;
+ }
} // switch
}
return value;
return mMaxSize;
}
-void TextSelectionToolbar::SetUpScrollView( Toolkit::ScrollView& scrollView )
+void TextSelectionToolbar::SetUpScrollView()
{
- scrollView.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
- scrollView.SetParentOrigin( ParentOrigin::CENTER_LEFT );
- scrollView.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
+ mScrollView.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
+ mScrollView.SetParentOrigin( ParentOrigin::CENTER_LEFT );
+ mScrollView.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
- scrollView.SetScrollingDirection( PanGestureDetector::DIRECTION_HORIZONTAL, Degree( 40.0f ) );
- scrollView.SetAxisAutoLock( true );
- scrollView.ScrollStartedSignal().Connect( this, &TextSelectionToolbar::OnScrollStarted );
- scrollView.ScrollCompletedSignal().Connect( this, &TextSelectionToolbar::OnScrollCompleted );
+ mScrollView.SetScrollingDirection( PanGestureDetector::DIRECTION_HORIZONTAL, Degree( 40.0f ) );
+ mScrollView.SetAxisAutoLock( true );
+ mScrollView.ScrollStartedSignal().Connect( this, &TextSelectionToolbar::OnScrollStarted );
+ mScrollView.ScrollCompletedSignal().Connect( this, &TextSelectionToolbar::OnScrollCompleted );
mRulerX = new DefaultRuler(); // IntrusivePtr which is unreferenced when ScrollView is destroyed.
RulerPtr rulerY = new DefaultRuler(); // IntrusivePtr which is unreferenced when ScrollView is destroyed.
rulerY->Disable();
- scrollView.SetRulerY( rulerY );
+ mScrollView.SetRulerY( rulerY );
+
+ mScrollView.SetOvershootEnabled( true );
}
void TextSelectionToolbar::SetUp()
stencil.SetParentOrigin( ParentOrigin::CENTER );
mScrollView = Toolkit::ScrollView::New();
- SetUpScrollView( mScrollView );
+ SetUpScrollView();
// Toolbar must start with at least one option, adding further options with increase it's size
mTableOfButtons = Dali::Toolkit::TableView::New( 1, 1 );
/**
* @brief Set up scrollview to scroll Toolbar horizontally
- * @param[out] scrollView scrollview to setup
*/
- void SetUpScrollView( Toolkit::ScrollView& scrollView );
+ void SetUpScrollView();
/**
* @brief Set up the parts that make the Toolbar
$(toolkit_src_dir)/controls/renderers/control-renderer-impl.cpp \
$(toolkit_src_dir)/controls/renderers/renderer-factory-cache.cpp \
$(toolkit_src_dir)/controls/renderers/renderer-factory-impl.cpp \
+ $(toolkit_src_dir)/controls/renderers/border/border-renderer.cpp \
$(toolkit_src_dir)/controls/renderers/color/color-renderer.cpp \
$(toolkit_src_dir)/controls/renderers/image/image-renderer.cpp \
+ $(toolkit_src_dir)/controls/renderers/npatch/npatch-renderer.cpp \
$(toolkit_src_dir)/controls/renderers/gradient/gradient.cpp \
$(toolkit_src_dir)/controls/renderers/gradient/linear-gradient.cpp \
$(toolkit_src_dir)/controls/renderers/gradient/radial-gradient.cpp \
cursor = CreateSolidColorActor( color );
cursor.SetSortModifier( DECORATION_DEPTH_INDEX );
cursor.SetParentOrigin( ParentOrigin::TOP_LEFT ); // Need to set the default parent origin as CreateSolidColorActor() sets a different one.
- cursor.SetAnchorPoint( AnchorPoint::TOP_RIGHT );
+ cursor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
}
// Add or Remove cursor(s) from parent
// Whether the font being validated is a default one not set by the user.
const bool isDefault = ( 0u == fontId );
+ FontId preferredFont = fontId;
DALI_LOG_INFO( gLogFilter,
Debug::Verbose,
// Emojis are present in many monochrome fonts; prefer color by default.
bool preferColor = ( TextAbstraction::EMOJI == script );
- // Find a default font.
- fontId = fontClient.FindDefaultFont( character, pointSize, preferColor );
+ // Find a fallback-font.
+ fontId = fontClient.FindFallbackFont( preferredFont, character, pointSize, preferColor );
// If the system does not support a suitable font, fallback to Latin
if( 0u == fontId )
subActor.SetSize( actorSize );
subActor.SetColor( shadowColor );
+ // Discard redundant render-tasks
+ RemoveShadowRenderTask();
+
// Create a render task to render the effect
- RenderTask task = Stage::GetCurrent().GetRenderTaskList().CreateTask();
- task.SetTargetFrameBuffer( meshRecord.mBuffer );
- task.SetSourceActor( subActor );
- task.SetClearEnabled( true );
- task.SetClearColor( Vector4::ZERO );
- task.SetExclusive( true );
- task.SetRefreshRate( RenderTask::REFRESH_ONCE );
- task.FinishedSignal().Connect( this, &AtlasRenderer::Impl::RenderComplete );
+ mShadowTask = Stage::GetCurrent().GetRenderTaskList().CreateTask();
+ mShadowTask.SetTargetFrameBuffer( meshRecord.mBuffer );
+ mShadowTask.SetSourceActor( subActor );
+ mShadowTask.SetClearEnabled( true );
+ mShadowTask.SetClearColor( Vector4::ZERO );
+ mShadowTask.SetExclusive( true );
+ mShadowTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
+ mShadowTask.FinishedSignal().Connect( this, &AtlasRenderer::Impl::RenderComplete );
actor.Add( subActor );
return actor;
}
- void RenderComplete( RenderTask& renderTask )
+ void RemoveShadowRenderTask()
{
- // Disconnect and remove this single shot render task
- renderTask.FinishedSignal().Disconnect( this, &AtlasRenderer::Impl::RenderComplete );
- Stage::GetCurrent().GetRenderTaskList().RemoveTask( renderTask );
+ if( mShadowTask )
+ {
+ mShadowTask.FinishedSignal().Disconnect( this, &AtlasRenderer::Impl::RenderComplete );
+ // Guard to prevent accessing Stage after dali-core destruction
+ if( Stage::IsInstalled() )
+ {
+ Stage::GetCurrent().GetRenderTaskList().RemoveTask( mShadowTask );
+ }
+
+ mShadowTask.Reset();
+ }
+ }
+
+ void RenderComplete( RenderTask& renderTask )
+ {
// Get the actor used for render to buffer and remove it from the parent
Actor renderActor = renderTask.GetSourceActor();
if ( renderActor )
parent.Remove( renderActor );
}
}
+
+ RemoveShadowRenderTask();
}
Actor mActor; ///< The actor parent which renders the text
AtlasGlyphManager mGlyphManager; ///< Glyph Manager to handle upload and caching
+ RenderTask mShadowTask; ///< Used to render shadows
TextAbstraction::FontClient mFontClient; ///> The font client used to supply glyph information
std::vector< MaxBlockSize > mBlockSizes; ///> Maximum size needed to contain a glyph in a block within a new atlas
std::vector< uint32_t > mFace; ///> Face indices for a quad
AtlasRenderer::~AtlasRenderer()
{
+ mImpl->RemoveShadowRenderTask();
+
mImpl->RemoveText();
delete mImpl;
}
cursorInfo.lineHeight = GetDefaultFontLineHeight();
cursorInfo.primaryCursorHeight = cursorInfo.lineHeight;
- cursorInfo.primaryPosition.x = mEventData->mDecorator->GetCursorWidth();
+ cursorInfo.primaryPosition.x = 0.f;
cursorInfo.primaryPosition.y = 0.f;
// Nothing else to do.
{
case LayoutEngine::HORIZONTAL_ALIGN_BEGIN:
{
- cursorPosition.x = mEventData->mDecorator->GetCursorWidth();
+ cursorPosition.x = 0.f;
break;
}
case LayoutEngine::HORIZONTAL_ALIGN_CENTER:
}
case LayoutEngine::HORIZONTAL_ALIGN_END:
{
- cursorPosition.x = mVisualModel->mControlSize.width;
+ cursorPosition.x = mVisualModel->mControlSize.width - mEventData->mDecorator->GetCursorWidth();
break;
}
}
return mImpl->mMaximumNumberOfCharacters;
}
-void Controller::SetDefaultFontFamily( const std::string& defaultFontFamily, bool userDefined )
+void Controller::SetDefaultFontFamily( const std::string& defaultFontFamily )
{
if( !mImpl->mFontDefaults )
{
}
mImpl->mFontDefaults->mFontDescription.family = defaultFontFamily;
- DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::SetDefaultFontFamily %s userDefined: %s\n", defaultFontFamily.c_str(), userDefined ? "true":"false" );
- mImpl->mUserDefinedFontFamily = userDefined;
+ DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::SetDefaultFontFamily %s\n", defaultFontFamily.c_str());
+ mImpl->mUserDefinedFontFamily = true;
// Clear the font-specific data
ClearFontData();
{
DALI_LOG_INFO( gLogFilter, Debug::Concise, "Controller::UpdateAfterFontChange");
- ClearFontData();
-
if ( !mImpl->mUserDefinedFontFamily ) // If user defined font then should not update when system font changes
{
DALI_LOG_INFO( gLogFilter, Debug::Concise, "Controller::UpdateAfterFontChange newDefaultFont(%s)\n", newDefaultFont.c_str() );
+ ClearFontData();
mImpl->mFontDefaults->mFontDescription.family = newDefaultFont;
mImpl->UpdateModel( ALL_OPERATIONS );
mImpl->QueueModifyEvent( ModifyEvent::TEXT_REPLACED );
for( unsigned int i=0; i<events.size(); ++i )
{
- if( ModifyEvent::TEXT_REPLACED == events[0].type )
+ if( ModifyEvent::TEXT_REPLACED == events[i].type )
{
// A (single) replace event should come first, otherwise we wasted time processing NOOP events
DALI_ASSERT_DEBUG( 0 == i && "Unexpected TEXT_REPLACED event" );
TextReplacedEvent();
}
- else if( ModifyEvent::TEXT_INSERTED == events[0].type )
+ else if( ModifyEvent::TEXT_INSERTED == events[i].type )
{
TextInsertedEvent();
}
- else if( ModifyEvent::TEXT_DELETED == events[0].type )
+ else if( ModifyEvent::TEXT_DELETED == events[i].type )
{
// Placeholder-text cannot be deleted
if( !mImpl->IsShowingPlaceholderText() )
case ImfManager::COMMIT:
{
InsertText( imfEvent.predictiveString, Text::Controller::COMMIT );
+ update=true;
requestRelayout = true;
break;
}
if( removed )
{
- // This is to reset the virtual keyboard to Upper-case
- if( 0u == mImpl->mLogicalModel->mText.Count() )
- {
- NotifyImfManager();
- }
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::KeyEvent %p DALI_KEY_BACKSPACE RemovedText\n", this );
+ // Notifiy the IMF manager after text changed
+ // Automatic Upper-case and restarting prediction on an existing word require this.
+ NotifyImfManager();
if( 0u != mImpl->mLogicalModel->mText.Count() ||
!mImpl->IsPlaceholderAvailable() )
* @brief Set the default font family.
*
* @param[in] defaultFontFamily The default font family.
- * @param[in] userDefined If set by the user
*/
- void SetDefaultFontFamily( const std::string& defaultFontFamily, bool userDefined );
+ void SetDefaultFontFamily( const std::string& defaultFontFamily );
/**
* @brief Retrieve the default font family.
class AccessibilityManager;
}
/**
- * @addtogroup dali-toolkit-accessibility-manager
+ * @addtogroup dali_toolkit_accessibility_manager
* @{
*/
class Alignment;
}
/**
- * @addtogroup dali-toolkit-controls-alignment
+ * @addtogroup dali_toolkit_controls_alignment
* @{
*/
class Button;
}
/**
- * @addtogroup dali-toolkit-controls-buttons
+ * @addtogroup dali_toolkit_controls_buttons
* @{
*/
// Deprecated API
/**
- * @deprecated Sets the label with an actor.
+ * @deprecated DALi 1.0.50
+ *
+ * @brief Sets the label with an actor.
+ *
* @param[in] label The actor to use as a label
*/
void SetLabel( Actor label );
/**
- * @deprecated Sets the button image.
+ * @deprecated DALi 1.0.50
+ *
+ * @brief Sets the button image.
+ *
* @param[in] image The button image.
*/
void SetButtonImage( Image image );
/**
- * @deprecated Sets the selected image.
+ * @deprecated DALi 1.0.50
+ *
+ * @brief Sets the selected image.
+ *
* @param[in] image The selected image.
*/
void SetSelectedImage( Image image );
/**
- * @deprecated Gets the button image.
+ * @deprecated DALi 1.0.50
+ *
+ * @brief Gets the button image.
+ *
* @return An actor with the button image.
*/
Actor GetButtonImage() const;
/**
- * @deprecated Gets the selected image.
+ * @deprecated DALi 1.0.50
+ *
+ * @brief Gets the selected image.
+ *
* @return An actor with the selected image.
*/
Actor GetSelectedImage() const;
class CheckBoxButton;
}
/**
- * @addtogroup dali-toolkit-controls-buttons
+ * @addtogroup dali_toolkit_controls_buttons
* @{
*/
class PushButton;
}
/**
- * @addtogroup dali-toolkit-controls-buttons
+ * @addtogroup dali_toolkit_controls_buttons
* @{
*/
using Button::SetButtonImage;
/**
- * @deprecated Sets the unselected image with an Actor.
+ * @deprecated DALi 1.0.50
+ *
+ * @brief Sets the unselected image with an Actor.
+ *
* @param[in] image The Actor to use.
*/
void SetButtonImage( Actor image );
using Button::SetBackgroundImage;
/**
- * @deprecated Sets the background image with an Actor.
+ * @deprecated DALi 1.0.50
+ *
+ * @brief Sets the background image with an Actor.
+ *
* @param[in] image The Actor to use.
*/
void SetBackgroundImage( Actor image );
using Button::SetSelectedImage;
/**
- * @deprecated Sets the selected image with an Actor.
+ * @deprecated DALi 1.0.50
+ *
+ * @brief Sets the selected image with an Actor.
+ *
* @param[in] image The Actor to use.
*/
void SetSelectedImage( Actor image );
using Button::SetSelectedBackgroundImage;
/**
- * @deprecated Sets the selected background image with an Actor.
+ * @deprecated DALi 1.0.50
+ *
+ * @brief Sets the selected background image with an Actor.
+ *
* @param[in] image The Actor to use.
*/
void SetSelectedBackgroundImage( Actor image );
using Button::SetDisabledBackgroundImage;
/**
- * @deprecated Sets the disabled background image with an Actor.
+ * @deprecated DALi 1.0.50
+ *
+ * @brief Sets the disabled background image with an Actor.
+ *
* @param[in] image The Actor to use.
*/
void SetDisabledBackgroundImage( Actor image );
using Button::SetDisabledImage;
/**
- * @deprecated Sets the disabled image with an Actor.
+ * @deprecated DALi 1.0.50
+ *
+ * @brief Sets the disabled image with an Actor.
+ *
* @param[in] image The Actor to use.
*/
void SetDisabledImage( Actor image );
using Button::SetDisabledSelectedImage;
/**
- * @deprecated Sets the disabled selected image with an Actor.
+ * @deprecated DALi 1.0.50
+ *
+ * @brief Sets the disabled selected image with an Actor.
+ *
* @param[in] image The Actor to use.
*/
void SetDisabledSelectedImage( Actor image );
class RadioButton;
}
/**
- * @addtogroup dali-toolkit-controls-buttons
+ * @addtogroup dali_toolkit_controls_buttons
* @{
*/
namespace Toolkit
{
/**
- * @addtogroup dali-toolkit-controls
+ * @addtogroup dali_toolkit_controls
* @{
*/
namespace Toolkit
{
/**
- * @addtogroup dali-toolkit-controls
+ * @addtogroup dali_toolkit_controls
* @{
*/
class Control;
}
/**
- * @addtogroup dali-toolkit-controls
+ * @addtogroup dali_toolkit_controls
* @{
*/
enum
{
STYLE_NAME = PROPERTY_START_INDEX, ///< name "style-name", @see SetStyleName, type std::string
- BACKGROUND, ///< name "background", @see SetBackgroundImage, type Map
+ BACKGROUND, ///< name "background", @see SetBackgroundImage, type Map, @since DALi 1.1.4
KEY_INPUT_FOCUS, ///< name "key-input-focus", @see SetKeyInputFocus, type bool
};
};
/**
* @brief Sets an image as the background of the control.
*
- * The color of this image is blended with the background color @see SetBackgroundColor
- *
* @param[in] image The image to set as the background.
*/
void SetBackgroundImage( Image image );
} // namespace Internal
/**
- * @addtogroup dali-toolkit-controls-gaussian-blur-view
+ * @addtogroup dali_toolkit_controls_gaussian_blur_view
* @{
*/
*/
// CLASS HEADER
-
#include <dali-toolkit/public-api/controls/image-view/image-view.h>
+// EXTERNAL INCLUDES
+#include <dali/public-api/images/resource-image.h>
+#include <dali/public-api/object/property-map.h>
+
// INTERNAL INCLUDES
#include <dali-toolkit/internal/controls/image-view/image-view-impl.h>
-// EXTERNAL INCLUDES
-
namespace Dali
{
{
ImageView imageView = Internal::ImageView::New();
imageView.SetImage( image );
- return imageView;
+ return ImageView( imageView );
}
ImageView ImageView::New( const std::string& url )
{
ImageView imageView = Internal::ImageView::New();
- imageView.SetProperty( ImageView::Property::RESOURCE_URL, Dali::Property::Value( url ) );
+ imageView.SetImage( url );
return imageView;
}
ImageView ImageView::DownCast( BaseHandle handle )
{
- return Control::DownCast<ImageView, Internal::ImageView>(handle);
+ return Control::DownCast<ImageView, Internal::ImageView>( handle );
}
void ImageView::SetImage( Image image )
Dali::Toolkit::GetImpl( *this ).SetImage( image );
}
+void ImageView::SetImage( const std::string& url )
+{
+ Dali::Toolkit::GetImpl( *this ).SetImage( url );
+}
+
Image ImageView::GetImage() const
{
- return Dali::Toolkit::GetImpl( *this ).GetImage();
+ return Image();
}
ImageView::ImageView( Internal::ImageView& implementation )
class ImageView;
}
/**
- * @addtogroup dali-toolkit-controls-image-view
+ * @addtogroup dali_toolkit_controls_image_view
* @{
*/
{
enum
{
- RESOURCE_URL = PROPERTY_START_INDEX, ///< name "resource-url", @see SetImage(), type string
+ IMAGE = PROPERTY_START_INDEX, ///< name "image", @see SetImage(), type string if it is a url, map otherwise
};
};
void SetImage( Image image );
/**
- * @brief Gets the Image
+ * @brief Sets this ImageView from an Image url
+ *
+ * If the handle is empty, ImageView will display nothing
+ *
+ * @since DALi 1.1.4
+ *
+ * @param[in] url The Image resource to display.
+ */
+ void SetImage( const std::string& url );
+
+ /**
+ * @deprecated Gets the Image
*
* @return The Image currently set to this ImageView
*/
*
* All the geometry loaded with the control is automatically centered and scaled to fit
* the size of all the other controls. So the max is (0.5,0.5) and the min is (-0.5,-0.5)
-*/
+ *
+ * @since DALi 1.1.4
+ */
class DALI_IMPORT_API Model3dView : public Control
{
public:
/**
* PageFactory is an abstract interface for providing image actors to PageTurnView
* Each image actor is identified by a unique ID, and has a linear order from 0 to GetNumberOfPages()-1
+ *
+ * @since DALi 1.1.4
*/
class DALI_IMPORT_API PageFactory
{
/**
* PageTurnLandscapeView provides a page turn view in portrait mode
+ *
+ * @since DALi 1.1.4
*/
class DALI_IMPORT_API PageTurnPortraitView : public PageTurnView
{
}
/**
- * PageTurnView is a base class of different mode of pageTurnViews ( portrait or landscape )
+ * @brief PageTurnView is a base class of different mode of pageTurnViews ( portrait or landscape )
+ *
* Page actors are provided from an external PageFactory
* PanGesture is used to activate the page bending, streching and tuning forward/backward
*
* | page-turn-finished | @ref PageTurnFinishedSignal() |
* | page-pan-started | @ref PagePanStartedSignal() |
* | page-pan-finished | @ref PagePanFinishedSignal() |
+ *
+ * @since DALi 1.1.4
*/
class DALI_IMPORT_API PageTurnView : public Control
{
class ScrollBar;
}
/**
- * @addtogroup dali-toolkit-controls-scroll-bar
+ * @addtogroup dali_toolkit_controls_scroll_bar
* @{
*/
namespace Toolkit
{
/**
- * @addtogroup dali-toolkit-controls-item-view
+ * @addtogroup dali_toolkit_controls_item_view
* @{
*/
namespace Toolkit
{
/**
- * @addtogroup dali-toolkit-controls-item-view
+ * @addtogroup dali_toolkit_controls_item_view
* @{
*/
namespace Toolkit
{
/**
- * @addtogroup dali-toolkit-controls-item-view
+ * @addtogroup dali_toolkit_controls_item_view
* @{
*/
namespace Toolkit
{
/**
- * @addtogroup dali-toolkit-controls-item-view
+ * @addtogroup dali_toolkit_controls_item_view
* @{
*/
class ItemView;
}
/**
- * @addtogroup dali-toolkit-controls-item-view
+ * @addtogroup dali_toolkit_controls_item_view
* @{
*/
namespace Toolkit
{
/**
- * @addtogroup dali-toolkit-controls-scroll-view
+ * @addtogroup dali_toolkit_controls_scroll_view
* @{
*/
class ScrollViewWobbleEffect;
}
/**
- * @addtogroup dali-toolkit-controls-scroll-view
+ * @addtogroup dali_toolkit_controls_scroll_view
* @{
*/
class ScrollViewPagePathEffect;
}
/**
- * @addtogroup dali-toolkit-controls-scroll-view
+ * @addtogroup dali_toolkit_controls_scroll_view
* @{
*/
class ScrollView;
}
/**
- * @addtogroup dali-toolkit-controls-scroll-view
+ * @addtogroup dali_toolkit_controls_scroll_view
* @{
*/
class Scrollable;
}
/**
- * @addtogroup dali-toolkit-controls-scrollable
+ * @addtogroup dali_toolkit_controls_scrollable
* @{
*/
class TableView;
}
/**
- * @addtogroup dali-toolkit-controls-table-view
+ * @addtogroup dali_toolkit_controls_table_view
* @{
*/
class TextField;
}
/**
- * @addtogroup dali-toolkit-controls-text-controls
+ * @addtogroup dali_toolkit_controls_text_controls
* @{
*/
class TextLabel;
}
/**
- * @addtogroup dali-toolkit-controls-text-controls
+ * @addtogroup dali_toolkit_controls_text_controls
* @{
*/
const unsigned int TOOLKIT_MAJOR_VERSION = 1;
const unsigned int TOOLKIT_MINOR_VERSION = 1;
-const unsigned int TOOLKIT_MICRO_VERSION = 2;
+const unsigned int TOOLKIT_MICRO_VERSION = 4;
const char * const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__;
#ifdef DEBUG_ENABLED
namespace Toolkit
{
/**
- * @addtogroup dali-toolkit-controls
+ * @addtogroup dali_toolkit_controls
* @{
*/
class KeyboardFocusManager;
}
/**
- * @addtogroup dali-toolkit-focus-manager
+ * @addtogroup dali_toolkit_focus_manager
* @{
*/
"popup-divider-color":[0.23,0.72,0.8,0.11],
"popup-icon-color":[1.0,1.0,1.0,1.0],
"popup-pressed-color":[0.24,0.72,0.8,0.11],
- "background-image": {
+ "background": {
"filename": "{DALI_IMAGE_DIR}selection-popup-bg.9.png"
},
"popup-fade-in-duration":0.25,
"font-style":"{\"weight\":\"light\"}"
}
},
+ "textselectiontoolbar":
+ {
+ "enable-overshoot":true
+ },
"scrollview":
{
"overshoot-effect-color":"B018"
"popup-divider-color":[0.23,0.72,0.8,0.11],
"popup-icon-color":[1.0,1.0,1.0,1.0],
"popup-pressed-color":[0.24,0.72,0.8,0.11],
- "background-image": {
+ "background": {
"filename": "{DALI_IMAGE_DIR}selection-popup-bg.9.png"
},
"popup-fade-in-duration":0.25,
"font-style":"{\"weight\":\"light\"}"
}
},
+ "textselectiontoolbar":
+ {
+ "enable-overshoot":true
+ },
"scrollview":
{
"overshoot-effect-color":"B018"
* <ul>
* <li>DALi Core: This module provides scene graph-based rendering, animation, and event handling.</li>
* <li>DALi Adaptor: This module is a platform adaptation layer.</li>
- * <li>DALi Toolkit: This module provides UI components and various effects on top of the dali-core.</li>
+ * <li>DALi Toolkit: This module provides UI components and various effects on top of the DALi Core.</li>
* </ul>
*
- * @defgroup dali-toolkit DALi Toolkit
+ * @defgroup dali_toolkit DALi Toolkit
* @ingroup dali
*
- * @brief This module provides UI components and various effects on top of the dali-core.
+ * @brief This module provides UI components and various effects on top of the DALi Core.
*
* @{
- * @defgroup dali-toolkit-accessibility-manager Accessibility Manager
+ * @defgroup dali_toolkit_accessibility_manager Accessibility Manager
* @brief AccessibilityManager manages a accessibility focus chain.
- * @defgroup dali-toolkit-controls Controls
+ * @defgroup dali_toolkit_controls Controls
* @brief Controls are interactive components for layouting the user interface.
* @{
- * @defgroup dali-toolkit-controls-alignment Alignment
+ * @defgroup dali_toolkit_controls_alignment Alignment
* @brief Alignment is a container which provides an easy way to align other actors inside its boundary.
- * @defgroup dali-toolkit-controls-buttons Buttons
+ * @defgroup dali_toolkit_controls_buttons Buttons
* @brief Button is a small object on UI that you can press.
- * @defgroup dali-toolkit-controls-gaussian-blur-view Gaussian Blur View
+ * @defgroup dali_toolkit_controls_gaussian_blur_view Gaussian Blur View
* @brief GaussianBlurView provides a render process that blurs an image.
- * @defgroup dali-toolkit-controls-image-view Image View
+ * @defgroup dali_toolkit_controls_image_view Image View
* @brief ImageView is a control displying an image.
- * @defgroup dali-toolkit-controls-scroll-bar Scroll Bar
+ * @defgroup dali_toolkit_controls_scroll_bar Scroll Bar
* @brief ScrollBar control.
- * @defgroup dali-toolkit-controls-scrollable Scrollable
+ * @defgroup dali_toolkit_controls_scrollable Scrollable
* @brief Scrollable container controls.
* @{
- * @defgroup dali-toolkit-controls-item-view Item View
+ * @defgroup dali_toolkit_controls_item_view Item View
* @brief ItemView class is a scrollable container that can contain many items.
- * @defgroup dali-toolkit-controls-scroll-view Scroll View
- * @brief ScrollView class provides scrollable view which contains actors and can be scrolled automatically or manually by panning.
+ * @defgroup dali_toolkit_controls_scroll_view Scroll View
+ * @brief ScrollView class provides scrollable view which contains actors and can be scrolled automatically or manually by panning.
* @}
- * @defgroup dali-toolkit-controls-table-view Table View
+ * @defgroup dali_toolkit_controls_table_view Table View
* @brief TableView class is a layout container for aligning child actors in a grid like layout.
- * @defgroup dali-toolkit-controls-text-controls Text Controls
+ * @defgroup dali_toolkit_controls_text_controls Text Controls
* @brief Controls for displaying text or text input.
* @}
- * @defgroup dali-toolkit-focus-manager Focus Manager
+ * @defgroup dali_toolkit_focus_manager Focus Manager
* @brief Classes for handling keyboard navigation and maintaining the two dimensional keyboard focus chain.
* @}
Name: dali-toolkit
Summary: The OpenGLES Canvas Core Library Toolkit
-Version: 1.1.2
+Version: 1.1.4
Release: 1
Group: System/Libraries
License: Apache-2.0, BSD-2.0, MIT
{ "Reload", ResourceImageApi::Reload, RESOURCE_IMAGE_API },
// nine-patch API
- { "GetStretchBorders", NinePatchImageApi::GetStretchBorders, NINE_PATCH_IMAGE_API },
{ "GetChildRectangle", NinePatchImageApi::GetChildRectangle, NINE_PATCH_IMAGE_API },
{ "CreateCroppedBufferImage",NinePatchImageApi::CreateCroppedBufferImage, NINE_PATCH_IMAGE_API },
return NinePatchImage::New( url );
}
-
-/**
- * Get the Stretch Borders
- *
- * @method getStretchBorders
- * @for NinePatchImage
- * @return object containing x,y,w,h properties
- */
-void NinePatchImageApi::GetStretchBorders( const v8::FunctionCallbackInfo< v8::Value >& args )
-{
- v8::Isolate* isolate = args.GetIsolate();
- v8::HandleScope handleScope( isolate );
-
- NinePatchImage image = GetNinePatchImage( isolate, args );
-
- v8::Local<v8::Object> rectObject = v8::Object::New( isolate );
-
- Vector4 borders = image.GetStretchBorders();
- // Set the direction
-
- rectObject->Set( v8::String::NewFromUtf8( isolate, "x" ), v8::Integer::New( isolate,borders.x ) );
- rectObject->Set( v8::String::NewFromUtf8( isolate, "y" ), v8::Integer::New( isolate,borders.y ) );
- rectObject->Set( v8::String::NewFromUtf8( isolate, "w" ), v8::Integer::New( isolate,borders.z ) );
- rectObject->Set( v8::String::NewFromUtf8( isolate, "h" ), v8::Integer::New( isolate,borders.w ) );
-
- args.GetReturnValue().Set( rectObject );
-}
-
/**
* Get the child rectangle
* @method getChildRectangle
/**
* Ninepatch Image API see nine-patch-image.h for a description
*/
- void GetStretchBorders( const v8::FunctionCallbackInfo< v8::Value >& args );
void GetChildRectangle( const v8::FunctionCallbackInfo< v8::Value >& args );
void CreateCroppedBufferImage( const v8::FunctionCallbackInfo< v8::Value >& args );