{
case SuspendFunc: return mTrace.FindMethod("Suspend");
case ResumeFunc: return mTrace.FindMethod("Resume");
- case LoadResourceFunc: return mTrace.FindMethod("LoadResource");
+ case LoadResourceFunc: return mTrace.FindMethod("LoadResource") || mTrace.FindMethod("LoadResourceSynchronously");
case LoadFileFunc: return mTrace.FindMethod("LoadFile");
case LoadShaderBinaryFileFunc: return mTrace.FindMethod("LoadShaderBinaryFile");
case SaveShaderBinaryFileFunc: return mTrace.FindMethod("SaveShaderBinaryFile");
return resourcePtr;
}
-void TestControlRendererRender( ToolkitTestApplication& application, Actor& actor, ControlRenderer& controlRenderer, Integration::ResourcePointer resourcePtr = Integration::ResourcePointer(), std::size_t expectedSamplers = 0)
+void TestControlRendererRender( ToolkitTestApplication& application,
+ Actor& actor,
+ ControlRenderer& controlRenderer,
+ std::size_t expectedSamplers = 0,
+ ImageDimensions imageDimensions = ImageDimensions(),
+ Integration::ResourcePointer resourcePtr = Integration::ResourcePointer())
{
+ if( resourcePtr )
+ {
+ // set the image size, for test case, this needs to be set before loading started
+ application.GetPlatform().SetClosestImageSize( Vector2(imageDimensions.GetWidth(), imageDimensions.GetHeight()) );
+ }
+
actor.SetSize( 200.f, 200.f );
Stage::GetCurrent().Add( actor );
controlRenderer.SetSize( Vector2(200.f, 200.f) );
// A lookup texture is generated and pass to shader as sampler
Actor actor = Actor::New();
- TestControlRendererRender( application, actor, controlRenderer, Integration::ResourcePointer(), 1u );
+ TestControlRendererRender( application, actor, controlRenderer, 1u );
controlRenderer.SetOffStage( actor );
DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
// A lookup texture is generated and pass to shader as sampler
Actor actor = Actor::New();
- TestControlRendererRender( application, actor, controlRenderer, Integration::ResourcePointer(), 1u );
+ TestControlRendererRender( application, actor, controlRenderer, 1u );
Matrix3 alignMatrix( radius, 0.f, 0.f, 0.f, radius, 0.f, center.x, center.y, 1.f );
alignMatrix.Invert();
DALI_TEST_CHECK( controlRenderer );
Actor actor = Actor::New();
- TestControlRendererRender( application, actor, controlRenderer, Integration::ResourcePointer(Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD)), 1u );
+ // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
+ // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
+ TestControlRendererRender( application, actor, controlRenderer, 1u,
+ ImageDimensions(512, 513),
+ Integration::ResourcePointer(Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD)));
TestGlAbstraction& gl = application.GetGlAbstraction();
int textureUnit = -1;
ControlRenderer controlRenderer = factory.GetControlRenderer( image );
Actor actor = Actor::New();
- TestControlRendererRender( application, actor, controlRenderer, Integration::ResourcePointer(Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD)), 1u );
+ // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
+ // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
+ TestControlRendererRender( application, actor, controlRenderer, 1u,
+ ImageDimensions(512, 513),
+ Integration::ResourcePointer(Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD)) );
TestGlAbstraction& gl = application.GetGlAbstraction();
int textureUnit = -1;
DALI_TEST_CHECK( controlRenderer );
Actor actor = Actor::New();
- TestControlRendererRender( application, actor, controlRenderer, ninePatchResource, 1u );
+ TestControlRendererRender( application, actor, controlRenderer, 1u,
+ ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
+ ninePatchResource );
TestGlAbstraction& gl = application.GetGlAbstraction();
int textureUnit = -1;
DALI_TEST_CHECK( controlRenderer );
Actor actor = Actor::New();
- TestControlRendererRender( application, actor, controlRenderer, ninePatchResource, 1u );
+ TestControlRendererRender( application, actor, controlRenderer, 1u,
+ ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
+ ninePatchResource );
TestGlAbstraction& gl = application.GetGlAbstraction();
int textureUnit = -1;
DALI_TEST_CHECK( controlRenderer );
Actor actor = Actor::New();
- TestControlRendererRender( application, actor, controlRenderer, ninePatchResource, 1u );
+ TestControlRendererRender( application, actor, controlRenderer, 1u,
+ ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
+ ninePatchResource );
TestGlAbstraction& gl = application.GetGlAbstraction();
int textureUnit = -1;
DALI_TEST_CHECK( controlRenderer );
Actor actor = Actor::New();
- TestControlRendererRender( application, actor, controlRenderer, ninePatchResource, 1u );
+ TestControlRendererRender( application, actor, controlRenderer, 1u,
+ ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
+ ninePatchResource );
TestGlAbstraction& gl = application.GetGlAbstraction();
int textureUnit = -1;
DALI_TEST_CHECK( controlRenderer );
Actor actor = Actor::New();
- TestControlRendererRender( application, actor, controlRenderer, ninePatchResource, 1u );
+ TestControlRendererRender( application, actor, controlRenderer, 1u,
+ ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
+ ninePatchResource );
TestGlAbstraction& gl = application.GetGlAbstraction();
int textureUnit = -1;
DALI_TEST_CHECK( controlRenderer );
Actor actor = Actor::New();
- TestControlRendererRender( application, actor, controlRenderer, ninePatchResource, 1u );
+ TestControlRendererRender( application, actor, controlRenderer, 1u,
+ ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
+ ninePatchResource );
TestGlAbstraction& gl = application.GetGlAbstraction();
int textureUnit = -1;
Actor actor = Actor::New();
//The testkit still has to load a bitmap for the broken renderer image
- TestControlRendererRender( application, actor, controlRenderer, Integration::ResourcePointer(Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD)), 1u );
+ TestControlRendererRender( application, actor, controlRenderer, 1u,
+ ImageDimensions(),
+ Integration::ResourcePointer(Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD)) );
TestGlAbstraction& gl = application.GetGlAbstraction();
int textureUnit = -1;
Actor actor = Actor::New();
//The testkit still has to load a bitmap for the broken renderer image
- TestControlRendererRender( application, actor, controlRenderer, Integration::ResourcePointer(Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD)), 1u );
+ TestControlRendererRender( application, actor, controlRenderer, 1u,
+ ImageDimensions(),
+ Integration::ResourcePointer(Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD)) );
TestGlAbstraction& gl = application.GetGlAbstraction();
int textureUnit = -1;
{
ToolkitTestApplication application;
- ShaderEffect effect = Toolkit::CreateAlphaDiscardEffect();
- DALI_TEST_CHECK( effect );
+ Property::Map effect = Toolkit::CreateAlphaDiscardEffect();
+ DALI_TEST_CHECK( !effect.Empty() );
+
+ Property::Value* customShaderValue = effect.Find( "shader" );
+ DALI_TEST_CHECK( customShaderValue );
+
+ Property::Map customShader;
+ DALI_TEST_CHECK( customShaderValue->Get( customShader ) );
+
+ Property::Value* vertexShaderValue = customShader.Find( "vertexShader" );
+ DALI_TEST_CHECK( !vertexShaderValue );
+
+ Property::Value* fragmentShaderValue = customShader.Find( "fragmentShader" );
+ DALI_TEST_CHECK( fragmentShaderValue );
+
+ std::string fragmentShader;
+ DALI_TEST_CHECK( fragmentShaderValue->Get( fragmentShader ) );
+ DALI_TEST_CHECK( !fragmentShader.empty() );
+
+ Property::Value* gridXValue = customShader.Find( "subdivideGridX" );
+ DALI_TEST_CHECK( !gridXValue );
+
+ Property::Value* gridYValue = customShader.Find( "subdivideGridY" );
+ DALI_TEST_CHECK( !gridYValue );
+
+ Property::Value* hintsValue = customShader.Find( "hints" );
+ DALI_TEST_CHECK( !hintsValue );
END_TEST;
}
{
ToolkitTestApplication application;
- ShaderEffect effect = Toolkit::CreateImageRegionEffect();
- DALI_TEST_CHECK( effect );
+ Property::Map effect = Toolkit::CreateImageRegionEffect();
+ DALI_TEST_CHECK( !effect.Empty() );
+
+ Property::Value* customShaderValue = effect.Find( "shader" );
+ DALI_TEST_CHECK( customShaderValue );
+
+ Property::Map customShader;
+ DALI_TEST_CHECK( customShaderValue->Get( customShader ) );
+
+ Property::Value* vertexShaderValue = customShader.Find( "vertexShader" );
+ DALI_TEST_CHECK( vertexShaderValue );
+
+ std::string vertexShader;
+ DALI_TEST_CHECK( vertexShaderValue->Get( vertexShader ) );
+ DALI_TEST_CHECK( !vertexShader.empty() );
+
+ Property::Value* fragmentShaderValue = customShader.Find( "fragmentShader" );
+ DALI_TEST_CHECK( !fragmentShaderValue );
+
+ Property::Value* gridXValue = customShader.Find( "subdivideGridX" );
+ DALI_TEST_CHECK( !gridXValue );
+
+ Property::Value* gridYValue = customShader.Find( "subdivideGridY" );
+ DALI_TEST_CHECK( !gridYValue );
+
+ Property::Value* hintsValue = customShader.Find( "hints" );
+ DALI_TEST_CHECK( !hintsValue );
END_TEST;
}
*
* Usage example:
*
- * ImageActor actor = ImageActor::New( Image( EXAMPLE_IMAGE_PATH ) );
- * ShaderEffect alphaDiscardEffect = CreateAlphaDiscardEffect();
- * actor.SetShaderEffect( alphaDiscardEffect );
+ * ImageView actor = ImageView::New( EXAMPLE_IMAGE_PATH );
+ * Property::Map alphaDiscardEffect = CreateAlphaDiscardEffect();
+ * actor.SetProperty( ImageView::Property::IMAGE, alphaDiscardEffect );
*
* @return A handle to a newly allocated ShaderEffect.
*/
-inline ShaderEffect CreateAlphaDiscardEffect()
+inline Property::Map CreateAlphaDiscardEffect()
{
const char* ALPHA_DISCARD_FRAGMENT_SHADER_SOURCE =
+ "varying mediump vec2 vTexCoord; \n"
+ " \n"
+ "uniform sampler2D sTexture; \n"
+ "uniform lowp vec4 uColor; \n"
"void main() \n"
"{ \n"
" mediump vec4 color = texture2D( sTexture, vTexCoord ); \n"
" gl_FragColor = color * uColor; \n"
"} \n";
- return ShaderEffect::New( "", // Use default
- ALPHA_DISCARD_FRAGMENT_SHADER_SOURCE );
-}
+ Property::Map map;
+
+ Property::Map customShader;
+ customShader[ "fragmentShader" ] = ALPHA_DISCARD_FRAGMENT_SHADER_SOURCE;
+
+ map[ "shader" ] = customShader;
+ return map;}
} // namespace Toolkit
*/
// EXTERNAL INCLUDES
-#include <dali/public-api/shader-effects/shader-effect.h>
+#include <dali/public-api/object/property-map.h>
namespace Dali
{
*
* @return A handle to a newly allocated ShaderEffect
*/
-inline ShaderEffect CreateImageRegionEffect()
+inline Property::Map CreateImageRegionEffect()
{
std::string vertexShader(
+ "attribute mediump vec2 aPosition;\n"
+ "\n"
+ "uniform mediump mat4 uMvpMatrix;\n"
+ "uniform vec3 uSize;\n"
+ "uniform vec4 uTextureRect;"
+ "\n"
+ "varying vec2 vTexCoord;\n"
+
"uniform mediump vec2 uTopLeft;\n"
"uniform mediump vec2 uBottomRight;\n"
"void main()\n"
"{\n"
- " mediump vec4 position = vec4(aPosition,1.0);\n"
+ " mediump vec4 position = vec4(aPosition, 0.0, 1.0);\n"
+ " position.xyz *= uSize;\n"
" gl_Position = uMvpMatrix * position;\n"
// The line below is doing the same as the following commented lines:
//" vec2 imageSize = sTextureRect.zw - sTextureRect.xy;\n"
//" vec2 bottomRight = sTextureRect.xy + uBottomRight * imageSize;\n"
//" vec2 texCoord = (aTexCoord - sTextureRect.xy) / imageSize;\n"
//" vTexCoord = topLeft + texCoord * ( bottomRight - topLeft );\n"
- " vTexCoord = sTextureRect.xy + uTopLeft * ( sTextureRect.zw - sTextureRect.xy ) + ( aTexCoord - sTextureRect.xy ) * ( uBottomRight - uTopLeft );\n"
+
+ " vec2 texCoord = aPosition + vec2(0.5);\n"
+ " vTexCoord = uTextureRect.xy + uTopLeft * ( uTextureRect.zw - uTextureRect.xy ) + ( texCoord - uTextureRect.xy ) * ( uBottomRight - uTopLeft );\n"
"}\n"
);
- Dali::ShaderEffect shaderEffect = Dali::ShaderEffect::New( vertexShader, "" );
- shaderEffect.SetUniform( "uTopLeft", Vector2( 0.f, 0.f ) );
- shaderEffect.SetUniform( "uBottomRight", Vector2( 1.f, 1.f ) );
+ Property::Map map;
+
+ Property::Map customShader;
+ customShader[ "vertexShader" ] = vertexShader;
- return shaderEffect;
+ map[ "shader" ] = customShader;
+ return map;
}
} // namespace Toolkit
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/default-controls/solid-color-actor.h>
#include <dali-toolkit/public-api/controls/text-controls/text-label.h>
+#include <dali-toolkit/public-api/controls/image-view/image-view.h>
/**
* Button states and contents
void Button::SetUnselectedImage( const std::string& filename )
{
- ImageActor newContent;
+ Toolkit::ImageView newContent;
if( !filename.empty() )
{
- Image resourceimage = Dali::ResourceImage::New( filename );
- if( resourceimage )
- {
- newContent = ImageActor::New( resourceimage );
- }
+ newContent = Toolkit::ImageView::New( filename );
}
else
{
- newContent = ImageActor::New();
+ newContent = Toolkit::ImageView::New();
}
if( newContent )
void Button::SetSelectedImage( const std::string& filename )
{
- ImageActor newContent;
+ Toolkit::ImageView newContent;
if( !filename.empty() )
{
- Image resourceimage = Dali::ResourceImage::New( filename );
- if( resourceimage )
- {
- newContent = ImageActor::New( resourceimage );
- }
+ newContent = Toolkit::ImageView::New( filename );
}
else
{
- newContent = ImageActor::New();
+ newContent = Toolkit::ImageView::New();
}
if( newContent )
void Button::SetBackgroundImage( const std::string& filename )
{
- Image resourceimage = Dali::ResourceImage::New( filename );
- if( resourceimage )
- {
- SetupContent( mBackgroundContent, ImageActor::New( resourceimage ) );
+ SetupContent( mBackgroundContent, Toolkit::ImageView::New( filename ) );
- OnBackgroundImageSet();
- RelayoutRequest();
- }
+ OnBackgroundImageSet();
+ RelayoutRequest();
}
Actor& Button::GetBackgroundImage()
void Button::SetSelectedBackgroundImage( const std::string& filename )
{
- Image resourceimage = Dali::ResourceImage::New( filename );
- if( resourceimage )
- {
- SetupContent( mSelectedBackgroundContent, ImageActor::New( resourceimage ) );
+ SetupContent( mSelectedBackgroundContent, Toolkit::ImageView::New( filename ) );
- OnSelectedBackgroundImageSet();
- RelayoutRequest();
- }
+ OnSelectedBackgroundImageSet();
+ RelayoutRequest();
}
Actor& Button::GetSelectedBackgroundImage()
void Button::SetDisabledImage( const std::string& filename )
{
- Image resourceimage = Dali::ResourceImage::New( filename );
- if( resourceimage )
- {
- SetupContent( mDisabledContent, ImageActor::New( resourceimage ) );
+ SetupContent( mDisabledContent, Toolkit::ImageView::New( filename ) );
- OnDisabledImageSet();
- RelayoutRequest();
- }
+ OnDisabledImageSet();
+ RelayoutRequest();
}
Actor& Button::GetDisabledImage()
void Button::SetDisabledSelectedImage( const std::string& filename )
{
- Image resourceimage = Dali::ResourceImage::New( filename );
- if( resourceimage )
- {
- SetupContent( mDisabledSelectedContent, ImageActor::New( resourceimage ) );
+ SetupContent( mDisabledSelectedContent, Toolkit::ImageView::New( filename ) );
- OnDisabledSelectedImageSet();
- RelayoutRequest();
- }
+ OnDisabledSelectedImageSet();
+ RelayoutRequest();
}
Actor& Button::GetDisabledSelectedImage()
void Button::SetDisabledBackgroundImage( const std::string& filename )
{
- Image resourceimage = Dali::ResourceImage::New( filename );
- if( resourceimage )
- {
- SetupContent( mDisabledBackgroundContent, ImageActor::New( resourceimage ) );
+ SetupContent( mDisabledBackgroundContent, Toolkit::ImageView::New( filename ) );
- OnDisabledBackgroundImageSet();
- RelayoutRequest();
- }
+ OnDisabledBackgroundImageSet();
+ RelayoutRequest();
}
Actor& Button::GetDisabledBackgroundImage()
{
if( actor )
{
- actor.Unparent();
Self().Add( actor );
PrepareForTranstionOut( actor );
}
{
if( actor )
{
- actor.Unparent();
Self().Add( actor );
}
}
#include "check-box-button-impl.h"
// EXTERNAL INCLUDES
-#include <dali/public-api/actors/image-actor.h>
#include <dali/public-api/object/type-registry.h>
#include <dali/public-api/images/resource-image.h>
//INTERNAL INCLUDES
+#include <dali-toolkit/public-api/controls/control-depth-index-ranges.h>
+#include <dali-toolkit/internal/controls/image-view/image-view-impl.h>
#include <dali-toolkit/devel-api/shader-effects/image-region-effect.h>
namespace Dali
const float DISTANCE_BETWEEN_IMAGE_AND_LABEL( 5.0f );
const float ANIMATION_TIME( 0.26f ); // EFL checkbox tick time
-// Required for the UV reveal shader to render the tick on top of the rest of the checkbox.
-const float SHADER_DEPTH_OFFSET = 1.0f;
BaseHandle Create()
{
{
}
+void CheckBoxButton::SetTickUVEffect()
+{
+ Toolkit::ImageView imageView = Toolkit::ImageView::DownCast( mSelectedImage );
+ if( imageView )
+ {
+ imageView.RegisterProperty( "uTextureRect", Vector4(0.f, 0.f, 1.f, 1.f ) );
+ imageView.RegisterProperty( "uTopLeft", Vector2::ZERO );
+
+ Property::Map shaderMap = CreateImageRegionEffect();
+ imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, shaderMap );
+
+ GetImpl( imageView ).SetDepthIndex( DECORATION_DEPTH_INDEX );
+ }
+}
+
void CheckBoxButton::OnButtonInitialize()
{
// Wrap around all children
SetSelectedImage( SELECTED_BUTTON_IMAGE_DIR );
SetDisabledImage( DISABLED_UNSELECTED_BUTTON_IMAGE_DIR );
SetDisabledSelectedImage( DISABLED_SELECTED_BUTTON_IMAGE_DIR );
+
+ mSelectedImage = GetSelectedImage();
+ SetTickUVEffect();
}
void CheckBoxButton::OnLabelSet( bool noPadding )
if( actor == selectedImage )
{
actor.SetScale( Vector3( 0.0f, 1.0f, 1.0f ) );
+ actor.RegisterProperty( "uBottomRight", Vector2( 0.0f, 1.0f ) );
- if( !mTickUVEffect )
+ if( mSelectedImage != selectedImage )
{
- mTickUVEffect = CreateImageRegionEffect();
- }
- mTickUVEffect.SetUniform( "uBottomRight", Vector2( 0.0f, 1.0f ) );
-
- ImageActor imageActor = ImageActor::DownCast( actor );
- if( imageActor )
- {
- // Ensure the tick effect is rendered above the reset of the checkbox.
- imageActor.SetSortModifier( SHADER_DEPTH_OFFSET );
- imageActor.SetShaderEffect( mTickUVEffect );
+ mSelectedImage = selectedImage;
+ SetTickUVEffect();
}
}
}
if( actor == selectedImage )
{
actor.SetScale( Vector3::ONE );
+ actor.RegisterProperty( "uBottomRight", Vector2::ONE );
- if( !mTickUVEffect )
+ if( mSelectedImage != selectedImage )
{
- mTickUVEffect = CreateImageRegionEffect();
- }
- mTickUVEffect.SetUniform( "uBottomRight", Vector2::ONE );
-
- ImageActor imageActor = ImageActor::DownCast( actor );
- if( imageActor )
- {
- imageActor.SetShaderEffect( mTickUVEffect );
+ mSelectedImage = selectedImage;
+ SetTickUVEffect();
}
}
}
Dali::Animation transitionAnimation = GetTransitionAnimation();
if( transitionAnimation )
{
- DALI_ASSERT_DEBUG( mTickUVEffect );
- if( mTickUVEffect )
- {
- // UV anim
- transitionAnimation.AnimateTo( Property( mTickUVEffect, "uBottomRight" ), Vector2::ONE );
- }
+ // UV anim
+ transitionAnimation.AnimateTo( Property( actor, "uBottomRight" ), Vector2::ONE );
+
// Actor size anim
transitionAnimation.AnimateTo( Property( actor, Actor::Property::SCALE_X ), 1.0f );
}
{
//explicitly end the swipe animation
actor.SetScale( Vector3::ONE );
- if( mTickUVEffect )
+ if( mSelectedImage == selectedImage )
{
- mTickUVEffect.SetUniform( "uBottomRight", Vector2::ONE );
+ actor.RegisterProperty( "uBottomRight", Vector2::ONE );
}
}
}
*/
virtual ~CheckBoxButton();
+ /**
+ * Setup the ticking effect to the selected image.
+ */
+ void SetTickUVEffect();
+
private: // From Button
CheckBoxButton& operator=( const CheckBoxButton& );
private:
- ShaderEffect mTickUVEffect; ///< ImageRegionEffect to expand the tick across
+ Actor mSelectedImage;
};
} // namespace Internal
#include <dali/devel-api/scripting/scripting.h>
// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/controls/image-view/image-view.h>
#include <dali-toolkit/public-api/controls/text-controls/text-label.h>
namespace Dali
void PushButton::SetIcon( DecorationState state, const std::string iconFilename )
{
mIconName[ state ] = iconFilename;
- SetDecoration( state, ImageActor::New( Dali::ResourceImage::New( iconFilename ) ) );
+ SetDecoration( state, Toolkit::ImageView::New( iconFilename ) );
ConfigureSizeNegotiation();
}
Actor self = Self();
Toolkit::RendererFactory::Get().ResetRenderer( mRenderer, self, mPropertyMap );
- int width = 0;
Property::Value* widthValue = mPropertyMap.Find( "width" );
if( widthValue )
{
- widthValue->Get( width );
+ int width;
+ if( widthValue->Get( width ) )
+ {
+ mImageSize = ImageDimensions( width, mImageSize.GetHeight() );
+ }
}
- int height = 0;
Property::Value* heightValue = mPropertyMap.Find( "height" );
if( heightValue )
{
- heightValue->Get( height );
+ int height;
+ if( heightValue->Get( height ) )
+ {
+ mImageSize = ImageDimensions( mImageSize.GetWidth(), height );
+ }
}
- mImageSize = ImageDimensions( width, height );
-
RelayoutRequest();
}
}
}
+void ImageView::SetDepthIndex( int depthIndex )
+{
+ mRenderer.SetDepthIndex( depthIndex );
+}
+
Vector3 ImageView::GetNaturalSize()
{
Vector3 size;
*/
static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
+ /**
+ * @brief Set the depth index of this image renderer
+ *
+ * Renderer with higher depth indices are rendered in front of other renderers with smaller values
+ *
+ * @param[in] depthIndex The depth index of this renderer
+ */
+ void SetDepthIndex( int depthIndex );
+
private: // From Control
/**
#include <dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.h>
#include <dali-toolkit/public-api/controls/control-impl.h>
#include <dali-toolkit/public-api/controls/default-controls/solid-color-actor.h>
+#include <dali-toolkit/public-api/controls/image-view/image-view.h>
#include <dali-toolkit/public-api/accessibility-manager/accessibility-manager.h>
#include <dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.h>
mPopupLayout = Toolkit::TableView::New( 3, 1 );
// Adds the default background image.
- SetPopupBackgroundImage( ImageActor::New( ResourceImage::New( DEFAULT_BACKGROUND_IMAGE_PATH ) ) );
+ SetPopupBackgroundImage( Toolkit::ImageView::New( ResourceImage::New( DEFAULT_BACKGROUND_IMAGE_PATH ) ) );
mPopupLayout.SetName( "popupLayoutTable" );
mPopupLayout.SetParentOrigin( ParentOrigin::CENTER );
{
// Adds the tail actor.
Image tail = ResourceImage::New( image );
- mTailImage = ImageActor::New( tail );
+ mTailImage = Toolkit::ImageView::New( tail );
mTailImage.SetName( "tailImage" );
const Vector3 anchorPoint = AnchorPoint::BOTTOM_RIGHT - position;
mTailImage.SetParentOrigin( position );
Image image = ResourceImage::New( valueString );
if( image )
{
- ImageActor actor = ImageActor::New( image );
+ Toolkit::ImageView actor = Toolkit::ImageView::New( image );
popupImpl.SetPopupBackgroundImage( actor );
}
}
Shader NPatchRenderer::CreateShader()
{
Shader shader;
- if( mStretchPixelsX.Size() == 1 && mStretchPixelsY.Size() == 1 )
+ if( !mImpl->mCustomShader )
{
- shader = mFactoryCache.GetShader( RendererFactoryCache::NINE_PATCH_SHADER );
- if( !shader )
+ if( mStretchPixelsX.Size() == 1 && mStretchPixelsY.Size() == 1 )
+ {
+ shader = mFactoryCache.GetShader( RendererFactoryCache::NINE_PATCH_SHADER );
+ if( !shader )
+ {
+ shader = Shader::New( VERTEX_SHADER_3X3, FRAGMENT_SHADER );
+ mFactoryCache.SaveShader( RendererFactoryCache::NINE_PATCH_SHADER, shader );
+ }
+ }
+ else if( mStretchPixelsX.Size() > 0 || mStretchPixelsY.Size() > 0)
{
- shader = Shader::New( VERTEX_SHADER_3X3, FRAGMENT_SHADER );
- mFactoryCache.SaveShader( RendererFactoryCache::NINE_PATCH_SHADER, shader );
+ std::stringstream vertexShader;
+ vertexShader << "#define FACTOR_SIZE_X " << mStretchPixelsX.Size() + 2 << "\n"
+ << "#define FACTOR_SIZE_Y " << mStretchPixelsY.Size() + 2 << "\n"
+ << VERTEX_SHADER;
+
+ shader = Shader::New( vertexShader.str(), FRAGMENT_SHADER );
}
}
- else if( mStretchPixelsX.Size() > 0 || mStretchPixelsY.Size() > 0)
+ else
{
- std::stringstream vertexShader;
- vertexShader << "#define FACTOR_SIZE_X " << mStretchPixelsX.Size() + 2 << "\n"
- << "#define FACTOR_SIZE_Y " << mStretchPixelsY.Size() + 2 << "\n"
- << VERTEX_SHADER;
+ const char* fragmentShader = FRAGMENT_SHADER;
+ Dali::Shader::ShaderHints hints = Dali::Shader::HINT_NONE;
- shader = Shader::New( vertexShader.str(), FRAGMENT_SHADER );
+ if( !mImpl->mCustomShader->mFragmentShader.empty() )
+ {
+ fragmentShader = mImpl->mCustomShader->mFragmentShader.c_str();
+ }
+ hints = mImpl->mCustomShader->mHints;
+
+ if( mStretchPixelsX.Size() == 1 && mStretchPixelsY.Size() == 1 )
+ {
+ shader = Shader::New( VERTEX_SHADER_3X3, fragmentShader, hints );
+ }
+ else if( mStretchPixelsX.Size() > 0 || mStretchPixelsY.Size() > 0)
+ {
+ std::stringstream vertexShader;
+ vertexShader << "#define FACTOR_SIZE_X " << mStretchPixelsX.Size() + 2 << "\n"
+ << "#define FACTOR_SIZE_Y " << mStretchPixelsY.Size() + 2 << "\n"
+ << VERTEX_SHADER;
+
+ shader = Shader::New( vertexShader.str(), fragmentShader, hints );
+ }
}
+
return shader;
}
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/control.h>
#include <dali-toolkit/public-api/controls/control-impl.h>
+#include <dali-toolkit/public-api/controls/image-view/image-view.h>
#include <dali-toolkit/public-api/accessibility-manager/accessibility-manager.h>
#include <dali-toolkit/devel-api/focus-manager/keyinput-focus-manager.h>
const char* const IS_FOCUS_GROUP_PROPERTY_NAME = "isKeyboardFocusGroup"; // This property will be replaced by a flag in Control.
-const char* const FOCUS_BORDER_IMAGE_PATH = DALI_IMAGE_DIR "keyboard_focus.png";
-const Vector4 FOCUS_BORDER_IMAGE_BORDER = Vector4(7.0f, 7.0f, 7.0f, 7.0f);
+const char* const FOCUS_BORDER_IMAGE_PATH = DALI_IMAGE_DIR "keyboard_focus.9.png";
BaseHandle Create()
{
void KeyboardFocusManager::CreateDefaultFocusIndicatorActor()
{
// Create a focus indicator actor shared by all the keyboard focusable actors
- Image borderImage = ResourceImage::New(FOCUS_BORDER_IMAGE_PATH);
-
- ImageActor focusIndicator = ImageActor::New(borderImage);
+ Toolkit::ImageView focusIndicator = Toolkit::ImageView::New(FOCUS_BORDER_IMAGE_PATH);
focusIndicator.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
- focusIndicator.SetStyle( ImageActor::STYLE_NINE_PATCH );
- focusIndicator.SetNinePatchBorder(FOCUS_BORDER_IMAGE_BORDER);
focusIndicator.SetPosition(Vector3(0.0f, 0.0f, 1.0f));
// Apply size constraint to the focus indicator