Size negotiation patch 3: Scope size negotiation enums
[platform/core/uifw/dali-demo.git] / examples / builder / examples.cpp
index 9bb3319..5578d7c 100644 (file)
 #include <fstream>
 #include <streambuf>
 #include <sstream>
-#include <boost/scoped_ptr.hpp>
 #include <dirent.h>
 #include <stdio.h>
+#include <iostream>
 
-//#include <boost/regex.hpp>
 #include "sys/stat.h"
 #include <ctime>
 
 #include <dali/integration-api/debug.h>
-#include "../shared/view.h"
+#include "shared/view.h"
 
 #define TOKEN_STRING(x) #x
 
@@ -60,7 +59,7 @@ std::string JSON_BROKEN("                                      \
   'stage':                                                     \
   [                                                            \
     {                                                          \
-      'type':'TextView',                                       \
+      'type':'TextLabel',                                      \
       'size': [50,50,1],                                       \
       'parent-origin': 'CENTER',                               \
       'text':'COULD NOT LOAD JSON FILE'                        \
@@ -242,7 +241,14 @@ public:
 
   void SetTitle(const std::string& title)
   {
-    // TODO
+    if(!mTitleActor)
+    {
+      mTitleActor = DemoHelper::CreateToolBarLabel( "" );
+      // Add title to the tool bar.
+      mToolBar.AddControl( mTitleActor, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarTitlePercentage, Alignment::HorizontalCenter );
+    }
+
+    mTitleActor.SetProperty( TextLabel::Property::TEXT, title );
   }
 
   bool OnToolSelectLayout( Toolkit::Button button )
@@ -270,6 +276,9 @@ public:
   {
     Stage stage = Stage::GetCurrent();
 
+    mTapDetector = TapGestureDetector::New();
+    mTapDetector.DetectedSignal().Connect( this, &ExampleApp::OnTap );
+
     if( mItemView )
     {
       stage.Remove( mItemView );
@@ -278,6 +287,7 @@ public:
     mFiles.clear();
 
     mItemView = ItemView::New(*this);
+    mItemView.SetRelayoutEnabled( false );
     stage.Add( mItemView );
     mItemView.SetParentOrigin(ParentOrigin::CENTER);
     mItemView.SetAnchorPoint(AnchorPoint::CENTER);
@@ -351,15 +361,6 @@ public:
       }
     }
 
-    mTapDetector = TapGestureDetector::New();
-
-    for( unsigned int i = 0u; i < mItemView.GetChildCount(); ++i )
-    {
-      mTapDetector.Attach( mItemView.GetChildAt(i) );
-    }
-
-    mTapDetector.DetectedSignal().Connect( this, &ExampleApp::OnTap );
-
     // Display item view on the stage
     stage.Add( mItemView );
 
@@ -392,7 +393,14 @@ public:
 
   Actor MenuItem(const std::string& text)
   {
-    return Actor();
+    TextLabel label = TextLabel::New( ShortName( text ) );
+    label.SetProperty( Dali::Toolkit::Control::Property::STYLE_NAME, "builderlabel" );
+    label.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
+
+    // Hook up tap detector
+    mTapDetector.Attach( label );
+
+    return label;
   }
 
   bool OnTimer()
@@ -462,6 +470,8 @@ public:
 
     builder.AddActors( layer );
 
+    // Force relayout on layer
+    layer.RelayoutRequestTree();
   }
 
 
@@ -494,6 +504,8 @@ public:
 
   void Create(Application& app)
   {
+    DemoHelper::RequestThemeChange();
+
     Stage stage = Stage::GetCurrent();
 
     Stage::GetCurrent().KeyEventSignal().Connect(this, &ExampleApp::OnKeyEvent);
@@ -513,7 +525,7 @@ public:
 
     // Create an edit mode button. (left of toolbar)
     Toolkit::PushButton editButton = Toolkit::PushButton::New();
-    editButton.SetBackgroundImage( Image::New( EDIT_IMAGE ) );
+    editButton.SetBackgroundImage( ResourceImage::New( EDIT_IMAGE ) );
     editButton.ClickedSignal().Connect( this, &ExampleApp::OnToolSelectLayout);
     editButton.SetLeaveRequired( true );
     mToolBar.AddControl( editButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalLeft, DemoHelper::DEFAULT_MODE_SWITCH_PADDING  );
@@ -583,6 +595,7 @@ private:
   unsigned int mOrientation;
 
   Toolkit::ToolBar mToolBar;
+  TextLabel mTitleActor;             ///< The Toolbar's Title.
 
   Layer mBuilderLayer;