X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=examples%2Fitem-view%2Fitem-view-example.cpp;h=6172a73eb9553ffc0730a4190bddc0b86bb5e578;hb=67dd4af369a77aa7c0f3b55d3ffdff3ed73fb1ca;hp=f93aaec1555304a76b41f670f5dd336f593cd7b0;hpb=adf210149fc391c9176d667e43e8d8b5a429cb57;p=platform%2Fcore%2Fuifw%2Fdali-demo.git diff --git a/examples/item-view/item-view-example.cpp b/examples/item-view/item-view-example.cpp index f93aaec..6172a73 100644 --- a/examples/item-view/item-view-example.cpp +++ b/examples/item-view/item-view-example.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,8 @@ #include #include +#include +#include using namespace Dali; using namespace Dali::Toolkit; @@ -213,16 +215,16 @@ public: // Create an edit mode button. (left of toolbar) Toolkit::PushButton editButton = Toolkit::PushButton::New(); - editButton.SetUnselectedImage( EDIT_IMAGE ); - editButton.SetSelectedImage( EDIT_IMAGE_SELECTED ); + editButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, EDIT_IMAGE ); + editButton.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, EDIT_IMAGE_SELECTED ); editButton.ClickedSignal().Connect( this, &ItemViewExample::OnModeButtonClicked); editButton.SetLeaveRequired( true ); mToolBar.AddControl( editButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalLeft, DemoHelper::DEFAULT_MODE_SWITCH_PADDING ); // Create a layout toggle button. (right of toolbar) mLayoutButton = Toolkit::PushButton::New(); - mLayoutButton.SetUnselectedImage( SPIRAL_LAYOUT_IMAGE ); - mLayoutButton.SetSelectedImage(SPIRAL_LAYOUT_IMAGE_SELECTED ); + mLayoutButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, SPIRAL_LAYOUT_IMAGE ); + mLayoutButton.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, SPIRAL_LAYOUT_IMAGE_SELECTED ); mLayoutButton.ClickedSignal().Connect( this, &ItemViewExample::OnLayoutButtonClicked); mLayoutButton.SetLeaveRequired( true ); mToolBar.AddControl( mLayoutButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalRight, DemoHelper::DEFAULT_MODE_SWITCH_PADDING ); @@ -233,9 +235,9 @@ public: mDeleteButton.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT); mDeleteButton.SetPosition( BUTTON_BORDER, BUTTON_BORDER ); mDeleteButton.SetDrawMode( DrawMode::OVERLAY_2D ); - mDeleteButton.SetUnselectedImage( DELETE_IMAGE ); - mDeleteButton.SetSelectedImage( DELETE_IMAGE_SELECTED ); - mDeleteButton.SetBackgroundImage( TOOLBAR_IMAGE ); + mDeleteButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, DELETE_IMAGE ); + mDeleteButton.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, DELETE_IMAGE_SELECTED ); + mDeleteButton.SetProperty( Toolkit::Control::Property::BACKGROUND, TOOLBAR_IMAGE ); mDeleteButton.SetSize( Vector2( stageSize.width * 0.15f, stageSize.width * 0.15f ) ); mDeleteButton.ClickedSignal().Connect( this, &ItemViewExample::OnDeleteButtonClicked); mDeleteButton.SetLeaveRequired( true ); @@ -248,9 +250,9 @@ public: mInsertButton.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT); mInsertButton.SetPosition( BUTTON_BORDER, BUTTON_BORDER ); mInsertButton.SetDrawMode( DrawMode::OVERLAY_2D ); - mInsertButton.SetUnselectedImage( INSERT_IMAGE ); - mInsertButton.SetSelectedImage( INSERT_IMAGE_SELECTED ); - mInsertButton.SetBackgroundImage( TOOLBAR_IMAGE ); + mInsertButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, INSERT_IMAGE ); + mInsertButton.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, INSERT_IMAGE_SELECTED ); + mInsertButton.SetProperty( Toolkit::Control::Property::BACKGROUND, TOOLBAR_IMAGE ); mInsertButton.SetSize( stageSize.width * 0.15f, stageSize.width * 0.15f ); mInsertButton.ClickedSignal().Connect( this, &ItemViewExample::OnInsertButtonClicked); mInsertButton.SetLeaveRequired( true ); @@ -263,9 +265,9 @@ public: mReplaceButton.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT); mReplaceButton.SetPosition( BUTTON_BORDER, BUTTON_BORDER ); mReplaceButton.SetDrawMode( DrawMode::OVERLAY_2D ); - mReplaceButton.SetUnselectedImage( REPLACE_IMAGE ); - mReplaceButton.SetSelectedImage( REPLACE_IMAGE_SELECTED ); - mReplaceButton.SetBackgroundImage( TOOLBAR_IMAGE ); + mReplaceButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, REPLACE_IMAGE ); + mReplaceButton.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, REPLACE_IMAGE_SELECTED ); + mReplaceButton.SetProperty( Toolkit::Control::Property::BACKGROUND, TOOLBAR_IMAGE ); mReplaceButton.SetSize( stageSize.width * 0.15f, stageSize.width * 0.15f ); mReplaceButton.ClickedSignal().Connect( this, &ItemViewExample::OnReplaceButtonClicked); mReplaceButton.SetLeaveRequired( true ); @@ -821,22 +823,22 @@ public: { case SPIRAL_LAYOUT: { - mLayoutButton.SetUnselectedImage( SPIRAL_LAYOUT_IMAGE ); - mLayoutButton.SetSelectedImage( SPIRAL_LAYOUT_IMAGE_SELECTED ); + mLayoutButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, SPIRAL_LAYOUT_IMAGE ); + mLayoutButton.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, SPIRAL_LAYOUT_IMAGE_SELECTED ); break; } case GRID_LAYOUT: { - mLayoutButton.SetUnselectedImage( GRID_LAYOUT_IMAGE ); - mLayoutButton.SetSelectedImage( GRID_LAYOUT_IMAGE_SELECTED ); + mLayoutButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, GRID_LAYOUT_IMAGE ); + mLayoutButton.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, GRID_LAYOUT_IMAGE_SELECTED ); break; } case DEPTH_LAYOUT: { - mLayoutButton.SetUnselectedImage( DEPTH_LAYOUT_IMAGE ); - mLayoutButton.SetSelectedImage( DEPTH_LAYOUT_IMAGE_SELECTED ); + mLayoutButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, DEPTH_LAYOUT_IMAGE ); + mLayoutButton.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, DEPTH_LAYOUT_IMAGE_SELECTED ); break; } @@ -865,7 +867,12 @@ public: // From ItemFactory virtual Actor NewItem(unsigned int itemId) { // Create an image view for this item - ImageView actor = ImageView::New( IMAGE_PATHS[ itemId % NUM_IMAGES ] ); + Property::Map propertyMap; + propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE); + propertyMap.Insert(ImageVisual::Property::URL, IMAGE_PATHS[ itemId % NUM_IMAGES ] ); + propertyMap.Insert(DevelVisual::Property::VISUAL_FITTING_MODE, DevelVisual::FILL); + ImageView actor = ImageView::New(); + actor.SetProperty( Toolkit::ImageView::Property::IMAGE, propertyMap ); actor.SetZ( 0.0f ); actor.SetPosition( INITIAL_OFFSCREEN_POSITION ); @@ -878,7 +885,7 @@ public: // From ItemFactory borderActor.SetColorMode( USE_PARENT_COLOR ); Property::Map borderProperty; - borderProperty.Insert( Visual::Property::TYPE, Visual::BORDER ); + borderProperty.Insert( Toolkit::Visual::Property::TYPE, Visual::BORDER ); borderProperty.Insert( BorderVisual::Property::COLOR, Color::WHITE ); borderProperty.Insert( BorderVisual::Property::SIZE, ITEM_BORDER_SIZE ); borderProperty.Insert( BorderVisual::Property::ANTI_ALIASING, true ); @@ -902,7 +909,7 @@ public: // From ItemFactory checkbox.SetZ( 0.1f ); Property::Map solidColorProperty; - solidColorProperty.Insert( Visual::Property::TYPE, Visual::COLOR ); + solidColorProperty.Insert( Toolkit::Visual::Property::TYPE, Visual::COLOR ); solidColorProperty.Insert( ColorVisual::Property::MIX_COLOR, Vector4(0.f, 0.f, 0.f, 0.6f) ); checkbox.SetProperty( ImageView::Property::IMAGE, solidColorProperty ); @@ -993,18 +1000,10 @@ private: LongPressGestureDetector mLongPressDetector; }; -void RunTest(Application& app) -{ - ItemViewExample test(app); - - app.MainLoop(); -} - int DALI_EXPORT_API main(int argc, char **argv) { Application app = Application::New(&argc, &argv, DEMO_THEME_PATH); - - RunTest(app); - + ItemViewExample test(app); + app.MainLoop(); return 0; }