X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=examples%2Ftext-field%2Ftext-field-example.cpp;h=84153e622589b78a68e9eb0c9cd01220f68a263f;hb=0efc4e729b2c12240d9d68f5df1929494685fb7f;hp=2f8c2838fa7fdb2ad272bdecbdddd56864363a38;hpb=102fd0ff958eca808fbf0c0c3195b20e9baf7282;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 2f8c283..84153e6 100644 --- a/examples/text-field/text-field-example.cpp +++ b/examples/text-field/text-field-example.cpp @@ -37,13 +37,11 @@ using namespace MultiLanguageStrings; namespace { - const char* const FOLDER_ICON_IMAGE = DALI_IMAGE_DIR "folder_appicon_empty_bg.png"; - const char* const FOLDER_OPEN_ICON_IMAGE = DALI_IMAGE_DIR "folder_appicon_empty_open_bg.png"; + const char* const FOLDER_ICON_IMAGE = DEMO_IMAGE_DIR "folder_appicon_empty_bg.png"; + const char* const FOLDER_OPEN_ICON_IMAGE = DEMO_IMAGE_DIR "folder_appicon_empty_open_bg.png"; 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 ); @@ -87,8 +88,8 @@ public: button.SetSelectedImage( 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() ); + ImageDimensions imageSize = ResourceImage::GetImageSize( FOLDER_ICON_IMAGE ); + button.SetSize( imageSize.GetWidth(), imageSize.GetHeight() ); return button; } @@ -103,9 +104,10 @@ 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 ); mPopup.SetDisplayState( Popup::SHOWN ); return true; @@ -114,12 +116,12 @@ public: TextField CreateTextField( const Vector2& stageSize, const std::string& text ) { TextField field = TextField::New(); + field.SetName("textField"); field.SetAnchorPoint( 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::PRIMARY_CURSOR_COLOR, Color::WHITE ); 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 ) ); @@ -127,15 +129,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; } @@ -158,15 +159,14 @@ 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 ) @@ -223,9 +223,10 @@ void RunTest( Application& application ) } /** Entry point for Linux & Tizen applications */ -int main( int argc, char **argv ) +int DALI_EXPORT_API main( int argc, char **argv ) { - Application application = Application::New( &argc, &argv, DALI_DEMO_THEME_PATH ); + // DALI_DEMO_THEME_PATH not passed to Application so TextField example uses default Toolkit style sheet. + Application application = Application::New( &argc, &argv ); RunTest( application );