/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
using namespace Dali;
ImageView::ImageView()
-: Control( ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) )
+: Control( ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ),
+ mImageSize()
{
}
mVisual = visual;
}
- DevelControl::RegisterVisual( *this, Toolkit::ImageView::Property::IMAGE, visual );
+ if( !mShaderMap.Empty() )
+ {
+ Internal::Visual::Base& visualImpl = Toolkit::GetImplementation( visual );
+ visualImpl.SetCustomShader( mShaderMap );
+ }
+
+ DevelControl::RegisterVisual( *this, Toolkit::ImageView::Property::IMAGE, visual );
}
else
{
- // Unregister the exsiting visual
+ // Unregister the existing visual
DevelControl::UnregisterVisual( *this, Toolkit::ImageView::Property::IMAGE );
// Trigger a size negotiation request that may be needed when unregistering a visual.
RelayoutRequest();
}
- Toolkit::DevelControl::RequestLayout( *this );
+ // Signal that a Relayout may be needed
}
void ImageView::SetImage( const Property::Map& map )
mVisual = visual;
}
+ if( !mShaderMap.Empty() )
+ {
+ Internal::Visual::Base& visualImpl = Toolkit::GetImplementation( visual );
+ visualImpl.SetCustomShader( mShaderMap );
+ }
+
DevelControl::RegisterVisual( *this, Toolkit::ImageView::Property::IMAGE, visual );
}
else
RelayoutRequest();
}
- Toolkit::DevelControl::RequestLayout( *this );
+ // Signal that a Relayout may be needed
}
void ImageView::SetImage( const std::string& url, ImageDimensions size )
{
// Don't bother comparing if we had a visual previously, just drop old visual and create new one
mUrl = url;
+ mImageSize = size;
mImage.Reset();
mPropertyMap.Clear();
mVisual = visual;
}
+ if( !mShaderMap.Empty() )
+ {
+ Internal::Visual::Base& visualImpl = Toolkit::GetImplementation( visual );
+ visualImpl.SetCustomShader( mShaderMap );
+ }
+
DevelControl::RegisterVisual( *this, Toolkit::ImageView::Property::IMAGE, visual );
}
else
RelayoutRequest();
}
- Toolkit::DevelControl::RequestLayout( *this );
+ // Signal that a Relayout may be needed
}
Image ImageView::GetImage() const
}
}
+void ImageView::OnStageConnection( int depth )
+{
+ if( mImage )
+ {
+ mImage.UploadedSignal().Emit( mImage );
+ }
+
+ Dali::ResourceImage resourceImage = Dali::ResourceImage::DownCast( mImage );
+ if( resourceImage )
+ {
+ resourceImage.LoadingFinishedSignal().Emit( resourceImage );
+ }
+
+ Control::OnStageConnection( depth ); // Enabled visuals will be put on stage
+}
+
Vector3 ImageView::GetNaturalSize()
{
if( mVisual )
{
// Visual ready so update visual attached to this ImageView, following call to RelayoutRequest will use this visual.
mVisual = DevelControl::GetVisual( *this, Toolkit::ImageView::Property::IMAGE );
+ // Signal that a Relayout may be needed
}
///////////////////////////////////////////////////////////
impl.SetImage( *map );
}
// the property map contains only the custom shader
- else if( ( impl.mVisual )&&( map->Count() == 1u )&&( shaderValue ) )
+ else if( ( map->Count() == 1u )&&( shaderValue ) )
{
Property::Map* shaderMap = shaderValue->GetMap();
if( shaderMap )
{
- Internal::Visual::Base& visual = Toolkit::GetImplementation( impl.mVisual );
- visual.SetCustomShader( *shaderMap );
- if( imageView.OnStage() )
+ impl.mShaderMap = *shaderMap;
+
+ if( !impl.mUrl.empty() )
+ {
+ impl.SetImage( impl.mUrl, impl.mImageSize );
+ }
+ else if( impl.mImage )
{
- // force to create new core renderer to use the newly set shader
- visual.SetOffStage( imageView );
- visual.SetOnStage( imageView );
+ impl.SetImage( impl.mImage );
+ }
+ else if( !impl.mPropertyMap.Empty() )
+ {
+ impl.SetImage( impl.mPropertyMap );
}
}
}
Scripting::CreatePropertyMap( impl.mImage, map );
value = map;
}
- else if( !impl.mPropertyMap.Empty() )
+ else
{
- value = impl.mPropertyMap;
+ Property::Map map;
+ Toolkit::Visual::Base visual = DevelControl::GetVisual( impl, Toolkit::ImageView::Property::IMAGE );
+ if( visual )
+ {
+ visual.CreatePropertyMap( map );
+ }
+ value = map;
}
break;
}