X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=examples%2Fimage-view-url%2Fimage-view-url-example.cpp;h=5046f081e2eaf08fdb55407def2b7d5f96bac77f;hb=2e182925204bf3ef9f2a36cbfbf998e79fbafaf5;hp=2bd35183ce95a67131849b4878b0150baa8bc024;hpb=d83929a26671bef443aeb9ca3de1fbb185cc62aa;p=platform%2Fcore%2Fuifw%2Fdali-demo.git diff --git a/examples/image-view-url/image-view-url-example.cpp b/examples/image-view-url/image-view-url-example.cpp index 2bd3518..5046f08 100644 --- a/examples/image-view-url/image-view-url-example.cpp +++ b/examples/image-view-url/image-view-url-example.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 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. @@ -16,8 +16,6 @@ */ #include -#include -#include #include #include "shared/view.h" @@ -58,8 +56,10 @@ const Vector2 TARGET_SIZE(800.f, 800.f); class ImageViewUrlApp : public ConnectionTracker { public: - ImageViewUrlApp( Application& application ) - : mApplication( application ) + ImageViewUrlApp( Application& application, std::string url ) + : mApplication( application ), + mUrl( url ), + mDeltaPropertyIndex( Property::INVALID_INDEX ) { // Connect to the Application's Init signal mApplication.InitSignal().Connect( this, &ImageViewUrlApp::Create ); @@ -87,36 +87,42 @@ private: // Add a button to switch the scene. (right of toolbar) Toolkit::PushButton switchButton = Toolkit::PushButton::New(); - switchButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, BUTTON_ICON ); - switchButton.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, BUTTON_ICON_SELECTED ); + switchButton.SetProperty( Toolkit::Button::Property::UNSELECTED_BACKGROUND_VISUAL, BUTTON_ICON ); + switchButton.SetProperty( Toolkit::Button::Property::SELECTED_BACKGROUND_VISUAL, BUTTON_ICON_SELECTED ); switchButton.ClickedSignal().Connect( this, &ImageViewUrlApp::OnButtonClicked ); toolBar.AddControl( switchButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalRight, DemoHelper::DEFAULT_MODE_SWITCH_PADDING ); - CreateRenderTask( ); + std::string url = mUrl; + if( url.empty() ) + { + url = BIG_TEST_IMAGE; + } + + CreateRenderTask( url ); CreateScene( ); } - void CreateRenderTask() + void CreateRenderTask( const std::string& url ) { auto rootActor = Stage::GetCurrent().GetRootLayer(); auto cameraActor = CameraActor::New(TARGET_SIZE); - cameraActor.SetParentOrigin(ParentOrigin::CENTER); + cameraActor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER); cameraActor.SetInvertYAxis(true); rootActor.Add(cameraActor); { // create actor to render input with applied shader - mActorForInput = Toolkit::ImageView::New(BIG_TEST_IMAGE); - mActorForInput.SetParentOrigin(ParentOrigin::CENTER); - mActorForInput.SetSize(TARGET_SIZE); + mActorForInput = Toolkit::ImageView::New( url ); + mActorForInput.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER); + mActorForInput.SetProperty( Actor::Property::SIZE, TARGET_SIZE); Property::Map customShader; customShader[Toolkit::Visual::Shader::Property::FRAGMENT_SHADER] = FILTER_FRAGMENT_SOURCE; Property::Map visualMap; - visualMap.Insert(Toolkit::DevelVisual::Property::SHADER, customShader); + visualMap.Insert(Toolkit::Visual::Property::SHADER, customShader); mActorForInput.SetProperty(Toolkit::ImageView::Property::IMAGE, visualMap); mDeltaPropertyIndex = mActorForInput.RegisterProperty(DELTA_UNIFORM_NAME, 0.f); @@ -139,7 +145,7 @@ private: Pixel::RGB888, unsigned(TARGET_SIZE.width), unsigned(TARGET_SIZE.height)); - auto framebuffer = FrameBuffer::New(TARGET_SIZE.width, TARGET_SIZE.height, Pixel::RGB888); + auto framebuffer = FrameBuffer::New(TARGET_SIZE.width, TARGET_SIZE.height, FrameBuffer::Attachment::NONE ); framebuffer.AttachColorTexture(mOutputTexture); renderTask.SetFrameBuffer(framebuffer); @@ -160,8 +166,8 @@ private: auto url = Dali::Toolkit::TextureManager::AddTexture(mOutputTexture); mImageView = Toolkit::ImageView::New(url); - mImageView.SetParentOrigin(ParentOrigin::CENTER); - mImageView.SetAnchorPoint(AnchorPoint::CENTER); + mImageView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER); + mImageView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::CENTER); mContent.Add(mImageView); } @@ -191,6 +197,7 @@ private: private: Application& mApplication; + std::string mUrl; Layer mContent; Toolkit::ImageView mImageView; Animation mAnimation; @@ -199,20 +206,17 @@ private: Texture mOutputTexture; }; -void RunTest( Application& application ) -{ - ImageViewUrlApp 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 ); - RunTest( application ); + std::string url; + if( argc > 1 ) + { + url = argv[1]; + } + ImageViewUrlApp test( application, url ); + application.MainLoop(); return 0; }