//
//------------------------------------------------------------------------------
-#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>
#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 <cstring>
#include <dali/integration-api/debug.h>
-#include "../shared/view.h"
+#include "shared/view.h"
#define TOKEN_STRING(x) #x
{
const char* BACKGROUND_IMAGE( "" );
-const char* TOOLBAR_IMAGE( DALI_IMAGE_DIR "top-bar.png" );
-const char* EDIT_IMAGE( DALI_IMAGE_DIR "icon-change.png" );
+const char* TOOLBAR_IMAGE( DEMO_IMAGE_DIR "top-bar.png" );
+const char* EDIT_IMAGE( DEMO_IMAGE_DIR "icon-change.png" );
+const char* EDIT_IMAGE_SELECTED( DEMO_IMAGE_DIR "icon-change-selected.png" );
std::string USER_DIRECTORY;
'stage': \
[ \
{ \
- 'type':'TextView', \
+ 'type':'TextLabel', \
'size': [50,50,1], \
- 'parent-origin': 'CENTER', \
+ 'parentOrigin': 'CENTER', \
'text':'COULD NOT LOAD JSON FILE' \
} \
] \
}
}
-static Vector3 SetItemSize(unsigned int numberOfColumns, float layoutWidth, float sideMargin, float columnSpacing)
-{
- return Vector3(layoutWidth, 50, 1);
-}
-
//------------------------------------------------------------------------------
//
//
{
if(!mTitleActor)
{
- mTitleActor = TextView::New();
+ mTitleActor = DemoHelper::CreateToolBarLabel( "" );
// Add title to the tool bar.
mToolBar.AddControl( mTitleActor, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarTitlePercentage, Alignment::HorizontalCenter );
}
- Font font = Font::New();
- mTitleActor.SetText( title );
- mTitleActor.SetSize( font.MeasureText( title ) );
- mTitleActor.SetStyleToCurrentText(DemoHelper::GetDefaultTextStyle());
+ mTitleActor.SetProperty( TextLabel::Property::TEXT, title );
}
bool OnToolSelectLayout( Toolkit::Button button )
void EnterSelection()
{
Stage stage = Stage::GetCurrent();
+ stage.SetBackgroundColor( Color::WHITE );
+
+ mTapDetector = TapGestureDetector::New();
+ mTapDetector.DetectedSignal().Connect( this, &ExampleApp::OnTap );
if( mItemView )
{
stage.Add( mItemView );
mItemView.SetParentOrigin(ParentOrigin::CENTER);
mItemView.SetAnchorPoint(AnchorPoint::CENTER);
- mGridLayout = GridLayout::New();
- mGridLayout->SetNumberOfColumns(1);
-
- mGridLayout->SetItemSizeFunction(SetItemSize);
+ mLayout = DefaultItemLayout::New( DefaultItemLayout::LIST );
- mGridLayout->SetTopMargin(DemoHelper::DEFAULT_VIEW_STYLE.mToolBarHeight);
+ mLayout->SetItemSize( Vector3( stage.GetSize().width, 50, 1 ) );
- mItemView.AddLayout(*mGridLayout);
+ mItemView.AddLayout( *mLayout );
- Vector3 size(stage.GetSize());
- mItemView.ActivateLayout(0, size, 0.0f/*immediate*/);
mItemView.SetKeyboardFocusable( true );
mFiles.clear();
}
else
{
- DirectoryFilesByType( DALI_SCRIPT_DIR, "json", files );
+ DirectoryFilesByType( DEMO_SCRIPT_DIR, "json", files );
}
std::sort(files.begin(), files.end());
}
}
- 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 );
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()
SetTitle("View");
}
- void OnTap( Actor actor, TapGesture tap )
+ void OnTap( Actor actor, const TapGesture& tap )
{
ItemId id = mItemView.GetItemId( actor );
Actor MenuItem(const std::string& text)
{
- TextView t = TextView::New();
- t.SetMarkupProcessingEnabled(true);
- t.SetText( std::string("<font size=6>") + ShortName( text ) + std::string("</font>") );
- t.SetTextAlignment( Alignment::HorizontalLeft );
- return t;
+ TextLabel label = TextLabel::New( ShortName( text ) );
+ label.SetStyleName( "BuilderLabel" );
+ label.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
+
+ // Hook up tap detector
+ mTapDetector.Attach( label );
+
+ return label;
}
bool OnTimer()
Stage stage = Stage::GetCurrent();
builder = Builder::New();
+ builder.QuitSignal().Connect( this, &ExampleApp::OnBuilderQuit );
- PropertyValueMap defaultDirs;
- defaultDirs[ TOKEN_STRING(DALI_IMAGE_DIR) ] = DALI_IMAGE_DIR;
- defaultDirs[ TOKEN_STRING(DALI_MODEL_DIR) ] = DALI_MODEL_DIR;
- defaultDirs[ TOKEN_STRING(DALI_SCRIPT_DIR) ] = DALI_SCRIPT_DIR;
+ Property::Map defaultDirs;
+ defaultDirs[ TOKEN_STRING(DEMO_IMAGE_DIR) ] = DEMO_IMAGE_DIR;
+ defaultDirs[ TOKEN_STRING(DEMO_MODEL_DIR) ] = DEMO_MODEL_DIR;
+ defaultDirs[ TOKEN_STRING(DEMO_SCRIPT_DIR) ] = DEMO_SCRIPT_DIR;
builder.AddConstants( defaultDirs );
}
builder.AddActors( layer );
-
}
{
ReloadJsonFile( name, mBuilder, mBuilderLayer );
- // do this here as GetCurrentSize()
- mBuilderLayer.SetParentOrigin(ParentOrigin::CENTER);
- mBuilderLayer.SetAnchorPoint(AnchorPoint::CENTER);
+ mBuilderLayer.SetParentOrigin(ParentOrigin::BOTTOM_CENTER);
+ mBuilderLayer.SetAnchorPoint(AnchorPoint::BOTTOM_CENTER);
Dali::Vector3 size = Stage::GetCurrent().GetRootLayer().GetCurrentSize();
size.y -= DemoHelper::DEFAULT_VIEW_STYLE.mToolBarHeight;
mBuilderLayer.SetSize( size );
// Create an edit mode button. (left of toolbar)
Toolkit::PushButton editButton = Toolkit::PushButton::New();
- editButton.SetBackgroundImage( Image::New( EDIT_IMAGE ) );
+ editButton.SetUnselectedImage( EDIT_IMAGE );
+ editButton.SetSelectedImage( EDIT_IMAGE_SELECTED );
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 );
{
if( IsKey( event, Dali::DALI_KEY_ESCAPE) || IsKey( event, Dali::DALI_KEY_BACK) )
{
- mApp.Quit();
+ if ( mItemView.IsVisible() )
+ {
+ mApp.Quit();
+ }
+ else
+ {
+ EnterSelection();
+ }
}
}
}
+ /**
+ * Event handler when Builder wants to quit (we only want to close the shown json unless we're at the top-level)
+ */
+ void OnBuilderQuit()
+ {
+ if ( mItemView.IsVisible() )
+ {
+ mApp.Quit();
+ }
+ else
+ {
+ EnterSelection();
+ }
+ }
+
private:
Application& mApp;
- GridLayoutPtr mGridLayout;
+ ItemLayoutPtr mLayout;
ItemView mItemView;
- Toolkit::View mView;
+ Toolkit::Control mView;
unsigned int mOrientation;
Toolkit::ToolBar mToolBar;
- TextView mTitleActor; ///< The Toolbar's Title.
+ TextLabel mTitleActor; ///< The Toolbar's Title.
Layer mBuilderLayer;
//
//
//------------------------------------------------------------------------------
-int main(int argc, char **argv)
+int DALI_EXPORT_API main(int argc, char **argv)
{
if(argc > 2)
{
}
}
- Application app = Application::New(&argc, &argv);
+ Application app = Application::New(&argc, &argv, DEMO_THEME_PATH);
ExampleApp dali_app(app);