X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=examples%2Fflex-container%2Fflex-container-example.cpp;h=4da35ea5bd72bfb322b8b4960779bb321768fd76;hb=refs%2Fchanges%2F70%2F155570%2F1;hp=cd723510d25f64df4f3db7acf24cfc5fc39fdfe2;hpb=ffec0c80ba888cde46b6ce7ccc85c00137b221dd;p=platform%2Fcore%2Fuifw%2Fdali-demo.git diff --git a/examples/flex-container/flex-container-example.cpp b/examples/flex-container/flex-container-example.cpp index cd72351..4da35ea 100644 --- a/examples/flex-container/flex-container-example.cpp +++ b/examples/flex-container/flex-container-example.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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,7 +20,7 @@ #include #include -#include +#include using namespace Dali; using namespace Dali::Toolkit; @@ -138,8 +138,8 @@ public: // Create a flex direction toggle button. (left of toolbar) mFlexDirectionButton = Toolkit::PushButton::New(); mFlexDirectionButton.SetName("mFlexDirectionButton"); - mFlexDirectionButton.SetUnselectedImage( DEMO_IMAGE_DIR "icon-change.png" ); - mFlexDirectionButton.SetSelectedImage( DEMO_IMAGE_DIR "icon-change-selected.png" ); + mFlexDirectionButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, DEMO_IMAGE_DIR "icon-change.png" ); + mFlexDirectionButton.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, DEMO_IMAGE_DIR "icon-change-selected.png" ); mFlexDirectionButton.ClickedSignal().Connect( this, &FlexContainerExample::OnFlexDirectionButtonClicked); mFlexDirectionButton.SetLeaveRequired( true ); mToolBar.AddControl( mFlexDirectionButton, VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalLeft, DemoHelper::DEFAULT_MODE_SWITCH_PADDING ); @@ -147,8 +147,8 @@ public: // Create a flex wrap toggle button. (left of toolbar) mFlexWrapButton = Toolkit::PushButton::New(); mFlexWrapButton.SetName("mFlexWrapButton"); - mFlexWrapButton.SetUnselectedImage( DEMO_IMAGE_DIR "icon-edit.png" ); - mFlexWrapButton.SetSelectedImage( DEMO_IMAGE_DIR "icon-edit-selected.png" ); + mFlexWrapButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, DEMO_IMAGE_DIR "icon-edit.png" ); + mFlexWrapButton.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, DEMO_IMAGE_DIR "icon-edit-selected.png" ); mFlexWrapButton.ClickedSignal().Connect( this, &FlexContainerExample::OnFlexWrapButtonClicked); mFlexWrapButton.SetLeaveRequired( true ); mToolBar.AddControl( mFlexWrapButton, VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalLeft, DemoHelper::DEFAULT_MODE_SWITCH_PADDING ); @@ -156,8 +156,8 @@ public: // Create a content direction toggle button. (left of toolbar) mContentDirectionButton = Toolkit::PushButton::New(); mContentDirectionButton.SetName("mContentDirectionButton"); - mContentDirectionButton.SetUnselectedImage( DEMO_IMAGE_DIR "icon-replace.png" ); - mContentDirectionButton.SetSelectedImage( DEMO_IMAGE_DIR "icon-replace-selected.png" ); + mContentDirectionButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, DEMO_IMAGE_DIR "icon-replace.png" ); + mContentDirectionButton.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, DEMO_IMAGE_DIR "icon-replace-selected.png" ); mContentDirectionButton.ClickedSignal().Connect( this, &FlexContainerExample::OnContentDirectionButtonClicked); mContentDirectionButton.SetLeaveRequired( true ); mToolBar.AddControl( mContentDirectionButton, VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalLeft, DemoHelper::DEFAULT_MODE_SWITCH_PADDING ); @@ -165,8 +165,8 @@ public: // Create a justify content toggle button. (right of toolbar) mJustifyContentButton = Toolkit::PushButton::New(); mJustifyContentButton.SetName("mJustifyContentButton"); - mJustifyContentButton.SetUnselectedImage( DEMO_IMAGE_DIR "icon-reset.png" ); - mJustifyContentButton.SetSelectedImage( DEMO_IMAGE_DIR "icon-reset-selected.png" ); + mJustifyContentButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, DEMO_IMAGE_DIR "icon-reset.png" ); + mJustifyContentButton.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, DEMO_IMAGE_DIR "icon-reset-selected.png" ); mJustifyContentButton.ClickedSignal().Connect( this, &FlexContainerExample::OnJustifyContentButtonClicked); mJustifyContentButton.SetLeaveRequired( true ); mToolBar.AddControl( mJustifyContentButton, VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalRight, DemoHelper::DEFAULT_MODE_SWITCH_PADDING ); @@ -174,8 +174,8 @@ public: // Create a align items toggle button. (right of toolbar) mAlignItemsButton = Toolkit::PushButton::New(); mAlignItemsButton.SetName("mAlignItemsButton"); - mAlignItemsButton.SetUnselectedImage( DEMO_IMAGE_DIR "icon-highp.png" ); - mAlignItemsButton.SetSelectedImage( DEMO_IMAGE_DIR "icon-highp-selected.png" ); + mAlignItemsButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, DEMO_IMAGE_DIR "icon-highp.png" ); + mAlignItemsButton.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, DEMO_IMAGE_DIR "icon-highp-selected.png" ); mAlignItemsButton.ClickedSignal().Connect( this, &FlexContainerExample::OnAlignItemsButtonClicked); mAlignItemsButton.SetLeaveRequired( true ); mToolBar.AddControl( mAlignItemsButton, VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalRight, DemoHelper::DEFAULT_MODE_SWITCH_PADDING ); @@ -183,8 +183,8 @@ public: // Create a align content toggle button. (right of toolbar) mAlignContentButton = Toolkit::PushButton::New(); mAlignContentButton.SetName("mAlignContentButton"); - mAlignContentButton.SetUnselectedImage( DEMO_IMAGE_DIR "icon-effect-cross.png" ); - mAlignContentButton.SetSelectedImage( DEMO_IMAGE_DIR "icon-effect-cross-selected.png" ); + mAlignContentButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, DEMO_IMAGE_DIR "icon-effect-cross.png" ); + mAlignContentButton.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, DEMO_IMAGE_DIR "icon-effect-cross-selected.png" ); mAlignContentButton.ClickedSignal().Connect( this, &FlexContainerExample::OnAlignContentButtonClicked); mAlignContentButton.SetLeaveRequired( true ); mToolBar.AddControl( mAlignContentButton, VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalRight, DemoHelper::DEFAULT_MODE_SWITCH_PADDING ); @@ -200,8 +200,8 @@ public: // Add a text label to the container for showing the recently updated flexbox property value mFlexPropertyLabel = TextLabel::New( FLEX_DIRECTION[mCurrentFlexDirection] ); - mFlexPropertyLabel.RegisterProperty("flexMargin", Vector4(10.0f, 10.0f, 10.0f, 10.0f), Property::READ_WRITE); - mFlexPropertyLabel.RegisterProperty("flex", 0.05f, Property::READ_WRITE); // 5 pecent of the container size in the main axis + mFlexPropertyLabel.SetProperty(FlexContainer::ChildProperty::FLEX_MARGIN, Vector4(10.0f, 10.0f, 10.0f, 10.0f)); + mFlexPropertyLabel.SetProperty(FlexContainer::ChildProperty::FLEX, 0.05f); // 5 pecent of the container size in the main axis mFlexPropertyLabel.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER"); mFlexPropertyLabel.SetProperty(TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER"); mFlexContainer.Add( mFlexPropertyLabel ); @@ -211,9 +211,9 @@ public: mFlexItemContainer.SetParentOrigin(ParentOrigin::TOP_LEFT); mFlexItemContainer.SetAnchorPoint(AnchorPoint::TOP_LEFT); mFlexItemContainer.SetBackgroundColor( Color::YELLOW ); - mFlexItemContainer.RegisterProperty("flex", 0.95f, Property::READ_WRITE); // 95 pecent of the container size in the main axis mFlexItemContainer.SetProperty(FlexContainer::Property::FLEX_DIRECTION, mCurrentFlexDirection); mFlexItemContainer.SetProperty(FlexContainer::Property::FLEX_WRAP, mCurrentFlexWrap); + mFlexItemContainer.SetProperty(FlexContainer::ChildProperty::FLEX, 0.95f); // 95 pecent of the container size in the main axis mFlexContainer.Add(mFlexItemContainer); // Create flex items and add them to the container @@ -225,13 +225,13 @@ public: // Set different background colour to help to identify different items flexItem.SetBackgroundColor(Vector4(static_cast(i) / NUM_FLEX_ITEMS, static_cast(NUM_FLEX_ITEMS - i) / NUM_FLEX_ITEMS, 1.0f, 1.0f)); - flexItem.SetUnselectedImage(""); - flexItem.SetSelectedImage(""); + flexItem.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, "" ); + flexItem.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, "" ); // Add a label to the button so that we can identify each item more easily std::ostringstream index; index << i + 1; - flexItem.SetLabelText(index.str()); + flexItem.SetProperty( Toolkit::Button::Property::LABEL, index.str() ); flexItem.SetName("FlexItem " + index.str()); // Set a fixed size to the items so that we can wrap the line and test these @@ -367,18 +367,10 @@ private: Toolkit::PushButton mAlignContentButton; }; -void RunTest(Application& app) -{ - FlexContainerExample test(app); - - app.MainLoop(); -} - int DALI_EXPORT_API main(int argc, char **argv) { Application app = Application::New(&argc, &argv, DEMO_THEME_PATH); - - RunTest(app); - + FlexContainerExample test(app); + app.MainLoop(); return 0; }