X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=examples%2Fbuilder%2Fexamples.cpp;h=79f50a17e64d87ee17efd7311235f2ccdc1b6d3e;hb=0727b27d000e0ce5968846b51a55311592f04655;hp=1c30aafa890a5a44ace391a68802afddb1ddfbbb;hpb=cbec58fd1bec862d96aa204625f276edc6696b9d;p=platform%2Fcore%2Fuifw%2Fdali-demo.git diff --git a/examples/builder/examples.cpp b/examples/builder/examples.cpp index 1c30aaf..79f50a1 100644 --- a/examples/builder/examples.cpp +++ b/examples/builder/examples.cpp @@ -20,26 +20,27 @@ // //------------------------------------------------------------------------------ -#include "dali.h" +#include #include -#include -#include -#include +#include +#include +#include +#include #include #include #include #include #include -#include #include #include +#include -//#include #include "sys/stat.h" #include +#include #include -#include "../shared/view.h" +#include "shared/view.h" #define TOKEN_STRING(x) #x @@ -60,7 +61,7 @@ std::string JSON_BROKEN(" \ 'stage': \ [ \ { \ - 'type':'TextView', \ + 'type':'TextLabel', \ 'size': [50,50,1], \ 'parent-origin': 'CENTER', \ 'text':'COULD NOT LOAD JSON FILE' \ @@ -142,11 +143,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); -} - //------------------------------------------------------------------------------ // // @@ -244,15 +240,12 @@ public: { 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 ) @@ -279,6 +272,10 @@ public: void EnterSelection() { Stage stage = Stage::GetCurrent(); + stage.SetBackgroundColor( Color::WHITE ); + + mTapDetector = TapGestureDetector::New(); + mTapDetector.DetectedSignal().Connect( this, &ExampleApp::OnTap ); if( mItemView ) { @@ -291,17 +288,12 @@ public: 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(); @@ -361,15 +353,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 ); @@ -378,9 +361,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() @@ -393,7 +376,7 @@ public: SetTitle("View"); } - void OnTap( Actor actor, TapGesture tap ) + void OnTap( Actor actor, const TapGesture& tap ) { ItemId id = mItemView.GetItemId( actor ); @@ -402,18 +385,14 @@ public: Actor MenuItem(const std::string& text) { - TextView t = TextView::New(); - t.SetMarkupProcessingEnabled(true); - - int size = static_cast(DemoHelper::ScalePointSize(6)); + TextLabel label = TextLabel::New( ShortName( text ) ); + label.SetProperty( Dali::Toolkit::Control::Property::STYLE_NAME, "builderlabel" ); + label.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); - std::ostringstream fontString; - fontString << ""<< ShortName( text ) << ""; + // Hook up tap detector + mTapDetector.Attach( label ); - t.SetText( fontString.str() ); - - t.SetTextAlignment( Alignment::HorizontalLeft ); - return t; + return label; } bool OnTimer() @@ -482,7 +461,6 @@ public: } builder.AddActors( layer ); - } @@ -534,7 +512,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 ); @@ -597,14 +575,14 @@ public: 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; @@ -638,7 +616,7 @@ int main(int argc, char **argv) } } - Application app = Application::New(&argc, &argv); + Application app = Application::New(&argc, &argv, DALI_DEMO_THEME_PATH); ExampleApp dali_app(app);