/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 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.
float ConvertToEven( float value )
{
int intValue(static_cast<int>( value ));
- return static_cast<float>(intValue % 2 == 0) ? intValue : (intValue + 1);
+ return static_cast<float>( intValue + ( intValue & 1 ) );
}
} // namespace
mImpl->mTextUpdateInfo.mFullRelayoutNeeded = true;
mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | layoutOperations );
+ // Need to recalculate natural size
+ mImpl->mRecalculateNaturalSize = true;
+
mImpl->RequestRelayout();
}
}
mImpl->mModel->mVisualModel->SetTextColor( mImpl->mTextColor );
MarkupProcessData markupProcessData( mImpl->mModel->mLogicalModel->mColorRuns,
- mImpl->mModel->mLogicalModel->mFontDescriptionRuns );
+ mImpl->mModel->mLogicalModel->mFontDescriptionRuns,
+ mImpl->mModel->mLogicalModel->mEmbeddedItems );
Length textSize = 0u;
const uint8_t* utf8 = NULL;
return mImpl->mModel->mVisualModel->GetOutlineColor();
}
-void Controller::SetOutlineWidth( unsigned int width )
+void Controller::SetOutlineWidth( uint16_t width )
{
mImpl->mModel->mVisualModel->SetOutlineWidth( width );
mImpl->RequestRelayout();
}
-unsigned int Controller::GetOutlineWidth() const
+uint16_t Controller::GetOutlineWidth() const
{
return mImpl->mModel->mVisualModel->GetOutlineWidth();
}
mImpl->mEventData->mInputStyle.textColor = color;
mImpl->mEventData->mInputStyle.isDefaultColor = false;
- if( EventData::SELECTING == mImpl->mEventData->mState )
+ if( EventData::SELECTING == mImpl->mEventData->mState || EventData::EDITING == mImpl->mEventData->mState || EventData::INACTIVE == mImpl->mEventData->mState )
{
const bool handlesCrossed = mImpl->mEventData->mLeftSelectionPosition > mImpl->mEventData->mRightSelectionPosition;
mImpl->mEventData->mInputStyle.familyName = fontFamily;
mImpl->mEventData->mInputStyle.isFamilyDefined = true;
- if( EventData::SELECTING == mImpl->mEventData->mState )
+ if( EventData::SELECTING == mImpl->mEventData->mState || EventData::EDITING == mImpl->mEventData->mState || EventData::INACTIVE == mImpl->mEventData->mState )
{
CharacterIndex startOfSelectedText = 0u;
Length lengthOfSelectedText = 0u;
mImpl->mEventData->mInputStyle.weight = weight;
mImpl->mEventData->mInputStyle.isWeightDefined = true;
- if( EventData::SELECTING == mImpl->mEventData->mState )
+ if( EventData::SELECTING == mImpl->mEventData->mState || EventData::EDITING == mImpl->mEventData->mState || EventData::INACTIVE == mImpl->mEventData->mState )
{
CharacterIndex startOfSelectedText = 0u;
Length lengthOfSelectedText = 0u;
mImpl->mEventData->mInputStyle.width = width;
mImpl->mEventData->mInputStyle.isWidthDefined = true;
- if( EventData::SELECTING == mImpl->mEventData->mState )
+ if( EventData::SELECTING == mImpl->mEventData->mState || EventData::EDITING == mImpl->mEventData->mState || EventData::INACTIVE == mImpl->mEventData->mState )
{
CharacterIndex startOfSelectedText = 0u;
Length lengthOfSelectedText = 0u;
mImpl->mEventData->mInputStyle.slant = slant;
mImpl->mEventData->mInputStyle.isSlantDefined = true;
- if( EventData::SELECTING == mImpl->mEventData->mState )
+ if( EventData::SELECTING == mImpl->mEventData->mState || EventData::EDITING == mImpl->mEventData->mState || EventData::INACTIVE == mImpl->mEventData->mState )
{
CharacterIndex startOfSelectedText = 0u;
Length lengthOfSelectedText = 0u;
mImpl->mEventData->mInputStyle.size = size;
mImpl->mEventData->mInputStyle.isSizeDefined = true;
- if( EventData::SELECTING == mImpl->mEventData->mState )
+ if( EventData::SELECTING == mImpl->mEventData->mState || EventData::EDITING == mImpl->mEventData->mState || EventData::INACTIVE == mImpl->mEventData->mState )
{
CharacterIndex startOfSelectedText = 0u;
Length lengthOfSelectedText = 0u;
UpdateTextType updateTextType = NONE_UPDATED;
- mImpl->mLayoutDirection = layoutDirection;
if( ( size.width < Math::MACHINE_EPSILON_1000 ) || ( size.height < Math::MACHINE_EPSILON_1000 ) )
{
if( 0u != mImpl->mModel->mVisualModel->mGlyphPositions.Count() )
mImpl->mTextUpdateInfo.mCharacterIndex = 0u;
}
+ if( mImpl->mModel->mMatchSystemLanguageDirection && mImpl->mLayoutDirection != layoutDirection )
+ {
+ // Clear the update info. This info will be set the next time the text is updated.
+ mImpl->mTextUpdateInfo.mClearAll = true;
+ // Apply modifications to the model
+ // Shape the text again is needed because characters like '()[]{}' have to be mirrored and the glyphs generated again.
+ mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
+ GET_GLYPH_METRICS |
+ SHAPE_TEXT |
+ UPDATE_DIRECTION |
+ LAYOUT |
+ BIDI_INFO |
+ REORDER );
+ mImpl->mLayoutDirection = layoutDirection;
+ }
+
// Make sure the model is up-to-date before layouting.
ProcessModifyEvents();
bool updated = mImpl->UpdateModel( mImpl->mOperationsPending );
{
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::KeyEvent %p keyString %s\n", this, keyString.c_str() );
- // InputMethodContext is no longer handling key-events
- mImpl->ClearPreEditFlag();
+ if( !keyString.empty() )
+ {
+ // InputMethodContext is no longer handling key-events
+ mImpl->ClearPreEditFlag();
- InsertText( keyString, COMMIT );
- textChanged = true;
+ InsertText( keyString, COMMIT );
+
+ textChanged = true;
+
+ // Will request for relayout.
+ relayoutNeeded = true;
+ }
- // Will request for relayout.
- relayoutNeeded = true;
}
if ( ( mImpl->mEventData->mState != EventData::INTERRUPTED ) &&
mImpl->mModel->mLogicalModel->RetrieveStyle( styleIndex, style );
// Whether to add a new text color run.
- const bool addColorRun = ( style.textColor != mImpl->mEventData->mInputStyle.textColor );
+ const bool addColorRun = ( style.textColor != mImpl->mEventData->mInputStyle.textColor ) && !mImpl->mEventData->mInputStyle.isDefaultColor;
// Whether to add a new font run.
- const bool addFontNameRun = style.familyName != mImpl->mEventData->mInputStyle.familyName;
- const bool addFontWeightRun = style.weight != mImpl->mEventData->mInputStyle.weight;
- const bool addFontWidthRun = style.width != mImpl->mEventData->mInputStyle.width;
- const bool addFontSlantRun = style.slant != mImpl->mEventData->mInputStyle.slant;
- const bool addFontSizeRun = style.size != mImpl->mEventData->mInputStyle.size;
+ const bool addFontNameRun = ( style.familyName != mImpl->mEventData->mInputStyle.familyName ) && mImpl->mEventData->mInputStyle.isFamilyDefined;
+ const bool addFontWeightRun = ( style.weight != mImpl->mEventData->mInputStyle.weight ) && mImpl->mEventData->mInputStyle.isWeightDefined;
+ const bool addFontWidthRun = ( style.width != mImpl->mEventData->mInputStyle.width ) && mImpl->mEventData->mInputStyle.isWidthDefined;
+ const bool addFontSlantRun = ( style.slant != mImpl->mEventData->mInputStyle.slant ) && mImpl->mEventData->mInputStyle.isSlantDefined;
+ const bool addFontSizeRun = ( style.size != mImpl->mEventData->mInputStyle.size ) && mImpl->mEventData->mInputStyle.isSizeDefined ;
// Add style runs.
if( addColorRun )
// Reset buffers.
mImpl->mModel->mLogicalModel->mText.Clear();
+ // Reset the embedded images buffer.
+ mImpl->mModel->mLogicalModel->ClearEmbeddedImages();
+
// We have cleared everything including the placeholder-text
mImpl->PlaceholderCleared();