Merge remote-tracking branch 'origin/tizen' into devel/new_mesh
[platform/core/uifw/dali-demo.git] / examples / text-label-multi-language / text-label-multi-language-example.cpp
index 27c5422..61af222 100644 (file)
  * @brief Basic usage of TextLabel control
  */
 
-// INTERNAL INCLUDES
-#include "vertical-layout.h"
-#include "shared/multi-language-strings.h"
-
 // EXTERNAL INCLUDES
 #include <dali-toolkit/dali-toolkit.h>
-#include <dali/public-api/text-abstraction/text-abstraction.h>
+
+// INTERNAL INCLUDES
+#include "shared/multi-language-strings.h"
+#include "shared/view.h"
 
 using namespace Dali;
 using namespace Dali::Toolkit;
@@ -60,34 +59,29 @@ public:
     Stage stage = Stage::GetCurrent();
 
     stage.KeyEventSignal().Connect(this, &TextLabelMultiLanguageExample::OnKeyEvent);
+    stage.SetBackgroundColor( Color::WHITE );
 
-    mLayout = VerticalLayout::New();
-    mLayout.SetParentOrigin( ParentOrigin::TOP_LEFT );
-    mLayout.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-
-    stage.Add( mLayout );
+    mTableView = Toolkit::TableView::New( NUMBER_OF_LANGUAGES, 1 );
+    mTableView.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
+    mTableView.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT );
+    mTableView.SetParentOrigin( ParentOrigin::TOP_LEFT );
+    mTableView.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+    mTableView.TouchedSignal().Connect( this, &TextLabelMultiLanguageExample::OnTouchEvent );
+    stage.Add( mTableView );
 
     for( unsigned int index = 0u; index < NUMBER_OF_LANGUAGES; ++index )
     {
       const Language& language = LANGUAGES[index];
 
       TextLabel label = TextLabel::New();
-      label.SetParentOrigin( ParentOrigin::TOP_CENTER );
-      label.SetAnchorPoint( AnchorPoint::TOP_CENTER );
-
       label.SetProperty( TextLabel::Property::MULTI_LINE, true );
 
       const std::string text = language.languageName + " " + language.languageRomanName + " " + language.text;
-
       label.SetProperty( TextLabel::Property::TEXT, text );
-      mLayout.AddLabel( label );
 
-      mLayout.TouchedSignal().Connect( this, &TextLabelMultiLanguageExample::OnTouchEvent );
+      mTableView.SetFitHeight( index );
+      mTableView.AddChild( label, Toolkit::TableView::CellPosition( index, 0 ) );
     }
-
-    const Vector2& size = Stage::GetCurrent().GetSize();
-    const float height = mLayout.GetHeightForWidth( size.width );
-    mLayout.SetSize( Size( size.width, height ) );
   }
 
   bool OnTouchEvent( Actor actor, const TouchEvent& event )
@@ -108,7 +102,7 @@ public:
       {
         if( mAnimation )
         {
-          mAnimation.MoveBy( mLayout, Vector3( 0.f, localPoint - mLastPoint, 0.f ), AlphaFunctions::Linear );
+          mAnimation.AnimateBy( Property(mTableView, Actor::Property::POSITION), Vector3( 0.f, localPoint - mLastPoint, 0.f ), AlphaFunction::LINEAR );
           mAnimation.Play();
           mLastPoint = localPoint;
         }
@@ -135,7 +129,7 @@ public:
 private:
 
   Application&   mApplication;
-  VerticalLayout mLayout;
+  TableView      mTableView;
   Animation      mAnimation;
   float          mLastPoint;
 };
@@ -150,7 +144,7 @@ void RunTest( Application& application )
 /** Entry point for Linux & Tizen applications */
 int main( int argc, char **argv )
 {
-  Application application = Application::New( &argc, &argv );
+  Application application = Application::New( &argc, &argv, DALI_DEMO_THEME_PATH );
 
   RunTest( application );