// resolution: 600*600, pixel format: RGB888
static const char* gImage_600_RGB = TEST_RESOURCE_DIR "/test-image-600.jpg";
+// resolution: 50*50, frame count: 4, frame delay: 0.2 second for each frame
+const char* TEST_GIF_FILE_NAME = TEST_RESOURCE_DIR "/anim.gif";
+
void TestImage( ImageView imageView, BufferImage image )
{
Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
END_TEST;
}
+int UtcDaliImageViewPixelArea(void)
+{
+ // Test pixel area property
+ ToolkitTestApplication application;
+
+ // Gif image, use AnimatedImageVisual internally
+ // Atlasing is applied to pack multiple frames, use custom wrap mode
+ ImageView gifView = ImageView::New();
+ const Vector4 pixelAreaVisual( 0.f, 0.f, 2.f, 2.f );
+ gifView.SetProperty( ImageView::Property::IMAGE,
+ Property::Map().Add( ImageVisual::Property::URL, TEST_GIF_FILE_NAME )
+ .Add( ImageVisual::Property::PIXEL_AREA, pixelAreaVisual ) );
+
+ // Add to stage
+ Stage stage = Stage::GetCurrent();
+ stage.Add( gifView );
+
+ // loading started
+ application.SendNotification();
+ application.Render(16);
+ DALI_TEST_CHECK( gifView.GetRendererCount() == 1u );
+
+ const Vector4 fullTextureRect( 0.f, 0.f, 1.f, 1.f );
+ // test that the pixel area value defined in the visual property map is registered on renderer
+ Renderer renderer = gifView.GetRendererAt(0);
+ Property::Value pixelAreaValue = renderer.GetProperty( renderer.GetPropertyIndex( "pixelArea" ) );
+ DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), pixelAreaVisual, TEST_LOCATION );
+
+ // test that the shader has the default pixel area value registered.
+ Shader shader = renderer.GetShader();
+ pixelAreaValue = shader.GetProperty( shader.GetPropertyIndex( "pixelArea" ) );
+ DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), fullTextureRect, TEST_LOCATION );
+
+ // test that the uniform uses the pixelArea property on the renderer.
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ Vector4 pixelAreaUniform;
+ DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
+ DALI_TEST_EQUALS( pixelAreaVisual, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
+
+ // set the pixelArea property on the control
+ const Vector4 pixelAreaControl( -1.f, -1.f, 3.f, 3.f );
+ gifView.SetProperty( ImageView::Property::PIXEL_AREA, pixelAreaControl );
+ application.SendNotification();
+ application.Render(16);
+
+ // check the pixelArea property on the control
+ pixelAreaValue = gifView.GetProperty( gifView.GetPropertyIndex( "pixelArea" ) );
+ DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), pixelAreaControl, TEST_LOCATION );
+ // test that the uniform uses the pixelArea property on the control.
+ DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
+ DALI_TEST_EQUALS( pixelAreaControl, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
+
+
+ END_TEST;
+}
+
int UtcDaliImageViewAsyncLoadingWithoutAltasing(void)
{
ToolkitTestApplication application;
END_TEST;
}
+
+int UtcDaliKeyboardFocusManagerChangeFocusDirectionByKeyEvents(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline(" UtcDaliKeyboardFocusManagerChangeFocusDirectionByKeyEvents");
+
+ KeyboardFocusManager manager = KeyboardFocusManager::Get();
+ DALI_TEST_CHECK(manager);
+
+ bool preFocusChangeSignalVerified = false;
+ PreFocusChangeCallback preFocusChangeCallback(preFocusChangeSignalVerified);
+ manager.PreFocusChangeSignal().Connect( &preFocusChangeCallback, &PreFocusChangeCallback::Callback );
+
+ bool focusChangedSignalVerified = false;
+ FocusChangedCallback focusChangedCallback(focusChangedSignalVerified);
+ manager.FocusChangedSignal().Connect( &focusChangedCallback, &FocusChangedCallback::Callback );
+
+ Integration::KeyEvent leftEvent("Left", "", 0, 0, 0, Integration::KeyEvent::Down);
+ Integration::KeyEvent rightEvent("Right", "", 0, 0, 0, Integration::KeyEvent::Down);
+ Integration::KeyEvent upEvent("Up", "", 0, 0, 0, Integration::KeyEvent::Down);
+ Integration::KeyEvent downEvent("Down", "", 0, 0, 0, Integration::KeyEvent::Down);
+ Integration::KeyEvent pageUpEvent("Prior", "", 0, 0, 0, Integration::KeyEvent::Down);
+ Integration::KeyEvent pageDownEvent("Next", "", 0, 0, 0, Integration::KeyEvent::Down);
+
+ // Create a 2x2 table view and try to move focus inside it
+ TableView tableView = TableView::New( 2, 2 );
+ Stage::GetCurrent().Add(tableView);
+
+ // Create the first actor
+ Actor first = Actor::New();
+ first.SetKeyboardFocusable(true);
+
+ // Create the second actor
+ Actor second = Actor::New();
+ second.SetKeyboardFocusable(true);
+
+ // Create the third actor
+ Actor third = Actor::New();
+ third.SetKeyboardFocusable(true);
+
+ // Create the fourth actor
+ Actor fourth = Actor::New();
+ fourth.SetKeyboardFocusable(true);
+
+ // Add the four children to table view
+ tableView.AddChild(first, TableView::CellPosition(0, 0));
+ tableView.AddChild(second, TableView::CellPosition(0, 1));
+ tableView.AddChild(third, TableView::CellPosition(1, 0));
+ tableView.AddChild(fourth, TableView::CellPosition(1, 1));
+
+ // Set the focus to the first actor
+ DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
+ DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
+ DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == Actor());
+ DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == first);
+ focusChangedCallback.Reset();
+
+ // Send the right key event to move the focus towards right
+ application.ProcessEvent(rightEvent);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
+ DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
+ DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == first);
+ DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == second);
+ focusChangedCallback.Reset();
+
+ // Send the down key event to move the focus towards down
+ application.ProcessEvent(downEvent);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == fourth);
+ DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
+ DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == second);
+ DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == fourth);
+ focusChangedCallback.Reset();
+
+ // Send the down event to move the focus towards left
+ application.ProcessEvent(leftEvent);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third);
+ DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
+ DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == fourth);
+ DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == third);
+ focusChangedCallback.Reset();
+
+ // Send the up event to move the focus towards up
+ application.ProcessEvent(upEvent);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
+ DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
+ DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == third);
+ DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == first);
+ focusChangedCallback.Reset();
+
+ // Send the pape up event, but focus should not be moved because page up is not supported by table view
+ application.ProcessEvent(pageUpEvent);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
+ DALI_TEST_CHECK(preFocusChangeCallback.mSignalVerified);
+ DALI_TEST_CHECK(preFocusChangeCallback.mCurrentFocusedActor == first);
+ DALI_TEST_CHECK(preFocusChangeCallback.mProposedActorToFocus == first);
+ DALI_TEST_CHECK(preFocusChangeCallback.mDirection == Control::KeyboardFocus::PAGE_UP);
+ preFocusChangeCallback.Reset();
+
+ // Send the pape down event, but focus should not be moved because page down is not supported by table view
+ application.ProcessEvent(pageDownEvent);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
+ DALI_TEST_CHECK(preFocusChangeCallback.mSignalVerified);
+ DALI_TEST_CHECK(preFocusChangeCallback.mCurrentFocusedActor == first);
+ DALI_TEST_CHECK(preFocusChangeCallback.mProposedActorToFocus == first);
+ DALI_TEST_CHECK(preFocusChangeCallback.mDirection == Control::KeyboardFocus::PAGE_DOWN);
+ preFocusChangeCallback.Reset();
+
+ // Clear the focus
+ manager.ClearFocus();
+
+ // Send the pape up event, but nothing was focued so focus manager will try the initial focus
+ preFocusChangeCallback.Reset();
+ application.ProcessEvent(pageUpEvent);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
+ DALI_TEST_CHECK(preFocusChangeCallback.mSignalVerified);
+ DALI_TEST_CHECK(preFocusChangeCallback.mCurrentFocusedActor == Actor());
+ DALI_TEST_CHECK(preFocusChangeCallback.mProposedActorToFocus == Actor());
+ DALI_TEST_CHECK(preFocusChangeCallback.mDirection == Control::KeyboardFocus::RIGHT);
+
+ // Clear the focus again
+ manager.ClearFocus();
+
+ // Send the pape down event, but nothing was focued so focus manager will try the initial focus
+ preFocusChangeCallback.Reset();
+ application.ProcessEvent(pageDownEvent);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
+ DALI_TEST_CHECK(preFocusChangeCallback.mSignalVerified);
+ DALI_TEST_CHECK(preFocusChangeCallback.mCurrentFocusedActor == Actor());
+ DALI_TEST_CHECK(preFocusChangeCallback.mProposedActorToFocus == Actor());
+ DALI_TEST_CHECK(preFocusChangeCallback.mDirection == Control::KeyboardFocus::RIGHT);
+
+ END_TEST;
+}
+
+
END_TEST;
}
+int UtcDaliVisualTextVisualDisableEnable(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliVisualTextVisualDisableEnable Ensure Text visible can be re-enabled" );
+
+ VisualFactory factory = VisualFactory::Get();
+ Property::Map propertyMap;
+ propertyMap.Insert( Visual::Property::TYPE, DevelVisual::TEXT );
+ propertyMap.Insert( "mixColor", Color::WHITE );
+ propertyMap.Insert( "renderingBackend", static_cast<int>( Toolkit::Text::DEFAULT_RENDERING_BACKEND ) );
+ propertyMap.Insert( "enableMarkup", false );
+ propertyMap.Insert( "text", "Hello world" );
+ propertyMap.Insert( "fontFamily", "TizenSans" );
+
+ Property::Map fontStyleMapSet;
+ fontStyleMapSet.Insert( "weight", "bold" );
+ propertyMap.Insert( "fontStyle", fontStyleMapSet );
+
+ propertyMap.Insert( "pointSize", 12.f );
+ propertyMap.Insert( "multiLine", true );
+ propertyMap.Insert( "horizontalAlignment", "CENTER" );
+ propertyMap.Insert( "verticalAlignment", "CENTER" );
+ propertyMap.Insert( "textColor", Color::RED );
+ Visual::Base textVisual = factory.CreateVisual( propertyMap );
+ textVisual.SetDepthIndex( 1.f );
+
+ DummyControl dummyControl = DummyControl::New(true);
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
+ dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, textVisual );
+ DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 0, TEST_LOCATION );
+
+ dummyControl.SetSize(200.f, 200.f);
+ dummyControl.SetParentOrigin( ParentOrigin::CENTER );
+
+ Stage::GetCurrent().Add( dummyControl );
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 1, TEST_LOCATION );
+
+ dummyImpl.EnableVisual( DummyControl::Property::TEST_VISUAL, false );
+
+ DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 0, TEST_LOCATION );
+
+ dummyImpl.EnableVisual( DummyControl::Property::TEST_VISUAL, true );
+
+ DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 1, TEST_LOCATION );
+
+ END_TEST;
+}
+
int UtcDaliVisualPremultipliedAlpha(void)
{
ToolkitTestApplication application;
END_TEST;
}
-int UtcDaliVisualFactoryGetAnimatedImageVisual(void)
+int UtcDaliVisualFactoryGetAnimatedImageVisual1(void)
{
ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetAnimatedImageVisual: Request animated image visual with a gif url" );
+ tet_infoline( "UtcDaliVisualFactoryGetAnimatedImageVisual1: Request animated image visual with a gif url" );
VisualFactory factory = VisualFactory::Get();
Visual::Base visual = factory.CreateVisual( TEST_GIF_FILE_NAME, ImageDimensions() );
DummyControl actor = DummyControl::New();
DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
+ actor.SetSize( 200.0f, 200.0f );
Stage::GetCurrent().Add( actor );
application.SendNotification();
END_TEST;
}
+
+int UtcDaliVisualFactoryGetAnimatedImageVisual2(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliVisualFactoryGetAnimatedImageVisual2: Request animated image visual with a Property::Map, test custom wrap mode and pixel area" );
+
+ const Vector4 pixelArea(-0.5f, -0.5f, 2.f, 2.f);
+ Property::Map propertyMap;
+ propertyMap.Add( Visual::Property::TYPE, Visual::IMAGE )
+ .Add( ImageVisual::Property::URL, TEST_GIF_FILE_NAME )
+ .Add( ImageVisual::Property::PIXEL_AREA, pixelArea )
+ .Add( ImageVisual::Property::WRAP_MODE_U, WrapMode::MIRRORED_REPEAT )
+ .Add( ImageVisual::Property::WRAP_MODE_V, WrapMode::REPEAT );
+
+ Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap );
+ DALI_TEST_CHECK( visual );
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
+ TraceCallStack& texParameterTrace = gl.GetTexParameterTrace();
+ texParameterTrace.Enable( true );
+
+ DummyControl actor = DummyControl::New();
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+ dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
+ actor.SetSize( 200.0f, 200.0f );
+ Stage::GetCurrent().Add( actor );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+
+ DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
+
+ // For animated image visual, the wrapping is handled manually in shader, so the following gl function should not be called
+ std::stringstream out;
+ out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_S << ", " << GL_MIRRORED_REPEAT;
+ DALI_TEST_CHECK( !texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) );
+ out.str("");
+ out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_T << ", " << GL_REPEAT;
+ DALI_TEST_CHECK( !texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) );
+
+ // test the uniforms which used to handle the wrap mode
+ Renderer renderer = actor.GetRendererAt( 0u );
+ DALI_TEST_CHECK( renderer );
+
+ Property::Value pixelAreaValue = renderer.GetProperty( renderer.GetPropertyIndex( "pixelArea" ) );
+ DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), pixelArea, TEST_LOCATION );
+ Vector4 pixelAreaUniform;
+ DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
+ DALI_TEST_EQUALS( pixelArea, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
+
+ Property::Value wrapModeValue = renderer.GetProperty( renderer.GetPropertyIndex( "wrapMode" ) );
+ Vector2 wrapMode( WrapMode::MIRRORED_REPEAT-1, WrapMode::REPEAT-1 );
+ DALI_TEST_EQUALS( wrapModeValue.Get<Vector2>(), wrapMode, TEST_LOCATION );
+ Vector2 wrapModeUniform;
+ DALI_TEST_CHECK( gl.GetUniformValue<Vector2>( "wrapMode", wrapModeUniform ) );
+ DALI_TEST_EQUALS( wrapMode, wrapModeUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
+
+ actor.Unparent( );
+ DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+
+ END_TEST;
+}
isFocusStartableKey = true;
}
+ else if (keyName == "Prior" && !isAccessibilityEnabled)
+ {
+ if(!mIsFocusIndicatorEnabled)
+ {
+ // Show focus indicator
+ mIsFocusIndicatorEnabled = true;
+ }
+ else
+ {
+ // Move the focus towards the previous page
+ MoveFocus(Toolkit::Control::KeyboardFocus::PAGE_UP);
+ }
+
+ isFocusStartableKey = true;
+ }
+ else if (keyName == "Next" && !isAccessibilityEnabled)
+ {
+ if(!mIsFocusIndicatorEnabled)
+ {
+ // Show focus indicator
+ mIsFocusIndicatorEnabled = true;
+ }
+ else
+ {
+ // Move the focus towards the next page
+ MoveFocus(Toolkit::Control::KeyboardFocus::PAGE_DOWN);
+ }
+
+ isFocusStartableKey = true;
+ }
else if (keyName == "Tab" && !isAccessibilityEnabled)
{
if(!mIsFocusIndicatorEnabled)
namespace Internal
{
+namespace
+{
+// wrap modes
+DALI_ENUM_TO_STRING_TABLE_BEGIN( WRAP_MODE )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::WrapMode, DEFAULT )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::WrapMode, CLAMP_TO_EDGE )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::WrapMode, REPEAT )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::WrapMode, MIRRORED_REPEAT )
+DALI_ENUM_TO_STRING_TABLE_END( WRAP_MODE )
+
+const Vector4 FULL_TEXTURE_RECT(0.f, 0.f, 1.f, 1.f);
+
+}
+
AnimatedImageVisualPtr AnimatedImageVisual::New( VisualFactoryCache& factoryCache, const std::string& imageUrl, const Property::Map& properties )
{
AnimatedImageVisual* visual = new AnimatedImageVisual( factoryCache );
AnimatedImageVisual::AnimatedImageVisual( VisualFactoryCache& factoryCache )
: Visual::Base( factoryCache ),
mFrameDelayTimer(),
+ mPixelArea( FULL_TEXTURE_RECT ),
mImageUrl(),
mImageSize(),
- mCurrentFrameIndex( 0 )
+ mCurrentFrameIndex( 0 ),
+ mWrapModeU( WrapMode::DEFAULT ),
+ mWrapModeV( WrapMode::DEFAULT )
{}
AnimatedImageVisual::~AnimatedImageVisual()
void AnimatedImageVisual::DoCreatePropertyMap( Property::Map& map ) const
{
map.Clear();
+
map.Insert( Toolkit::DevelVisual::Property::TYPE, Toolkit::Visual::IMAGE );
if( !mImageUrl.empty() )
{
map.Insert( Toolkit::ImageVisual::Property::URL, mImageUrl );
}
+
+ map.Insert( Toolkit::ImageVisual::Property::PIXEL_AREA, mPixelArea );
+ map.Insert( Toolkit::ImageVisual::Property::WRAP_MODE_U, mWrapModeU );
+ map.Insert( Toolkit::ImageVisual::Property::WRAP_MODE_V, mWrapModeV );
}
void AnimatedImageVisual::DoSetProperties( const Property::Map& propertyMap )
{
// url already passed in from constructor
+
+ Property::Value* pixelAreaValue = propertyMap.Find( Toolkit::ImageVisual::Property::PIXEL_AREA, PIXEL_AREA_UNIFORM_NAME );
+ if( pixelAreaValue )
+ {
+ pixelAreaValue->Get( mPixelArea );
+ }
+
+ Property::Value* wrapModeValueU = propertyMap.Find( Toolkit::ImageVisual::Property::WRAP_MODE_U, IMAGE_WRAP_MODE_U );
+ if( wrapModeValueU )
+ {
+ int value;
+ Scripting::GetEnumerationProperty( *wrapModeValueU, WRAP_MODE_TABLE, WRAP_MODE_TABLE_COUNT, value );
+ mWrapModeU = Dali::WrapMode::Type( value );
+ }
+
+ Property::Value* wrapModeValueV = propertyMap.Find( Toolkit::ImageVisual::Property::WRAP_MODE_V, IMAGE_WRAP_MODE_V );
+ if( wrapModeValueV )
+ {
+ int value;
+ Scripting::GetEnumerationProperty( *wrapModeValueV, WRAP_MODE_TABLE, WRAP_MODE_TABLE_COUNT, value );
+ mWrapModeV = Dali::WrapMode::Type( value );
+ }
}
void AnimatedImageVisual::DoSetOnStage( Actor& actor )
Texture texture = PrepareAnimatedImage();
if( texture ) // if the image loading is successful
{
- Shader shader = ImageVisual::GetImageShader( mFactoryCache, true, true );
+ bool defaultWrapMode = mWrapModeU <= WrapMode::CLAMP_TO_EDGE && mWrapModeV <= WrapMode::CLAMP_TO_EDGE;
+ Shader shader = ImageVisual::GetImageShader( mFactoryCache, true, defaultWrapMode );
+
Geometry geometry = mFactoryCache.GetGeometry( VisualFactoryCache::QUAD_GEOMETRY );
+
TextureSet textureSet = TextureSet::New();
+ textureSet.SetTexture( 0u, texture );
+
mImpl->mRenderer = Renderer::New( geometry, shader );
mImpl->mRenderer.SetTextures( textureSet );
- textureSet.SetTexture( 0u, PrepareAnimatedImage() );
- mImpl->mRenderer.RegisterProperty( ATLAS_RECT_UNIFORM_NAME, mTextureRectContainer[0] );
// Register transform properties
mImpl->mTransform.RegisterUniforms( mImpl->mRenderer, Direction::LEFT_TO_RIGHT );
+ if( !defaultWrapMode ) // custom wrap mode
+ {
+ Vector2 wrapMode(mWrapModeU-WrapMode::CLAMP_TO_EDGE, mWrapModeV-WrapMode::CLAMP_TO_EDGE);
+ wrapMode.Clamp( Vector2::ZERO, Vector2( 2.f, 2.f ) );
+ mImpl->mRenderer.RegisterProperty( WRAP_MODE_UNIFORM_NAME, wrapMode );
+ }
+
+ if( mPixelArea != FULL_TEXTURE_RECT )
+ {
+ mImpl->mRenderer.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, mPixelArea );
+ }
+
mCurrentFrameIndex = 0;
+ mImpl->mRenderer.RegisterProperty( ATLAS_RECT_UNIFORM_NAME, mTextureRectContainer[mCurrentFrameIndex] );
if( mFrameDelayContainer.Count() > 1 )
{
mFrameDelayTimer = Timer::New( mFrameDelayContainer[0] );
*
* The following property is essential
*
- * | %Property Name | Type |
- * |--------------------------|------------------|
- * | url | STRING |
+ * | %Property Name | Type |
+ * |------------------- |-------------------|
+ * | url | STRING |
+ * | pixelArea | VECTOR4 |
+ * | wrapModeU | INTEGER OR STRING |
+ * | wrapModeV | INTEGER OR STRING |
*
+ * where pixelArea is a rectangular area.
+ * In its Vector4 value, the first two elements indicate the top-left position of the area,
+ * and the last two elements are the area width and height respectively.
+ * If not specified, the default value is [0.0, 0.0, 1.0, 1.0], i.e. the entire area of the image.
+ *
+ * where wrapModeU and wrapModeV separately decide how the texture should be sampled when the u and v coordinate exceeds the range of 0.0 to 1.0.
+ * Its value should be one of the following wrap mode:
+ * "DEFAULT"
+ * "CLAMP_TO_EDGE"
+ * "REPEAT"
+ * "MIRRORED_REPEAT"
*/
class AnimatedImageVisual : public Visual::Base, public ConnectionTracker
Timer mFrameDelayTimer;
Dali::Vector<Vector4> mTextureRectContainer;
Dali::Vector<uint32_t> mFrameDelayContainer;
+ Vector4 mPixelArea;
std::string mImageUrl;
+
ImageDimensions mImageSize;
uint32_t mCurrentFrameIndex;
+ Dali::WrapMode::Type mWrapModeU:3;
+ Dali::WrapMode::Type mWrapModeV:3;
};
} // namespace Internal
const char * const IMAGE_SAMPLING_MODE( "samplingMode" );
const char * const IMAGE_DESIRED_WIDTH( "desiredWidth" );
const char * const IMAGE_DESIRED_HEIGHT( "desiredHeight" );
-const char * const IMAGE_WRAP_MODE_U("wrapModeU");
-const char * const IMAGE_WRAP_MODE_V("wrapModeV");
const char * const SYNCHRONOUS_LOADING( "synchronousLoading" );
const char * const BATCHING_ENABLED( "batchingEnabled" );
DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::WrapMode, MIRRORED_REPEAT )
DALI_ENUM_TO_STRING_TABLE_END( WRAP_MODE )
-const std::string PIXEL_AREA_UNIFORM_NAME = "pixelArea";
-const std::string WRAP_MODE_UNIFORM_NAME = "wrapMode";
-
const Vector4 FULL_TEXTURE_RECT(0.f, 0.f, 1.f, 1.f);
const char* DEFAULT_SAMPLER_TYPENAME = "sampler2D";
*
* The following properties are optional
*
- * | %Property Name | Type |
- * |--------------------|------------------|
- * | url | STRING |
- * | fittingMode | STRING |
- * | samplingMode | STRING |
- * | desiredWidth | INT |
- * | desiredHeight | INT |
- * | synchronousLoading | BOOLEAN |
+ * | %Property Name | Type |
+ * |--------------------|-------------------|
+ * | url | STRING |
+ * | fittingMode | INTEGER OR STRING |
+ * | samplingMode | INTEGER OR STRING |
+ * | desiredWidth | INTEGER |
+ * | desiredHeight | INTEGER |
+ * | synchronousLoading | BOOLEAN |
+ * | pixelArea | VECTOR4 |
+ * | wrapModeU | INTEGER OR STRING |
+ * | wrapModeV | INTEGER OR STRING |
+ *
+ * where pixelArea is a rectangular area.
+ * In its Vector4 value, the first two elements indicate the top-left position of the area,
+ * and the last two elements are the area width and height respectively.
+ * If not specified, the default value is [0.0, 0.0, 1.0, 1.0], i.e. the entire area of the image.
+ *
+ * where wrapModeU and wrapModeV separately decide how the texture should be sampled when the u and v coordinate exceeds the range of 0.0 to 1.0.
+ * Its value should be one of the following wrap mode:
+ * "DEFAULT"
+ * "CLAMP_TO_EDGE"
+ * "REPEAT"
+ * "MIRRORED_REPEAT"
*
* where imageFittingMode should be one of the following fitting modes:
* "SHRINK_TO_FIT"
const char * const TEXT_COLOR_PROPERTY( "textColor" );
const char * const ENABLE_MARKUP_PROPERTY( "enableMarkup" );
-const std::string PIXEL_AREA_UNIFORM_NAME = "pixelArea";
-
const Scripting::StringEnum HORIZONTAL_ALIGNMENT_STRING_TABLE[] =
{
{ "BEGIN", Toolkit::Text::Layout::HORIZONTAL_ALIGN_BEGIN },
mImpl->mRenderer = Renderer::New( geometry, shader );
mImpl->mRenderer.SetProperty( Dali::Renderer::Property::DEPTH_INDEX, Toolkit::DepthIndex::TEXT );
- UpdateRenderer();
+ UpdateRenderer( true ); // Renderer needs textures and to be added to control
}
void TextVisual::DoSetOffStage( Actor& actor )
void TextVisual::OnSetTransform()
{
- UpdateRenderer();
+ UpdateRenderer( false );
}
void TextVisual::DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue )
}
}
-void TextVisual::UpdateRenderer()
+void TextVisual::UpdateRenderer( bool initializeRendererAndTexture )
{
Actor control = mControl.GetHandle();
if( !control )
const Text::Controller::UpdateTextType updateTextType = mController->Relayout( relayoutSize );
- if( Text::Controller::NONE_UPDATED != ( Text::Controller::MODEL_UPDATED & updateTextType ) )
+ if( Text::Controller::NONE_UPDATED != ( Text::Controller::MODEL_UPDATED & updateTextType ) || initializeRendererAndTexture )
{
// Removes the texture set.
RemoveTextureSet();
/**
* @brief Updates the text's renderer.
+ * @param[in] initializeRendererAndTexture Set flag to true to initialize textures and add renderer to control.
*/
- void UpdateRenderer();
+ void UpdateRenderer( bool initializeRendererAndTexture );
/**
* @brief Removes the texture set from the renderer.
// Image visual
const char * const IMAGE_URL_NAME( "url" );
-const char * const ATLAS_RECT_UNIFORM_NAME ( "uAtlasRect" );
+const char * const ATLAS_RECT_UNIFORM_NAME( "uAtlasRect" );
+const char * const PIXEL_AREA_UNIFORM_NAME( "pixelArea" );
+const char * const WRAP_MODE_UNIFORM_NAME( "wrapMode" );
+const char * const IMAGE_WRAP_MODE_U("wrapModeU");
+const char * const IMAGE_WRAP_MODE_V("wrapModeV");
// Text visual
const char * const TEXT_PROPERTY( "text" );
// Image visual
extern const char * const IMAGE_URL_NAME;
extern const char * const ATLAS_RECT_UNIFORM_NAME;
+extern const char * const PIXEL_AREA_UNIFORM_NAME;
+extern const char * const WRAP_MODE_UNIFORM_NAME;
+extern const char * const IMAGE_WRAP_MODE_U;
+extern const char * const IMAGE_WRAP_MODE_V;
// Text visual
extern const char * const TEXT_PROPERTY;
/**
* @brief Move the focus to prev focused actor
*
- * @SINCE_1_2.17
+ * @SINCE_1_2.19
*/
void MoveFocusBackward();
| Dali::Toolkit::ImageVisual::Property::SAMPLING_MODE | samplingMode | INTEGER or STRING | No | Filtering options, used when resizing images to sample original pixels. [More info](@ref resourceimagescaling-scaling) |
| Dali::Toolkit::ImageVisual::Property::DESIRED_WIDTH | desiredWidth | INT | No | The desired image width. Will use actual image width if not specified. |
| Dali::Toolkit::ImageVisual::Property::DESIRED_HEIGHT | desiredHeight | INT | No | The desired image height. Will use actual image height if not specified. |
+| Dali::Toolkit::ImageVisual::Property::PIXEL_AREA | pixelArea | VECTOR4 | No | The image area to be displayed, default value is [0.0, 0.0, 1.0, 1.0] |
+| Dali::Toolkit::ImageVisual::Property::WRAP_MODE_U | wrapModeU | INTEGER or STRING | No | Wrap mode for u coordinate, valid values are CLAMP_TO_EDGE(default), REPEAT, MIRRORED_REPEAT |
+| Dali::Toolkit::ImageVisual::Property::WRAP_MODE_V | wrapModeV | INTEGER or STRING | No | Wrap mode for v coordinate, valid values are CLAMP_TO_EDGE(default), REPEAT, MIRRORED_REPEAT |
#### Usage
**VisualType:** Dali::Toolkit::Visual::IMAGE, "IMAGE"
-| Property | String | Type | Required | Description |
-|-------------------------------------------|--------|:-------:|:--------:|----------------------------------|
-| Dali::Toolkit::ImageVisual::Property::URL | url | STRING | Yes | The URL of the animated image. |
+| Property | String | Type | Required | Description |
+|---------------------------------------------------|------------|:-----------------:|:--------:|----------------------------------------------------------------------------------------------|
+| Dali::Toolkit::ImageVisual::Property::URL | url | STRING | Yes | The URL of the animated image. |
+| Dali::Toolkit::ImageVisual::Property::PIXEL_AREA | pixelArea | VECTOR4 | No | The image area to be displayed, default value is [0.0, 0.0, 1.0, 1.0] |
+| Dali::Toolkit::ImageVisual::Property::WRAP_MODE_U | wrapModeU | INTEGER or STRING | No | Wrap mode for u coordinate, valid values are CLAMP_TO_EDGE(default), REPEAT, MIRRORED_REPEAT |
+| Dali::Toolkit::ImageVisual::Property::WRAP_MODE_V | wrapModeV | INTEGER or STRING | No | Wrap mode for v coordinate, valid values are CLAMP_TO_EDGE(default), REPEAT, MIRRORED_REPEAT |
#### Usage