X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fimage-view%2Fimage-view-impl.cpp;h=72faf14cb0d4a998fa6ec23577a2af3260a9dd4c;hb=74c8fd064793430f586e7f2572e3a0bd0fb50af4;hp=80f1ee472d562a851a80743484d778d427ea6a9a;hpb=cb93c3930ba6271ae4b93a46fbb518833d580651;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/controls/image-view/image-view-impl.cpp b/dali-toolkit/internal/controls/image-view/image-view-impl.cpp index 80f1ee4..72faf14 100644 --- a/dali-toolkit/internal/controls/image-view/image-view-impl.cpp +++ b/dali-toolkit/internal/controls/image-view/image-view-impl.cpp @@ -1,4 +1,19 @@ -// Copyright (c) 2016 Samsung Electronics Co., Ltd. +/* + * Copyright (c) 2017 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ // CLASS HEADER #include "image-view-impl.h" @@ -11,6 +26,7 @@ // INTERNAL INCLUDES #include +#include #include #include #include @@ -71,6 +87,13 @@ Toolkit::ImageView ImageView::New() ///////////////////////////////////////////////////////////// +void ImageView::OnInitialize() +{ + // ImageView can relayout in the OnImageReady, alternative to a signal would be to have a upcall from the Control to ImageView + Dali::Toolkit::Control handle( GetOwner() ); + Toolkit::DevelControl::ResourceReadySignal( handle ).Connect( this, &ImageView::OnResourceReady ); +} + void ImageView::SetImage( Image image ) { // Don't bother comparing if we had a visual previously, just drop old visual and create new one @@ -78,10 +101,13 @@ void ImageView::SetImage( Image image ) mUrl.clear(); mPropertyMap.Clear(); - mVisual = Toolkit::VisualFactory::Get().CreateVisual( image ); - RegisterVisual( Toolkit::ImageView::Property::IMAGE, mVisual ); + Toolkit::Visual::Base visual = Toolkit::VisualFactory::Get().CreateVisual( image ); + if (!mVisual) + { + mVisual = visual; + } - RelayoutRequest(); + DevelControl::RegisterVisual( *this, Toolkit::ImageView::Property::IMAGE, visual ); } void ImageView::SetImage( const Property::Map& map ) @@ -91,10 +117,14 @@ void ImageView::SetImage( const Property::Map& map ) mUrl.clear(); mImage.Reset(); - mVisual = Toolkit::VisualFactory::Get().CreateVisual( mPropertyMap ); - RegisterVisual( Toolkit::ImageView::Property::IMAGE, mVisual ); + Toolkit::Visual::Base visual = Toolkit::VisualFactory::Get().CreateVisual( mPropertyMap ); + // Don't set mVisual until it is ready and shown. Getters will still use current visual. + if (!mVisual) + { + mVisual = visual; + } - RelayoutRequest(); + DevelControl::RegisterVisual( *this, Toolkit::ImageView::Property::IMAGE, visual ); } void ImageView::SetImage( const std::string& url, ImageDimensions size ) @@ -104,10 +134,14 @@ void ImageView::SetImage( const std::string& url, ImageDimensions size ) mImage.Reset(); mPropertyMap.Clear(); - mVisual = Toolkit::VisualFactory::Get().CreateVisual( url, size ); - RegisterVisual( Toolkit::ImageView::Property::IMAGE, mVisual ); + // Don't set mVisual until it is ready and shown. Getters will still use current visual. + Toolkit::Visual::Base visual = Toolkit::VisualFactory::Get().CreateVisual( url, size ); + if (!mVisual) + { + mVisual = visual; + } - RelayoutRequest(); + DevelControl::RegisterVisual( *this, Toolkit::ImageView::Property::IMAGE, visual ); } Image ImageView::GetImage() const @@ -189,6 +223,12 @@ void ImageView::OnRelayout( const Vector2& size, RelayoutContainer& container ) } } +void ImageView::OnResourceReady( Toolkit::Control control ) +{ + // 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 ); +} + /////////////////////////////////////////////////////////// // // Properties