Test mTest;
};
-static bool TestCallback(Actor actor, const TouchEvent& event)
+static bool TestCallback(Actor actor, const TouchData& event)
{
return true;
}
// * Actor's touch event is connected to a callback function
// and this callback function consumes the event.
- actor.TouchedSignal().Connect( &TestCallback );
+ actor.TouchSignal().Connect( &TestCallback );
// * Button's pressed signal is connected to a callback function
// which also consumes the event.
// * Actor's touch event is connected to a callback function
// and this callback function consumes the event.
- actor.TouchedSignal().Connect( &TestCallback );
+ actor.TouchSignal().Connect( &TestCallback );
// * Button's pressed signal is connected to a callback function
// which also consumes the event.
*type = GL_SAMPLER_2D;
*size = 1;
break;
+ case 2:
+ *length = snprintf(name, bufsize, "sGloss");
+ *type = GL_SAMPLER_2D;
+ *size = 1;
+ break;
default:
break;
}
namedParams["program"] = ToString(program);
mShaderTrace.PushCall("LinkProgram", out.str(), namedParams);
- mNumberOfActiveUniforms=2;
+ mNumberOfActiveUniforms=3;
GetUniformLocation(program, "sTexture");
GetUniformLocation(program, "sEffect");
+ GetUniformLocation(program, "sGloss");
}
inline void PixelStorei(GLenum pname, GLint param)
bool IsScalable( const FontDescription& fontDescription ){return true;}
void GetFixedSizes( const FontPath& path, Dali::Vector< PointSize26Dot6>& sizes ){}
void GetFixedSizes( const FontDescription& fontDescription, Dali::Vector< PointSize26Dot6 >& sizes ){}
- void GetFontMetrics( FontId fontId, FontMetrics& metrics, int desiredFixedSize ){}
+ void GetFontMetrics( FontId fontId, FontMetrics& metrics ){}
GlyphIndex GetGlyphIndex( FontId fontId, Character charcode ){return 0;}
- bool GetGlyphMetrics( GlyphInfo* array, uint32_t size, bool horizontal, int desiredFixedSize ){return true;}
+ bool GetGlyphMetrics( GlyphInfo* array, uint32_t size, bool horizontal ){return true;}
BufferImage CreateBitmap( FontId fontId, GlyphIndex glyphIndex ){return BufferImage();}
void CreateVectorBlob( FontId fontId, GlyphIndex glyphIndex, VectorBlob*& blob,
unsigned int& blobLength, unsigned int& nominalWidth, unsigned int& nominalHeight )
GetImplementation(*this).GetFixedSizes( fontDescription, sizes );
}
-void FontClient::GetFontMetrics( FontId fontId, FontMetrics& metrics, int desiredFixedSize )
+void FontClient::GetFontMetrics( FontId fontId, FontMetrics& metrics )
{
- GetImplementation(*this).GetFontMetrics( fontId, metrics, desiredFixedSize );
+ GetImplementation(*this).GetFontMetrics( fontId, metrics );
}
GlyphIndex FontClient::GetGlyphIndex( FontId fontId, Character charcode )
return GetImplementation(*this).GetGlyphIndex( fontId, charcode );
}
-bool FontClient::GetGlyphMetrics( GlyphInfo* array, uint32_t size, GlyphType type, bool horizontal, int desiredFixedSize )
+bool FontClient::GetGlyphMetrics( GlyphInfo* array, uint32_t size, GlyphType type, bool horizontal )
{
- return GetImplementation(*this).GetGlyphMetrics( array, size, horizontal, desiredFixedSize );
+ return GetImplementation(*this).GetGlyphMetrics( array, size, horizontal );
}
BufferImage FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex )
}
///////////////////////////////////////////////////////////////////////////////
-static bool TouchEventCallback(Actor actor, const TouchEvent& event)
+static bool TouchCallback(Actor actor, const TouchData& event)
{
return false;
}
alignment.SetAnchorPoint(AnchorPoint::TOP_LEFT);
Stage::GetCurrent().Add(alignment);
- alignment.TouchedSignal().Connect(&TouchEventCallback);
+ alignment.TouchSignal().Connect(&TouchCallback);
application.Render();
application.SendNotification();
DALI_TEST_CHECK( gCheckBoxButtonState );
END_TEST;
}
+
+int UtcDaliCheckBoxSetLabelP(void)
+{
+ TestApplication application;
+
+ CheckBoxButton checkBox = CheckBoxButton::New();
+
+ Property::Map propertyMap;
+ propertyMap.Insert("text", "activate");
+ checkBox.SetProperty( checkBox.GetPropertyIndex("label"), propertyMap );
+
+ DALI_TEST_EQUALS( checkBox.GetLabelText(), "activate", TEST_LOCATION ); // Change to use GerProperty once that code is implemented
+
+ END_TEST;
+}
+
+int UtcDaliCheckBoxSetLabelDisabledP(void)
+{
+ TestApplication application;
+
+ CheckBoxButton checkBox = CheckBoxButton::New();
+ Stage::GetCurrent().Add( checkBox );
+
+ checkBox.SetSize( Vector2( 20.0f, 20.0f ) );
+ checkBox.SetDisabledBackgroundImage( "Image.jpg" );
+
+ application.SendNotification();
+ application.Render();
+
+ Property::Map propertyMap;
+ propertyMap.Insert("text", "activate");
+ checkBox.SetProperty(checkBox.GetPropertyIndex("disabled"), true);
+
+ checkBox.SetProperty( checkBox.GetPropertyIndex("label"), propertyMap );
+
+ DALI_TEST_CHECK( checkBox.GetProperty<bool>(checkBox.GetPropertyIndex("disabled")) );
+ DALI_TEST_EQUALS( checkBox.GetLabelText(), "activate", TEST_LOCATION ); // Change to use GerProperty once that code is implemented
+
+ END_TEST;
+}
+
+int UtcDaliCheckBoxSettingDisabled(void)
+{
+ ToolkitTestApplication application;
+
+ CheckBoxButton checkBox = CheckBoxButton::New();
+
+ checkBox.SetProperty(checkBox.GetPropertyIndex("disabled"), true);
+ DALI_TEST_CHECK( checkBox.GetProperty<bool>(checkBox.GetPropertyIndex("disabled")) );
+
+ checkBox.SetProperty(checkBox.GetPropertyIndex("disabled"), false);
+
+ DALI_TEST_CHECK( !checkBox.GetProperty<bool>(checkBox.GetPropertyIndex("disabled")) );
+
+ END_TEST;
+}
Property::Map propertyMap;
propertyMap.Insert("rendererType", "color");
propertyMap.Insert("mixColor", Color::BLUE);
- ControlRenderer controlRenderer = factory.GetControlRenderer( propertyMap );
+ ControlRenderer controlRenderer = factory.CreateControlRenderer( propertyMap );
ControlRenderer controlRendererCopy( controlRenderer );
DALI_TEST_CHECK(controlRenderer == controlRendererCopy);
Property::Map propertyMap;
propertyMap.Insert("rendererType", "color");
propertyMap.Insert("mixColor", Color::BLUE);
- ControlRenderer controlRenderer = factory.GetControlRenderer( propertyMap );
+ ControlRenderer controlRenderer = factory.CreateControlRenderer( propertyMap );
controlRenderer.SetDepthIndex( 1.f );
Vector2 naturalSize;
// color renderer
- ControlRenderer colorRenderer = factory.GetControlRenderer( Color::MAGENTA );
+ Dali::Property::Map map;
+ map[ "rendererType" ] = "color";
+ map[ "mixColor" ] = Color::MAGENTA;
+ ControlRenderer colorRenderer = factory.CreateControlRenderer( map );
colorRenderer.SetSize( rendererSize );
DALI_TEST_EQUALS( colorRenderer.GetSize(), rendererSize, TEST_LOCATION );
colorRenderer.GetNaturalSize(naturalSize);
// image renderer
Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME, ImageDimensions(100, 200));
- ControlRenderer imageRenderer = factory.GetControlRenderer( image );
+ ControlRenderer imageRenderer = factory.CreateControlRenderer( image );
imageRenderer.SetSize( rendererSize );
DALI_TEST_EQUALS( imageRenderer.GetSize(), rendererSize, TEST_LOCATION );
imageRenderer.GetNaturalSize(naturalSize);
Vector2 testSize(80.f, 160.f);
platform.SetClosestImageSize(testSize);
image = ResourceImage::New(TEST_NPATCH_FILE_NAME);
- ControlRenderer nPatchRenderer = factory.GetControlRenderer( image );
+ ControlRenderer nPatchRenderer = factory.CreateControlRenderer( image );
nPatchRenderer.SetSize( rendererSize );
DALI_TEST_EQUALS( nPatchRenderer.GetSize(), rendererSize, TEST_LOCATION );
nPatchRenderer.GetNaturalSize(naturalSize);
// border renderer
float borderSize = 5.f;
- ControlRenderer borderRenderer = factory.GetControlRenderer( borderSize, Color::RED );
+ map.Clear();
+ map[ "rendererType" ] = "border";
+ map[ "borderColor" ] = Color::RED;
+ map[ "borderSize" ] = borderSize;
+ ControlRenderer borderRenderer = factory.CreateControlRenderer( map );
borderRenderer.SetSize( rendererSize );
DALI_TEST_EQUALS( borderRenderer.GetSize(), rendererSize, TEST_LOCATION );
borderRenderer.GetNaturalSize(naturalSize);
stopColors.PushBack( Color::RED );
stopColors.PushBack( Color::GREEN );
propertyMap.Insert("stopColor", stopColors);
- ControlRenderer gradientRenderer = factory.GetControlRenderer(propertyMap);
+ ControlRenderer gradientRenderer = factory.CreateControlRenderer(propertyMap);
gradientRenderer.SetSize( rendererSize );
DALI_TEST_EQUALS( gradientRenderer.GetSize(), rendererSize, TEST_LOCATION );
gradientRenderer.GetNaturalSize(naturalSize);
DALI_TEST_EQUALS( naturalSize, Vector2::ZERO,TEST_LOCATION );
//svg renderer
- ControlRenderer svgRenderer = factory.GetControlRenderer( TEST_SVG_FILE_NAME );
+ ControlRenderer svgRenderer = factory.CreateControlRenderer( TEST_SVG_FILE_NAME, ImageDimensions() );
svgRenderer.SetSize( rendererSize );
DALI_TEST_EQUALS( svgRenderer.GetSize(), rendererSize, TEST_LOCATION );
svgRenderer.GetNaturalSize(naturalSize);
Property::Map propertyMap;
propertyMap.Insert("rendererType", "color");
propertyMap.Insert("mixColor", Color::BLUE);
- ControlRenderer controlRenderer = factory.GetControlRenderer( propertyMap );
+ ControlRenderer controlRenderer = factory.CreateControlRenderer( propertyMap );
Actor actor = Actor::New();
actor.SetSize(200.f, 200.f);
}
Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME, ImageDimensions(100, 200));
- imageRenderer = factory.GetControlRenderer(image);
+ imageRenderer = factory.CreateControlRenderer(image);
DALI_TEST_CHECK( imageRenderer );
imageRenderer.SetOnStage( actor );
Property::Map propertyMap;
propertyMap.Insert("rendererType", "color");
propertyMap.Insert("mixColor", Color::BLUE);
- ControlRenderer colorRenderer = factory.GetControlRenderer( propertyMap );
+ ControlRenderer colorRenderer = factory.CreateControlRenderer( propertyMap );
Property::Map resultMap;
colorRenderer.CreatePropertyMap( resultMap );
// change the blend color
Actor actor;
- factory.ResetRenderer( colorRenderer, actor, Color::CYAN );
+ colorRenderer.RemoveAndReset( actor );
+ propertyMap["mixColor"] = Color::CYAN;
+ colorRenderer = factory.CreateControlRenderer( propertyMap );
colorRenderer.CreatePropertyMap( resultMap );
colorValue = resultMap.Find( "mixColor", Property::VECTOR4 );
propertyMap.Insert("rendererType", "border");
propertyMap.Insert("borderColor", Color::BLUE);
propertyMap.Insert("borderSize", 5.f);
- ControlRenderer borderRenderer = factory.GetControlRenderer( propertyMap );
+ ControlRenderer borderRenderer = factory.CreateControlRenderer( propertyMap );
Property::Map resultMap;
borderRenderer.CreatePropertyMap( resultMap );
DALI_TEST_CHECK( sizeValue );
DALI_TEST_CHECK( sizeValue->Get<float>() == 5.f );
- borderRenderer = factory.GetControlRenderer( 10.f, Color::CYAN );
+ Property::Map propertyMap1;
+ propertyMap1[ "rendererType" ] = "border";
+ propertyMap1[ "borderColor" ] = Color::CYAN;
+ propertyMap1[ "borderSize" ] = 10.0f;
+ borderRenderer = factory.CreateControlRenderer( propertyMap1 );
borderRenderer.CreatePropertyMap( resultMap );
typeValue = resultMap.Find( "rendererType", Property::STRING );
stopColors.PushBack( Color::GREEN );
propertyMap.Insert("stopColor", stopColors);
- ControlRenderer gradientRenderer = factory.GetControlRenderer(propertyMap);
+ ControlRenderer gradientRenderer = factory.CreateControlRenderer(propertyMap);
Property::Map resultMap;
gradientRenderer.CreatePropertyMap( resultMap );
stopColors.PushBack( Color::GREEN );
propertyMap.Insert("stopColor", stopColors);
- ControlRenderer gradientRenderer = factory.GetControlRenderer(propertyMap);
+ ControlRenderer gradientRenderer = factory.CreateControlRenderer(propertyMap);
DALI_TEST_CHECK( gradientRenderer );
Property::Map resultMap;
propertyMap.Insert( "samplingMode", "BOX_THEN_NEAREST" );
propertyMap.Insert( "synchronousLoading", true );
- ControlRenderer imageRenderer = factory.GetControlRenderer(propertyMap);
+ ControlRenderer imageRenderer = factory.CreateControlRenderer(propertyMap);
DALI_TEST_CHECK( imageRenderer );
Property::Map resultMap;
// 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 = factory.CreateControlRenderer(image);
imageRenderer.CreatePropertyMap( resultMap );
value = resultMap.Find( "rendererType", Property::STRING );
propertyMap.Insert( "rendererType", "image" );
propertyMap.Insert( "url", TEST_NPATCH_FILE_NAME );
propertyMap.Insert( "borderOnly", true );
- ControlRenderer nPatchRenderer = factory.GetControlRenderer( propertyMap );
+ ControlRenderer nPatchRenderer = factory.CreateControlRenderer( propertyMap );
Property::Map resultMap;
nPatchRenderer.CreatePropertyMap( resultMap );
Property::Map propertyMap;
propertyMap.Insert( "rendererType", "image" );
propertyMap.Insert( "url", TEST_SVG_FILE_NAME );
- ControlRenderer svgRenderer = factory.GetControlRenderer( propertyMap );
+ ControlRenderer svgRenderer = factory.CreateControlRenderer( propertyMap );
Property::Map resultMap;
svgRenderer.CreatePropertyMap( resultMap );
DALI_TEST_CHECK( value->Get<std::string>() == TEST_SVG_FILE_NAME );
// request SvgRenderer with an URL
- ControlRenderer svgRenderer2 = factory.GetControlRenderer( TEST_SVG_FILE_NAME );
+ ControlRenderer svgRenderer2 = factory.CreateControlRenderer( TEST_SVG_FILE_NAME, ImageDimensions() );
resultMap.Clear();
svgRenderer2.CreatePropertyMap( resultMap );
// check the property values from the returned map from control renderer
propertyMap.Insert( "materialUrl", TEST_MTL_FILE_NAME );
propertyMap.Insert( "texturesPath", TEST_RESOURCE_LOCATION );
propertyMap.Insert( "shaderType", "textureless" );
- ControlRenderer meshRenderer = factory.GetControlRenderer( propertyMap );
+ ControlRenderer meshRenderer = factory.CreateControlRenderer( propertyMap );
Property::Map resultMap;
meshRenderer.CreatePropertyMap( resultMap );
Property::Map propertyMap1;
propertyMap1.Insert("rendererType", "color");
propertyMap1.Insert("mixColor", Color::BLUE);
- ControlRenderer colorRenderer = factory.GetControlRenderer(propertyMap1);
+ ControlRenderer colorRenderer = factory.CreateControlRenderer(propertyMap1);
DALI_TEST_CHECK( colorRenderer );
DALI_TEST_CHECK( IsDebugRenderer( colorRenderer ) );
propertyMap2.Insert("rendererType", "border");
propertyMap2.Insert("borderColor", Color::BLUE);
propertyMap2.Insert("borderSize", 2.f);
- ControlRenderer borderRenderer = factory.GetControlRenderer(propertyMap2);
+ ControlRenderer borderRenderer = factory.CreateControlRenderer(propertyMap2);
DALI_TEST_CHECK( borderRenderer );
DALI_TEST_CHECK( IsDebugRenderer( borderRenderer ) );
stopColors.PushBack( Color::RED );
stopColors.PushBack( Color::GREEN );
propertyMap3.Insert("gradientStopColor", stopColors);
- ControlRenderer gradientRenderer = factory.GetControlRenderer(propertyMap3);
+ ControlRenderer gradientRenderer = factory.CreateControlRenderer(propertyMap3);
DALI_TEST_CHECK( gradientRenderer );
DALI_TEST_CHECK( IsDebugRenderer( gradientRenderer ) );
Property::Map propertyMap4;
propertyMap4.Insert( "rendererType", "image" );
propertyMap4.Insert( "url", TEST_IMAGE_FILE_NAME );
- ControlRenderer imageRenderer = factory.GetControlRenderer( propertyMap4 );
+ ControlRenderer imageRenderer = factory.CreateControlRenderer( propertyMap4 );
DALI_TEST_CHECK( imageRenderer );
DALI_TEST_CHECK( IsDebugRenderer( imageRenderer ) );
Property::Map propertyMap5;
propertyMap5.Insert( "rendererType", "image" );
propertyMap5.Insert( "url", TEST_NPATCH_FILE_NAME );
- ControlRenderer nPatchRenderer = factory.GetControlRenderer( propertyMap4 );
+ ControlRenderer nPatchRenderer = factory.CreateControlRenderer( propertyMap4 );
DALI_TEST_CHECK( nPatchRenderer );
DALI_TEST_CHECK( IsDebugRenderer( nPatchRenderer ) );
DALI_TEST_CHECK( factory );
// Test that color renderer is replaced with debug renderer
- ControlRenderer colorRenderer = factory.GetControlRenderer(Color::CYAN);
+ Dali::Property::Map map;
+ map[ "rendererType" ] = "color";
+ map[ "mixColor" ] = Color::CYAN;
+
+ ControlRenderer colorRenderer = factory.CreateControlRenderer( map);
DALI_TEST_CHECK( colorRenderer );
DALI_TEST_CHECK( IsDebugRenderer( colorRenderer ) );
// Test that border renderer is replaced with debug renderer
- ControlRenderer borderRenderer = factory.GetControlRenderer(2.f, Color::GREEN);
+ map.Clear();
+ map[ "rendererType" ] = "border";
+ map[ "borderColor" ] = Color::GREEN;
+ map[ "borderSize" ] = 2.f;
+ ControlRenderer borderRenderer = factory.CreateControlRenderer( map );
DALI_TEST_CHECK( borderRenderer );
DALI_TEST_CHECK( IsDebugRenderer( borderRenderer ) );
// Test that image renderer is replaced with debug renderer
Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME);
- ControlRenderer imageRenderer = factory.GetControlRenderer( image );
+ ControlRenderer imageRenderer = factory.CreateControlRenderer( image );
DALI_TEST_CHECK( imageRenderer );
DALI_TEST_CHECK( IsDebugRenderer( imageRenderer ) );
// Test that n patch renderer is replaced with debug renderer
- ControlRenderer nPatchRenderer = factory.GetControlRenderer( TEST_NPATCH_FILE_NAME );
+ ControlRenderer nPatchRenderer = factory.CreateControlRenderer( TEST_NPATCH_FILE_NAME, ImageDimensions() );
DALI_TEST_CHECK( nPatchRenderer );
DALI_TEST_CHECK( IsDebugRenderer( nPatchRenderer ) );
EnvironmentVariable::SetTestingEnvironmentVariable(false);
END_TEST;
}
-
-int UtcDaliDebugRendererResetRenderer(void)
-{
- EnvironmentVariable::SetTestingEnvironmentVariable(true);
- ToolkitTestApplication application;
- tet_infoline( "UtcDaliDebugRendererResetRenderer: Reset renderer with various parameters" );
-
- RendererFactory factory = RendererFactory::Get();
- DALI_TEST_CHECK( factory );
-
- // Test that color renderer is replaced with debug renderer
- ControlRenderer controlRenderer = factory.GetControlRenderer(Color::CYAN);
- DALI_TEST_CHECK( controlRenderer );
- DALI_TEST_CHECK( IsDebugRenderer( controlRenderer ) );
-
- Actor actor;
- // Reset to render another color
- // Test that color renderer is replaced with debug renderer
- factory.ResetRenderer( controlRenderer, actor, Color::BLUE );
- DALI_TEST_CHECK( IsDebugRenderer( controlRenderer ) );
-
- // Reset to render an image
- // Test that image renderer is replaced with debug renderer
- Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME);
- factory.ResetRenderer( controlRenderer, actor, image );
- DALI_TEST_CHECK( IsDebugRenderer( controlRenderer ) );
-
- // Reset with a property map of border renderer
- // Test that border renderer is replaced with debug renderer
- Property::Map propertyMap;
- propertyMap.Insert("rendererType", "border");
- propertyMap.Insert("borderColor", Color::BLUE);
- propertyMap.Insert("borderSize", 2.f);
- factory.ResetRenderer( controlRenderer, actor, propertyMap );
- DALI_TEST_CHECK( IsDebugRenderer( controlRenderer ) );
-
- EnvironmentVariable::SetTestingEnvironmentVariable(false);
- END_TEST;
-}
// Sync loading, no atlasing for big size image
{
- ImageView imageView = ImageView::New( gImage_600_RGB );
+ ImageView imageView = ImageView::New();
// Sync loading is used
+ syncLoadingMap[ "url" ] = gImage_600_RGB;
imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
// BitmapLoader is used, and the loading is started immediately even the actor is not on stage.
customShader.Insert( "hints", shaderHints );
Property::Map map;
- map.Insert( "rendererType", "image" );
map.Insert( "shader", customShader );
TestNativeImagePointer nativeImageInterface = TestNativeImage::New( width, height );
imageView.SetProperty( ImageView::Property::IMAGE, map );
Stage::GetCurrent().Add( imageView );
- imageView.SetProperty( ImageView::Property::IMAGE, map );
-
TestGlAbstraction& gl = application.GetGlAbstraction();
gl.EnableTextureCallTrace( true );
customShader.Insert( "hints", shaderHints );
Property::Map map;
- map.Insert( "rendererType", "image" );
map.Insert( "shader", customShader );
BufferImage image = CreateBufferImage( width, height, Color::WHITE );
imageView.SetProperty( ImageView::Property::IMAGE, map );
Stage::GetCurrent().Add( imageView );
- imageView.SetProperty( ImageView::Property::IMAGE, map );
-
TestGlAbstraction& gl = application.GetGlAbstraction();
gl.EnableTextureCallTrace( true );
propertyMap.Insert("rendererType", "color");
propertyMap.Insert("mixColor", testColor);
- ControlRenderer controlRenderer = factory.GetControlRenderer(propertyMap);
+ ControlRenderer controlRenderer = factory.CreateControlRenderer(propertyMap);
DALI_TEST_CHECK( controlRenderer );
Actor actor = Actor::New();
DALI_TEST_CHECK( factory );
Vector4 testColor( 1.f, 0.5f, 0.3f, 0.2f );
- ControlRenderer controlRenderer = factory.GetControlRenderer(testColor);
+ Dali::Property::Map map;
+ map[ "rendererType" ] = "color";
+ map[ "mixColor" ] = testColor;
+ ControlRenderer controlRenderer = factory.CreateControlRenderer( map );
DALI_TEST_CHECK( controlRenderer );
Actor actor = Actor::New();
propertyMap.Insert("borderColor", testColor);
propertyMap.Insert("borderSize", testSize);
- ControlRenderer controlRenderer = factory.GetControlRenderer(propertyMap);
+ ControlRenderer controlRenderer = factory.CreateControlRenderer(propertyMap);
DALI_TEST_CHECK( controlRenderer );
Actor actor = Actor::New();
Vector4 testColor( 1.f, 0.5f, 0.3f, 1.f );
float testSize = 5.f;
- ControlRenderer controlRenderer = factory.GetControlRenderer(testSize, testColor );
+ Dali::Property::Map propertyMap;
+ propertyMap[ "rendererType" ] = "border";
+ propertyMap[ "borderColor" ] = testColor;
+ propertyMap[ "borderSize" ] = testSize;
+ ControlRenderer controlRenderer = factory.CreateControlRenderer( propertyMap );
DALI_TEST_CHECK( controlRenderer );
Actor actor = Actor::New();
controlRenderer.SetOffStage( actor );
// enable the anti-aliasing
- controlRenderer = factory.GetControlRenderer(testSize, testColor, true );
+ Dali::Property::Map map;
+ map[ "rendererType" ] = "border";
+ map[ "borderColor" ] = testColor;
+ map[ "borderSize" ] = testSize;
+ map[ "antiAliasing" ] = true;
+ controlRenderer = factory.CreateControlRenderer( map );
controlRenderer.SetOnStage( actor );
application.SendNotification();
stopColors.PushBack( Color::GREEN );
propertyMap.Insert("stopColor", stopColors);
- ControlRenderer controlRenderer = factory.GetControlRenderer(propertyMap);
+ ControlRenderer controlRenderer = factory.CreateControlRenderer(propertyMap);
DALI_TEST_CHECK( controlRenderer );
// A lookup texture is generated and pass to shader as sampler
stopColors.PushBack( Color::GREEN );
propertyMap.Insert("stopColor", stopColors);
- ControlRenderer controlRenderer = factory.GetControlRenderer(propertyMap);
+ ControlRenderer controlRenderer = factory.CreateControlRenderer(propertyMap);
DALI_TEST_CHECK( controlRenderer );
// A lookup texture is generated and pass to shader as sampler
stopColors.PushBack( Color::GREEN );
propertyMap.Insert("stopColor", stopColors);
- ControlRenderer controlRenderer = factory.GetControlRenderer(propertyMap);
+ ControlRenderer controlRenderer = factory.CreateControlRenderer(propertyMap);
DALI_TEST_CHECK( controlRenderer );
// A lookup texture is generated and pass to shader as sampler
propertyMap.Insert( "rendererType", "image" );
propertyMap.Insert( "url", TEST_IMAGE_FILE_NAME );
- ControlRenderer controlRenderer = factory.GetControlRenderer( propertyMap );
+ ControlRenderer controlRenderer = factory.CreateControlRenderer( propertyMap );
DALI_TEST_CHECK( controlRenderer );
Actor actor = Actor::New();
DALI_TEST_CHECK( factory );
Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME);
- ControlRenderer controlRenderer = factory.GetControlRenderer( image );
+ ControlRenderer controlRenderer = factory.CreateControlRenderer( image );
Actor actor = Actor::New();
// For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
propertyMap.Insert( "url", TEST_NPATCH_FILE_NAME );
{
tet_infoline( "whole grid" );
- ControlRenderer controlRenderer = factory.GetControlRenderer( propertyMap );
+ ControlRenderer controlRenderer = factory.CreateControlRenderer( propertyMap );
DALI_TEST_CHECK( controlRenderer );
Actor actor = Actor::New();
propertyMap.Insert( "borderOnly", true );
{
tet_infoline( "border only" );
- ControlRenderer controlRenderer = factory.GetControlRenderer( propertyMap );
+ ControlRenderer controlRenderer = factory.CreateControlRenderer( propertyMap );
DALI_TEST_CHECK( controlRenderer );
Actor actor = Actor::New();
propertyMap.Insert( "rendererType", "image" );
propertyMap.Insert( "url", TEST_NPATCH_FILE_NAME );
{
- ControlRenderer controlRenderer = factory.GetControlRenderer( propertyMap );
+ ControlRenderer controlRenderer = factory.CreateControlRenderer( propertyMap );
DALI_TEST_CHECK( controlRenderer );
Actor actor = Actor::New();
propertyMap.Insert( "borderOnly", true );
{
tet_infoline( "border only" );
- ControlRenderer controlRenderer = factory.GetControlRenderer( propertyMap );
+ ControlRenderer controlRenderer = factory.CreateControlRenderer( propertyMap );
DALI_TEST_CHECK( controlRenderer );
TestGlAbstraction& gl = application.GetGlAbstraction();
stretchRangesY.PushBack( Uint16Pair( 4, 5 ) );
Integration::ResourcePointer ninePatchResource = CustomizeNinePatch( application, ninePatchImageWidth, ninePatchImageHeight, stretchRangesX, stretchRangesY );
- ControlRenderer controlRenderer = factory.GetControlRenderer( TEST_NPATCH_FILE_NAME );
+ ControlRenderer controlRenderer = factory.CreateControlRenderer( TEST_NPATCH_FILE_NAME, ImageDimensions() );
DALI_TEST_CHECK( controlRenderer );
Actor actor = Actor::New();
stretchRangesY.PushBack( Uint16Pair( 25, 27 ) );
Integration::ResourcePointer ninePatchResource = CustomizeNinePatch( application, ninePatchImageWidth, ninePatchImageHeight, stretchRangesX, stretchRangesY );
- ControlRenderer controlRenderer = factory.GetControlRenderer( TEST_NPATCH_FILE_NAME );
+ ControlRenderer controlRenderer = factory.CreateControlRenderer( TEST_NPATCH_FILE_NAME, ImageDimensions() );
DALI_TEST_CHECK( controlRenderer );
Actor actor = Actor::New();
RendererFactory factory = RendererFactory::Get();
DALI_TEST_CHECK( factory );
- ControlRenderer controlRenderer = factory.GetControlRenderer( "ERROR.9.jpg" );
+ ControlRenderer controlRenderer = factory.CreateControlRenderer( "ERROR.9.jpg", ImageDimensions() );
DALI_TEST_CHECK( controlRenderer );
Actor actor = Actor::New();
propertyMap.Insert( "rendererType", 111 );
propertyMap.Insert( "url", "ERROR.9.jpg" );
- ControlRenderer controlRenderer = factory.GetControlRenderer( propertyMap );
+ ControlRenderer controlRenderer = factory.CreateControlRenderer( propertyMap );
DALI_TEST_CHECK( controlRenderer );
Actor actor = Actor::New();
tet_infoline( "UtcDaliRendererFactoryGetSvgRenderer: Request svg renderer with a svg url" );
RendererFactory factory = RendererFactory::Get();
- ControlRenderer controlRenderer = factory.GetControlRenderer( TEST_SVG_FILE_NAME );
+ ControlRenderer controlRenderer = factory.CreateControlRenderer( TEST_SVG_FILE_NAME, ImageDimensions() );
DALI_TEST_CHECK( controlRenderer );
TestGlAbstraction& gl = application.GetGlAbstraction();
propertyMap.Insert( "rendererType", "mesh" );
propertyMap.Insert( "objectUrl", TEST_OBJ_FILE_NAME );
- ControlRenderer controlRenderer = factory.GetControlRenderer( propertyMap );
+ ControlRenderer controlRenderer = factory.CreateControlRenderer( propertyMap );
DALI_TEST_CHECK( controlRenderer );
Actor actor = Actor::New();
propertyMap.Insert( "materialUrl", "" );
propertyMap.Insert( "texturesPath", "" );
- ControlRenderer controlRenderer = factory.GetControlRenderer( propertyMap );
+ ControlRenderer controlRenderer = factory.CreateControlRenderer( propertyMap );
DALI_TEST_CHECK( controlRenderer );
//Add renderer to an actor on stage.
propertyMap.Insert( "materialUrl", TEST_MTL_FILE_NAME );
propertyMap.Insert( "texturesPath", TEST_RESOURCE_DIR "/" );
- ControlRenderer controlRenderer = factory.GetControlRenderer( propertyMap );
+ ControlRenderer controlRenderer = factory.CreateControlRenderer( propertyMap );
DALI_TEST_CHECK( controlRenderer );
//Add renderer to an actor on stage.
propertyMap.Insert( "materialUrl", TEST_SIMPLE_MTL_FILE_NAME );
propertyMap.Insert( "texturesPath", TEST_RESOURCE_DIR "/" );
- ControlRenderer controlRenderer = factory.GetControlRenderer( propertyMap );
+ ControlRenderer controlRenderer = factory.CreateControlRenderer( propertyMap );
DALI_TEST_CHECK( controlRenderer );
//Add renderer to an actor on stage.
propertyMap.Insert( "materialUrl", TEST_MTL_FILE_NAME );
propertyMap.Insert( "texturesPath", TEST_RESOURCE_DIR "/" );
- ControlRenderer controlRenderer = factory.GetControlRenderer( propertyMap );
+ ControlRenderer controlRenderer = factory.CreateControlRenderer( propertyMap );
DALI_TEST_CHECK( controlRenderer );
//Add renderer to an actor on stage.
propertyMap.Insert( "materialUrl", "invalid" );
propertyMap.Insert( "texturesPath", "also invalid" );
- ControlRenderer controlRenderer = factory.GetControlRenderer( propertyMap );
+ ControlRenderer controlRenderer = factory.CreateControlRenderer( propertyMap );
DALI_TEST_CHECK( controlRenderer );
//Add renderer to an actor on stage.
propertyMap.Insert( "materialUrl", TEST_MTL_FILE_NAME );
propertyMap.Insert( "texturesPath", TEST_RESOURCE_DIR "/" );
- ControlRenderer controlRenderer = factory.GetControlRenderer( propertyMap );
+ ControlRenderer controlRenderer = factory.CreateControlRenderer( propertyMap );
DALI_TEST_CHECK( controlRenderer );
//Add renderer to an actor on stage.
END_TEST;
}
-
-int UtcDaliRendererFactoryResetRenderer1(void)
-{
- ToolkitTestApplication application;
- tet_infoline( "UtcDaliRendererFactoryResetRenderer1" );
-
- RendererFactory factory = RendererFactory::Get();
- DALI_TEST_CHECK( factory );
-
- ControlRenderer controlRenderer = factory.GetControlRenderer( Color::RED );
- DALI_TEST_CHECK( controlRenderer );
-
- Actor actor = Actor::New();
- TestControlRendererRender( application, actor, controlRenderer );
-
- Vector4 actualValue(Vector4::ZERO);
- TestGlAbstraction& gl = application.GetGlAbstraction();
- DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "mixColor", actualValue ) );
- DALI_TEST_EQUALS( actualValue, Color::RED, TEST_LOCATION );
-
- factory.ResetRenderer( controlRenderer, actor, Color::GREEN );
- application.SendNotification();
- application.Render(0);
- DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "mixColor", actualValue ) );
- DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
-
- Image bufferImage = CreateBufferImage( 100, 200, Vector4( 1.f, 1.f, 1.f, 1.f ) );
- factory.ResetRenderer( controlRenderer, actor, bufferImage );
-
- Actor actor2 = Actor::New();
- actor2.SetSize(200.f, 200.f);
- Stage::GetCurrent().Add( actor2 );
- controlRenderer.SetSize(Vector2(200.f, 200.f));
- controlRenderer.SetOnStage( actor2 );
- application.SendNotification();
- application.Render(0);
-
- END_TEST;
-}
-
-int UtcDaliRendererFactoryResetRenderer2(void)
-{
- ToolkitTestApplication application;
- tet_infoline( "UtcDaliRendererFactoryResetRenderer2" );
-
- Actor actor = Actor::New();
- actor.SetSize(200.f, 200.f);
- Stage::GetCurrent().Add( actor );
- RendererFactory factory = RendererFactory::Get();
- DALI_TEST_CHECK( factory );
-
- Image resourceImage = ResourceImage::New(TEST_IMAGE_FILE_NAME);
- ControlRenderer controlRenderer = factory.GetControlRenderer( resourceImage );
- DALI_TEST_CHECK( controlRenderer );
- controlRenderer.SetSize(Vector2(200.f, 200.f));
- controlRenderer.SetOnStage( actor );
- DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
-
- application.SendNotification();
- application.Render(0);
-
- Image bufferImage = CreateBufferImage( 100, 200, Vector4( 1.f, 1.f, 1.f, 1.f ) );
- factory.ResetRenderer( controlRenderer, actor, bufferImage );
- application.SendNotification();
- application.Render(0);
-
- factory.ResetRenderer( controlRenderer, actor, Color::RED );
-
- Actor actor2 = Actor::New();
- actor2.SetSize(200.f, 200.f);
- Stage::GetCurrent().Add( actor2 );
- controlRenderer.SetSize(Vector2(200.f, 200.f));
- controlRenderer.SetOnStage( actor2 );
- TestGlAbstraction& gl = application.GetGlAbstraction();
- application.SendNotification();
- application.Render(0);
- Vector4 actualValue(Vector4::ZERO);
- DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "mixColor", actualValue ) );
- DALI_TEST_EQUALS( actualValue, Color::RED, TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcDaliRendererFactoryResetRenderer3(void)
-{
- ToolkitTestApplication application;
- tet_infoline( "UtcDaliRendererFactoryResetRenderer3" );
-
- Actor actor = Actor::New();
- actor.SetSize(200.f, 200.f);
- Stage::GetCurrent().Add( actor );
- RendererFactory factory = RendererFactory::Get();
- DALI_TEST_CHECK( factory );
-
- // Get renderer for rendering a resource image
- Image resourceImage = ResourceImage::New(TEST_IMAGE_FILE_NAME);
- ControlRenderer controlRenderer = factory.GetControlRenderer( resourceImage );
- DALI_TEST_CHECK( controlRenderer );
- controlRenderer.SetSize(Vector2(200.f, 200.f));
- controlRenderer.SetOnStage( actor );
- application.SendNotification();
- application.Render();
-
- DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
-
- // reset the renderer to renderer a svg image
- factory.ResetRenderer( controlRenderer, actor, TEST_SVG_FILE_NAME, ImageDimensions( 100, 100 ) );
- application.SendNotification();
- application.Render();
-
- DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
-
- EventThreadCallback* eventTrigger = EventThreadCallback::Get();
- CallbackBase* callback = eventTrigger->GetCallback();
-
- eventTrigger->WaitingForTrigger( 1 );// waiting until the svg image is rasterized.
- CallbackBase::Execute( *callback );
-
- END_TEST;
-}
-
-//Test resetting mesh and primitive shape renderers
-int UtcDaliRendererFactoryResetRenderer4(void)
-{
- ToolkitTestApplication application;
- tet_infoline( "UtcDaliRendererFactoryResetRenderer4: Mesh and primitive renderers" );
-
- Actor actor = Actor::New();
- actor.SetSize( 200.f, 200.f );
- Stage::GetCurrent().Add( actor );
- RendererFactory factory = RendererFactory::Get();
- DALI_TEST_CHECK( factory );
-
- Property::Map map;
-
- //******
-
- //Start with basic color renderer
- ControlRenderer controlRenderer = factory.GetControlRenderer( Color::RED );
- DALI_TEST_CHECK( controlRenderer );
-
- TestControlRendererRender( application, actor, controlRenderer );
-
- DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
-
- //Ensure set correctly.
- Vector4 actualValue( Vector4::ZERO );
- TestGlAbstraction& gl = application.GetGlAbstraction();
- DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "mixColor", actualValue ) );
- DALI_TEST_EQUALS( actualValue, Color::RED, TEST_LOCATION );
-
- //******
-
- //Reset to mesh renderer
- map.Insert( "rendererType", "mesh" );
- map.Insert( "objectUrl", TEST_OBJ_FILE_NAME );
- map.Insert( "materialUrl", TEST_MTL_FILE_NAME );
- map.Insert( "texturesPath", TEST_RESOURCE_DIR "/" );
- factory.ResetRenderer( controlRenderer, actor, map );
- application.SendNotification();
- application.Render( 0 );
-
- DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
-
- //Tell the platform abstraction that the required resources have been loaded.
- TestPlatformAbstraction& platform = application.GetPlatform();
- platform.SetAllResourceRequestsAsLoaded();
-
- //Render again to upload the now-loaded textures.
- application.SendNotification();
- application.Render( 0 );
-
- //Ensure set correctly.
- controlRenderer.CreatePropertyMap( map );
- DALI_TEST_EQUALS( map.Find( "objectUrl", Property::STRING )->Get<std::string>(), TEST_OBJ_FILE_NAME, TEST_LOCATION );
-
- Matrix testScaleMatrix;
- testScaleMatrix.SetIdentityAndScale( Vector3( 1.0, -1.0, 1.0 ) );
- Matrix actualScaleMatrix;
-
- //Test to see if the object has been successfully loaded.
- DALI_TEST_CHECK( gl.GetUniformValue<Matrix>( "uObjectMatrix", actualScaleMatrix ) );
- DALI_TEST_EQUALS( actualScaleMatrix, testScaleMatrix, Math::MACHINE_EPSILON_100, TEST_LOCATION );
-
- //******
-
- //Reset back to color renderer
- factory.ResetRenderer( controlRenderer, actor, Color::GREEN );
- application.SendNotification();
- application.Render( 0 );
-
- DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
-
- //Ensure set correctly.
- DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "mixColor", actualValue ) );
- DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
-
- //******
-
- END_TEST;
-}
application.SendNotification();
application.Render();
- // Check there are the expected number of children ( active layer, offscreen root actor, and the offscreen image view
- DALI_TEST_EQUALS( editor.GetChildCount(), 3u, TEST_LOCATION );
+ // Check there are the expected number of children ( offscreen root actor, and the offscreen image view
+ DALI_TEST_EQUALS( editor.GetChildCount(), 2u, TEST_LOCATION );
- Actor layer = editor.GetChildAt( 0u );
- DALI_TEST_CHECK( layer.IsLayer() );
-
- Actor offscreenRoot = editor.GetChildAt( 1u );
+ Actor offscreenRoot = editor.GetChildAt( 0u );
DALI_TEST_CHECK( offscreenRoot.IsLayer() );
DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 1u, TEST_LOCATION ); // The camera actor.
- Actor offscreenImage = editor.GetChildAt( 2u );
+ Actor offscreenImage = editor.GetChildAt( 1u );
DALI_TEST_CHECK( offscreenImage );
// Create a tap event to touch the text editor.
application.SendNotification();
application.Render();
+ Actor layer = editor.GetChildAt( 2u );
+ DALI_TEST_CHECK( layer.IsLayer() );
+
DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 1u, TEST_LOCATION ); // The camera actor.
application.Render();
// The offscreen root actor should have three actors: the camera, a renderer and the highlight actor.
- Actor offscreenRoot = editor.GetChildAt( 1u );
+ Actor offscreenRoot = editor.GetChildAt( 0u );
DALI_TEST_CHECK( offscreenRoot.IsLayer() );
CameraActor camera = CameraActor::DownCast( offscreenRoot.GetChildAt( 0u ) );
application.SendNotification();
application.Render();
- // Check there are the expected number of children ( active layer, offscreen root actor, and the offscreen image view
- DALI_TEST_EQUALS( field.GetChildCount(), 3u, TEST_LOCATION );
+ // Check there are the expected number of children ( offscreen root actor, and the offscreen image view
+ DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
- Actor layer = field.GetChildAt( 0u );
- DALI_TEST_CHECK( layer.IsLayer() );
-
- Actor offscreenRoot = field.GetChildAt( 1u );
+ Actor offscreenRoot = field.GetChildAt( 0u );
DALI_TEST_CHECK( offscreenRoot.IsLayer() );
DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 1u, TEST_LOCATION ); // The camera actor.
- Actor offscreenImage = field.GetChildAt( 2u );
+ Actor offscreenImage = field.GetChildAt( 1u );
DALI_TEST_CHECK( offscreenImage );
// Create a tap event to touch the text field.
application.SendNotification();
application.Render();
+ Actor layer = field.GetChildAt( 2u );
+ DALI_TEST_CHECK( layer.IsLayer() );
+
DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 1u, TEST_LOCATION ); // The camera actor.
Actor solidColorActor = Actor::New();
RendererFactory factory = RendererFactory::Get();
- ControlRenderer colorRenderer = factory.GetControlRenderer( color );
+ Dali::Property::Map map;
+ map[ "rendererType" ] = "color";
+ map[ "mixColor" ] = color;
+ ControlRenderer colorRenderer = factory.CreateControlRenderer( map );
colorRenderer.SetOnStage( solidColorActor );
return solidColorActor;
{
}
-ControlRenderer RendererFactory::GetControlRenderer( const Property::Map& propertyMap )
+ControlRenderer RendererFactory::CreateControlRenderer( const Property::Map& propertyMap )
{
- return GetImplementation( *this ).GetControlRenderer( propertyMap );
+ return GetImplementation( *this ).CreateControlRenderer( propertyMap );
}
-ControlRenderer RendererFactory::GetControlRenderer( const Vector4& color )
+ControlRenderer RendererFactory::CreateControlRenderer( const Image& image )
{
- return GetImplementation( *this ).GetControlRenderer( color );
+ return GetImplementation( *this ).CreateControlRenderer( image );
}
-void RendererFactory::ResetRenderer( ControlRenderer& renderer, Actor& actor, const Vector4& color )
+ControlRenderer RendererFactory::CreateControlRenderer( const std::string& url, ImageDimensions size )
{
- GetImplementation( *this ).ResetRenderer( renderer, actor, color );
-}
-
-ControlRenderer RendererFactory::GetControlRenderer( float borderSize, const Vector4& borderColor )
-{
- return GetImplementation( *this ).GetControlRenderer( borderSize, borderColor, false );
-}
-
-
-ControlRenderer RendererFactory::GetControlRenderer( float borderSize, const Vector4& borderColor, bool antiAliasing )
-{
- return GetImplementation( *this ).GetControlRenderer( borderSize, borderColor, antiAliasing );
-}
-
-ControlRenderer RendererFactory::GetControlRenderer( const Image& image )
-{
- return GetImplementation( *this ).GetControlRenderer( image );
-}
-
-void RendererFactory::ResetRenderer( ControlRenderer& renderer, Actor& actor, const Image& image )
-{
- GetImplementation( *this ).ResetRenderer( renderer, actor, image );
-}
-
-ControlRenderer RendererFactory::GetControlRenderer( const std::string& url, ImageDimensions size )
-{
- return GetImplementation( *this ).GetControlRenderer( url, size );
-}
-
-void RendererFactory::ResetRenderer( ControlRenderer& renderer, Actor& actor, const std::string& url, ImageDimensions size )
-{
- GetImplementation( *this ).ResetRenderer( renderer, actor, url, size );
-}
-
-void RendererFactory::ResetRenderer( ControlRenderer& renderer, Actor& actor, const Property::Map& propertyMap )
-{
- GetImplementation( *this ).ResetRenderer( renderer, actor, propertyMap );
+ return GetImplementation( *this ).CreateControlRenderer( url, size );
}
} // namespace Toolkit
// EXTERNAL INCLUDES
#include <dali/public-api/object/base-handle.h>
#include <dali/public-api/images/image-operations.h>
+#include <dali/public-api/object/property-map.h>
// INTERNAK INCLUDES
#include <dali-toolkit/devel-api/controls/renderer-factory/control-renderer.h>
* Depends on the content of the map, different kind of renderer would be returned.
* @return The pointer pointing to control renderer
*/
- ControlRenderer GetControlRenderer( const Property::Map& propertyMap );
-
- /**
- * @brief Request the control renderer to render the given color
- *
- * @param[in] color The color to be rendered
- * @return The pointer pointing to the control renderer
- */
- ControlRenderer GetControlRenderer( const Vector4& color );
-
- /**
- * @brief Request the current control renderer to render the given color
- *
- * 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] actor The Actor the renderer is applied to, empty if the renderer has not been applied to any Actor
- * @param[in] color The color to be rendered.
- */
- void ResetRenderer( ControlRenderer& renderer, Actor& actor, 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 renderer the border with the given size and color, and specify whether anti-aliasing is needed.
- *
- * @param[in] borderSize The size of the border. Border size is the same along all edges.
- * @param[in] borderColor The color of the border.
- * @param[in] antiAliasing Whether anti-aliasing is required for border rendering.
- * @return The pointer pointing to the control renderer
- */
- ControlRenderer GetControlRenderer( float borderSize, const Vector4& borderColor, bool antiAliasing );
+ ControlRenderer CreateControlRenderer( const Property::Map& propertyMap );
/**
* @brief Request the control renderer to render the image.
* @param[in] image The image to be rendered.
* @return The pointer pointing to the control renderer
*/
- ControlRenderer GetControlRenderer( const Image& image );
-
- /**
- * @brief Request the current control renderer to render the given image
- *
- * 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] actor The Actor the renderer is applied to, empty if the renderer has not been applied to any Actor
- * @param[in] image The Image to be rendered.
- */
- void ResetRenderer( ControlRenderer& renderer, Actor& actor, const Image& image );
+ ControlRenderer CreateControlRenderer( const Image& image );
/**
* @brief Request the control renderer to render the given resource at the url.
* @param[in] size The width and height to fit the loaded image to.
* @return The pointer pointing to the control renderer
*/
- ControlRenderer GetControlRenderer( const std::string& url,
- ImageDimensions size = ImageDimensions() );
-
- /**
- * @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] actor The Actor the renderer is applied to, empty if the renderer has not been applied to any Actor
- * @param[in] url The URL to the resource to be rendered.
- * @param[in] size The width and height to fit the loaded image to.
- */
- void ResetRenderer( ControlRenderer& renderer, Actor& actor, const std::string& url,
- ImageDimensions size = ImageDimensions() );
-
- /**
- * @brief Request the current control renderer from the property map, merging the property map with the renderer
- *
- * if the current renderer is capable of merging with the property map the reset the renderer with the merged properties
- * else the renderer would be a handle to a newly created internal renderer.
- *
- * @param[in] renderer The ControlRenderer to reset
- * @param[in] actor The Actor the renderer is applied to, empty if the renderer has not been applied to any Actor
- * @param[in] propertyMap The map contains the properties required by the control renderer
- * Depends on the content of the map, different kind of renderer would be returned.
- */
- void ResetRenderer( ControlRenderer& renderer, Actor& actor, const Property::Map& propertyMap );
+ ControlRenderer CreateControlRenderer( const std::string& url, ImageDimensions size );
private:
};
+
+/**
+ * @brief Template to allow discard old renderer, get new one and set it on stage if possible
+ *
+ * @tparam ParameterType0 The type of first argument passed to the CreateControlRenderer()
+ * @tparam ParameterType1 The type of second argument passed to the CreateControlRenderer()
+ * @SINCE_1_0.39
+ * @param[in] actor Actor for which the renderer will be replaced
+ * @param[in,out] renderer The renderer object to be replaced
+ * @param[in] param0 First template based argument passed to the renderer factory
+ * @param[in] param1 Second template based argument passed to the renderer factory
+ */
+template< class ParameterType0, class ParameterType1 >
+void InitializeControlRenderer( Actor& actor, ControlRenderer& renderer, ParameterType0& param0, ParameterType1& param1 )
+{
+ renderer.RemoveAndReset( actor );
+ renderer = Toolkit::RendererFactory::Get().CreateControlRenderer( param0, param1 );
+ if( renderer && actor && actor.OnStage() )
+ {
+ renderer.SetOnStage( actor );
+ }
+}
+
+/**
+ * @brief Template to allow discard old renderer, get new one and set it on stage if possible
+ *
+ * @tparam ParameterType The type of argument passed to the CreateControlRenderer()
+ * @SINCE_1_0.39
+ * @param[in] actor Actor for which the renderer will be replaced
+ * @param[in,out] renderer The renderer object to be replaced
+ * @param[in] param Template based argument passed to the renderer factory
+ */
+template< class ParameterType >
+void InitializeControlRenderer( Actor& actor, ControlRenderer& renderer, ParameterType& param )
+{
+ renderer.RemoveAndReset( actor );
+ renderer = Toolkit::RendererFactory::Get().CreateControlRenderer( param );
+ if( renderer && actor && actor.OnStage() )
+ {
+ renderer.SetOnStage( actor );
+ }
+}
+
} // namespace Toolkit
} // namespace Dali
+
#endif /* __DALI_TOOLKIT_RENDERER_FACTORY_H__ */
mBloomExtractImageView = Toolkit::ImageView::New();
mBloomExtractImageView.SetParentOrigin( ParentOrigin::CENTER );
- // Create shader used for extracting the bright parts of an image
- Property::Map customShader;
- customShader[ "fragmentShader" ] = BLOOM_EXTRACT_FRAGMENT_SOURCE;
- Property::Map rendererMap;
- rendererMap.Insert( "rendererType", "image" );
- rendererMap.Insert( "shader", customShader );
- mBloomExtractImageView.SetProperty( Toolkit::ImageView::Property::IMAGE, rendererMap );
-
// Create an image view for compositing the result (scene and bloom textures) to output
mCompositeImageView = Toolkit::ImageView::New();
mCompositeImageView.SetParentOrigin( ParentOrigin::CENTER );
- // Create shader used to composite bloom and original image to output render target
- customShader[ "fragmentShader" ] = COMPOSITE_FRAGMENT_SOURCE;
- rendererMap[ "shader" ] = customShader;
- mCompositeImageView.SetProperty( Toolkit::ImageView::Property::IMAGE, rendererMap );
-
// Create an image view for holding final result, i.e. the blurred image. This will get rendered to screen later, via default / user render task
mTargetImageView = Toolkit::ImageView::New();
mTargetImageView.SetParentOrigin( ParentOrigin::CENTER );
mBloomExtractImageView.SetImage( mRenderTargetForRenderingChildren );
mBloomExtractImageView.SetSize(mDownsampledWidth, mDownsampledHeight); // size needs to match render target
+ // Create shader used for extracting the bright parts of an image
+ Property::Map customShader;
+ customShader[ "fragmentShader" ] = BLOOM_EXTRACT_FRAGMENT_SOURCE;
+ Property::Map rendererMap;
+ rendererMap.Insert( "shader", customShader );
+ mBloomExtractImageView.SetProperty( Toolkit::ImageView::Property::IMAGE, rendererMap );
// set GaussianBlurView to blur our extracted bloom
mGaussianBlurView.SetUserImageAndOutputRenderTarget(mBloomExtractTarget, mBlurExtractTarget);
// use the completed blur in the first buffer and composite with the original child actors render
mCompositeImageView.SetImage( mRenderTargetForRenderingChildren );
+ // Create shader used to composite bloom and original image to output render target
+ customShader[ "fragmentShader" ] = COMPOSITE_FRAGMENT_SOURCE;
+ rendererMap[ "shader" ] = customShader;
+ mCompositeImageView.SetProperty( Toolkit::ImageView::Property::IMAGE, rendererMap );
TextureSet textureSet = mCompositeImageView.GetRendererAt(0).GetTextures();
textureSet.SetImage( 1u, mBlurExtractTarget );
Image shapeImage,
unsigned int maximumNumberOfBubble,
const Vector2& bubbleSizeRange )
-: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS ) ),
+: Control( ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) ),
mShapeImage( shapeImage ),
mMovementArea( movementArea ),
mBubbleSizeRange( bubbleSizeRange ),
mBackgroundImage = bgImage;
mHSVDelta = hsvDelta;
- Toolkit::ImageView sourceActor = Toolkit::ImageView::New( bgImage );
+ Toolkit::ImageView sourceActor = Toolkit::ImageView::New(bgImage);
sourceActor.SetSize( mMovementArea );
sourceActor.SetParentOrigin(ParentOrigin::CENTER);
// EXTERNAL INCLUDES
#include <cstring> // for strcmp
-#include <dali/public-api/events/touch-event.h>
+#include <dali/public-api/events/touch-data.h>
#include <dali/public-api/images/resource-image.h>
#include <dali/public-api/object/type-registry.h>
#include <dali/public-api/object/type-registry-helper.h>
} // unnamed namespace
Button::Button()
-: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS ) ),
+: Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ),
mAutoRepeatingTimer(),
mUnselectedColor( Color::WHITE ), // The natural colors of the specified images will be used by default.
mSelectedColor( Color::WHITE ),
return connected;
}
-bool Button::OnTouchEvent(const TouchEvent& event)
+void Button::OnInitialize()
+{
+ Actor self = Self();
+
+ mTapDetector = TapGestureDetector::New();
+ mTapDetector.Attach( self );
+ mTapDetector.DetectedSignal().Connect(this, &Button::OnTap);
+
+ self.SetKeyboardFocusable( true );
+
+ self.TouchSignal().Connect( this, &Button::OnTouch );
+}
+
+bool Button::OnAccessibilityActivated()
+{
+ return OnKeyboardEnter();
+}
+
+bool Button::OnKeyboardEnter()
+{
+ // When the enter key is pressed, or button is activated, the click action is performed.
+ Property::Map attributes;
+ bool ret = DoClickAction( attributes );
+
+ return ret;
+}
+
+void Button::OnStageDisconnection()
+{
+ if( ButtonDown == mState )
+ {
+ if( !mTogglableButton )
+ {
+ Released();
+
+ if( mAutoRepeating )
+ {
+ mAutoRepeatingTimer.Reset();
+ }
+ }
+ }
+
+ mState = ButtonUp;
+
+ Control::OnStageDisconnection();
+}
+
+bool Button::OnTouch( Actor actor, const TouchData& touch )
{
// Only events are processed when the button is not disabled and the touch event has only
// one touch point.
- if( ( !mDisabled ) && ( 1 == event.GetPointCount() ) )
+ if( ( !mDisabled ) && ( 1 == touch.GetPointCount() ) )
{
- switch( event.GetPoint(0).state )
+ switch( touch.GetState( 0 ) )
{
- case TouchPoint::Down:
+ case PointState::DOWN:
{
OnButtonDown(); // Notification for derived classes.
mState = ButtonDown;
break;
}
- case TouchPoint::Up:
+ case PointState::UP:
{
OnButtonUp(); // Notification for derived classes.
mState = ButtonUp;
break;
}
- case TouchPoint::Interrupted:
+ case PointState::INTERRUPTED:
{
OnTouchPointInterrupted(); // Notification for derived classes.
mState = ButtonUp;
break;
}
- case TouchPoint::Leave:
+ case PointState::LEAVE:
{
OnTouchPointLeave(); // Notification for derived classes.
mState = ButtonUp;
break;
}
- case TouchPoint::Motion:
- case TouchPoint::Stationary: // FALLTHROUGH
+ case PointState::MOTION:
+ case PointState::STATIONARY: // FALLTHROUGH
{
// Nothing to do
break;
}
- default:
- {
- DALI_ASSERT_ALWAYS( !"Point status unhandled." );
- break;
- }
}
}
- else if( 1 < event.GetPointCount() )
+ else if( 1 < touch.GetPointCount() )
{
OnTouchPointLeave(); // Notification for derived classes.
return false;
}
-void Button::OnInitialize()
-{
- Actor self = Self();
-
- mTapDetector = TapGestureDetector::New();
- mTapDetector.Attach( self );
- mTapDetector.DetectedSignal().Connect(this, &Button::OnTap);
-
- self.SetKeyboardFocusable( true );
-}
-
-bool Button::OnAccessibilityActivated()
-{
- return OnKeyboardEnter();
-}
-
-bool Button::OnKeyboardEnter()
-{
- // When the enter key is pressed, or button is activated, the click action is performed.
- Property::Map attributes;
- bool ret = DoClickAction( attributes );
-
- return ret;
-}
-
-void Button::OnStageDisconnection()
-{
- if( ButtonDown == mState )
- {
- if( !mTogglableButton )
- {
- Released();
-
- if( mAutoRepeating )
- {
- mAutoRepeatingTimer.Reset();
- }
- }
- }
-
- mState = ButtonUp;
-
- Control::OnStageDisconnection();
-}
-
void Button::OnTap(Actor actor, const TapGesture& tap)
{
// Do nothing.
virtual void OnDisabledBackgroundImageSet() {}
/**
- * This method is called from the OnTouchEvent method when the button is down.
+ * This method is called the button is down.
* Could be reimplemented in subclasses to provide specific behaviour.
*/
virtual void OnButtonDown();
/**
- * This method is called from the OnTouchEvent method when the button is up.
+ * This method is called when the button is up.
* Could be reimplemented in subclasses to provide specific behaviour.
*/
virtual void OnButtonUp();
/**
- * This method is called from the OnTouchEvent method when the touch point leaves the boundary of the button or
- * more than one touch points are received.
+ * This method is called when touch leaves the boundary of the button or several touch points are received.
* Could be reimplemented in subclasses to provide specific behaviour.
*/
virtual void OnTouchPointLeave();
/**
- * This method is called from the OnTouchEvent method when the touch point is interrupted.
+ * This method is called when the touch is interrupted.
* Could be reimplemented in subclasses to provide specific behaviour.
*/
virtual void OnTouchPointInterrupted();
protected: // From Control
/**
- * @copydoc Dali::Control::OnTouchEvent( const TouchEvent& event )
- */
- virtual bool OnTouchEvent( const TouchEvent& event );
-
- /**
* @copydoc Toolkit::Control::OnInitialize()
* @note If overridden by deriving button classes, then an up-call to Button::OnInitialize MUST be made at the start.
*/
private:
/**
+ * @brief Handler for touch data
+ * @param[in] actor The touched actor.
+ * @param[in] touch The touch info.
+ * @return true, if consumed, false otherwise.
+ */
+ bool OnTouch( Actor actor, const TouchData& touch );
+
+ /**
* Handler for tap events.
* We do not actually do anything when we receive a tap as the button handles tap event through
* the touch event system itself as it requires more than just tap handling (e.g. leave events).
#include <dali/public-api/object/type-registry.h>
#include <dali/public-api/object/type-registry-helper.h>
#include <dali/public-api/render-tasks/render-task-list.h>
+#include <dali/devel-api/rendering/renderer.h>
// INTERNAL INCLUDES
#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
+#include <dali-toolkit/devel-api/controls/renderer-factory/renderer-factory.h>
#include <dali-toolkit/internal/filters/blur-two-pass-filter.h>
#include <dali-toolkit/internal/filters/emboss-filter.h>
#include <dali-toolkit/internal/filters/spread-filter.h>
customShader[ "vertexShader" ] = EFFECTS_VIEW_VERTEX_SOURCE;
customShader[ "fragmentShader" ] = EFFECTS_VIEW_FRAGMENT_SOURCE;
rendererMap[ "shader" ] = customShader;
- Toolkit::RendererFactory::Get().ResetRenderer( mRendererPostFilter, self, rendererMap );
+ InitializeControlRenderer( self, mRendererPostFilter, rendererMap );
mEffectType = type;
}
mLastSize = mTargetSize;
SetupCameras();
- Toolkit::RendererFactory rendererFactory = Toolkit::RendererFactory::Get();
- Actor self = Self();
+ Actor self( Self() );
mImageForChildren = FrameBufferImage::New( mTargetSize.width, mTargetSize.height, mPixelFormat, Dali::Image::UNUSED );
- rendererFactory.ResetRenderer(mRendererForChildren, self, mImageForChildren);
+ InitializeControlRenderer( self, mRendererForChildren, mImageForChildren );
mRendererForChildren.SetDepthIndex( DepthIndex::CONTENT+1 );
mImagePostFilter = FrameBufferImage::New( mTargetSize.width, mTargetSize.height, mPixelFormat, Dali::Image::UNUSED );
- rendererFactory.ResetRenderer(mRendererPostFilter, self, mImagePostFilter);
+ TextureSet textureSet = TextureSet::New();
+ textureSet.SetImage( 0u, mImagePostFilter);
+ self.GetRendererAt( 0 ).SetTextures( textureSet );
mRendererPostFilter.SetDepthIndex( DepthIndex::CONTENT );
SetupFilters();
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/animation/constraints.h>
#include <dali/public-api/common/stage.h>
-#include <dali/public-api/object/property-map.h>
#include <dali/public-api/object/type-registry.h>
#include <dali/public-api/object/type-registry-helper.h>
#include <dali/public-api/render-tasks/render-task-list.h>
mUserInputImage = inputImage;
mImageViewHorizBlur.SetImage( mUserInputImage );
+ mImageViewHorizBlur.SetProperty( Toolkit::ImageView::Property::IMAGE, mCustomShader );
mUserOutputRenderTarget = outputRenderTarget;
}
std::ostringstream horizFragmentShaderStringStream;
horizFragmentShaderStringStream << "#define NUM_SAMPLES " << mNumSamples << "\n";
horizFragmentShaderStringStream << GAUSSIAN_BLUR_FRAGMENT_SOURCE;
- Property::Map customShader;
- customShader[ "fragmentShader" ] = horizFragmentShaderStringStream.str();
- Property::Map rendererMap;
- rendererMap.Insert( "rendererType", "image" );
- rendererMap.Insert( "shader", customShader );
+ Property::Map source;
+ source[ "fragmentShader" ] = horizFragmentShaderStringStream.str();
+ mCustomShader["shader"] = source;
//////////////////////////////////////////////////////
// Create actors
// Create an image view for performing a horizontal blur on the texture
mImageViewHorizBlur = Toolkit::ImageView::New();
mImageViewHorizBlur.SetParentOrigin(ParentOrigin::CENTER);
- mImageViewHorizBlur.SetProperty( Toolkit::ImageView::Property::IMAGE, rendererMap );
// Create an image view for performing a vertical blur on the texture
mImageViewVertBlur = Toolkit::ImageView::New();
mImageViewVertBlur.SetParentOrigin(ParentOrigin::CENTER);
- mImageViewVertBlur.SetProperty( Toolkit::ImageView::Property::IMAGE, rendererMap );
// Register a property that the user can control to fade the blur in / out via the GaussianBlurView object
Actor self = Self();
// Set image view for performing a horizontal blur on the texture
mImageViewHorizBlur.SetImage( mRenderTargetForRenderingChildren );
+ mImageViewHorizBlur.SetProperty( Toolkit::ImageView::Property::IMAGE, mCustomShader );
// Create offscreen buffer for vert blur pass
mRenderTarget1 = FrameBufferImage::New( mDownsampledWidth, mDownsampledHeight, mPixelFormat );
// size needs to match render target
mImageViewVertBlur.SetImage( mRenderTarget2 );
+ mImageViewVertBlur.SetProperty( Toolkit::ImageView::Property::IMAGE, mCustomShader );
mImageViewVertBlur.SetSize(mDownsampledWidth, mDownsampledHeight);
// set gaussian blur up for new sized render targets
// EXTERNAL INCLUDES
#include <sstream>
#include <cmath>
+#include <dali/public-api/object/property-map.h>
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/control-impl.h>
Toolkit::ImageView mImageViewHorizBlur;
Toolkit::ImageView mImageViewVertBlur;
+ Property::Map mCustomShader;
+
RenderTask mHorizBlurTask;
RenderTask mVertBlurTask;
// 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/renderer-string-constants.h>
+#include <dali-toolkit/internal/controls/renderers/control-renderer-impl.h>
namespace Dali
{
mImage = image;
- Actor self = Self();
- Toolkit::RendererFactory::Get().ResetRenderer( mRenderer, self, image );
+ Actor self( Self() );
+ InitializeControlRenderer( self, mRenderer, image );
mImageSize = image ? ImageDimensions( image.GetWidth(), image.GetHeight() ) : ImageDimensions( 0, 0 );
RelayoutRequest();
mImage.Reset();
mPropertyMap = map;
- Actor self = Self();
- Toolkit::RendererFactory::Get().ResetRenderer( mRenderer, self, mPropertyMap );
+ Actor self( Self() );
+ InitializeControlRenderer( self, mRenderer, mPropertyMap );
Property::Value* widthValue = mPropertyMap.Find( "width" );
if( widthValue )
void ImageView::SetImage( const std::string& url, ImageDimensions size )
{
if( ( mUrl != url ) ||
- mImage || // If we're changing from an Image type to a URL type
+ mImage || // If we're changing from an Image type to a URL type
! mPropertyMap.Empty() ) // If we're changing from a property map type to a URL type
{
mImage.Reset();
mImageSize = size;
}
- Actor self = Self();
- Toolkit::RendererFactory::Get().ResetRenderer( mRenderer, self, mUrl, size );
+ Actor self( Self() );
+ InitializeControlRenderer( self, mRenderer, url, size );
+
+ mRenderer.SetSize( mSizeSet );
RelayoutRequest();
}
void ImageView::OnSizeSet( const Vector3& targetSize )
{
Control::OnSizeSet( targetSize );
+ mSizeSet = targetSize;
if( mRenderer )
{
if ( imageView )
{
+ ImageView& impl = GetImpl( imageView );
switch ( index )
{
case Toolkit::ImageView::Property::RESOURCE_URL:
std::string imageUrl;
if( value.Get( imageUrl ) )
{
- GetImpl( imageView ).SetImage( imageUrl, ImageDimensions() );
+ impl.SetImage( imageUrl, ImageDimensions() );
}
break;
}
case Toolkit::ImageView::Property::IMAGE:
{
std::string imageUrl;
+ Property::Map map;
if( value.Get( imageUrl ) )
{
- ImageView& impl = GetImpl( imageView );
impl.SetImage( imageUrl, ImageDimensions() );
}
-
// if its not a string then get a Property::Map from the property if possible.
- Property::Map map;
- if( value.Get( map ) )
+ else if( value.Get( map ) )
{
- ImageView& impl = GetImpl( imageView );
- impl.SetImage( map );
+ Property::Value* shaderValue = map.Find( "shader" );
+ // set image only if property map contains image information other than custom shader
+ if( map.Count() > 1u || !shaderValue )
+ {
+ impl.SetImage( map );
+ }
+ // the property map contains only the custom shader
+ else if( impl.mRenderer && map.Count() == 1u && shaderValue )
+ {
+ Property::Map shaderMap;
+ if( shaderValue->Get( shaderMap ) )
+ {
+ Internal::ControlRenderer& renderer = GetImplementation( impl.mRenderer );
+ renderer.SetCustomShader( shaderMap );
+ if( imageView.OnStage() )
+ {
+ // force to create new core renderer to use the newly set shader
+ renderer.SetOffStage( imageView );
+ renderer.SetOnStage( imageView );
+ }
+ }
+ }
}
-
break;
}
bool isPre;
if( value.Get( isPre ) )
{
- GetImpl(imageView).EnablePreMultipliedAlpha( isPre );
+ impl.EnablePreMultipliedAlpha( isPre );
}
break;
}
private:
Toolkit::ControlRenderer mRenderer;
ImageDimensions mImageSize;
+ Vector2 mSizeSet;
std::string mUrl; ///< the url for the image if the image came from a URL, empty otherwise
Image mImage; ///< the Image if the image came from a Image, null otherwise
#include <dali/public-api/images/resource-image.h>
#include <dali/public-api/object/type-registry.h>
#include <dali/public-api/object/type-registry-helper.h>
+#include <dali/public-api/object/property-map.h>
// INTERNAL INCLUDES
#include <dali-toolkit/devel-api/controls/renderer-factory/renderer-factory.h>
+#include <dali-toolkit/internal/controls/renderers/renderer-string-constants.h>
namespace Dali
{
}
Magnifier::Magnifier()
-: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS ) ),
+: Control( ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) ),
mDefaultCameraDistance(1000.f),
mActorSize(Vector3::ZERO),
mMagnificationFactor(1.0f)
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);
+
+ Property::Map map;
+ map[ RENDERER_TYPE ] = BORDER_RENDERER;
+ map[ "borderColor" ] = Color::WHITE;
+ map[ "borderSize" ] = IMAGE_BORDER_INDENT;
+ Toolkit::ControlRenderer borderRenderer = rendererFactory.CreateControlRenderer( map );
borderRenderer.SetOnStage( mFrame );
Constraint constraint = Constraint::New<Vector3>( mFrame, Actor::Property::POSITION, EqualToConstraint() );
if( illuminationType == Toolkit::Model3dView::DIFFUSE_WITH_NORMAL_MAP )
{
- objectProperties |= ObjLoader::TANGENTS | ObjLoader::BINOMIALS;
+ objectProperties |= ObjLoader::TANGENTS | ObjLoader::BINORMALS;
}
return objectProperties;
}
//Some need tangent and bitangent
- if( ( objectProperties & TANGENTS ) && ( objectProperties & BINOMIALS ) && mHasTexturePoints )
+ if( ( objectProperties & TANGENTS ) && ( objectProperties & BINORMALS ) && mHasTexturePoints )
{
Property::Map vertexExtFormat;
vertexExtFormat["aTangent"] = Property::VECTOR3;
{
TEXTURE_COORDINATES = 1 << 0,
TANGENTS = 1 << 1,
- BINOMIALS = 1 << 2
+ BINORMALS = 1 << 2
};
ObjLoader();
}
PageTurnView::PageTurnView( PageFactory& pageFactory, const Vector2& pageSize )
-: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS ) ),
+: Control( ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) ),
mPageFactory( &pageFactory ),
mPageSize( pageSize ),
mSpineShadowParameter( DEFAULT_SPINE_SHADOW_PARAMETER ),
#include <dali/public-api/animation/constraints.h>
#include <dali/public-api/common/stage.h>
#include <dali/public-api/events/key-event.h>
-#include <dali/public-api/events/touch-event.h>
+#include <dali/public-api/events/touch-data.h>
#include <dali/public-api/images/resource-image.h>
#include <dali/public-api/object/type-registry.h>
#include <dali/devel-api/scripting/scripting.h>
}
Popup::Popup()
-: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS ) ),
+: Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ),
mTouchedOutsideSignal(),
mShowingSignal(),
mShownSignal(),
mPopupLayout.SetFitHeight( 0 ); // Set row to fit.
mPopupLayout.SetFitHeight( 1 ); // Set row to fit.
- mPopupLayout.TouchedSignal().Connect( this, &Popup::OnDialogTouched );
+ mPopupLayout.TouchSignal().Connect( this, &Popup::OnDialogTouched );
mPopupContainer.Add( mPopupLayout );
mPopupBackgroundImage.SetParentOrigin( ParentOrigin::CENTER );
// OnDialogTouched only consumes the event. It prevents the touch event to be caught by the backing.
- mPopupBackgroundImage.TouchedSignal().Connect( this, &Popup::OnDialogTouched );
+ mPopupBackgroundImage.TouchSignal().Connect( this, &Popup::OnDialogTouched );
// Set the popup border to be slightly larger than the layout contents.
mPopupBackgroundImage.SetResizePolicy( ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT, Dimension::ALL_DIMENSIONS );
// Default to being transparent.
backing.SetProperty( Actor::Property::COLOR_ALPHA, 0.0f );
- backing.TouchedSignal().Connect( this, &Popup::OnBackingTouched );
+ backing.TouchSignal().Connect( this, &Popup::OnBackingTouched );
backing.WheelEventSignal().Connect( this, &Popup::OnBackingWheelEvent );
return backing;
}
return connected;
}
-bool Popup::OnBackingTouched( Actor actor, const TouchEvent& event )
+bool Popup::OnBackingTouched( Actor actor, const TouchData& touch )
{
// Allow events to pass through if touch transparency is enabled.
if( mTouchTransparent )
return false;
}
- if( event.GetPointCount() > 0 )
+ if( touch.GetPointCount() > 0 )
{
- const TouchPoint& point = event.GetPoint( 0 );
-
- if( point.state == TouchPoint::Down )
+ if( touch.GetState( 0 ) == PointState::DOWN )
{
// Guard against destruction during signal emission.
Toolkit::Popup handle( GetOwner() );
return true;
}
-bool Popup::OnDialogTouched(Actor actor, const TouchEvent& event)
+bool Popup::OnDialogTouched( Actor actor, const TouchData& touch )
{
// Allow events to pass through if touch transparency is enabled.
if( mTouchTransparent )
/**
* Signal occurs when the dimmed backing for the Popup is touched.
* @param[in] actor The Actor Touched
- * @param[in] event The Touch Event.
+ * @param[in] touch The Touch Data.
* @return Whether to consume event or not.
*/
- bool OnBackingTouched(Actor actor, const TouchEvent& event);
+ bool OnBackingTouched(Actor actor, const TouchData& touch);
/**
* Signal occurs when a mouse wheel event occurs on the dimmed backing.
/**
* Signal occurs when the dialog has been touched.
* @param[in] actor The Actor Touched
- * @param[in] event The Touch Event.
+ * @param[in] touch The Touch Data.
* @return Whether to consume event or not.
*/
- bool OnDialogTouched(Actor actor, const TouchEvent& event);
+ bool OnDialogTouched( Actor actor, const TouchData& touch );
/**
* @copydoc Toolkit::Control::OnInitialize()
SetPropertyMap( map );
}
-void Internal::ControlRenderer::Impl::CustomShader::SetPropertyMap( const Property::Map& propertyMap )
+void Internal::ControlRenderer::Impl::CustomShader::SetPropertyMap( const Property::Map& shaderMap )
{
- Property::Value* shaderValue = propertyMap.Find( CUSTOM_SHADER );
- if( shaderValue )
+ mVertexShader.clear();
+ mFragmentShader.clear();
+ mGridSize = ImageDimensions( 1, 1 );
+ mHints = Shader::HINT_NONE;
+
+ Property::Value* vertexShaderValue = shaderMap.Find( CUSTOM_VERTEX_SHADER );
+ if( vertexShaderValue )
{
- mVertexShader.clear();
- mFragmentShader.clear();
- mGridSize = ImageDimensions( 1, 1 );
- mHints = Shader::HINT_NONE;
+ if( !vertexShaderValue->Get( mVertexShader ) )
+ {
+ DALI_LOG_ERROR( "'%s' parameter does not correctly specify a string", CUSTOM_VERTEX_SHADER );
+ }
+ }
- Property::Map shaderMap;
- if( shaderValue->Get( shaderMap ) )
+ Property::Value* fragmentShaderValue = shaderMap.Find( CUSTOM_FRAGMENT_SHADER );
+ if( fragmentShaderValue )
+ {
+ if( !fragmentShaderValue->Get( mFragmentShader ) )
{
- Property::Value* vertexShaderValue = shaderMap.Find( CUSTOM_VERTEX_SHADER );
- if( vertexShaderValue )
- {
- if( !vertexShaderValue->Get( mVertexShader ) )
- {
- DALI_LOG_ERROR( "'%s' parameter does not correctly specify a string", CUSTOM_VERTEX_SHADER );
- }
- }
+ DALI_LOG_ERROR( "'%s' parameter does not correctly specify a string", CUSTOM_FRAGMENT_SHADER );
+ }
+ }
- Property::Value* fragmentShaderValue = shaderMap.Find( CUSTOM_FRAGMENT_SHADER );
- if( fragmentShaderValue )
- {
- if( !fragmentShaderValue->Get( mFragmentShader ) )
- {
- DALI_LOG_ERROR( "'%s' parameter does not correctly specify a string", CUSTOM_FRAGMENT_SHADER );
- }
- }
+ Property::Value* subdivideXValue = shaderMap.Find( CUSTOM_SUBDIVIDE_GRID_X );
+ if( subdivideXValue )
+ {
+ int subdivideX;
+ if( !subdivideXValue->Get( subdivideX ) || subdivideX < 1 )
+ {
+ DALI_LOG_ERROR( "'%s' parameter does not correctly specify a value greater than 1", CUSTOM_SUBDIVIDE_GRID_X );
+ }
+ else
+ {
+ mGridSize = ImageDimensions( subdivideX, mGridSize.GetY() );
+ }
+ }
- Property::Value* subdivideXValue = shaderMap.Find( CUSTOM_SUBDIVIDE_GRID_X );
- if( subdivideXValue )
- {
- int subdivideX;
- if( !subdivideXValue->Get( subdivideX ) || subdivideX < 1 )
- {
- DALI_LOG_ERROR( "'%s' parameter does not correctly specify a value greater than 1", CUSTOM_SUBDIVIDE_GRID_X );
- }
- else
- {
- mGridSize = ImageDimensions( subdivideX, mGridSize.GetY() );
- }
- }
+ Property::Value* subdivideYValue = shaderMap.Find( CUSTOM_SUBDIVIDE_GRID_Y );
+ if( subdivideYValue )
+ {
+ int subdivideY;
+ if( !subdivideYValue->Get( subdivideY ) || subdivideY < 1 )
+ {
+ DALI_LOG_ERROR( "'%s' parameter does not correctly specify a value greater than 1", CUSTOM_SUBDIVIDE_GRID_Y );
+ }
+ else
+ {
+ mGridSize = ImageDimensions( mGridSize.GetX(), subdivideY );
+ }
+ }
- Property::Value* subdivideYValue = shaderMap.Find( CUSTOM_SUBDIVIDE_GRID_Y );
- if( subdivideYValue )
- {
- int subdivideY;
- if( !subdivideYValue->Get( subdivideY ) || subdivideY < 1 )
- {
- DALI_LOG_ERROR( "'%s' parameter does not correctly specify a value greater than 1", CUSTOM_SUBDIVIDE_GRID_Y );
- }
- else
- {
- mGridSize = ImageDimensions( mGridSize.GetX(), subdivideY );
- }
- }
+ Property::Value* hintsValue = shaderMap.Find( CUSTOM_SHADER_HINTS );
+ if( hintsValue )
+ {
+ std::string hintString;
+ Property::Array hintsArray;
- Property::Value* hintsValue = shaderMap.Find( CUSTOM_SHADER_HINTS );
- if( hintsValue )
+ if( hintsValue->Get( hintString ) )
+ {
+ mHints = HintFromString( hintString );
+ }
+ else if( hintsValue->Get( hintsArray ) )
+ {
+ int hints = Shader::HINT_NONE;
+ for( Property::Array::SizeType i = 0; i < hintsArray.Count(); ++i)
{
- std::string hintString;
- Property::Array hintsArray;
-
- if( hintsValue->Get( hintString ) )
- {
- mHints = HintFromString( hintString );
- }
- else if( hintsValue->Get( hintsArray ) )
+ Property::Value hintValue = hintsArray[ i ];
+ if( hintValue.Get( hintString ) )
{
- int hints = Shader::HINT_NONE;
- for( Property::Array::SizeType i = 0; i < hintsArray.Count(); ++i)
- {
- Property::Value hintValue = hintsArray[ i ];
- if( hintValue.Get( hintString ) )
- {
- hints |= static_cast< int >( HintFromString( hintString ) );
- }
- else
- {
- DALI_LOG_ERROR( "'%s' parameter does not correctly specify an hint string at index %d", CUSTOM_SHADER_HINTS, i );
- }
-
- mHints = static_cast< Shader::ShaderHints >( hints );
- }
+ hints |= static_cast< int >( HintFromString( hintString ) );
}
else
{
- DALI_LOG_ERROR( "'%s' parameter does not correctly specify a hint string or an array of hint strings", CUSTOM_SHADER_HINTS );
+ DALI_LOG_ERROR( "'%s' parameter does not correctly specify an hint string at index %d", CUSTOM_SHADER_HINTS, i );
}
+
+ mHints = static_cast< Shader::ShaderHints >( hints );
}
}
else
{
- //use value with no type to mean reseting the shader back to default
- if( shaderValue->GetType() != Dali::Property::NONE )
- {
- DALI_LOG_ERROR( "'%s' parameter does not correctly specify a property map", CUSTOM_SHADER );
- }
+ DALI_LOG_ERROR( "'%s' parameter does not correctly specify a hint string or an array of hint strings", CUSTOM_SHADER_HINTS );
}
}
}
delete mImpl;
}
-void ControlRenderer::Initialize( Actor& actor, const Property::Map& propertyMap )
+void ControlRenderer::SetCustomShader( const Property::Map& shaderMap )
{
if( mImpl->mCustomShader )
{
- mImpl->mCustomShader->SetPropertyMap( propertyMap );
+ mImpl->mCustomShader->SetPropertyMap( shaderMap );
}
else
{
- Property::Value* customShaderValue = propertyMap.Find( CUSTOM_SHADER );
- if( customShaderValue )
+ mImpl->mCustomShader = new Impl::CustomShader( shaderMap );
+ }
+}
+
+void ControlRenderer::Initialize( Actor& actor, const Property::Map& propertyMap )
+{
+ Property::Value* customShaderValue = propertyMap.Find( CUSTOM_SHADER );
+ if( customShaderValue )
+ {
+ Property::Map shaderMap;
+ if( customShaderValue->Get( shaderMap ) )
{
- Property::Map customShader;
- if( customShaderValue->Get( customShader ) )
- {
- mImpl->mCustomShader = new Impl::CustomShader( propertyMap );
- }
+ SetCustomShader( shaderMap );
}
}
+
DoInitialize( actor, propertyMap );
}
*/
bool IsPreMultipliedAlphaEnabled() const;
+ /**
+ * @brief Sets properties of custom shader
+ * @param[in] propertyMap Property map containing the custom shader data
+ */
+ void SetCustomShader( const Property::Map& propertyMap );
+
protected:
/**
#include <dali/integration-api/debug.h>
#include <dali/public-api/images/resource-image.h>
#include <dali/public-api/common/stage.h>
+#include <dali/devel-api/adaptor-framework/bitmap-loader.h>
#include <dali/devel-api/adaptor-framework/file-loader.h>
#include <fstream>
namespace Dali
{
+namespace
+{
+ /**
+ * @brief Loads a texture from a file
+ * @param[in] imageUrl The url of the file
+ * @param[in] generateMipmaps Indicates whether to generate mipmaps for the texture
+ * @return A texture if loading succeeds, an empty handle otherwise
+ */
+ Texture LoadTexture( const char* imageUrl, bool generateMipmaps )
+ {
+ Texture texture;
+ Dali::BitmapLoader loader = Dali::BitmapLoader::New( imageUrl );
+ loader.Load();
+ PixelData pixelData = loader.GetPixelData();
+ if( pixelData )
+ {
+ texture = Texture::New( TextureType::TEXTURE_2D, pixelData.GetPixelFormat(), pixelData.GetWidth(), pixelData.GetHeight() );
+ texture.Upload( pixelData );
+
+ if( generateMipmaps )
+ {
+ texture.GenerateMipmaps();
+ }
+ }
+
+ return texture;
+ }
+}// unnamed namespace
+
namespace Toolkit
{
MeshRenderer::MeshRenderer( RendererFactoryCache& factoryCache )
: ControlRenderer( factoryCache ),
mShaderType( ALL_TEXTURES ),
- mUseTexture( true )
+ mUseTexture( true ),
+ mUseMipmapping( true )
{
}
mTexturesPath.clear();
}
+ Property::Value* useMipmapping = propertyMap.Find( USE_MIPMAPPING );
+ if( useMipmapping )
+ {
+ useMipmapping->Get( mUseMipmapping );
+ }
+
Property::Value* shaderType = propertyMap.Find( SHADER_TYPE );
if( shaderType && shaderType->Get( mShaderTypeString ) )
{
bool MeshRenderer::CreateGeometry()
{
//Determine if we need to use a simpler shader to handle the provided data
- if( mShaderType == ALL_TEXTURES )
+ if( !mUseTexture || !mObjLoader.IsDiffuseMapPresent() )
{
- if( !mObjLoader.IsNormalMapPresent() || !mObjLoader.IsSpecularMapPresent() )
- {
- mShaderType = DIFFUSE_TEXTURE;
- }
+ mShaderType = TEXTURELESS;
}
- if( !mObjLoader.IsTexturePresent() || !mObjLoader.IsDiffuseMapPresent() || !mUseTexture )
+ else if( mShaderType == ALL_TEXTURES && (!mObjLoader.IsNormalMapPresent() || !mObjLoader.IsSpecularMapPresent()) )
{
- mShaderType = TEXTURELESS;
+ mShaderType = DIFFUSE_TEXTURE;
}
int objectProperties = 0;
if( mShaderType == ALL_TEXTURES )
{
- objectProperties |= ObjLoader::TANGENTS | ObjLoader::BINOMIALS;
+ objectProperties |= ObjLoader::TANGENTS | ObjLoader::BINORMALS;
}
//Create geometry with attributes required by shader.
{
mTextureSet = TextureSet::New();
- if( !mDiffuseTextureUrl.empty() )
+ if( mShaderType != TEXTURELESS )
{
- std::string imageUrl = mTexturesPath + mDiffuseTextureUrl;
-
- //Load textures
- Image diffuseTexture = ResourceImage::New( imageUrl );
- if( diffuseTexture )
- {
- mTextureSet.SetImage( DIFFUSE_INDEX, diffuseTexture );
- }
- else
+ Sampler sampler = Sampler::New();
+ if( mUseMipmapping )
{
- DALI_LOG_ERROR( "Failed to load diffuse map texture in mesh renderer.\n");
- return false;
+ sampler.SetFilterMode( FilterMode::LINEAR_MIPMAP_LINEAR, FilterMode::LINEAR_MIPMAP_LINEAR );
}
- }
-
- if( !mNormalTextureUrl.empty() && ( mShaderType == ALL_TEXTURES ) )
- {
- std::string imageUrl = mTexturesPath + mNormalTextureUrl;
- //Load textures
- Image normalTexture = ResourceImage::New( imageUrl );
- if( normalTexture )
+ if( !mDiffuseTextureUrl.empty() )
{
- mTextureSet.SetImage( NORMAL_INDEX, normalTexture );
+ std::string imageUrl = mTexturesPath + mDiffuseTextureUrl;
+
+ //Load textures
+ Texture diffuseTexture = LoadTexture( imageUrl.c_str(), mUseMipmapping );
+ if( diffuseTexture )
+ {
+ mTextureSet.SetTexture( DIFFUSE_INDEX, diffuseTexture );
+ mTextureSet.SetSampler( DIFFUSE_INDEX, sampler );
+ }
+ else
+ {
+ DALI_LOG_ERROR( "Failed to load diffuse map texture in mesh renderer.\n");
+ return false;
+ }
}
- else
- {
- DALI_LOG_ERROR( "Failed to load normal map texture in mesh renderer.\n");
- return false;
- }
- }
-
- if( !mGlossTextureUrl.empty() && ( mShaderType == ALL_TEXTURES ) )
- {
- std::string imageUrl = mTexturesPath + mGlossTextureUrl;
- //Load textures
- Image glossTexture = ResourceImage::New( imageUrl );
- if( glossTexture )
+ if( !mNormalTextureUrl.empty() && ( mShaderType == ALL_TEXTURES ) )
{
- mTextureSet.SetImage( GLOSS_INDEX, glossTexture );
+ std::string imageUrl = mTexturesPath + mNormalTextureUrl;
+
+ //Load textures
+ Texture normalTexture = LoadTexture( imageUrl.c_str(), mUseMipmapping );
+ if( normalTexture )
+ {
+ mTextureSet.SetTexture( NORMAL_INDEX, normalTexture );
+ mTextureSet.SetSampler( NORMAL_INDEX, sampler );
+ }
+ else
+ {
+ DALI_LOG_ERROR( "Failed to load normal map texture in mesh renderer.\n");
+ return false;
+ }
}
- else
+
+ if( !mGlossTextureUrl.empty() && ( mShaderType == ALL_TEXTURES ) )
{
- DALI_LOG_ERROR( "Failed to load gloss map texture in mesh renderer.\n");
- return false;
+ std::string imageUrl = mTexturesPath + mGlossTextureUrl;
+
+ //Load textures
+ Texture glossTexture = LoadTexture( imageUrl.c_str(), mUseMipmapping );
+ if( glossTexture )
+ {
+ mTextureSet.SetTexture( GLOSS_INDEX, glossTexture );
+ mTextureSet.SetSampler( GLOSS_INDEX, sampler );
+ }
+ else
+ {
+ DALI_LOG_ERROR( "Failed to load gloss map texture in mesh renderer.\n");
+ return false;
+ }
}
}
-
return true;
}
ShaderType mShaderType;
bool mUseTexture;
+ bool mUseMipmapping;
};
} // namespace Internal
return rendererType;
}
-Toolkit::ControlRenderer RendererFactory::GetControlRenderer( const Property::Map& propertyMap )
+Toolkit::ControlRenderer RendererFactory::CreateControlRenderer( const Property::Map& propertyMap )
{
ControlRenderer* rendererPtr = NULL;
return Toolkit::ControlRenderer( rendererPtr );
}
-Toolkit::ControlRenderer RendererFactory::GetControlRenderer( const Vector4& color )
-{
- if( !mFactoryCache )
- {
- mFactoryCache = new RendererFactoryCache();
- }
-
- if( mDebugEnabled )
- {
- return Toolkit::ControlRenderer( new DebugRenderer( *( mFactoryCache.Get() ) ) );
- }
-
- ColorRenderer* rendererPtr = new ColorRenderer( *( mFactoryCache.Get() ) );
- rendererPtr->SetColor( color );
-
- return Toolkit::ControlRenderer( rendererPtr );
-}
-
-void RendererFactory::ResetRenderer( Toolkit::ControlRenderer& renderer, Actor& actor, const Vector4& color )
-{
- if( mDebugEnabled && renderer )
- {
- return;
- }
-
- if( renderer )
- {
- ColorRenderer* rendererPtr = dynamic_cast< ColorRenderer* >( &GetImplementation( renderer ) );
- if( rendererPtr )
- {
- rendererPtr->SetColor( color );
- return;
- }
-
- renderer.RemoveAndReset( actor );
- }
-
- renderer = GetControlRenderer( color );
- if( actor && actor.OnStage() )
- {
- renderer.SetOnStage( actor );
- }
-}
-
-Toolkit::ControlRenderer RendererFactory::GetControlRenderer( float borderSize, const Vector4& borderColor, bool antiAliasing )
-{
- if( !mFactoryCache )
- {
- mFactoryCache = new RendererFactoryCache();
- }
-
- if( mDebugEnabled )
- {
- return Toolkit::ControlRenderer( new DebugRenderer( *( mFactoryCache.Get() ) ) );
- }
-
- BorderRenderer* rendererPtr = new BorderRenderer( *mFactoryCache.Get() );
-
- rendererPtr->SetBorderSize( borderSize );
- rendererPtr->SetBorderColor( borderColor );
- rendererPtr->RequireAntiAliasing( antiAliasing );
-
- return Toolkit::ControlRenderer( rendererPtr );
-}
-
-Toolkit::ControlRenderer RendererFactory::GetControlRenderer( const Image& image )
+Toolkit::ControlRenderer RendererFactory::CreateControlRenderer( const Image& image )
{
if( !mFactoryCache )
{
}
}
-void RendererFactory::ResetRenderer( Toolkit::ControlRenderer& renderer, Actor& actor, const Image& image )
-{
- if( mDebugEnabled && renderer )
- {
- return;
- }
-
- if( renderer )
- {
- if( ! image )
- {
- // If the image is empty, then reset the renderer and return
- renderer.RemoveAndReset( actor );
- return;
- }
-
- NinePatchImage npatchImage = NinePatchImage::DownCast( image );
- if( npatchImage )
- {
- NPatchRenderer* rendererPtr = dynamic_cast< NPatchRenderer* >( &GetImplementation( renderer ) );
- if( rendererPtr )
- {
- rendererPtr->SetImage( npatchImage );
- return;
- }
- }
- else
- {
- ImageRenderer* rendererPtr = dynamic_cast< ImageRenderer* >( &GetImplementation( renderer ) );
- if( rendererPtr )
- {
- rendererPtr->SetImage( actor, image );
- return;
- }
- }
-
- renderer.RemoveAndReset( actor );
- }
-
- renderer = GetControlRenderer( image );
- if( actor && actor.OnStage() )
- {
- renderer.SetOnStage( actor );
- }
-}
-
-Toolkit::ControlRenderer RendererFactory::GetControlRenderer( const std::string& url, ImageDimensions size )
+Toolkit::ControlRenderer RendererFactory::CreateControlRenderer( const std::string& url, ImageDimensions size )
{
if( !mFactoryCache )
{
}
}
-void RendererFactory::ResetRenderer( Toolkit::ControlRenderer& renderer, Actor& actor, const std::string& url, ImageDimensions size )
-{
- if( mDebugEnabled && renderer )
- {
- return;
- }
-
- if( renderer )
- {
- if( url.empty() )
- {
- // If the URL is empty, then reset the renderer and return
- renderer.RemoveAndReset( actor );
- return;
- }
- else if( NinePatchImage::IsNinePatchUrl( url ) )
- {
- NPatchRenderer* rendererPtr = dynamic_cast< NPatchRenderer* >( &GetImplementation( renderer ) );
- if( rendererPtr )
- {
- rendererPtr->SetImage( url );
- return;
- }
- }
- else if( SvgRenderer::IsSvgUrl( url ) )
- {
- SvgRenderer* rendererPtr = dynamic_cast< SvgRenderer* >( &GetImplementation( renderer ) );
- if( rendererPtr )
- {
- rendererPtr->SetImage( url, size );
- return;
- }
- }
- else
- {
- ImageRenderer* rendererPtr = dynamic_cast< ImageRenderer* >( &GetImplementation( renderer ) );
- if( rendererPtr )
- {
- rendererPtr->SetImage( actor, url, size );
- return;
- }
- }
-
- renderer.RemoveAndReset( actor );
- }
-
- renderer = GetControlRenderer( url, size );
- if( actor && actor.OnStage() )
- {
- renderer.SetOnStage( actor );
- }
-}
-
-void RendererFactory::ResetRenderer( Toolkit::ControlRenderer& renderer, Actor& actor, const Property::Map& propertyMap )
-{
- if( mDebugEnabled && renderer )
- {
- return;
- }
-
- if( renderer )
- {
- ControlRenderer& controlRenderer = GetImplementation( renderer );
-
- RendererType type = GetRendererType( propertyMap );
-
- //If there's no renderer type specified or if there hasn't been a renderer type change then we can reuse the renderer
- if( type == UNDEFINED ||
- ( type == IMAGE && typeid( controlRenderer ) == typeid( ImageRenderer ) ) ||
- ( type == N_PATCH && typeid( controlRenderer ) == typeid( NPatchRenderer ) ) ||
- ( type == COLOR && typeid( controlRenderer ) == typeid( ColorRenderer ) ) ||
- ( type == GRADIENT && typeid( controlRenderer ) == typeid( GradientRenderer ) ) ||
- ( type == BORDER && typeid( controlRenderer ) == typeid( BorderRenderer ) ) ||
- ( type == SVG && typeid( controlRenderer ) == typeid( SvgRenderer ) ) ||
- ( type == MESH && typeid( controlRenderer ) == typeid( MeshRenderer ) ) )
- {
- controlRenderer.Initialize( actor, propertyMap );
- return;
- }
-
- renderer.RemoveAndReset( actor );
- }
-
- renderer = GetControlRenderer( propertyMap );
- if( renderer && actor && actor.OnStage() )
- {
- renderer.SetOnStage( actor );
- }
-}
-
Image RendererFactory::GetBrokenRendererImage()
{
return ResourceImage::New( BROKEN_RENDERER_IMAGE_URL );
RendererFactory( bool debugEnabled );
/**
- * @copydoc Toolkit::RenderFactory::GetControlRenderer( const Property::Map& )
+ * @copydoc Toolkit::RenderFactory::CreateControlRenderer( const Property::Map& )
*/
- Toolkit::ControlRenderer GetControlRenderer( const Property::Map& propertyMap );
+ Toolkit::ControlRenderer CreateControlRenderer( const Property::Map& propertyMap );
/**
- * @copydoc Toolkit::RenderFactory::ResetRenderer( Toolkit::ControlRenderer& renderer, Actor& actor, const Property::Map& propertyMap )
+ * @copydoc Toolkit::RenderFactory::CreateControlRenderer( const Image& )
*/
- void ResetRenderer( Toolkit::ControlRenderer& renderer, Actor& actor, const Property::Map& propertyMap );
+ Toolkit::ControlRenderer CreateControlRenderer( const Image& image );
/**
- * @copydoc Toolkit::RenderFactory::GetControlRenderer( const Vector4& )
+ * @copydoc Toolkit::RenderFactory::CreateControlRenderer( const std::string&, ImageDimensions )
*/
- Toolkit::ControlRenderer GetControlRenderer( const Vector4& color );
-
- /**
- * @copydoc Toolkit::RendererFactory::ResetRenderer( Toolkit::ControlRenderer&, Actor& actor, const Vector4& )
- */
- void ResetRenderer( Toolkit::ControlRenderer& renderer, Actor& actor, const Vector4& color );
-
- /**
- * @copydoc Toolkit::RenderFactory::GetControlRenderer( float, const Vector4&, bool )
- */
- Toolkit::ControlRenderer GetControlRenderer( float borderSize, const Vector4& borderColor, bool antiAliasing );
-
- /**
- * @copydoc Toolkit::RenderFactory::GetControlRenderer( const Image& )
- */
- Toolkit::ControlRenderer GetControlRenderer( const Image& image );
-
- /**
- * @copydoc Toolkit::RendererFactory::ResetRenderer( Toolkit::ControlRenderer&, Actor& actor, const Image& )
- */
- void ResetRenderer( Toolkit::ControlRenderer& renderer, Actor& actor, const Image& image );
-
- /**
- * @copydoc Toolkit::RenderFactory::GetControlRenderer( const std::string&, ImageDimensions )
- */
- Toolkit::ControlRenderer GetControlRenderer( const std::string& image, ImageDimensions size );
-
- /**
- * @copydoc Toolkit::RendererFactory::ResetRenderer( Toolkit::ControlRenderer&, Actor& actor, const std::string&, ImageDimensions )
- */
- void ResetRenderer( Toolkit::ControlRenderer& renderer, Actor& actor, const std::string& image, ImageDimensions size );
+ Toolkit::ControlRenderer CreateControlRenderer( const std::string& image, ImageDimensions size );
public:
/**
const char * const MATERIAL_URL( "materialUrl" );
const char * const TEXTURES_PATH( "texturesPath" );
const char * const SHADER_TYPE( "shaderType" );
+const char * const USE_MIPMAPPING( "useMipmapping" );
} // namespace Internal
extern const char * const MATERIAL_URL;
extern const char * const TEXTURES_PATH;
extern const char * const SHADER_TYPE;
+extern const char * const USE_MIPMAPPING;
} // namespace Internal
}
ScrollBar::ScrollBar(Toolkit::ScrollBar::Direction direction)
-: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS ) ),
+: Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ),
mIndicatorShowAlpha(1.0f),
mDirection(direction),
mScrollableObject(WeakHandleBase()),
#include <dali/devel-api/common/set-wrapper.h>
#include <dali/public-api/common/stage.h>
#include <dali/public-api/events/wheel-event.h>
-#include <dali/public-api/events/touch-event.h>
+#include <dali/public-api/events/touch-data.h>
#include <dali/public-api/object/type-registry.h>
#include <dali/public-api/object/type-registry-helper.h>
Vector2 stageSize = Stage::GetCurrent().GetSize();
mWheelScrollDistanceStep = stageSize.y * DEFAULT_WHEEL_SCROLL_DISTANCE_STEP_PROPORTION;
+ self.TouchSignal().Connect( this, &ItemView::OnTouch );
EnableGestureDetection(Gesture::Type(Gesture::Pan));
mWheelEventFinishedTimer = Timer::New( WHEEL_EVENT_FINISHED_TIME_OUT );
}
}
-bool ItemView::OnTouchEvent(const TouchEvent& event)
-{
- // Ignore events with multiple-touch points
- if (event.GetPointCount() != 1)
- {
- return false;
- }
-
- if (event.GetPoint(0).state == TouchPoint::Down)
- {
- // Cancel ongoing scrolling etc.
- mGestureState = Gesture::Clear;
-
- mScrollDistance = 0.0f;
- mScrollSpeed = 0.0f;
- Self().SetProperty(Toolkit::ItemView::Property::SCROLL_SPEED, mScrollSpeed);
-
- mScrollOvershoot = 0.0f;
- AnimateScrollOvershoot(0.0f);
-
- if(mScrollAnimation)
- {
- mScrollCompletedSignal.Emit(GetCurrentScrollPosition());
- }
-
- RemoveAnimation(mScrollAnimation);
- }
-
- return true; // consume since we're potentially scrolling
-}
-
bool ItemView::OnWheelEvent(const WheelEvent& event)
{
// Respond the wheel event to scroll
return clamppedPosition;
}
+bool ItemView::OnTouch( Actor actor, const TouchData& touch )
+{
+ // Ignore events with multiple-touch points
+ if (touch.GetPointCount() != 1)
+ {
+ return false;
+ }
+
+ if ( touch.GetState( 0 ) == PointState::DOWN )
+ {
+ // Cancel ongoing scrolling etc.
+ mGestureState = Gesture::Clear;
+
+ mScrollDistance = 0.0f;
+ mScrollSpeed = 0.0f;
+ Self().SetProperty(Toolkit::ItemView::Property::SCROLL_SPEED, mScrollSpeed);
+
+ mScrollOvershoot = 0.0f;
+ AnimateScrollOvershoot(0.0f);
+
+ if(mScrollAnimation)
+ {
+ mScrollCompletedSignal.Emit(GetCurrentScrollPosition());
+ }
+
+ RemoveAnimation(mScrollAnimation);
+ }
+
+ return true; // consume since we're potentially scrolling
+}
+
void ItemView::OnPan( const PanGesture& gesture )
{
Actor self = Self();
virtual void OnChildAdd(Actor& child);
/**
- * From CustomActorImpl; called after a touch-signal is received by the owning actor.
- * @param[in] event The touch event.
- * @return True if the event should be consumed.
- */
- virtual bool OnTouchEvent(const TouchEvent& event);
-
- /**
* From CustomActorImpl; called after a wheel-event is received by the owning actor.
* @param[in] event The wheel event.
* @return True if the event should be consumed.
// Input Handling
/**
- * Helper to handle pressed (Down) events.
- * @param[in] x The X coordinate of the touch event.
- * @param[in] y The Y coordinate of the touch event.
- * @param[in] timeMs The time-stamp of the touch event.
- */
- void OnPressed(float x, float y, unsigned long timeMs);
-
- /**
* Helper to clamp the first-item position when dragging/swiping.
* @param[in] targetPosition The target position of the drag etc.
* @param[in] targetSize The target ItemView & layout size.
float ClampFirstItemPosition(float targetPosition, const Vector3& targetSize, ItemLayout& layout, bool updateOvershoot = true);
/**
+ * Called after a touch-signal is received by the owning actor.
+ * @param[in] actor The touched actor.
+ * @param[in] touch The touch information.
+ * @return True if the event should be consumed.
+ */
+ bool OnTouch( Actor actor, const TouchData& touch );
+
+ /**
* Called upon pan gesture event.
*
* @param[in] gesture The gesture event.
#include <dali/public-api/animation/constraints.h>
#include <dali/public-api/common/stage.h>
#include <dali/public-api/events/wheel-event.h>
-#include <dali/public-api/events/touch-event.h>
+#include <dali/public-api/events/touch-data.h>
#include <dali/public-api/object/type-registry.h>
#include <dali/public-api/object/type-registry-helper.h>
#include <dali/integration-api/debug.h>
mGestureStackDepth = 0;
+ self.TouchSignal().Connect( this, &ScrollView::OnTouch );
EnableGestureDetection( Gesture::Type( Gesture::Pan ) );
// By default we'll allow the user to freely drag the scroll view,
return false;
}
-bool ScrollView::OnTouchEvent(const TouchEvent& event)
+bool ScrollView::OnTouch( Actor actor, const TouchData& touch )
{
if(!mSensitive)
{
}
// Ignore events with multiple-touch points
- if (event.GetPointCount() != 1)
+ if (touch.GetPointCount() != 1)
{
DALI_LOG_SCROLL_STATE("[0x%X], multiple touch, ignoring", this);
return false;
}
- const TouchPoint::State pointState = event.GetPoint(0).state;
- if( pointState == TouchPoint::Down )
+ const PointState::Type pointState = touch.GetState( 0 );
+ if( pointState == PointState::DOWN )
{
DALI_LOG_SCROLL_STATE("[0x%X] Down", this);
if(mGestureStackDepth==0)
{
- mTouchDownTime = event.time;
+ mTouchDownTime = touch.GetTime();
// This allows time for a pan-gesture to start, to avoid breaking snap-animation behavior with fast flicks.
// If touch-down does not become a pan (after timeout interval), then snap-animation can be interrupted.
StartTouchDownTimer();
}
}
- else if( ( pointState == TouchPoint::Up ) ||
- ( ( pointState == TouchPoint::Interrupted ) && ( event.GetPoint(0).hitActor == Self() ) ) )
+ else if( ( pointState == PointState::UP ) ||
+ ( ( pointState == PointState::INTERRUPTED ) && ( touch.GetHitActor( 0 )== Self() ) ) )
{
DALI_LOG_SCROLL_STATE("[0x%X] %s", this, ( ( pointState == TouchPoint::Up ) ? "Up" : "Interrupted" ) );
// otherwise our scroll could be stopped (interrupted) half way through an animation.
if(mGestureStackDepth==0 && mTouchDownTimeoutReached)
{
- if( ( event.GetPoint(0).state == TouchPoint::Interrupted ) ||
- ( ( event.time - mTouchDownTime ) >= MINIMUM_TIME_BETWEEN_DOWN_AND_UP_FOR_RESET ) )
+ if( ( pointState == PointState::INTERRUPTED ) ||
+ ( ( touch.GetTime() - mTouchDownTime ) >= MINIMUM_TIME_BETWEEN_DOWN_AND_UP_FOR_RESET ) )
{
// Reset the velocity only if down was received a while ago
mLastVelocity = Vector2( 0.0f, 0.0f );
*/
static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
-private: // private overriden functions from CustomActorImpl and Controls
+private: // private overridden functions from CustomActorImpl and Controls
/**
* @copydoc Dali::CustomActorImpl::OnSizeAnimation(Animation&, const Vector3&)
virtual void OnChildRemove(Actor& child);
/**
- * From CustomActorImpl; called after a touchSignal is received by the owning actor.
- *
- * We don't listen to these events as content within the contain may consume events.
- *
- * @param[in] event The touch event.
- * @return True if the event should be consumed.
- */
- virtual bool OnTouchEvent(const TouchEvent& event);
-
- /**
* From CustomActorImpl; called after a wheelEvent is received by the owning actor.
* @param[in] event The wheel event.
* @return True if the event should be consumed.
private:
/**
+ * Called after a touchSignal is received by the owning actor.
+ *
+ * We don't consume these events as content within the container may consume events.
+ *
+ * @param[in] actor The touched actor.
+ * @param[in] touch The touch information.
+ * @return True if the event should be consumed.
+ */
+ bool OnTouch( Actor actor, const TouchData& touch );
+
+ /**
* Start a timer which calls OnTouchDownTimeout()
*/
void StartTouchDownTimer();
Vector2 mLastVelocity; ///< Record the last velocity from PanGesture (Finish event doesn't have correct velocity)
LockAxis mLockAxis;
- Timer mTouchDownTimer; ///< Used to interrupt snap-animation. This cannot be done in OnTouchEvent without breaking fast flick behavior.
+ Timer mTouchDownTimer; ///< Used to interrupt snap-animation. This cannot be done in OnTouch without breaking fast flick behavior.
float mScrollUpdateDistance; ///< Distance for scrolling to travel for the scroll update notifications
Dali::PropertyNotification mScrollXUpdateNotification; ///< scroll x position update notification
// Scrollable controls are not layout containers so they dont need size negotiation..
// we dont want size negotiation while scrolling if we can avoid it
Scrollable::Scrollable()
-: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS | DISABLE_SIZE_NEGOTIATION ) ),
+: Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS | DISABLE_SIZE_NEGOTIATION ) ),
mOvershootEffectColor( DEFAULT_OVERSHOOT_COLOUR ),
mOvershootAnimationSpeed ( DEFAULT_OVERSHOOT_ANIMATION_SPEED ),
mOvershootSize( OVERSHOOT_DEFAULT_SIZE ),
}
Scrollable::Scrollable( ControlBehaviour behaviourFlags )
-: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS | behaviourFlags ) ),
+: Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS | behaviourFlags ) ),
mOvershootEffectColor( DEFAULT_OVERSHOOT_COLOUR ),
mOvershootAnimationSpeed ( DEFAULT_OVERSHOOT_ANIMATION_SPEED ),
mOvershootSize( OVERSHOOT_DEFAULT_SIZE ),
{
mShadowPlaneBg = shadowPlaneBackground;
- mShadowPlane = Toolkit::ImageView::New();
+ mShadowPlane = Toolkit::ImageView::New( mOutputImage );
mShadowPlane.SetName( "SHADOW_PLANE" );
mShadowPlane.SetParentOrigin(ParentOrigin::CENTER);
mShadowPlane.SetAnchorPoint(AnchorPoint::CENTER);
- mShadowPlane.SetImage(mOutputImage);
mShadowPlane.SetProperty( Toolkit::ImageView::Property::IMAGE, mShadowRenderShader );
SetShaderConstants();
#include <cstring> // for strcmp
#include <sstream>
#include <limits>
-#include <dali/public-api/events/touch-event.h>
+#include <dali/public-api/events/touch-data.h>
#include <dali/public-api/object/type-registry.h>
#include <dali/public-api/object/type-registry-helper.h>
#include <dali/public-api/images/resource-image.h>
}
Slider::Slider()
-: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS ) ),
+: Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ),
mState( NORMAL ),
mPopupVisual(""),
mPopupArrowVisual(""),
// Size the Slider actor to a default
self.SetSize( DEFAULT_HIT_REGION.x, DEFAULT_HIT_REGION.y );
+
+ // Connect to the touch signal
+ self.TouchSignal().Connect( this, &Slider::OnTouch );
}
void Slider::OnSizeSet( const Vector3& size )
SetTrackRegion( Vector2( size.x - GetHandleSize().x, GetTrackRegion().y ) );
}
-bool Slider::OnTouchEvent(Actor actor, const TouchEvent& event)
+bool Slider::OnTouch(Actor actor, const TouchData& touch)
{
if( mState != DISABLED )
{
- TouchPoint::State touchState = event.GetPoint(0).state;
+ const PointState::Type touchState = touch.GetState(0);
- if( touchState == TouchPoint::Down )
+ if( touchState == PointState::DOWN )
{
mState = PRESSED;
- float percentage = MapPercentage( event.GetPoint(0).local );
+ float percentage = MapPercentage( touch.GetLocalPosition( 0 ) );
float value = MapBounds( ( GetSnapToMarks() ) ? SnapToMark( percentage ) : MarkFilter( percentage ), GetLowerBound(), GetUpperBound() );
SetValue( value );
DisplayPopup( value );
}
- else if( touchState == TouchPoint::Up)
+ else if( touchState == PointState::UP )
{
if( mState == PRESSED )
{
Actor hitRegion = Actor::New();
hitRegion.SetParentOrigin( ParentOrigin::CENTER );
hitRegion.SetAnchorPoint( AnchorPoint::CENTER );
- hitRegion.TouchedSignal().Connect( this, &Slider::OnTouchEvent );
+ hitRegion.TouchSignal().Connect( this, &Slider::OnTouch );
return hitRegion;
}
virtual void OnInitialize();
/**
- * Hit region touch event
+ * Hit region touch
*
* @param[in] actor The actor the event is raised for
- * @param[in] event The touch event info
- * @return If the event is handled or not
+ * @param[in] touch The touch info
+ * @return If touch is handled or not
*/
- bool OnTouchEvent( Actor actor, const TouchEvent& event );
+ bool OnTouch( Actor actor, const TouchData& touch );
/**
* Pan gesture event
#include <dali/devel-api/scripting/scripting.h>
#include <dali/integration-api/debug.h>
+// INTERNAL_INCLUDES
+#include <dali-toolkit/internal/controls/renderers/control-renderer-impl.h>
+
namespace //Unnamed namespace
{
void SuperBlurView::OnInitialize()
{
mBlurStrengthPropertyIndex = Self().RegisterProperty( "blurStrength", 0.f );
-
- Property::Map rendererMap;
- rendererMap.Insert( "rendererType", "image");
-
- Property::Map shaderMap;
- std::stringstream verterShaderString;
- shaderMap[ "fragmentShader" ] = FRAGMENT_SHADER;
- rendererMap.Insert( "shader", shaderMap );
-
- Toolkit::RendererFactory rendererFactory = Toolkit::RendererFactory::Get();
- for(unsigned int i=0; i<=mBlurLevels; i++)
- {
- mRenderers[i] = rendererFactory.GetControlRenderer( rendererMap );
- mRenderers[i].SetDepthIndex(i);
- }
}
void SuperBlurView::SetImage(Image inputImage)
ClearBlurResource();
mInputImage = inputImage;
- Actor self = Self();
- Toolkit::RendererFactory::Get().ResetRenderer( mRenderers[0], self, mInputImage );
+ Actor self( Self() );
+ InitializeControlRenderer( self, mRenderers[0], mInputImage );
+ mRenderers[0].SetDepthIndex(0);
+ SetShaderEffect( mRenderers[0] );
+ if( self.OnStage() )
+ {
+ mRenderers[0].SetOnStage( self );
+ }
BlurImage( 0, inputImage);
for(unsigned int i=1; i<mBlurLevels;i++)
mResourcesCleared = true;
}
}
+void SuperBlurView::SetShaderEffect( Toolkit::ControlRenderer& renderer )
+{
+ Property::Map shaderMap;
+ std::stringstream verterShaderString;
+ shaderMap[ "fragmentShader" ] = FRAGMENT_SHADER;
+
+ Internal::ControlRenderer& rendererImpl = GetImplementation( renderer );
+ rendererImpl.SetCustomShader( shaderMap );
+}
void SuperBlurView::OnSizeSet( const Vector3& targetSize )
{
Toolkit::RendererFactory rendererFactory = Toolkit::RendererFactory::Get();
Actor self = Self();
- for(unsigned int i=1; i<=mBlurLevels;i++)
+ for( unsigned int i = 1; i <= mBlurLevels; i++ )
{
float exponent = static_cast<float>(i);
mBlurredImage[i-1] = FrameBufferImage::New( mTargetSize.width/std::pow(2.f,exponent) , mTargetSize.height/std::pow(2.f,exponent),
GAUSSIAN_BLUR_RENDER_TARGET_PIXEL_FORMAT, Dali::Image::NEVER );
- rendererFactory.ResetRenderer( mRenderers[i], self, mBlurredImage[i-1] );
+ InitializeControlRenderer( self, mRenderers[i], mBlurredImage[i - 1] );
+ mRenderers[ i ].SetDepthIndex( i );
+ SetShaderEffect( mRenderers[ i ] );
}
if( mInputImage )
if( self.OnStage() )
{
- for(unsigned int i=0; i<=mBlurLevels;i++)
+ for( unsigned int i = 1; i <= mBlurLevels; i++ )
{
mRenderers[i].SetOnStage( self );
}
}
Actor self = Self();
- mRenderers[0].SetOnStage( self );
+ if( mRenderers[0] )
+ {
+ mRenderers[0].SetOnStage( self );
+ }
for(unsigned int i=1; i<=mBlurLevels;i++)
{
- mRenderers[i].SetOnStage( self );
+ if( mRenderers[i] )
+ {
+ mRenderers[i].SetOnStage( self );
+ }
Renderer renderer = self.GetRendererAt( i );
Property::Index index = renderer.RegisterProperty( ALPHA_UNIFORM_NAME, 0.f );
*/
void ClearBlurResource();
+ /**
+ * Sets shader effect on the control renderer
+ * @param[in,out] Sets custom shader effect on the given renderer
+ */
+ void SetShaderEffect( Toolkit::ControlRenderer& renderer );
+
private:
std::vector<Toolkit::GaussianBlurView> mGaussianBlurView;
std::vector<FrameBufferImage> mBlurredImage;
EnableGestureDetection( static_cast<Gesture::Type>( Gesture::Tap | Gesture::Pan | Gesture::LongPress ) );
GetTapGestureDetector().SetMaximumTapsRequired( 2 );
- self.TouchedSignal().Connect( this, &TextEditor::OnTouched );
+ self.TouchSignal().Connect( this, &TextEditor::OnTouched );
// Set BoundingBox to stage size if not already set.
Rect<int> boundingBox;
{
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor OnRelayout\n");
- if( mController->Relayout( size ) ||
+ const Text::Controller::UpdateTextType updateTextType = mController->Relayout( size );
+
+ if( ( Text::Controller::NONE_UPDATED != updateTextType ) ||
!mRenderer )
{
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor::OnRelayout %p Displaying new contents\n", mController.Get() );
- if( mDecorator )
+ if( mDecorator &&
+ ( Text::Controller::NONE_UPDATED != ( Text::Controller::DECORATOR_UPDATED & updateTextType ) ) )
{
mDecorator->Relayout( size );
}
}
EnableClipping( true, size );
- RenderText();
+ RenderText( updateTextType );
}
}
-void TextEditor::RenderText()
+void TextEditor::RenderText( Text::Controller::UpdateTextType updateTextType )
{
Actor self = Self();
Actor renderableActor;
- if( mRenderer )
- {
- renderableActor = mRenderer->Render( mController->GetView(), DepthIndex::TEXT );
- }
- if( renderableActor != mRenderableActor )
+ if( Text::Controller::NONE_UPDATED != ( Text::Controller::MODEL_UPDATED & updateTextType ) )
{
- UnparentAndReset( mRenderableActor );
- mRenderableActor = renderableActor;
+ if( mRenderer )
+ {
+ renderableActor = mRenderer->Render( mController->GetView(), DepthIndex::TEXT );
+ }
+
+ if( renderableActor != mRenderableActor )
+ {
+ UnparentAndReset( mRenderableActor );
+ mRenderableActor = renderableActor;
+ }
}
if( mRenderableActor )
{
if ( mHasBeenStaged )
{
- RenderText();
+ RenderText( static_cast<Text::Controller::UpdateTextType>( Text::Controller::MODEL_UPDATED | Text::Controller::DECORATOR_UPDATED ) );
}
else
{
// The depth of the text renderer is set in the RenderText() called from OnRelayout().
}
-bool TextEditor::OnTouched( Actor actor, const TouchEvent& event )
+bool TextEditor::OnTouched( Actor actor, const TouchData& touch )
{
return true;
}
* @brief Callback when TextEditor is touched
*
* @param[in] actor TextEditor touched
- * @param[in] event TouchEvent information
+ * @param[in] touch Touch information
*/
- bool OnTouched( Actor actor, const TouchEvent& event );
+ bool OnTouched( Actor actor, const TouchData& touch );
/**
* Construct a new TextEditor.
/**
* @brief Render view, create and attach actor(s) to this text editor.
*/
- void RenderText();
+ void RenderText( Text::Controller::UpdateTextType updateTextType );
// Connection needed to re-render text, when a text editor returns to the stage.
void OnStageConnect( Dali::Actor actor );
EnableGestureDetection( static_cast<Gesture::Type>( Gesture::Tap | Gesture::Pan | Gesture::LongPress ) );
GetTapGestureDetector().SetMaximumTapsRequired( 2 );
- self.TouchedSignal().Connect( this, &TextField::OnTouched );
+ self.TouchSignal().Connect( this, &TextField::OnTouched );
// Set BoundingBox to stage size if not already set.
Rect<int> boundingBox;
{
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField OnRelayout\n");
- if( mController->Relayout( size ) ||
+ const Text::Controller::UpdateTextType updateTextType = mController->Relayout( size );
+
+ if( ( Text::Controller::NONE_UPDATED != updateTextType ) ||
!mRenderer )
{
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnRelayout %p Displaying new contents\n", mController.Get() );
- if( mDecorator )
+ if( mDecorator &&
+ ( Text::Controller::NONE_UPDATED != ( Text::Controller::DECORATOR_UPDATED & updateTextType ) ) )
{
mDecorator->Relayout( size );
}
mRenderer = Backend::Get().NewRenderer( mRenderingBackend );
}
- EnableClipping( (Dali::Toolkit::TextField::EXCEED_POLICY_CLIP == mExceedPolicy), size );
- RenderText();
+ EnableClipping( ( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP == mExceedPolicy ), size );
+ RenderText( updateTextType );
}
}
-void TextField::RenderText()
+void TextField::RenderText( Text::Controller::UpdateTextType updateTextType )
{
Actor self = Self();
Actor renderableActor;
- if( mRenderer )
- {
- renderableActor = mRenderer->Render( mController->GetView(), DepthIndex::TEXT );
- }
- if( renderableActor != mRenderableActor )
+ if( Text::Controller::NONE_UPDATED != ( Text::Controller::MODEL_UPDATED & updateTextType ) )
{
- UnparentAndReset( mRenderableActor );
- mRenderableActor = renderableActor;
+ if( mRenderer )
+ {
+ renderableActor = mRenderer->Render( mController->GetView(), DepthIndex::TEXT );
+ }
+
+ if( renderableActor != mRenderableActor )
+ {
+ UnparentAndReset( mRenderableActor );
+ mRenderableActor = renderableActor;
+ }
}
if( mRenderableActor )
{
if ( mHasBeenStaged )
{
- RenderText();
+ RenderText( static_cast<Text::Controller::UpdateTextType>( Text::Controller::MODEL_UPDATED | Text::Controller::DECORATOR_UPDATED ) );
}
else
{
// The depth of the text renderer is set in the RenderText() called from OnRelayout().
}
-bool TextField::OnTouched( Actor actor, const TouchEvent& event )
+bool TextField::OnTouched( Actor actor, const TouchData& touch )
{
return true;
}
* @brief Callback when TextField is touched
*
* @param[in] actor TextField touched
- * @param[in] event TouchEvent information
+ * @param[in] touch Touch information
*/
- bool OnTouched( Actor actor, const TouchEvent& event );
+ bool OnTouched( Actor actor, const TouchData& touch );
/**
* Construct a new TextField.
/**
* @brief Render view, create and attach actor(s) to this Text Field.
*/
- void RenderText();
+ void RenderText( Text::Controller::UpdateTextType updateTextType );
// Connection needed to re-render text, when a Text Field returns to the stage.
void OnStageConnect( Dali::Actor actor );
{
DALI_LOG_INFO( gLogFilter, Debug::General, "TextLabel::OnRelayout\n" );
- if( mController->Relayout( size ) ||
+ const Text::Controller::UpdateTextType updateTextType = mController->Relayout( size );
+
+ if( ( Text::Controller::NONE_UPDATED != ( Text::Controller::MODEL_UPDATED & updateTextType ) ) ||
!mRenderer )
{
if( !mRenderer )
{
mPropertyMap = map;
- Actor self = Self();
- Toolkit::RendererFactory::Get().ResetRenderer( mRenderer, self, mPropertyMap );
+ Actor self( Self() );
+ InitializeControlRenderer( self, mRenderer, mPropertyMap );
Property::Value* widthValue = mPropertyMap.Find( "width" );
if( widthValue )
void VideoView::SetNativeImageTarget()
{
- Actor self = Self();
+ Actor self( Self() );
int curPos = mVideoPlayer.GetPlayPosition();
mSetRenderingTarget = true;
mVideoPlayer.SetUrl( mUrl );
mVideoPlayer.FinishedSignal().Connect( this, &VideoView::EmitSignalFinish );
- Toolkit::RendererFactory::Get().ResetRenderer( mRenderer, self, mNativeImage );
+ InitializeControlRenderer( self, mRenderer, mNativeImage );
if( mIsPlay )
{
#include <dali/devel-api/rendering/renderer.h>
#include <dali-toolkit/devel-api/controls/renderer-factory/renderer-factory.h>
-// INTERNAL INCLUDES
-
namespace Dali
{
rendererMap.Insert( "shader", customShader );
// create actor to render input with applied emboss effect
- mActorForInput1 = Toolkit::ImageView::New( mInputImage );
+ mActorForInput1 = Toolkit::ImageView::New(mInputImage);
mActorForInput1.SetParentOrigin( ParentOrigin::CENTER );
mActorForInput1.SetSize(mTargetSize);
Vector2 textureScale( 1.5f/mTargetSize.width, 1.5f/mTargetSize.height);
mActorForInput1.SetProperty( Toolkit::ImageView::Property::IMAGE, rendererMap );
mRootActor.Add( mActorForInput1 );
- mActorForInput2 = Toolkit::ImageView::New( mInputImage );
+ mActorForInput2 = Toolkit::ImageView::New(mInputImage);
mActorForInput2.SetParentOrigin( ParentOrigin::CENTER );
mActorForInput2.SetSize(mTargetSize);
mActorForInput2.RegisterProperty( TEX_SCALE_UNIFORM_NAME, textureScale );
customShader[ "fragmentShader" ] = COMPOSITE_FRAGMENT_SOURCE;
rendererMap[ "shader"] = customShader;
- Toolkit::RendererFactory rendererFactory = Toolkit::RendererFactory::Get();
- mRendererForEmboss1 = rendererFactory.GetControlRenderer( mImageForEmboss1 );
- mRendererForEmboss2 = rendererFactory.GetControlRenderer( mImageForEmboss2 );
- // set COMPOSITE custom shader to both renderers
- rendererFactory.ResetRenderer( mRendererForEmboss1, mActorForComposite, rendererMap);
- rendererFactory.ResetRenderer( mRendererForEmboss2, mActorForComposite, rendererMap);
- // apply renderers to the actor
- mRendererForEmboss1.SetOnStage( mActorForComposite );
- mRendererForEmboss2.SetOnStage( mActorForComposite );
+ rendererMap[ "rendererType"] = "image";
+
+ mRootActor.Add( mActorForComposite );
+
+ InitializeControlRenderer( mActorForComposite, mRendererForEmboss1, rendererMap );
+ InitializeControlRenderer( mActorForComposite, mRendererForEmboss2, rendererMap );
+
+ TextureSet textureSet1 = TextureSet::New();
+ textureSet1.SetImage( 0, mImageForEmboss1 );
+ mActorForComposite.GetRendererAt(0).SetTextures( textureSet1 );
mActorForComposite.GetRendererAt(0).RegisterProperty( COLOR_UNIFORM_NAME, Color::BLACK );
+
+ TextureSet textureSet2 = TextureSet::New();
+ textureSet2.SetImage( 0, mImageForEmboss2 );
+ mActorForComposite.GetRendererAt(1).SetTextures( textureSet2 );
mActorForComposite.GetRendererAt(1).RegisterProperty( COLOR_UNIFORM_NAME, Color::WHITE );
- mRootActor.Add( mActorForComposite );
SetupCamera();
CreateRenderTasks();
#include <dali/public-api/animation/constraints.h>
#include <dali/public-api/common/stage.h>
#include <dali/public-api/events/key-event.h>
+#include <dali/public-api/events/touch-data.h>
#include <dali/public-api/object/type-registry.h>
#include <dali/public-api/object/type-registry-helper.h>
#include <dali/public-api/images/resource-image.h>
OnPhysicalKeyboardStatusChanged(PhysicalKeyboard::Get());
Toolkit::KeyInputFocusManager::Get().UnhandledKeyEventSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnKeyEvent);
- Stage::GetCurrent().TouchedSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnTouched);
+ Stage::GetCurrent().TouchSignal().Connect( mSlotDelegate, &KeyboardFocusManager::OnTouch );
PhysicalKeyboard::Get().StatusChangedSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnPhysicalKeyboardStatusChanged);
}
}
}
-void KeyboardFocusManager::OnTouched(const TouchEvent& touchEvent)
+void KeyboardFocusManager::OnTouch(const TouchData& touch)
{
// Clear the focus when user touch the screen.
// We only do this on a Down event, otherwise the clear action may override a manually focused actor.
- if( ( touchEvent.GetPointCount() < 1 ) || ( touchEvent.GetPoint( 0 ).state == TouchPoint::Down ) )
+ if( ( touch.GetPointCount() < 1 ) || ( touch.GetState( 0 ) == PointState::DOWN ) )
{
ClearFocus();
}
/**
* Callback for the touch event when the screen is touched and when the touch ends
* (i.e. the down & up touch events only).
- * @param[in] touchEvent The touch event
+ * @param[in] touch The touch information
*/
- void OnTouched(const TouchEvent& touchEvent);
+ void OnTouch( const TouchData& touch );
/**
* Change the keyboard focus status when keyboard focus feature turned on or off.
#include <dali/public-api/adaptor-framework/timer.h>
#include <dali/public-api/actors/layer.h>
#include <dali/public-api/common/stage.h>
-#include <dali/public-api/events/touch-event.h>
+#include <dali/public-api/events/touch-data.h>
#include <dali/public-api/events/pan-gesture.h>
#include <dali/public-api/images/resource-image.h>
#include <dali/public-api/object/property-notification.h>
{
mQuadVertexFormat[ "aPosition" ] = Property::VECTOR2;
mHighlightShader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
- SetupTouchEvents();
+ SetupGestures();
}
/**
return true;
}
- void SetupTouchEvents()
+ void SetupGestures()
{
mTapDetector = TapGestureDetector::New();
mTapDetector.DetectedSignal().Connect( this, &Decorator::Impl::OnTap );
grabHandle.actor.Add( grabHandle.grabArea );
grabHandle.actor.SetColor( mHandleColor );
- grabHandle.grabArea.TouchedSignal().Connect( this, &Decorator::Impl::OnGrabHandleTouched );
+ grabHandle.grabArea.TouchSignal().Connect( this, &Decorator::Impl::OnGrabHandleTouched );
mTapDetector.Attach( grabHandle.grabArea );
mPanGestureDetector.Attach( grabHandle.grabArea );
mTapDetector.Attach( primary.grabArea );
mPanGestureDetector.Attach( primary.grabArea );
- primary.grabArea.TouchedSignal().Connect( this, &Decorator::Impl::OnHandleOneTouched );
+ primary.grabArea.TouchSignal().Connect( this, &Decorator::Impl::OnHandleOneTouched );
primary.actor.Add( primary.grabArea );
mTapDetector.Attach( secondary.grabArea );
mPanGestureDetector.Attach( secondary.grabArea );
- secondary.grabArea.TouchedSignal().Connect( this, &Decorator::Impl::OnHandleTwoTouched );
+ secondary.grabArea.TouchSignal().Connect( this, &Decorator::Impl::OnHandleTwoTouched );
secondary.actor.Add( secondary.grabArea );
}
}
- bool OnGrabHandleTouched( Actor actor, const TouchEvent& event )
+ bool OnGrabHandleTouched( Actor actor, const TouchData& touch )
{
// Switch between pressed/release grab-handle images
- if( event.GetPointCount() > 0 &&
+ if( touch.GetPointCount() > 0 &&
mHandle[GRAB_HANDLE].actor )
{
- const TouchPoint& point = event.GetPoint(0);
+ const PointState::Type state = touch.GetState( 0 );
- if( TouchPoint::Down == point.state )
+ if( PointState::DOWN == state )
{
mHandle[GRAB_HANDLE].pressed = true;
}
- else if( ( TouchPoint::Up == point.state ) ||
- ( TouchPoint::Interrupted == point.state ) )
+ else if( ( PointState::UP == state ) ||
+ ( PointState::INTERRUPTED == state ) )
{
mHandle[GRAB_HANDLE].pressed = false;
}
return true;
}
- bool OnHandleOneTouched( Actor actor, const TouchEvent& event )
+ bool OnHandleOneTouched( Actor actor, const TouchData& touch )
{
// Switch between pressed/release selection handle images
- if( event.GetPointCount() > 0 &&
+ if( touch.GetPointCount() > 0 &&
mHandle[LEFT_SELECTION_HANDLE].actor )
{
- const TouchPoint& point = event.GetPoint(0);
+ const PointState::Type state = touch.GetState( 0 );
- if( TouchPoint::Down == point.state )
+ if( PointState::DOWN == state )
{
mHandle[LEFT_SELECTION_HANDLE].pressed = true;
}
- else if( ( TouchPoint::Up == point.state ) ||
- ( TouchPoint::Interrupted == point.state ) )
+ else if( ( PointState::UP == state ) ||
+ ( PointState::INTERRUPTED == state ) )
{
mHandle[LEFT_SELECTION_HANDLE].pressed = false;
mHandlePreviousCrossed = mHandleCurrentCrossed;
return true;
}
- bool OnHandleTwoTouched( Actor actor, const TouchEvent& event )
+ bool OnHandleTwoTouched( Actor actor, const TouchData& touch )
{
// Switch between pressed/release selection handle images
- if( event.GetPointCount() > 0 &&
+ if( touch.GetPointCount() > 0 &&
mHandle[RIGHT_SELECTION_HANDLE].actor )
{
- const TouchPoint& point = event.GetPoint(0);
+ const PointState::Type state = touch.GetState( 0 );
- if( TouchPoint::Down == point.state )
+ if( PointState::DOWN == state )
{
mHandle[RIGHT_SELECTION_HANDLE].pressed = true;
}
- else if( ( TouchPoint::Up == point.state ) ||
- ( TouchPoint::Interrupted == point.state ) )
+ else if( ( PointState::UP == state ) ||
+ ( PointState::INTERRUPTED == state ) )
{
mHandle[RIGHT_SELECTION_HANDLE].pressed = false;
mHandlePreviousCrossed = mHandleCurrentCrossed;
typedef IntrusivePtr<Metrics> MetricsPtr;
/**
- * @brief A wrapper around FontClient used to get metrics & potentially down-scaled Emoji metrics.
+ * @brief A wrapper around FontClient used to get metrics.
*/
class Metrics : public RefObject
{
}
/**
- * @brief Set the maximum Emoji size.
- *
- * @param[in] emojiSize Emoticons will be scaled to fit this size in pixels.
- */
- void SetMaxEmojiSize( int emojiSize )
- {
- mEmojiSize = emojiSize;
- }
-
- /**
- * @brief Get the maximum Emoji size.
- *
- * @return The maximum Emoji size.
- */
- int GetMaxEmojiSize() const
- {
- return mEmojiSize;
- }
-
- /**
* @brief Query the metrics for a font.
*
* @param[in] fontId The ID of the font for the required glyph.
*/
void GetFontMetrics( FontId fontId, FontMetrics& metrics )
{
- mFontClient.GetFontMetrics( fontId, metrics, mEmojiSize ); // inline for performance
+ mFontClient.GetFontMetrics( fontId, metrics ); // inline for performance
}
/**
*/
bool GetGlyphMetrics( GlyphInfo* array, uint32_t size )
{
- return mFontClient.GetGlyphMetrics( array, size, mGlyphType, true, mEmojiSize ); // inline for performance
+ return mFontClient.GetGlyphMetrics( array, size, mGlyphType, true ); // inline for performance
}
protected:
*/
Metrics( TextAbstraction::FontClient& fontClient )
: mFontClient( fontClient ),
- mGlyphType( TextAbstraction::BITMAP_GLYPH ),
- mEmojiSize( 0 )
- {
- }
+ mGlyphType( TextAbstraction::BITMAP_GLYPH )
+ {}
// Undefined
Metrics(const Metrics&);
TextAbstraction::FontClient mFontClient;
TextAbstraction::GlyphType mGlyphType;
- int mEmojiSize;
};
} // namespace Text
while( !endOfText &&
( TextAbstraction::COMMON == script ) )
{
+ if( TextAbstraction::EMOJI == currentScriptRun.script )
+ {
+ // Emojis doesn't mix well with characters common to all scripts. Insert the emoji run.
+ scripts.Insert( scripts.Begin() + scriptIndex, currentScriptRun );
+ ++scriptIndex;
+
+ // Initialize the new one.
+ currentScriptRun.characterRun.characterIndex = currentScriptRun.characterRun.characterIndex + currentScriptRun.characterRun.numberOfCharacters;
+ currentScriptRun.characterRun.numberOfCharacters = 0u;
+ currentScriptRun.script = TextAbstraction::UNKNOWN;
+ numberOfAllScriptCharacters = 0u;
+ }
+
// Count all these characters to be added into a script.
++numberOfAllScriptCharacters;
character = *( textBuffer + index );
script = TextAbstraction::GetCharacterScript( character );
}
- }
+ } // end while( !endOfText && ( TextAbstraction::COMMON == script ) )
if( endOfText )
{
// Check if it is the first character of a paragraph.
if( isFirstScriptToBeSet &&
( TextAbstraction::UNKNOWN != script ) &&
- ( TextAbstraction::COMMON != script ) )
+ ( TextAbstraction::COMMON != script ) &&
+ ( TextAbstraction::EMOJI != script ) )
{
// Sets the direction of the first valid script.
isParagraphRTL = TextAbstraction::IsRightToLeftScript( script );
currentScriptRun.characterRun.numberOfCharacters += numberOfAllScriptCharacters;
numberOfAllScriptCharacters = 0u;
}
+ else if( ( TextAbstraction::UNKNOWN == currentScriptRun.script ) &&
+ ( TextAbstraction::EMOJI == script ) )
+ {
+ currentScriptRun.script = TextAbstraction::LATIN;
+ currentScriptRun.characterRun.numberOfCharacters += numberOfAllScriptCharacters;
+ numberOfAllScriptCharacters = 0u;
+ }
if( 0u != currentScriptRun.characterRun.numberOfCharacters )
{
PointSize26Dot6 currentPointSize = defaultPointSize;
FontId currentFontId = 0u;
FontId previousFontId = 0u;
+ bool isPreviousEmojiScript = false;
// Whether it's the first set of characters to be validated.
// Used in case the paragraph starts with characters common to all scripts.
isValidFont = isValidCachedDefaultFont && ( fontId == cachedDefaultFontId );
bool isCommonScript = false;
+ bool isEmojiScript = TextAbstraction::EMOJI == script;
+
+ if( isEmojiScript && !isPreviousEmojiScript )
+ {
+ if( 0u != currentFontRun.characterRun.numberOfCharacters )
+ {
+ // Store the font run.
+ fonts.Insert( fonts.Begin() + fontIndex, currentFontRun );
+ ++fontIndex;
+ }
+
+ // Initialize the new one.
+ currentFontRun.characterRun.characterIndex = currentFontRun.characterRun.characterIndex + currentFontRun.characterRun.numberOfCharacters;
+ currentFontRun.characterRun.numberOfCharacters = 0u;
+ currentFontRun.fontId = fontId;
+ }
+
// If the given font is not valid, it means either:
// - there is no cached font for the current script yet or,
if( isCommonScript )
{
if( isValidCachedDefaultFont &&
- ( isDefault || ( currentFontId == previousFontId ) ) )
+ ( isDefault || ( currentFontId == previousFontId ) ) &&
+ !isEmojiScript )
{
// At this point the character common for all scripts has no font assigned.
// If there is a valid previously cached default font for it, use that one.
// Emojis are present in many monochrome fonts; prefer color by default.
if( isValidFont &&
- ( TextAbstraction::EMOJI == script ) )
+ isEmojiScript )
{
const BufferImage bitmap = fontClient.CreateBitmap( fontId, glyphIndex );
// Cache the font.
if( NULL == defaultFontsPerScript )
{
- defaultFontsPerScript = new DefaultFonts();
- *( defaultFontPerScriptCacheBuffer + script ) = defaultFontsPerScript;
+ defaultFontsPerScript = *( defaultFontPerScriptCacheBuffer + script );
+
+ if( NULL == defaultFontsPerScript )
+ {
+ defaultFontsPerScript = new DefaultFonts();
+ *( defaultFontPerScriptCacheBuffer + script ) = defaultFontsPerScript;
+ }
}
defaultFontsPerScript->mFonts.PushBack( fontId );
}
// Whether the current character is a new paragraph character.
isNewParagraphCharacter = TextAbstraction::IsNewParagraph( character );
previousFontId = currentFontId;
+ isPreviousEmojiScript = isEmojiScript;
} // end traverse characters.
if( 0u != currentFontRun.characterRun.numberOfCharacters )
#endif
const float MAX_FLOAT = std::numeric_limits<float>::max();
-const unsigned int POINTS_PER_INCH = 72;
const std::string EMPTY_STRING("");
mImpl->mFontDefaults->mDefaultPointSize = pointSize;
mImpl->mFontDefaults->sizeDefined = true;
- unsigned int horizontalDpi( 0u );
- unsigned int verticalDpi( 0u );
- mImpl->mFontClient.GetDpi( horizontalDpi, verticalDpi );
-
- // Adjust the metrics if the fixed-size font should be down-scaled
- int maxEmojiSize( pointSize/POINTS_PER_INCH * verticalDpi );
- DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::SetDefaultPointSize %p setting MaxEmojiSize %d\n", this, maxEmojiSize );
- mImpl->mMetrics->SetMaxEmojiSize( maxEmojiSize );
-
// Clear the font-specific data
ClearFontData();
return layoutSize.height;
}
-bool Controller::Relayout( const Size& size )
+Controller::UpdateTextType Controller::Relayout( const Size& size )
{
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->Controller::Relayout %p size %f,%f, autoScroll[%s]\n", this, size.width, size.height, (mImpl->mAutoScrollEnabled)?"true":"false" );
+ UpdateTextType updateTextType = NONE_UPDATED;
+
if( ( size.width < Math::MACHINE_EPSILON_1000 ) || ( size.height < Math::MACHINE_EPSILON_1000 ) )
{
- bool glyphsRemoved( false );
if( 0u != mImpl->mVisualModel->mGlyphPositions.Count() )
{
mImpl->mVisualModel->mGlyphPositions.Clear();
- glyphsRemoved = true;
+ updateTextType = MODEL_UPDATED;
}
// Clear the update info. This info will be set the next time the text is updated.
// Not worth to relayout if width or height is equal to zero.
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::Relayout (skipped)\n" );
- return glyphsRemoved;
+ return updateTextType;
}
// Whether a new size has been set.
mImpl->mOperationsPending,
layoutSize ) || updated;
+ if( updated )
+ {
+ updateTextType = MODEL_UPDATED;
+ }
+
// Do not re-do any operation until something changes.
mImpl->mOperationsPending = NO_OPERATION;
}
// Move the cursor, grab handle etc.
- updated = mImpl->ProcessInputEvents() || updated;
+ if( mImpl->ProcessInputEvents() )
+ {
+ updateTextType = static_cast<UpdateTextType>( updateTextType | DECORATOR_UPDATED );
+ }
}
// Clear the update info. This info will be set the next time the text is updated.
mImpl->mTextUpdateInfo.Clear();
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::Relayout\n" );
- return updated;
+ return updateTextType;
}
void Controller::ProcessModifyEvents()
mImpl->mEventData->mScrollAfterDelete = true;
requestRelayout = true;
- retrieveCursor = true;
}
break;
}
DONT_UPDATE_INPUT_STYLE
};
+ enum UpdateTextType
+ {
+ NONE_UPDATED = 0x0,
+ MODEL_UPDATED = 0x1,
+ DECORATOR_UPDATED = 0x2
+ };
+
/**
* @brief Create a new instance of a Controller.
*
*
* @note UI Controls are expected to minimize calls to this method e.g. call once after size negotiation.
* @param[in] size A the size of a bounding box to layout text within.
- * @return True if the text model or decorations were updated.
+ *
+ * @return Whether the text model or decorations were updated.
*/
- bool Relayout( const Size& size );
+ UpdateTextType Relayout( const Size& size );
/**
* @brief Process queued events which modify the model.
#include <dali-toolkit/devel-api/focus-manager/keyinput-focus-manager.h>
#include <dali-toolkit/internal/styling/style-manager-impl.h>
#include <dali-toolkit/internal/controls/renderers/color/color-renderer.h>
+#include <dali-toolkit/internal/controls/renderers/renderer-string-constants.h>
namespace Dali
{
void Control::SetBackgroundColor( const Vector4& color )
{
- mImpl->mBackgroundColor = color;
-
Actor self( Self() );
- Toolkit::RendererFactory factory = Toolkit::RendererFactory::Get();
- factory.ResetRenderer( mImpl->mBackgroundRenderer, self, color );
- mImpl->mBackgroundRenderer.SetDepthIndex( DepthIndex::BACKGROUND );
+ mImpl->mBackgroundColor = color;
+ Property::Map map;
+ map[ RENDERER_TYPE ] = COLOR_RENDERER;
+ map[ "mixColor" ] = color;
+ InitializeControlRenderer( self, mImpl->mBackgroundRenderer, map );
+ if( mImpl->mBackgroundRenderer )
+ {
+ mImpl->mBackgroundRenderer.SetDepthIndex( DepthIndex::BACKGROUND );
+ }
}
Vector4 Control::GetBackgroundColor() const
return mImpl->mBackgroundColor;
}
-void Control::SetBackground(const Property::Map& map)
+void Control::SetBackground( const Property::Map& map )
{
Actor self( Self() );
- mImpl->mBackgroundRenderer.RemoveAndReset( self );
- Toolkit::RendererFactory factory = Toolkit::RendererFactory::Get();
- mImpl->mBackgroundRenderer = factory.GetControlRenderer( map );
- if( mImpl->mBackgroundRenderer && self.OnStage() ) // Request control renderer with a property map might return an empty handle
+ InitializeControlRenderer( self, mImpl->mBackgroundRenderer, map );
+ if( mImpl->mBackgroundRenderer )
{
mImpl->mBackgroundRenderer.SetDepthIndex( DepthIndex::BACKGROUND );
- mImpl->mBackgroundRenderer.SetOnStage( self );
}
}
void Control::SetBackgroundImage( Image image )
{
Actor self( Self() );
- Toolkit::RendererFactory factory = Toolkit::RendererFactory::Get();
- factory.ResetRenderer( mImpl->mBackgroundRenderer, self, image );
- mImpl->mBackgroundRenderer.SetDepthIndex( DepthIndex::BACKGROUND );
+ InitializeControlRenderer( self, mImpl->mBackgroundRenderer, image );
+ if( mImpl->mBackgroundRenderer )
+ {
+ mImpl->mBackgroundRenderer.SetDepthIndex( DepthIndex::BACKGROUND );
+ }
}
void Control::ClearBackground()
const unsigned int TOOLKIT_MAJOR_VERSION = 1;
const unsigned int TOOLKIT_MINOR_VERSION = 1;
-const unsigned int TOOLKIT_MICRO_VERSION = 41;
+const unsigned int TOOLKIT_MICRO_VERSION = 42;
const char * const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__;
#ifdef DEBUG_ENABLED
* <td>Controls for displaying text or text input.</td>
* </tr>
* <tr>
+ * <td style="padding-left:1em">@ref dali_toolkit_controls_flex_container</td>
+ * <td>FlexContainer is a container for Flexbox layout.</td>
+ * </tr>
+ * <tr>
+ * <td style="padding-left:1em">@ref dali_toolkit_controls_video_view</td>
+ * <td>VideoView is a control for video playback and display.</td>
+ * </tr>
+ * <tr>
+ * <td style="padding-left:1em">@ref dali_toolkit_controls_slider</td>
+ * <td>Slider is a control to enable sliding an indicator between two values.</td>
+ * </tr>
+ * <tr>
* <td>@ref dali_toolkit_managers</td>
* <td>Singleton classes for managing application-wide functionalities.</td>
* </tr>
* @defgroup dali_toolkit_controls_video_view Video View
* @brief VideoView is a control for video playback and display.
+ * @defgroup dali_toolkit_controls_slider Slider
+ * @brief Slider is a control to enable sliding an indicator between two values.
+
* @}
* @defgroup dali_toolkit_managers Managers
mTagPropertyIndex = mImageView.RegisterProperty( TAG_PROPERTY_NAME, 0, Property::READ_WRITE /* Event-side only, i.e. not animatable */ );
// Connect to the touch-event
- mImageView.TouchedSignal().Connect( this, &PropertyController::OnTouched );
+ mImageView.TouchSignal().Connect( this, &PropertyController::OnTouched );
// Create text label
mTagText = Toolkit::TextLabel::New( "0" );
* param[in] touch The touch-event
* return Set to true if the signal was consumed correctly
*/
- bool OnTouched( Actor actor, const TouchEvent& touch )
+ bool OnTouched( Actor actor, const TouchData& touch )
{
int touchedCount = 0;
DALi emits several signals to an application to inform it of user actions.
-<h2 class="pg">Touch Events</h2>
+<h2 class="pg">Touch</h2>
-An application can be notified when a user interacts with the touch screen on the device by connecting to the touch signal provided by Dali::Actor. This signal will be emitted by DALi whenever the touch occurs within the connected actor's bounds.
+An application can be notified when a user interacts with the touch screen on the device by connecting to the touch signal provided by Dali::Actor.
+This signal will be emitted by DALi whenever the touch occurs within the connected actor's bounds.
-Each point on the screen that is currently being touched or where touch has stopped is represented by a Dali::TouchPoint. This object stores information about the state of the touch point (down, up, motion etc.) and the co-ordinates of the touch.
+Each point on the screen that is currently being touched or where touch has stopped is represented by a point.
+Dali::TouchData stores information about the state of each point (down, up, motion etc.) and the co-ordinates of the touch.
-A collection of touch points at a specific moment in time is collated into a Dali::TouchEvent. When a multi-touch event occurs, each touch point represents the points that are currently being touched or the points where touch has stopped.
+When a multi-touch event occurs, each point represents the points that are currently being touched or the points where touch has stopped.
The following example shows how a connection to a touch event signal can be established:
@code
-bool OnTouch(Actor actor, const TouchEvent& touch)
+bool OnTouch( Dali::Actor actor, const Dali::TouchData& touch )
{
bool handled = false;
- switch(touch.GetPointCount())
+ switch( touch.GetPointCount() )
{
case 1: // Single touch
- if (touch.GetPoint(0).GetState == TouchPoint::Down)
+ if ( touch.GetState( 0 ) == Dali::PointState::DOWN )
{
// Do action when first touches the touch screen.
...
}
// Elsewhere
-Actor actor = Actor::New();
-actor.SignalTouch().Connect(&OnTouch);
+Dali::Actor actor = Actor::New();
+actor.TouchSignal().Connect( &OnTouch );
@endcode
The primary touch point is the first point that the user touches.
-The touch event is first emitted to the actor which is hit by the primary touch point. If this hit actor does not handle the event, then the event is offered to the hit actor's parent. Again, if the parent does not handle this event, it is then offered to its parent and so on until the stage is reached or the event is consumed.
+The touch signal is first emitted to the actor which is hit by the primary touch point.
+If this hit actor does not handle (consume) the event, then the event is offered to the hit actor's parent.
+Again, if the parent does not handle this event, it is then offered to its parent and so on until the stage is reached or the event is consumed.
-If a parent and child both connect to the Touch signal, then the touch event is first offered to the child. If it is consumed by the child, then the parent will not be informed.
+If the TouchSignal of both a parent and child are connected to, then the touch event is first offered to the child's listener.
+If it is consumed by the child's listener, then the parent will not be informed.
<h2 class="pg">Gestures</h2>
-A Dali::GestureDetector analyses a stream of touch events and attempts to determine the intention of the user. An actor is attached to a gesture detector and if the detector recognises a pattern, it will emit a detected signal to the application.
+A Dali::GestureDetector analyses a stream of touch input and attempts to determine the intention of the user.
+An actor is attached to a gesture detector and if the detector recognises a pattern, it will emit a detected signal to the application.
-The following gesture detectors are currently supported in Dali:
+The following gesture detectors are currently supported in DALi:
+- Dali::LongPressGestureDetector - When the user presses and holds a particular point on the screen for a specified length of time.
- Dali::PinchGestureDetector - When the user moves two fingers towards or away from each other.
- Dali::PanGestureDetector - When the user moves one or more fingers in the same direction.
+- Dali::TapGestureDetector - When the user taps the screen.
The example below shows how an application can be notified of a pinch gesture:
@code
-void OnPinch(Actor actor, PinchGesture pinch)
+void OnPinch( Dali::Actor actor, const Dali::PinchGesture& pinch )
{
// Scale your actor according to the pinch scale
- Vector3 newSize = actor.GetCurrentSize() * pinch.GetScale();
+ Vector3 newSize = actor.GetCurrentSize() * pinch.scale;
actor.SetSize(newSize);
}
// Elsewhere
-PinchDetector detector = PinchDetector::New();
-detector.Attach(myActor);
-detector.SignalDetected().Connect(&OnPinch);
+Dali::PinchGestureDetector detector = Dali::PinchDetector::New();
+detector.Attach( myActor );
+detector.DetectedSignal().Connect( &OnPinch );
@endcode
- */
-
-// @TODO: Add "Key Events" section
+*/
stage.Add( mTextLabel );
// Respond to a click anywhere on the stage
- stage.GetRootLayer().TouchedSignal().Connect( this, &HelloWorldController::OnTouch );
+ stage.GetRootLayer().TouchSignal().Connect( this, &HelloWorldController::OnTouch );
}
- bool OnTouch( Actor actor, const TouchEvent& touch )
+ bool OnTouch( Actor actor, const TouchData& touch )
{
// quit the application
mApplication.Quit();
| Behaviour | Description |
|--------------------------------------|-------------------------------------------------------------------------|
| ACTOR_BEHAVIOUR_NONE | No behaviour required. |
-| REQUIRES_TOUCH_EVENTS | If our control requires [touch events](@ref creating-controls-events). |
| REQUIRES_HOVER_EVENTS | If our control requires [hover events](@ref creating-controls-events). |
| REQUIRES_WHEEL_EVENTS | If our control requires [wheel events](@ref creating-controls-events). |
| REQUIRES_STYLE_CHANGE_SIGNALS | True if need to monitor style change signals such as Theme/Font change. |
### Touch, Hover & Wheel Events {#creating-controls-events}
-+ A **touch event** is when any touch occurs within the bounds of the custom actor.
++ A **touch** is when any touch occurs within the bounds of the custom actor. Connect to Dali::Actor::TouchSignal().
+ A **hover event** is when a pointer moves within the bounds of a custom actor (e.g. mouse pointer or hover pointer).
+ A **wheel event** is when the mouse wheel (or similar) is moved while hovering over an actor (via a mouse pointer or hover pointer).
-If the control should needs to utilise these events, then the correct behaviour flag should be used when constructing the control.
-
-Then the appropriate method should be overridden.
-~~~{.cpp}
-// C++
-bool MyUIControlImpl::OnTouchEvent( const TouchEvent& event )
-{
- bool consumed = false;
-
- // Handle touch event
-
- // Return true if handled/consumed, false otherwise
- return consumed;
-}
-~~~
+If the control needs to utilise hover and wheel events, then the correct behaviour flag should be used when constructing the control and then the appropriate method should be overridden.
~~~{.cpp}
// C++
bool MyUIControlImpl::OnHoverEvent( const HoverEvent& event )
Touch events are received via signals.
-For C++ API see Dali::Actor::TouchedSignal() and Dali::Actor::HoveredSignal() for more details.
+For C++ API see Dali::Actor::TouchSignal() and Dali::Actor::HoveredSignal() for more details.
-For JavaScript use actor.connect( "touched", myCallback ) and actor.connect("hovered", myCallback );
+For JavaScript use actor.connect( "touch", myCallback ) and actor.connect("hovered", myCallback );
### Hit Testing Rules Summary:
IF ( TOUCH-SIGNAL-NOT-EMPTY )
{
// Only do the emission if touch signal of actor has connections.
- CONSUMED = TOUCHED-SIGNAL( TOUCH-EVENT )
+ CONSUMED = TOUCH-SIGNAL( TOUCH-DATA )
}
IF ( NOT-CONSUMED )
~~~
Inside the event processing, the application may be listening for certain events.
-For example when an actor is touched, some application code may be run in an OnTouchEvent callback.
+For example when an actor is touched, some application code may be run in an OnTouch callback.
By checking the max times you can check for any spikes that occur when interacting with the application.
Example:
actor.SetAnchorPoint( Dali::AnchorPoint::CENTER );
Dali::Stage::GetCurrent().Add( actor );
...
-bool OnPressed( Dali::Actor, const TouchEvent& event )
+bool OnPressed( Dali::Actor, const TouchData& touch )
{
Dali::Animation anim = Dali::Animation::New( 1.5f );
- anim.AnimateTo( Property( actor, Actor::Property::POSITION ), Vector3( 200,-100,0), AlphaFunctions::Bounce );
+ anim.AnimateTo( Property( actor, Actor::Property::POSITION ), Vector3( 200, -100, 0 ), AlphaFunctions::Bounce );
anim.play();
return true; // consume the touch event
}
...
-actor.TouchedSignal().Connect( &OnPressed );
+actor.TouchSignal().Connect( &OnPressed );
~~~
*/
actor.anchorPoint = dali.CENTER;
dali.stage.add( actor );
...
-function onPressed( actor, touchEvent )
+function onPressed( actor, touch )
{
var animOptions = { alpha: "bounce", delay: 0, duration: 15 };
var anim = new dali.Animation();
- anim.animateTo( actor, "position", [ 200,-100,0], animOptions );
+ anim.animateTo( actor, "position", [ 200, -100, 0 ], animOptions );
anim.play();
return true; // consume the touch event
}
...
-actor.connect( "touched", onPressed );
+actor.connect( "touch", onPressed );
~~~
"parentOrigin": "CENTER",
"signals" :
[
- { "name" : "touched", "action": "play", "animation": "move" }
+ { "name" : "touch", "action": "play", "animation": "move" }
]
}
]
Name: dali-toolkit
Summary: The OpenGLES Canvas Core Library Toolkit
-Version: 1.1.41
+Version: 1.1.42
Release: 1
Group: System/Libraries
License: Apache-2.0 and BSD-2-Clause and MIT