X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=examples%2Frefraction-effect%2Frefraction-effect-example.cpp;h=14c4878c7fda7d416302f39da40367045f8fbc21;hb=6fe7d8ae1f183af0c9c0b9bdd1ee7a15b9f9a3b3;hp=189a7c79c349adade3b3a30d2248a7fa3532dba7;hpb=8703f6e3f98f81e8d500d8c494a6ef50374b3162;p=platform%2Fcore%2Fuifw%2Fdali-demo.git diff --git a/examples/refraction-effect/refraction-effect-example.cpp b/examples/refraction-effect/refraction-effect-example.cpp index 189a7c7..14c4878 100644 --- a/examples/refraction-effect/refraction-effect-example.cpp +++ b/examples/refraction-effect/refraction-effect-example.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 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. @@ -17,8 +17,8 @@ // EXTERNAL INCLUDES #include -#include #include +#include #include #include @@ -26,6 +26,7 @@ // INTERNAL INCLUDES #include "shared/view.h" +#include "shared/utility.h" using namespace Dali; @@ -74,19 +75,6 @@ struct LightOffsetConstraint }; /** - * @brief Load an image, scaled-down to no more than the stage dimensions. - * - * Uses image scaling mode SCALE_TO_FILL to resize the image at - * load time to cover the entire stage with pixels with no borders, - * and filter mode BOX_THEN_LINEAR to sample the image with maximum quality. - */ -ResourceImage LoadStageFillingImage( const char * const imagePath ) -{ - Size stageSize = Stage::GetCurrent().GetSize(); - return ResourceImage::New( imagePath, ImageDimensions( stageSize.x, stageSize.y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR ); -} - -/** * structure of the vertex in the mesh */ struct Vertex @@ -223,6 +211,21 @@ class RefractionEffectExample : public ConnectionTracker public: RefractionEffectExample( Application &application ) : mApplication( application ), + mContent(), + mTextureSet(), + mGeometry(), + mRenderer(), + mMeshActor(), + mShaderFlat(), + mShaderRefraction(), + mLightAnimation(), + mStrenghAnimation(), + mLightXYOffsetIndex( Property::INVALID_INDEX ), + mSpinAngleIndex( Property::INVALID_INDEX ), + mLightIntensityIndex( Property::INVALID_INDEX ), + mEffectStrengthIndex( Property::INVALID_INDEX ), + mChangeTextureButton(), + mChangeMeshButton(), mCurrentTextureId( 1 ), mCurrentMeshId( 0 ) { @@ -257,8 +260,8 @@ private: // Add a button to change background. (right of toolbar) mChangeTextureButton = Toolkit::PushButton::New(); - mChangeTextureButton.SetUnselectedImage( CHANGE_TEXTURE_ICON ); - mChangeTextureButton.SetSelectedImage( CHANGE_TEXTURE_ICON_SELECTED ); + mChangeTextureButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, CHANGE_TEXTURE_ICON ); + mChangeTextureButton.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, CHANGE_TEXTURE_ICON_SELECTED ); mChangeTextureButton.ClickedSignal().Connect( this, &RefractionEffectExample::OnChangeTexture ); toolBar.AddControl( mChangeTextureButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, @@ -266,8 +269,8 @@ private: DemoHelper::DEFAULT_MODE_SWITCH_PADDING ); // Add a button to change mesh pattern. ( left of bar ) mChangeMeshButton = Toolkit::PushButton::New(); - mChangeMeshButton.SetUnselectedImage( CHANGE_MESH_ICON ); - mChangeMeshButton.SetSelectedImage( CHANGE_MESH_ICON_SELECTED ); + mChangeMeshButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, CHANGE_MESH_ICON ); + mChangeMeshButton.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, CHANGE_MESH_ICON_SELECTED ); mChangeMeshButton.ClickedSignal().Connect( this, &RefractionEffectExample::OnChangeMesh ); toolBar.AddControl( mChangeMeshButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, @@ -280,9 +283,9 @@ private: mShaderFlat = Shader::New( VERTEX_SHADER_FLAT, FRAGMENT_SHADER_FLAT ); mGeometry = CreateGeometry( MESH_FILES[mCurrentMeshId] ); - Image texture = LoadStageFillingImage( TEXTURE_IMAGES[mCurrentTextureId] ); + Texture texture = DemoHelper::LoadStageFillingTexture( TEXTURE_IMAGES[mCurrentTextureId] ); mTextureSet = TextureSet::New(); - mTextureSet.SetImage( 0u, texture ); + mTextureSet.SetTexture( 0u, texture ); mRenderer = Renderer::New( mGeometry, mShaderFlat ); mRenderer.SetTextures( mTextureSet ); @@ -343,8 +346,8 @@ private: bool OnChangeTexture( Toolkit::Button button ) { mCurrentTextureId = ( mCurrentTextureId + 1 ) % NUM_TEXTURE_IMAGES; - Image texture = LoadStageFillingImage( TEXTURE_IMAGES[mCurrentTextureId] ); - mTextureSet.SetImage( 0u, texture ); + Texture texture = DemoHelper::LoadStageFillingTexture( TEXTURE_IMAGES[mCurrentTextureId] ); + mTextureSet.SetTexture( 0u, texture ); return true; } @@ -585,20 +588,10 @@ private: /*****************************************************************************/ -static void -RunTest(Application& app) -{ - RefractionEffectExample theApp(app); - app.MainLoop(); -} - -/*****************************************************************************/ - int DALI_EXPORT_API main(int argc, char **argv) { Application app = Application::New(&argc, &argv, DEMO_THEME_PATH); - - RunTest(app); - + RefractionEffectExample theApp(app); + app.MainLoop(); return 0; }