mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-05-31 10:36:30 +03:00
A few extra optimizations.
This commit is contained in:
@@ -40,7 +40,7 @@ class EE_API Text {
|
||||
|
||||
static inline bool canSkipShaping( Uint32 textDrawHints ) {
|
||||
return Text::TextShaperOptimizations &&
|
||||
( textDrawHints & ( TextHints::AllAscii | TextHints::AllLatin1 ) ) != 0;
|
||||
( textDrawHints & ( TextHints::AllLatin1 | TextHints::AllAscii ) ) != 0;
|
||||
}
|
||||
|
||||
static Float tabAdvance( Float spaceHorizontalAdvance, Uint32 tabLength,
|
||||
|
||||
@@ -131,6 +131,7 @@ class EE_API UITextView : public UIWidget {
|
||||
Vector2f mRealAlignOffset;
|
||||
Int32 mSelCurInit;
|
||||
Int32 mSelCurEnd;
|
||||
Uint32 mTextDrawHints{ 0 };
|
||||
struct SelPosCache {
|
||||
SelPosCache( Vector2f ip, Vector2f ep ) : initPos( ip ), endPos( ep ) {}
|
||||
|
||||
|
||||
@@ -822,7 +822,7 @@ Vector2f Text::findCharacterPos( std::size_t index ) const {
|
||||
|
||||
return Text::findCharacterPos( index, mFontStyleConfig.Font, mFontStyleConfig.CharacterSize,
|
||||
mString, mFontStyleConfig.Style, mTabWidth,
|
||||
mFontStyleConfig.OutlineThickness );
|
||||
mFontStyleConfig.OutlineThickness, {}, true, mTextHints );
|
||||
}
|
||||
|
||||
Int32 Text::findCharacterFromPos( const Vector2i& pos, bool nearest ) const {
|
||||
|
||||
@@ -92,7 +92,7 @@ DocumentView::computeLineBreaks( const String::View& string, const FontStyleConf
|
||||
( fontStyle.Font->isMonospace() ||
|
||||
( fontStyle.Font->getType() == FontType::TTF &&
|
||||
static_cast<FontTrueType*>( fontStyle.Font )->isIdentifiedAsMonospace() &&
|
||||
( textDrawHints & TextHints::AllAscii ) ) );
|
||||
Text::canSkipShaping( textDrawHints ) ) );
|
||||
|
||||
size_t lastSpace = 0;
|
||||
Uint32 prevChar = 0;
|
||||
|
||||
@@ -195,6 +195,7 @@ const String& UITextView::getText() const {
|
||||
UITextView* UITextView::setText( const String& text ) {
|
||||
if ( mString != text ) {
|
||||
mString = text;
|
||||
mTextDrawHints = mString.getTextHints();
|
||||
mTextCache->setString( mString );
|
||||
|
||||
recalculate();
|
||||
@@ -208,6 +209,7 @@ UITextView* UITextView::setText( const String& text ) {
|
||||
UITextView* UITextView::setText( String&& text ) {
|
||||
if ( mString != text ) {
|
||||
mString = std::move( text );
|
||||
mTextDrawHints = mString.getTextHints();
|
||||
mTextCache->setString( mString );
|
||||
|
||||
recalculate();
|
||||
@@ -473,7 +475,7 @@ void UITextView::setTheme( UITheme* Theme ) {
|
||||
}
|
||||
|
||||
Float UITextView::getTextWidth() {
|
||||
return hasTextOverflow() ? Text::getTextWidth( mString, mFontStyleConfig )
|
||||
return hasTextOverflow() ? Text::getTextWidth( mString, mFontStyleConfig, 4, mTextDrawHints )
|
||||
: mTextCache->getTextWidth();
|
||||
}
|
||||
|
||||
@@ -878,16 +880,18 @@ void UITextView::loadFromXmlNode( const pugi::xml_node& node ) {
|
||||
|
||||
void UITextView::updateTextOverflow() {
|
||||
if ( hasTextOverflow() ) {
|
||||
mTextOverflowWidth = Text::getTextWidth( mTextOverflow, mFontStyleConfig );
|
||||
mTextOverflowWidth =
|
||||
Text::getTextWidth( mTextOverflow, mFontStyleConfig, 4, mTextDrawHints );
|
||||
|
||||
Float maxWidth = mSize.getWidth() - mPaddingPx.Left - mPaddingPx.Right;
|
||||
|
||||
std::size_t charPos =
|
||||
Text::findLastCharPosWithinLength( mString, maxWidth, mFontStyleConfig );
|
||||
std::size_t charPos = Text::findLastCharPosWithinLength(
|
||||
mString, maxWidth, mFontStyleConfig, 4, {}, mTextDrawHints );
|
||||
|
||||
if ( charPos != mString.size() ) {
|
||||
maxWidth -= mTextOverflowWidth;
|
||||
charPos = Text::findLastCharPosWithinLength( mString, maxWidth, mFontStyleConfig );
|
||||
charPos = Text::findLastCharPosWithinLength( mString, maxWidth, mFontStyleConfig, 4, {},
|
||||
mTextDrawHints );
|
||||
mTextCache->setString( mString.view().substr( 0, charPos ) + mTextOverflow );
|
||||
} else {
|
||||
if ( mFlags & UI_WORD_WRAP ) {
|
||||
|
||||
Reference in New Issue
Block a user