X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Ftext-controls%2Ftext-field-impl.cpp;h=9c3d4c8ac54aec83ae3d896c71bcc74fc6dc4f24;hb=refs%2Fchanges%2F69%2F46069%2F9;hp=5b6d9504e10f3d975043eccbad60b890776721ae;hpb=dbe59842bb6226eaccfc27f189e35c7614c6d814;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp index 5b6d950..9c3d4c8 100644 --- a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp @@ -19,21 +19,17 @@ #include // EXTERNAL INCLUDES -#include -#include #include #include #include #include -#include -#include -#include #include +#include #include // INTERNAL INCLUDES #include -#include +#include #include #include #include @@ -57,7 +53,6 @@ namespace // unnamed namespace #endif const unsigned int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND; - } // unnamed namespace namespace @@ -149,6 +144,9 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr { Toolkit::TextField textField = Toolkit::TextField::DownCast( Dali::BaseHandle( object ) ); + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField SetProperty\n"); + + if( textField ) { TextField& impl( GetImpl( textField ) ); @@ -210,23 +208,14 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr if( impl.mController->GetDefaultFontFamily() != fontFamily ) { - impl.mController->SetDefaultFontFamily( fontFamily ); + impl.mController->SetDefaultFontFamily( fontFamily, true ); // "true" as SetProperty means user defined font so don't change when system font changes. } } break; } case Toolkit::TextField::Property::FONT_STYLE: { - if( impl.mController ) - { - const std::string fontStyle = value.Get< std::string >(); - DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p FONT_STYLE %s\n", impl.mController.Get(), fontStyle.c_str() ); - - if( impl.mController->GetDefaultFontStyle() != fontStyle ) - { - impl.mController->SetDefaultFontStyle( fontStyle ); - } - } + SetFontStyleProperty( impl.mController, value ); break; } case Toolkit::TextField::Property::POINT_SIZE: @@ -234,7 +223,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr if( impl.mController ) { const float pointSize = value.Get< float >(); - DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p FONT_STYLE %f\n", impl.mController.Get(), pointSize ); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p POINT_SIZE %f\n", impl.mController.Get(), pointSize ); if( !Equals( impl.mController->GetDefaultPointSize(), pointSize ) ) { @@ -475,7 +464,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr { const Image image = Scripting::NewImage( value ); - if( impl.mDecorator ) + if( impl.mDecorator && image ) { impl.mDecorator->SetHandleImage( LEFT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED, image ); impl.RequestTextRelayout(); @@ -486,7 +475,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr { const Image image = Scripting::NewImage( value ); - if( impl.mDecorator ) + if( impl.mDecorator && image ) { impl.mDecorator->SetHandleImage( RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED, image ); impl.RequestTextRelayout(); @@ -497,7 +486,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr { const Image image = Scripting::NewImage( value ); - if( impl.mDecorator ) + if( impl.mDecorator && image ) { impl.mDecorator->SetHandleImage( LEFT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED, image ); impl.RequestTextRelayout(); @@ -508,7 +497,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr { const Image image = Scripting::NewImage( value ); - if( impl.mDecorator ) + if( impl.mDecorator && image ) { impl.mDecorator->SetHandleImage( RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED, image ); impl.RequestTextRelayout(); @@ -518,7 +507,8 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT: { const Image image = Scripting::NewImage( value ); - if( impl.mDecorator ) + + if( impl.mDecorator && image ) { impl.mDecorator->SetHandleImage( LEFT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED, image ); impl.RequestTextRelayout(); @@ -528,7 +518,8 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT: { const Image image = Scripting::NewImage( value ); - if( impl.mDecorator ) + + if( impl.mDecorator && image ) { impl.mDecorator->SetHandleImage( RIGHT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED, image ); impl.RequestTextRelayout(); @@ -627,10 +618,7 @@ Property::Value TextField::GetProperty( BaseObject* object, Property::Index inde } case Toolkit::TextField::Property::FONT_STYLE: { - if( impl.mController ) - { - value = impl.mController->GetDefaultFontStyle(); - } + GetFontStyleProperty( impl.mController, value ); break; } case Toolkit::TextField::Property::POINT_SIZE: @@ -841,7 +829,9 @@ Property::Value TextField::GetProperty( BaseObject* object, Property::Index inde { if( impl.mDecorator ) { - value = impl.mDecorator->GetBoundingBox(); + Rect boundingBox; + impl.mDecorator->GetBoundingBox( boundingBox ); + value = boundingBox; } break; } @@ -909,7 +899,10 @@ void TextField::OnInitialize() self.TouchedSignal().Connect( this, &TextField::OnTouched ); // Set BoundingBox to stage size if not already set. - if ( mDecorator->GetBoundingBox().IsEmpty() ) + Rect boundingBox; + mDecorator->GetBoundingBox( boundingBox ); + + if( boundingBox.IsEmpty() ) { Vector2 stageSize = Dali::Stage::GetCurrent().GetSize(); mDecorator->SetBoundingBox( Rect( 0.0f, 0.0f, stageSize.width, stageSize.height ) ); @@ -923,7 +916,36 @@ void TextField::OnInitialize() void TextField::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change ) { - GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) ); + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnStyleChange\n"); + + switch ( change ) + { + case StyleChange::DEFAULT_FONT_CHANGE: + { + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnStyleChange DEFAULT_FONT_CHANGE\n"); + std::string newFont = styleManager.GetDefaultFontFamily(); + // Property system did not set the font so should update it. + mController->UpdateAfterFontChange( newFont ); + break; + } + + case StyleChange::DEFAULT_FONT_SIZE_CHANGE: + { + DALI_LOG_INFO( gLogFilter, Debug::General, "TextField::OnStyleChange StyleChange::DEFAULT_FONT_SIZE_CHANGE (%f)\n", mController->GetDefaultPointSize() ); + + if ( (mController->GetDefaultPointSize() <= 0.0f) ) // If DefaultPointSize not set by Property system it will be 0.0f + { + // Property system did not set the PointSize so should update it. + // todo instruct text-controller to update model + } + break; + } + case StyleChange::THEME_CHANGE: + { + GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) ); + break; + } + } } Vector3 TextField::GetNaturalSize() @@ -938,6 +960,8 @@ float TextField::GetHeightForWidth( float width ) void TextField::OnRelayout( const Vector2& size, RelayoutContainer& container ) { + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField OnRelayout\n"); + if( mController->Relayout( size ) || !mRenderer ) { @@ -1099,7 +1123,15 @@ void TextField::OnPan( const PanGesture& gesture ) void TextField::OnLongPress( const LongPressGesture& gesture ) { + // Show the keyboard if it was hidden. + if (!VirtualKeyboard::IsVisible()) + { + VirtualKeyboard::Show(); + } + mController->LongPressEvent( gesture.state, gesture.localPoint.x, gesture.localPoint.y ); + + SetKeyInputFocus(); } bool TextField::OnKeyEvent( const KeyEvent& event )