X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=examples%2Fimage-scaling-and-filtering%2Fimage-scaling-and-filtering-example.cpp;h=cdd8ee68c676c6d10d8ca201c4182da1d8bcbde0;hb=refs%2Fchanges%2F70%2F155570%2F1;hp=f5d17c6e8f495bda43d9c8c7ba8aab01069c9e8c;hpb=56fcceb48527c03dc629c76aa6a2c8c6cf26d421;p=platform%2Fcore%2Fuifw%2Fdali-demo.git diff --git a/examples/image-scaling-and-filtering/image-scaling-and-filtering-example.cpp b/examples/image-scaling-and-filtering/image-scaling-and-filtering-example.cpp index f5d17c6..cdd8ee6 100644 --- a/examples/image-scaling-and-filtering/image-scaling-and-filtering-example.cpp +++ b/examples/image-scaling-and-filtering/image-scaling-and-filtering-example.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -373,7 +373,7 @@ public: Toolkit::PushButton button = Toolkit::PushButton::New(); button.SetStyleName( STYLE_BUTTON_TEXT ); button.SetName( id ); - button.SetLabelText( label ); + button.SetProperty( Toolkit::Button::Property::LABEL, label ); button.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); button.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT ); button.ClickedSignal().Connect( this, &ImageScalingAndFilteringController::OnButtonClicked ); @@ -400,7 +400,7 @@ public: { Toolkit::PushButton button = Toolkit::PushButton::New(); button.SetName( id ); - button.SetLabelText( id ); + button.SetProperty( Toolkit::Button::Property::LABEL, id ); button.SetAnchorPoint( AnchorPoint::TOP_LEFT ); button.SetParentOrigin( ParentOrigin::BOTTOM_LEFT ); @@ -489,7 +489,7 @@ public: if( button.GetName() == modeName ) { mFittingMode = mode; - mFittingModeButton.SetLabelText( modeName ); + mFittingModeButton.SetProperty( Toolkit::Button::Property::LABEL, modeName ); ResizeImage(); mPopup.SetDisplayState( Toolkit::Popup::HIDDEN ); mPopup.Reset(); @@ -504,7 +504,7 @@ public: if( button.GetName() == modeName ) { mSamplingMode = mode; - mSamplingModeButton.SetLabelText( modeName ); + mSamplingModeButton.SetProperty( Toolkit::Button::Property::LABEL, modeName ); ResizeImage(); mPopup.SetDisplayState( Toolkit::Popup::HIDDEN ); mPopup.Reset(); @@ -522,21 +522,6 @@ public: } } - void OnImageLoaded( ResourceImage image ) - { - DALI_ASSERT_DEBUG( image == mNextImage ); - mImageView.SetImage( image ); - mImageView.SetSize( Size( image.GetWidth(), image.GetHeight() ) ); - mImageLoading = false; - - // We have finished loading, if a resize had occured during the load, trigger another load now. - if( mQueuedImageLoad ) - { - mQueuedImageLoad = false; - LoadImage(); - } - } - bool OnControlTouched( Actor actor, const TouchData& event ) { if(event.GetPointCount() > 0) @@ -661,13 +646,13 @@ public: else if ( event.keyPressedName == "f" ) { mSamplingMode = NextFilterMode( mSamplingMode ); - mSamplingModeButton.SetLabelText( StringFromFilterMode( mSamplingMode ) ); + mSamplingModeButton.SetProperty( Toolkit::Button::Property::LABEL, StringFromFilterMode( mSamplingMode ) ); } // Cycle filter and scaling modes: else if ( event.keyPressedName == "s" ) { mFittingMode = NextScalingMode( mFittingMode ); - mFittingModeButton.SetLabelText( StringFromScalingMode( mFittingMode ) ); + mFittingModeButton.SetProperty( Toolkit::Button::Property::LABEL, StringFromScalingMode( mFittingMode ) ); } else { @@ -687,21 +672,17 @@ private: const char * const path = IMAGE_PATHS[ mCurrentPath ]; Stage stage = Stage::GetCurrent(); Size imageSize = stage.GetSize() * mImageStageScale; - const ImageDimensions imageSizeInt = ImageDimensions::FromFloatArray( &imageSize.x ); + mImageView.SetSize( imageSize ); - ResourceImage image = ResourceImage::New( path, imageSizeInt, mFittingMode, mSamplingMode ); + Property::Map map; + map[Toolkit::ImageVisual::Property::URL] = path; + map[Toolkit::ImageVisual::Property::DESIRED_WIDTH] = imageSize.x; + map[Toolkit::ImageVisual::Property::DESIRED_HEIGHT] = imageSize.y; + map[Toolkit::ImageVisual::Property::FITTING_MODE] = mFittingMode; + map[Toolkit::ImageVisual::Property::SAMPLING_MODE] = mSamplingMode; - // If the image was cached, the load has already occured, bypass hooking the signal. - if( image.GetLoadingState() ) - { - OnImageLoaded( image ); - } - else - { - image.LoadingFinishedSignal().Connect( this, &ImageScalingAndFilteringController::OnImageLoaded ); - } + mImageView.SetProperty( Toolkit::ImageView::Property::IMAGE, map ); - mNextImage = image; } void ResizeImage() @@ -710,16 +691,7 @@ private: Stage stage = Stage::GetCurrent(); Size imageSize = stage.GetSize() * mImageStageScale; - // If an image is already loading, queue another load when it has finished. - // This way we get continuous updates instead of constantly re-requesting loads. - if( mImageLoading ) - { - mQueuedImageLoad = true; - } - else - { - LoadImage(); - } + LoadImage(); // Border size needs to be modified to take into account the width of the frame. Vector2 borderScale( ( imageSize + Vector2( BORDER_WIDTH * 2.0f, BORDER_WIDTH * 2.0f ) ) / stage.GetSize() ); @@ -742,7 +714,6 @@ private: Toolkit::ImageView mGrabCorner; PanGestureDetector mPanGestureDetector; Toolkit::ImageView mImageView; - ResourceImage mNextImage; //< Currently-loading image Vector2 mImageStageScale; int mCurrentPath; FittingMode::Type mFittingMode; @@ -752,19 +723,10 @@ private: }; -void RunTest( Application& application ) -{ - ImageScalingAndFilteringController test( application ); - - application.MainLoop(); -} - -// Entry point for Linux & Tizen applications int DALI_EXPORT_API main( int argc, char **argv ) { Application application = Application::New( &argc, &argv, DEMO_THEME_PATH ); - - RunTest( application ); - + ImageScalingAndFilteringController test( application ); + application.MainLoop(); return 0; }