Revert "[Tizen] Update demo to use LinearLayout."
[platform/core/uifw/dali-demo.git] / examples / primitive-shapes / primitive-shapes-example.cpp
index 06e794a..29112a3 100644 (file)
@@ -1,6 +1,22 @@
+/*
+ * 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.
+ *
+ */
+
 #include <dali-toolkit/dali-toolkit.h>
-#include <dali/public-api/object/property-map.h>
-#include <dali-toolkit/public-api/controls/slider/slider.h>
+#include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
 
 using namespace Dali;
 using namespace Dali::Toolkit;
@@ -12,7 +28,7 @@ namespace
   {
     DEMO_IMAGE_DIR "sphere-button.png",
     DEMO_IMAGE_DIR "cone-button.png",
-    DEMO_IMAGE_DIR "conical-frustrum-button.png",
+    DEMO_IMAGE_DIR "conical-frustum-button.png",
     DEMO_IMAGE_DIR "cylinder-button.png",
     DEMO_IMAGE_DIR "cube-button.png",
     DEMO_IMAGE_DIR "bevelled-cube-button.png",
@@ -170,8 +186,8 @@ public:
       button.SetAnchorPoint( AnchorPoint::CENTER );
       button.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
       button.SetPadding( Padding( elementPadding, elementPadding, elementPadding, elementPadding ) );
-      button.SetProperty( Button::Property::UNSELECTED_STATE_IMAGE, Property::Value( BUTTON_IMAGE_URL[modelNumber] ) );
-      button.SetProperty( Button::Property::SELECTED_STATE_IMAGE, Property::Value( BUTTON_IMAGE_URL[modelNumber] ) );
+      button.SetProperty( DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, BUTTON_IMAGE_URL[modelNumber] );
+      button.SetProperty( DevelButton::Property::SELECTED_BACKGROUND_VISUAL,  BUTTON_IMAGE_URL[modelNumber] );
       button.RegisterProperty( "modelNumber", Property::Value( modelNumber ) );
       button.ClickedSignal().Connect( this, &PrimitiveShapesController::OnChangeShapeClicked );
 
@@ -335,8 +351,11 @@ public:
 
     //Visual map for model
     mVisualMap.Clear();
-    mVisualMap[ Visual::Property::TYPE           ] = Visual::PRIMITIVE;
+    mVisualMap[ Toolkit::Visual::Property::TYPE           ] = Visual::PRIMITIVE;
     mVisualMap[ PrimitiveVisual::Property::MIX_COLOR ] = mColor;
+    mVisualMap[ Visual::Property::TRANSFORM ] =
+        Property::Map().Add( Visual::Transform::Property::ORIGIN, Align::CENTER )
+                       .Add( Visual::Transform::Property::ANCHOR_POINT, Align::CENTER );
   }
 
   //Sets the 3D model to a sphere and modifies the sliders appropriately.
@@ -394,13 +413,13 @@ public:
     mShapeTitle.SetProperty( TextLabel::Property::TEXT, SHAPE_TITLE_PREFIX + "Cone" );
   }
 
-  //Sets the 3D model to a conical frustrum and modifies the sliders appropriately.
-  void LoadConicalFrustrum()
+  //Sets the 3D model to a conical frustum and modifies the sliders appropriately.
+  void LoadConicalFrustum()
   {
     InitialiseSlidersAndModel();
 
     //Set up specific visual properties.
-    mVisualMap[ PrimitiveVisual::Property::SHAPE               ] = PrimitiveVisual::Shape::CONICAL_FRUSTRUM;
+    mVisualMap[ PrimitiveVisual::Property::SHAPE               ] = PrimitiveVisual::Shape::CONICAL_FRUSTUM;
     mVisualMap[ PrimitiveVisual::Property::SCALE_TOP_RADIUS    ] = DEFAULT_SCALE_TOP_RADIUS;
     mVisualMap[ PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS ] = DEFAULT_SCALE_BOTTOM_RADIUS;
     mVisualMap[ PrimitiveVisual::Property::SCALE_HEIGHT        ] = DEFAULT_SCALE_HEIGHT;
@@ -420,7 +439,7 @@ public:
     mModel.SetProperty( Control::Property::BACKGROUND, Property::Value( mVisualMap ) );
 
     //Update title.
-    mShapeTitle.SetProperty( TextLabel::Property::TEXT, SHAPE_TITLE_PREFIX + "Conical Frustrum" );
+    mShapeTitle.SetProperty( TextLabel::Property::TEXT, SHAPE_TITLE_PREFIX + "Conical Frustum" );
   }
 
   //Sets the 3D model to a cylinder and modifies the sliders appropriately.
@@ -570,7 +589,7 @@ public:
       }
       case 2:
       {
-        LoadConicalFrustrum();
+        LoadConicalFrustum();
         break;
       }
       case 3:
@@ -687,20 +706,10 @@ private:
   Vector2                   mRotation;              ///< Keeps track of model rotation.
 };
 
-void RunTest( Application& application )
+int DALI_EXPORT_API main( int argc, char **argv )
 {
+  Application application = Application::New( &argc, &argv );
   PrimitiveShapesController test( application );
-
   application.MainLoop();
-}
-
-// Entry point for Linux & Tizen applications
-//
-int main( int argc, char **argv )
-{
-  Application application = Application::New( &argc, &argv );
-
-  RunTest( application );
-
   return 0;
 }