(ArcVisual) Add code to update properties
[platform/core/uifw/dali-demo.git] / examples / effects-view / effects-view-example.cpp
index e4c0373..597bd40 100644 (file)
@@ -1,18 +1,19 @@
-//
-// Copyright (c) 2017 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.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://floralicense.org/license/
-//
-// 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.
-//
+/*
+ * 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.
+ * 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.
+ *
+ */
 
 // EXTERNAL INCLUDES
 
@@ -21,7 +22,6 @@
 
 #include <dali/dali.h>
 #include <dali-toolkit/dali-toolkit.h>
-#include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
 #include <dali-toolkit/devel-api/controls/effects-view/effects-view.h>
 #include <sstream>
 
@@ -132,23 +132,23 @@ void EffectsViewApp::OnAppInitialize( Application& application )
 
   // Creates view change button.
   Toolkit::PushButton viewButton = Toolkit::PushButton::New();
-  viewButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, VIEW_SWAP_IMAGE );
-  viewButton.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, VIEW_SWAP_SELECTED_IMAGE );
+  viewButton.SetProperty( Toolkit::Button::Property::UNSELECTED_BACKGROUND_VISUAL, VIEW_SWAP_IMAGE );
+  viewButton.SetProperty( Toolkit::Button::Property::SELECTED_BACKGROUND_VISUAL, VIEW_SWAP_SELECTED_IMAGE );
   // Connects the view change button clicked signal to the OnView method.
   viewButton.ClickedSignal().Connect( this, &EffectsViewApp::ChangeEffectSize );
   mToolBar.AddControl( viewButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalRight, DemoHelper::DEFAULT_MODE_SWITCH_PADDING  );
 
   Vector2 effectsViewSize( mStageSize.width, mStageSize.height * 0.25f );
   mDropShadowView = CreateEffectsView( EffectsView::DROP_SHADOW, effectsViewSize, mEffectSize );
-  mDropShadowView.SetParentOrigin( ParentOrigin::CENTER );
-  mDropShadowView.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER );
-  mDropShadowView.SetZ( -mStageSize.height * 0.1f );
+  mDropShadowView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+  mDropShadowView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_CENTER );
+  mDropShadowView.SetProperty( Actor::Property::POSITION_Z,  -mStageSize.height * 0.1f );
   mContents.Add( mDropShadowView );
 
   mEmbossView = CreateEffectsView( EffectsView::EMBOSS, effectsViewSize, mEffectSize );
-  mEmbossView.SetParentOrigin( ParentOrigin::CENTER );
-  mEmbossView.SetAnchorPoint( AnchorPoint::TOP_CENTER );
-  mEmbossView.SetZ( mStageSize.height * 0.1f );
+  mEmbossView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+  mEmbossView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER );
+  mEmbossView.SetProperty( Actor::Property::POSITION_Z,  mStageSize.height * 0.1f );
   mContents.Add( mEmbossView );
 
   SetTitle( mEffectSize );
@@ -159,7 +159,7 @@ EffectsView EffectsViewApp::CreateEffectsView( EffectsView::EffectType type, con
 {
   Toolkit::EffectsView effectsView = Toolkit::EffectsView::New(type);
   // set control size
-   effectsView.SetSize( viewSize.width, viewSize.height );
+   effectsView.SetProperty( Actor::Property::SIZE, Vector2( viewSize.width, viewSize.height ) );
   // set effect size property
   effectsView.SetProperty( EffectsView::Property::EFFECT_SIZE, effectSize );
 
@@ -167,19 +167,19 @@ EffectsView EffectsViewApp::CreateEffectsView( EffectsView::EffectType type, con
   // text
   std::string text = ( type == EffectsView::DROP_SHADOW) ? "Drop Shadow" : "Emboss";
   TextLabel textActor( TextLabel::New( text ) );
-  textActor.SetParentOrigin( ParentOrigin::CENTER_LEFT );
-  textActor.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
-  textActor.SetSize( viewSize );
-  textActor.SetPosition( viewSize.width*0.4f, viewSize.height*0.3f );
+  textActor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
+  textActor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
+  textActor.SetProperty( Actor::Property::SIZE, viewSize );
+  textActor.SetProperty( Actor::Property::POSITION, Vector2( viewSize.width*0.4f, viewSize.height*0.3f ));
   textActor.SetProperty(  TextLabel::Property::POINT_SIZE, DemoHelper::ScalePointSize(14.f) );
   effectsView.Add( textActor );
 
   // image
   ImageView icon = ImageView::New( TEST_IMAGE );
-  icon.SetParentOrigin( ParentOrigin::CENTER_LEFT );
-  icon.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
-  icon.SetX( viewSize.width*0.1f );
-  icon.SetSize( viewSize.height*0.8f, viewSize.height*0.8f );
+  icon.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
+  icon.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
+  icon.SetProperty( Actor::Property::POSITION_X,  viewSize.width*0.1f );
+  icon.SetProperty( Actor::Property::SIZE, Vector2( viewSize.height*0.8f, viewSize.height*0.8f ) );
   effectsView.Add( icon );
 
   AnimateEffectProperties( effectsView );
@@ -245,20 +245,10 @@ void EffectsViewApp::OnKeyEvent(const KeyEvent& event)
 
 /*****************************************************************************/
 
-static void RunTest( Application& application )
-{
-  EffectsViewApp test( application );
-
-  application.MainLoop();
-}
-
-/*****************************************************************************/
-
 int DALI_EXPORT_API main(int argc, char **argv)
 {
   Application application = Application::New(&argc, &argv, DEMO_THEME_PATH);
-
-  RunTest(application);
-
+  EffectsViewApp test( application );
+  application.MainLoop();
   return 0;
 }