Merge branch 'devel/master' into tizen
[platform/core/uifw/dali-demo.git] / examples / text-field / text-field-example.cpp
index 70e7e7d..9451fdf 100644 (file)
@@ -25,7 +25,6 @@
 #include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
 #include <dali-toolkit/devel-api/controls/popup/popup.h>
 #include <iostream>
-#include <dali/public-api/events/touch-point.h>
 
 // INTERNAL INCLUDES
 #include "shared/multi-language-strings.h"
@@ -43,8 +42,6 @@ namespace
 
   const float BORDER_WIDTH = 4.0f;
 
-  const Vector3 POPUP_SIZE_FACTOR_TO_PARENT = Vector3( 0.0, 0.25, 0.0 );
-
 } // unnamed namespace
 
 /**
@@ -90,10 +87,6 @@ public:
     button.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, FOLDER_ICON_IMAGE );
     button.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, FOLDER_OPEN_ICON_IMAGE );
     button.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-    button.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
-    ImageDimensions imageSize = ResourceImage::GetImageSize( FOLDER_ICON_IMAGE );
-    button.SetSize( imageSize.GetWidth(), imageSize.GetHeight() );
-
     return button;
   }
 
@@ -107,7 +100,7 @@ public:
 
     // Launch a pop-up containing TextField
     mField = CreateTextField( stageSize, mButtonLabel );
-    mPopup = CreatePopup( stageSize.width * 0.8f );
+    mPopup = CreatePopup();
     mPopup.Add( mField );
     mPopup.OutsideTouchedSignal().Connect( this, &TextFieldExample::OnPopupOutsideTouched );
     stage.Add( mPopup );
@@ -132,14 +125,13 @@ public:
     return field;
   }
 
-  Popup CreatePopup( float width )
+  Popup CreatePopup()
   {
     Popup popup = Popup::New();
     popup.SetParentOrigin( ParentOrigin::CENTER );
     popup.SetAnchorPoint( AnchorPoint::CENTER );
-    popup.SetSize( width, 0.0f );
-    popup.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::HEIGHT );
-    popup.SetSizeModeFactor( POPUP_SIZE_FACTOR_TO_PARENT );
+    popup.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::WIDTH );
+    popup.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::HEIGHT );
     popup.TouchSignal().Connect( this, &TextFieldExample::OnPopupTouched );
 
     return popup;
@@ -152,7 +144,7 @@ public:
     {
       Property::Value text = mField.GetProperty( TextField::Property::TEXT );
       mButtonLabel = text.Get< std::string >();
-      mButton.SetLabelText( mButtonLabel );
+      mButton.SetProperty( Toolkit::Button::Property::LABEL, mButtonLabel );
     }
 
     // Hide & discard the pop-up
@@ -177,7 +169,7 @@ public:
           {
             Property::Value text = mField.GetProperty( TextField::Property::TEXT );
             mButtonLabel = text.Get< std::string >();
-            mButton.SetLabelText( mButtonLabel );
+            mButton.SetProperty( Toolkit::Button::Property::LABEL, mButtonLabel );
             mField.ClearKeyInputFocus();
           }
           break;
@@ -219,20 +211,11 @@ private:
   Popup mPopup;
 };
 
-void RunTest( Application& application )
-{
-  TextFieldExample test( application );
-
-  application.MainLoop();
-}
-
-/** Entry point for Linux & Tizen applications */
 int DALI_EXPORT_API main( int argc, char **argv )
 {
   // DALI_DEMO_THEME_PATH not passed to Application so TextField example uses default Toolkit style sheet.
   Application application = Application::New( &argc, &argv );
-
-  RunTest( application );
-
+  TextFieldExample test( application );
+  application.MainLoop();
   return 0;
 }