X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=examples%2Ftext-field%2Ftext-field-example.cpp;h=36fd1db91437eb0dbfb9f274820638c09d51c6fc;hb=a832af2813558a32f0a18747f3e6134ff6f6f301;hp=8b611b2916a5ec6e1e9aab0db7f34fe02c1fd934;hpb=24c8baf69f0196d4a9a6ad746b370d026532a585;p=platform%2Fcore%2Fuifw%2Fdali-demo.git diff --git a/examples/text-field/text-field-example.cpp b/examples/text-field/text-field-example.cpp index 8b611b2..36fd1db 100644 --- a/examples/text-field/text-field-example.cpp +++ b/examples/text-field/text-field-example.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 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. @@ -22,9 +22,9 @@ // EXTERNAL INCLUDES #include +#include #include #include -#include // INTERNAL INCLUDES #include "shared/multi-language-strings.h" @@ -42,8 +42,6 @@ namespace const float BORDER_WIDTH = 4.0f; - const Vector3 POPUP_SIZE_FACTOR_TO_PARENT = Vector3( 0.0, 0.25, 0.0 ); - } // unnamed namespace /** @@ -75,6 +73,9 @@ public: stage.SetBackgroundColor( Vector4( 0.04f, 0.345f, 0.392f, 1.0f ) ); stage.KeyEventSignal().Connect(this, &TextFieldExample::OnKeyEvent); + // Hide the indicator bar + application.GetWindow().ShowIndicator( Dali::Window::INVISIBLE ); + mButton = CreateFolderButton(); mButton.ClickedSignal().Connect( this, &TextFieldExample::OnButtonClicked ); stage.Add( mButton ); @@ -83,13 +84,9 @@ public: PushButton CreateFolderButton() { PushButton button = PushButton::New(); - button.SetUnselectedImage( FOLDER_ICON_IMAGE ); - button.SetSelectedImage( FOLDER_OPEN_ICON_IMAGE ); + button.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, FOLDER_ICON_IMAGE ); + button.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, FOLDER_OPEN_ICON_IMAGE ); button.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - button.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS ); - ResourceImage imageClosed = ResourceImage::New( FOLDER_ICON_IMAGE ); - button.SetSize( imageClosed.GetWidth(), imageClosed.GetHeight() ); - return button; } @@ -103,7 +100,7 @@ public: // Launch a pop-up containing TextField mField = CreateTextField( stageSize, mButtonLabel ); - mPopup = CreatePopup( stageSize.width * 0.8f ); + mPopup = CreatePopup(); mPopup.Add( mField ); mPopup.OutsideTouchedSignal().Connect( this, &TextFieldExample::OnPopupOutsideTouched ); stage.Add( mPopup ); @@ -128,15 +125,14 @@ public: return field; } - Popup CreatePopup( float width ) + Popup CreatePopup() { Popup popup = Popup::New(); popup.SetParentOrigin( ParentOrigin::CENTER ); popup.SetAnchorPoint( AnchorPoint::CENTER ); - popup.SetSize( width, 0.0f ); - popup.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::HEIGHT ); - popup.SetSizeModeFactor( POPUP_SIZE_FACTOR_TO_PARENT ); - popup.TouchedSignal().Connect( this, &TextFieldExample::OnPopupTouched ); + popup.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::WIDTH ); + popup.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::HEIGHT ); + popup.TouchSignal().Connect( this, &TextFieldExample::OnPopupTouched ); return popup; } @@ -148,7 +144,7 @@ public: { Property::Value text = mField.GetProperty( TextField::Property::TEXT ); mButtonLabel = text.Get< std::string >(); - mButton.SetLabelText( mButtonLabel ); + mButton.SetProperty( Toolkit::Button::Property::LABEL, mButtonLabel ); } // Hide & discard the pop-up @@ -159,22 +155,21 @@ public: mField.Reset(); } - bool OnPopupTouched( Actor actor, const TouchEvent& event ) + bool OnPopupTouched( Actor actor, const TouchData& event ) { // End edit mode for TextField if parent Popup touched. if(event.GetPointCount() > 0) { - const TouchPoint& point = event.GetPoint(0); - switch(point.state) + switch( event.GetState( 0 ) ) { - case TouchPoint::Down: + case PointState::DOWN: { // Update the folder text and lose focus for Key events if( mButton && mField ) { Property::Value text = mField.GetProperty( TextField::Property::TEXT ); mButtonLabel = text.Get< std::string >(); - mButton.SetLabelText( mButtonLabel ); + mButton.SetProperty( Toolkit::Button::Property::LABEL, mButtonLabel ); mField.ClearKeyInputFocus(); } break;