X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=examples%2Ftext-field%2Ftext-field-example.cpp;h=751380b9d39473be57e6d97f7325709033117590;hb=1a473d5189ca7e7d55aca3a64a8a4ff2dc3b6c67;hp=944cb718573961482f3cc832c056be85b27a768e;hpb=94d678d62ca15faaced5deaf379f9ea4a6f16b7d;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 944cb71..751380b 100644 --- a/examples/text-field/text-field-example.cpp +++ b/examples/text-field/text-field-example.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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,10 +22,8 @@ // EXTERNAL INCLUDES #include -#include #include #include -#include // INTERNAL INCLUDES #include "shared/multi-language-strings.h" @@ -43,8 +41,6 @@ namespace const float BORDER_WIDTH = 4.0f; - const Vector3 POPUP_SIZE_FACTOR_TO_PARENT = Vector3( 0.8, 0.25, 0.0 ); - } // unnamed namespace /** @@ -71,59 +67,56 @@ public: */ void Create( Application& application ) { - Stage stage = Stage::GetCurrent(); - - stage.SetBackgroundColor( Vector4( 0.04f, 0.345f, 0.392f, 1.0f ) ); - stage.KeyEventSignal().Connect(this, &TextFieldExample::OnKeyEvent); + Window window = application.GetWindow(); - // Hide the indicator bar - application.GetWindow().ShowIndicator( Dali::Window::INVISIBLE ); + window.SetBackgroundColor( Vector4( 0.04f, 0.345f, 0.392f, 1.0f ) ); + window.KeyEventSignal().Connect(this, &TextFieldExample::OnKeyEvent); mButton = CreateFolderButton(); mButton.ClickedSignal().Connect( this, &TextFieldExample::OnButtonClicked ); - stage.Add( mButton ); + window.Add( mButton ); } PushButton CreateFolderButton() { PushButton button = PushButton::New(); - 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.SetProperty( Toolkit::Button::Property::UNSELECTED_BACKGROUND_VISUAL, FOLDER_ICON_IMAGE ); + button.SetProperty( Toolkit::Button::Property::SELECTED_BACKGROUND_VISUAL, FOLDER_OPEN_ICON_IMAGE ); + button.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); return button; } bool OnButtonClicked( Toolkit::Button button ) { - Stage stage = Stage::GetCurrent(); - Vector2 stageSize = stage.GetSize(); + Window window = mApplication.GetWindow(); + Vector2 windowSize = window.GetSize(); // Remove previously hidden pop-up UnparentAndReset(mPopup); // Launch a pop-up containing TextField - mField = CreateTextField( stageSize, mButtonLabel ); + mField = CreateTextField( windowSize, mButtonLabel ); mPopup = CreatePopup(); mPopup.Add( mField ); mPopup.OutsideTouchedSignal().Connect( this, &TextFieldExample::OnPopupOutsideTouched ); - stage.Add( mPopup ); + window.Add( mPopup ); mPopup.SetDisplayState( Popup::SHOWN ); return true; } - TextField CreateTextField( const Vector2& stageSize, const std::string& text ) + TextField CreateTextField( const Vector2& windowSize, const std::string& text ) { TextField field = TextField::New(); - field.SetName("textField"); - field.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + field.SetProperty( Dali::Actor::Property::NAME,"textField"); + field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); field.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT ); field.SetProperty( TextField::Property::TEXT, text ); field.SetProperty( TextField::Property::TEXT_COLOR, Vector4( 0.0f, 1.0f, 1.0f, 1.0f ) ); // CYAN field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Unnamed folder" ); field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Enter folder name." ); - field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect( BORDER_WIDTH, BORDER_WIDTH, stageSize.width - BORDER_WIDTH*2, stageSize.height - BORDER_WIDTH*2 ) ); + field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect( BORDER_WIDTH, BORDER_WIDTH, windowSize.width - BORDER_WIDTH*2, windowSize.height - BORDER_WIDTH*2 ) ); return field; } @@ -131,11 +124,11 @@ public: Popup CreatePopup() { Popup popup = Popup::New(); - popup.SetParentOrigin( ParentOrigin::CENTER ); - popup.SetAnchorPoint( AnchorPoint::CENTER ); - popup.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS ); - popup.SetSizeModeFactor( POPUP_SIZE_FACTOR_TO_PARENT ); - popup.TouchSignal().Connect( this, &TextFieldExample::OnPopupTouched ); + popup.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER ); + popup.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER ); + popup.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::WIDTH ); + popup.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::HEIGHT ); + popup.TouchedSignal().Connect( this, &TextFieldExample::OnPopupTouched ); return popup; } @@ -158,10 +151,10 @@ public: mField.Reset(); } - bool OnPopupTouched( Actor actor, const TouchData& event ) + bool OnPopupTouched( Actor actor, const TouchEvent& event ) { // End edit mode for TextField if parent Popup touched. - if(event.GetPointCount() > 0) + if((event.GetPointCount() > 0) && (mPopup == event.GetHitActor(0))) { switch( event.GetState( 0 ) ) { @@ -184,7 +177,7 @@ public: } // end switch } - return true; + return false; } /** @@ -192,7 +185,7 @@ public: */ void OnKeyEvent(const KeyEvent& event) { - if(event.state == KeyEvent::Down) + if(event.GetState() == KeyEvent::DOWN) { if( IsKey( event, DALI_KEY_ESCAPE) || IsKey( event, DALI_KEY_BACK ) ) { @@ -214,20 +207,11 @@ private: Popup mPopup; }; -void RunTest( Application& application ) -{ - TextFieldExample test( application ); - - application.MainLoop(); -} - -/** Entry point for Linux & Tizen applications */ int DALI_EXPORT_API main( int argc, char **argv ) { // DALI_DEMO_THEME_PATH not passed to Application so TextField example uses default Toolkit style sheet. Application application = Application::New( &argc, &argv ); - - RunTest( application ); - + TextFieldExample test( application ); + application.MainLoop(); return 0; }