[dali_1.0.42] Merge branch 'tizen'
[platform/core/uifw/dali-demo.git] / examples / builder / examples.cpp
index e00c114..79f50a1 100644 (file)
 //
 //------------------------------------------------------------------------------
 
-#include "dali.h"
+#include <dali/dali.h>
 #include <dali-toolkit/dali-toolkit.h>
-#include <dali-toolkit/public-api/builder/builder.h>
-#include <dali-toolkit/public-api/builder/tree-node.h>
-#include <dali-toolkit/public-api/builder/json-parser.h>
+#include <dali-toolkit/devel-api/builder/builder.h>
+#include <dali-toolkit/devel-api/builder/tree-node.h>
+#include <dali-toolkit/devel-api/builder/json-parser.h>
+#include <dali-toolkit/devel-api/controls/popup/popup.h>
 #include <map>
 #include <string>
 #include <fstream>
@@ -36,6 +37,7 @@
 
 #include "sys/stat.h"
 #include <ctime>
+#include <cstring>
 
 #include <dali/integration-api/debug.h>
 #include "shared/view.h"
@@ -141,11 +143,6 @@ const std::string ShortName( const std::string& name )
   }
 }
 
-static Vector3 SetItemSize(unsigned int numberOfColumns, float layoutWidth, float sideMargin, float columnSpacing)
-{
-  return Vector3(layoutWidth, 50, 1);
-}
-
 //------------------------------------------------------------------------------
 //
 //
@@ -275,6 +272,7 @@ public:
   void EnterSelection()
   {
     Stage stage = Stage::GetCurrent();
+    stage.SetBackgroundColor( Color::WHITE );
 
     mTapDetector = TapGestureDetector::New();
     mTapDetector.DetectedSignal().Connect( this, &ExampleApp::OnTap );
@@ -287,21 +285,15 @@ public:
     mFiles.clear();
 
     mItemView = ItemView::New(*this);
-    mItemView.SetRelayoutEnabled( false );
     stage.Add( mItemView );
     mItemView.SetParentOrigin(ParentOrigin::CENTER);
     mItemView.SetAnchorPoint(AnchorPoint::CENTER);
-    mGridLayout = GridLayout::New();
-    mGridLayout->SetNumberOfColumns(1);
+    mLayout = DefaultItemLayout::New( DefaultItemLayout::LIST );
 
-    mGridLayout->SetItemSizeFunction(SetItemSize);
+    mLayout->SetItemSize( Vector3( stage.GetSize().width, 50, 1 ) );
 
-    mGridLayout->SetTopMargin(DemoHelper::DEFAULT_VIEW_STYLE.mToolBarHeight);
+    mItemView.AddLayout( *mLayout );
 
-    mItemView.AddLayout(*mGridLayout);
-
-    Vector3 size(stage.GetSize());
-    mItemView.ActivateLayout(0, size, 0.0f/*immediate*/);
     mItemView.SetKeyboardFocusable( true );
 
     mFiles.clear();
@@ -369,9 +361,9 @@ public:
 
     SetTitle("Select");
 
-    // Itemview renderes the previous items unless its scrolled. Not sure why at the moment so we force a scroll
-    mItemView.ScrollToItem(0, 0);
-
+    // Activate the layout
+    Vector3 size(stage.GetSize());
+    mItemView.ActivateLayout(0, size, 0.0f/*immediate*/);
   }
 
   void ExitSelection()
@@ -395,7 +387,7 @@ public:
   {
     TextLabel label = TextLabel::New( ShortName( text ) );
     label.SetProperty( Dali::Toolkit::Control::Property::STYLE_NAME, "builderlabel" );
-    label.SetResizePolicy( FILL_TO_PARENT, WIDTH );
+    label.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
 
     // Hook up tap detector
     mTapDetector.Attach( label );
@@ -469,9 +461,6 @@ public:
     }
 
     builder.AddActors( layer );
-
-    // Force relayout on layer
-    layer.RelayoutRequestTree();
   }
 
 
@@ -504,8 +493,6 @@ public:
 
   void Create(Application& app)
   {
-    DemoHelper::RequestThemeChange();
-
     Stage stage = Stage::GetCurrent();
 
     Stage::GetCurrent().KeyEventSignal().Connect(this, &ExampleApp::OnKeyEvent);
@@ -588,10 +575,10 @@ public:
 private:
   Application& mApp;
 
-  GridLayoutPtr mGridLayout;
+  ItemLayoutPtr mLayout;
   ItemView mItemView;
 
-  Toolkit::View mView;
+  Toolkit::Control mView;
   unsigned int mOrientation;
 
   Toolkit::ToolBar mToolBar;
@@ -629,7 +616,7 @@ int main(int argc, char **argv)
     }
   }
 
-  Application app = Application::New(&argc, &argv);
+  Application app = Application::New(&argc, &argv, DALI_DEMO_THEME_PATH);
 
   ExampleApp dali_app(app);