X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=examples%2Fbuilder%2Fexamples.cpp;h=fe2f88bac8d7b630e78ef91afd5ddd23a3bc8fcb;hb=d143329bbf55451e73772b589d2a7c3de401e4b0;hp=e00c11402ce51e3c541aaef8e9148aa046930b7c;hpb=8054811cf315080dc444dffe373d47c634cd3163;p=platform%2Fcore%2Fuifw%2Fdali-demo.git diff --git a/examples/builder/examples.cpp b/examples/builder/examples.cpp index e00c114..fe2f88b 100644 --- a/examples/builder/examples.cpp +++ b/examples/builder/examples.cpp @@ -20,11 +20,12 @@ // //------------------------------------------------------------------------------ -#include "dali.h" +#include #include -#include -#include -#include +#include +#include +#include +#include #include #include #include @@ -36,6 +37,7 @@ #include "sys/stat.h" #include +#include #include #include "shared/view.h" @@ -49,8 +51,9 @@ namespace { 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; @@ -61,7 +64,7 @@ std::string JSON_BROKEN(" \ { \ 'type':'TextLabel', \ 'size': [50,50,1], \ - 'parent-origin': 'CENTER', \ + 'parentOrigin': 'CENTER', \ 'text':'COULD NOT LOAD JSON FILE' \ } \ ] \ @@ -141,11 +144,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 +273,7 @@ public: void EnterSelection() { Stage stage = Stage::GetCurrent(); + stage.SetBackgroundColor( Color::WHITE ); mTapDetector = TapGestureDetector::New(); mTapDetector.DetectedSignal().Connect( this, &ExampleApp::OnTap ); @@ -287,21 +286,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(); @@ -313,7 +306,7 @@ public: } else { - DirectoryFilesByType( DALI_SCRIPT_DIR, "json", files ); + DirectoryFilesByType( DEMO_SCRIPT_DIR, "json", files ); } std::sort(files.begin(), files.end()); @@ -369,9 +362,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 +388,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 ); @@ -421,9 +414,9 @@ public: builder.QuitSignal().Connect( this, &ExampleApp::OnBuilderQuit ); Property::Map 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; + 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 ); @@ -469,9 +462,6 @@ public: } builder.AddActors( layer ); - - // Force relayout on layer - layer.RelayoutRequestTree(); } @@ -504,8 +494,6 @@ public: void Create(Application& app) { - DemoHelper::RequestThemeChange(); - Stage stage = Stage::GetCurrent(); Stage::GetCurrent().KeyEventSignal().Connect(this, &ExampleApp::OnKeyEvent); @@ -525,7 +513,8 @@ public: // Create an edit mode button. (left of toolbar) Toolkit::PushButton editButton = Toolkit::PushButton::New(); - editButton.SetBackgroundImage( ResourceImage::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 ); @@ -588,10 +577,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 +618,7 @@ int main(int argc, char **argv) } } - Application app = Application::New(&argc, &argv); + Application app = Application::New(&argc, &argv, DEMO_THEME_PATH); ExampleApp dali_app(app);