X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Ftext-controls%2Ftext-editor-impl.cpp;h=1a918cd2585ec0de9db3cc3f5d96348d14d69dd0;hp=fc86c7ea532de0df061251a51aa93e876eb33e61;hb=6a9bd26564f5c34ba105b04cec4111523d294bec;hpb=de3eeac76074ae55de7a795e519d80a628c11628 diff --git a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp index fc86c7e..1a918cd 100644 --- a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp @@ -32,6 +32,7 @@ // INTERNAL INCLUDES #include #include +#include #include #include #include @@ -133,6 +134,10 @@ DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "smoothScrollDuration", DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "enableScrollBar", BOOLEAN, ENABLE_SCROLL_BAR ) DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "scrollBarShowDuration", FLOAT, SCROLL_BAR_SHOW_DURATION ) DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "scrollBarFadeDuration", FLOAT, SCROLL_BAR_FADE_DURATION ) +DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "pixelSize", FLOAT, PIXEL_SIZE ) +DALI_DEVEL_PROPERTY_REGISTRATION_READ_ONLY( Toolkit, TextEditor, "lineCount", INTEGER, LINE_COUNT ) +DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "placeholderText", STRING, PLACEHOLDER_TEXT ) +DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "placeholderTextColor", VECTOR4, PLACEHOLDER_TEXT_COLOR ) DALI_SIGNAL_REGISTRATION( Toolkit, TextEditor, "textChanged", SIGNAL_TEXT_CHANGED ) DALI_SIGNAL_REGISTRATION( Toolkit, TextEditor, "inputStyleChanged", SIGNAL_INPUT_STYLE_CHANGED ) @@ -231,9 +236,9 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P const float pointSize = value.Get< float >(); DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p POINT_SIZE %f\n", impl.mController.Get(), pointSize ); - if( !Equals( impl.mController->GetDefaultPointSize(), pointSize ) ) + if( !Equals( impl.mController->GetDefaultFontSize( Text::Controller::POINT_SIZE ), pointSize ) ) { - impl.mController->SetDefaultPointSize( pointSize ); + impl.mController->SetDefaultFontSize( pointSize, Text::Controller::POINT_SIZE ); } } break; @@ -645,6 +650,46 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P impl.mAnimationPeriod.durationSeconds = duration; break; } + case Toolkit::DevelTextEditor::Property::PIXEL_SIZE: + { + if( impl.mController ) + { + const float pixelSize = value.Get< float >(); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p PIXEL_SIZE %f\n", impl.mController.Get(), pixelSize ); + + if( !Equals( impl.mController->GetDefaultFontSize( Text::Controller::PIXEL_SIZE ), pixelSize ) ) + { + impl.mController->SetDefaultFontSize( pixelSize, Text::Controller::PIXEL_SIZE ); + } + } + break; + } + case Toolkit::DevelTextEditor::Property::PLACEHOLDER_TEXT: + { + if( impl.mController ) + { + const std::string& text = value.Get< std::string >(); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor::OnPropertySet %p PLACEHOLDER_TEXT %s\n", impl.mController.Get(), text.c_str() ); + + impl.mController->SetPlaceholderText( text ); + } + break; + } + case Toolkit::DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR: + { + if( impl.mController ) + { + const Vector4& textColor = value.Get< Vector4 >(); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p PLACEHOLDER_TEXT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), textColor.r, textColor.g, textColor.b, textColor.a ); + + if( impl.mController->GetPlaceholderTextColor() != textColor ) + { + impl.mController->SetPlaceholderTextColor( textColor ); + impl.mRenderer.Reset(); + } + } + break; + } } // switch } // texteditor } @@ -702,7 +747,7 @@ Property::Value TextEditor::GetProperty( BaseObject* object, Property::Index ind { if( impl.mController ) { - value = impl.mController->GetDefaultPointSize(); + value = impl.mController->GetDefaultFontSize( Text::Controller::POINT_SIZE ); } break; } @@ -971,6 +1016,41 @@ Property::Value TextEditor::GetProperty( BaseObject* object, Property::Index ind value = impl.mAnimationPeriod.durationSeconds; break; } + case Toolkit::DevelTextEditor::Property::PIXEL_SIZE: + { + if( impl.mController ) + { + value = impl.mController->GetDefaultFontSize( Text::Controller::PIXEL_SIZE ); + } + break; + } + case Toolkit::DevelTextEditor::Property::LINE_COUNT: + { + if( impl.mController ) + { + float width = textEditor.GetProperty( Actor::Property::SIZE_WIDTH ).Get(); + value = impl.mController->GetLineCount( width ); + } + break; + } + case Toolkit::DevelTextEditor::Property::PLACEHOLDER_TEXT: + { + if( impl.mController ) + { + std::string text; + impl.mController->GetPlaceholderText( text ); + value = text; + } + break; + } + case Toolkit::DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR: + { + if( impl.mController ) + { + value = impl.mController->GetPlaceholderTextColor(); + } + break; + } } //switch } @@ -1011,6 +1091,11 @@ Toolkit::TextEditor::InputStyleChangedSignalType& TextEditor::InputStyleChangedS return mInputStyleChangedSignal; } +Toolkit::DevelTextEditor::ScrollStateChangedSignalType& TextEditor::ScrollStateChangedSignal() +{ + return mScrollStateChangedSignal; +} + void TextEditor::OnInitialize() { Actor self = Self(); @@ -1098,20 +1183,25 @@ void TextEditor::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange: const std::string& newFont = GetImpl( styleManager ).GetDefaultFontFamily(); // Property system did not set the font so should update it. mController->UpdateAfterFontChange( newFont ); + RelayoutRequest(); break; } case StyleChange::DEFAULT_FONT_SIZE_CHANGE: { GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) ); + RelayoutRequest(); break; } case StyleChange::THEME_CHANGE: { - GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) ); + // Nothing to do, let control base class handle this break; } } + + // Up call to Control + Control::OnStyleChange( styleManager, change ); } Vector3 TextEditor::GetNaturalSize() @@ -1410,6 +1500,14 @@ void TextEditor::UpdateScrollBar() return; } + // If scrolling is not started, start scrolling and emit ScrollStateChangedSignal + if( !mScrollStarted ) + { + mScrollStarted = true; + Dali::Toolkit::TextEditor handle( GetOwner() ); + mScrollStateChangedSignal.Emit( handle, DevelTextEditor::Scroll::STARTED ); + } + CustomActor self = Self(); if( !mScrollBar ) { @@ -1431,6 +1529,15 @@ void TextEditor::UpdateScrollBar() mScrollBar.SetScrollPropertySource(self, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize); + // Set style name of ScrollBar for styling + mScrollBar.SetStyleName("TextEditorScrollBar"); + Toolkit::Control scrollIndicator = Toolkit::Control::DownCast( mScrollBar.GetScrollIndicator() ); + if( scrollIndicator ) + { + // Set style name of ScrollBarIndicator for styling + scrollIndicator.SetStyleName("TextEditorScrollBarIndicator"); + } + self.Add( mScrollBar ); } else @@ -1456,6 +1563,18 @@ void TextEditor::UpdateScrollBar() indicator.SetOpacity(1.0f); mAnimation.AnimateTo( Property( indicator, Actor::Property::COLOR_ALPHA ), 0.0f, AlphaFunction::EASE_IN, mAnimationPeriod ); mAnimation.Play(); + mAnimation.FinishedSignal().Connect( this, &TextEditor::OnScrollIndicatorAnimationFinished ); +} + +void TextEditor::OnScrollIndicatorAnimationFinished( Animation& animation ) +{ + // If animation is successfully ended, then emit ScrollStateChangedSignal + if( animation.GetCurrentProgress() == 0.0f ) + { + mScrollStarted = false; + Dali::Toolkit::TextEditor handle( GetOwner() ); + mScrollStateChangedSignal.Emit( handle, DevelTextEditor::Scroll::FINISHED ); + } } void TextEditor::OnStageConnect( Dali::Actor actor ) @@ -1573,7 +1692,8 @@ TextEditor::TextEditor() mRenderingBackend( DEFAULT_RENDERING_BACKEND ), mHasBeenStaged( false ), mScrollAnimationEnabled( false ), - mScrollBarEnabled( false ) + mScrollBarEnabled( false ), + mScrollStarted( false ) { }