X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fnpatch%2Fnpatch-visual.cpp;h=1a3f640cb9f01366c2ffbdaabd6c6ee930307374;hb=44835162f4c0107591223e60557ee62b79cab35a;hp=fb133838b66d73692c835cb0f83f955b23a22da7;hpb=11ed6421771d05113ae1a6510167d8c2557ac20e;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/visuals/npatch/npatch-visual.cpp b/dali-toolkit/internal/visuals/npatch/npatch-visual.cpp index fb13383..1a3f640 100644 --- a/dali-toolkit/internal/visuals/npatch/npatch-visual.cpp +++ b/dali-toolkit/internal/visuals/npatch/npatch-visual.cpp @@ -202,10 +202,43 @@ void RegisterStretchProperties( Renderer& renderer, const char * uniformName, co NPatchVisual::NPatchVisual( VisualFactoryCache& factoryCache ) : Visual::Base( factoryCache ), + mImage(), + mCroppedImage(), + mImageUrl(), + mStretchPixelsX(), + mStretchPixelsY(), + mImageSize(), mBorderOnly( false ) { } +NPatchVisual::NPatchVisual( VisualFactoryCache& factoryCache, const std::string& imageUrl, bool borderOnly ) +: Visual::Base( factoryCache ), + mImage(), + mCroppedImage(), + mImageUrl( imageUrl ), + mStretchPixelsX(), + mStretchPixelsY(), + mImageSize(), + mBorderOnly( borderOnly ) +{ + NinePatchImage nPatch = NinePatchImage::New( mImageUrl ); + InitializeFromImage( nPatch ); +} + +NPatchVisual::NPatchVisual( VisualFactoryCache& factoryCache, NinePatchImage image, bool borderOnly ) +: Visual::Base( factoryCache ), + mImage( image ), + mCroppedImage(), + mImageUrl(), + mStretchPixelsX(), + mStretchPixelsY(), + mImageSize(), + mBorderOnly( borderOnly ) +{ + InitializeFromImage( image ); +} + NPatchVisual::~NPatchVisual() { } @@ -254,17 +287,6 @@ void NPatchVisual::GetNaturalSize( Vector2& naturalSize ) const } } -void NPatchVisual::SetClipRect( const Rect& clipRect ) -{ - Visual::Base::SetClipRect( clipRect ); - //ToDo: renderer responds to the clipRect change -} - -void NPatchVisual::SetOffset( const Vector2& offset ) -{ - //ToDo: renderer applies the offset -} - Geometry NPatchVisual::CreateGeometry() { Geometry geometry; @@ -390,6 +412,8 @@ void NPatchVisual::DoSetOnStage( Actor& actor ) { ApplyImageToSampler(); } + + actor.AddRenderer( mImpl->mRenderer ); } void NPatchVisual::DoSetOffStage( Actor& actor ) @@ -414,6 +438,17 @@ void NPatchVisual::DoCreatePropertyMap( Property::Map& map ) const map.Insert( Toolkit::ImageVisual::Property::BORDER_ONLY, mBorderOnly ); } +void NPatchVisual::DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue ) +{ + // TODO +} + +Dali::Property::Value NPatchVisual::DoGetProperty( Dali::Property::Index index ) +{ + // TODO + return Dali::Property::Value(); +} + void NPatchVisual::ChangeRenderer( bool oldBorderOnly, size_t oldGridX, size_t oldGridY ) { //check to see if the border style has changed @@ -450,60 +485,6 @@ void NPatchVisual::ChangeRenderer( bool oldBorderOnly, size_t oldGridX, size_t o } } -void NPatchVisual::SetImage( const std::string& imageUrl, bool borderOnly ) -{ - bool oldBorderOnly = mBorderOnly; - size_t oldGridX = mStretchPixelsX.Size(); - size_t oldGridY = mStretchPixelsY.Size(); - - mBorderOnly = borderOnly; - mImage.Reset(); - if( mImageUrl == imageUrl ) - { - return; - } - - mImageUrl = imageUrl; - if( mImpl->mRenderer ) - { - NinePatchImage nPatch = NinePatchImage::New( mImageUrl ); - InitializeFromImage( nPatch ); - - ChangeRenderer( oldBorderOnly, oldGridX, oldGridY ); - - if( mCroppedImage ) - { - ApplyImageToSampler(); - } - } -} - -void NPatchVisual::SetImage( NinePatchImage image, bool borderOnly ) -{ - bool oldBorderOnly = mBorderOnly; - size_t oldGridX = mStretchPixelsX.Size(); - size_t oldGridY = mStretchPixelsY.Size(); - - mBorderOnly = borderOnly; - mImageUrl.empty(); - if( mImage == image ) - { - return; - } - - mImage = image; - if( mImpl->mRenderer ) - { - InitializeFromImage( mImage ); - ChangeRenderer( oldBorderOnly, oldGridX, oldGridY ); - - if( mCroppedImage ) - { - ApplyImageToSampler(); - } - } -} - void NPatchVisual::InitializeFromImage( NinePatchImage nPatch ) { mCroppedImage = nPatch.CreateCroppedBufferImage(); @@ -522,7 +503,7 @@ void NPatchVisual::InitializeFromImage( NinePatchImage nPatch ) void NPatchVisual::InitializeFromBrokenImage() { - mCroppedImage = VisualFactory::GetBrokenVisualImage(); + mCroppedImage = VisualFactoryCache::GetBrokenVisualImage(); mImageSize = ImageDimensions( mCroppedImage.GetWidth(), mCroppedImage.GetHeight() ); mStretchPixelsX.Clear();