mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-08-13 04:42:12 +03:00
Minor improvements.
This commit is contained in:
@@ -56,6 +56,8 @@ class EE_API Text {
|
||||
|
||||
void setString( const String& string );
|
||||
|
||||
void setString( String&& string );
|
||||
|
||||
void setFont( Font* font );
|
||||
|
||||
void setFontSize( unsigned int size );
|
||||
@@ -229,6 +231,8 @@ class EE_API Text {
|
||||
BlendMode effect, const OriginPoint& rotationCenter, const OriginPoint& scaleCenter,
|
||||
const std::vector<Color>& colors, const std::vector<Color>& outlineColors,
|
||||
const Color& backgroundColor );
|
||||
|
||||
void onNewString();
|
||||
};
|
||||
|
||||
}} // namespace EE::Graphics
|
||||
|
||||
@@ -52,14 +52,14 @@ class EE_API SyntaxColorScheme {
|
||||
SyntaxColorScheme();
|
||||
|
||||
SyntaxColorScheme( const std::string& name,
|
||||
const std::unordered_map<std::string, Style>& syntaxColors,
|
||||
const std::unordered_map<std::string, Style>& editorColors );
|
||||
const UnorderedMap<std::string, Style>& syntaxColors,
|
||||
const UnorderedMap<std::string, Style>& editorColors );
|
||||
|
||||
const Style& getSyntaxStyle( const std::string& type ) const;
|
||||
|
||||
bool hasSyntaxStyle( const std::string& type ) const;
|
||||
|
||||
void setSyntaxStyles( const std::unordered_map<std::string, Style>& styles );
|
||||
void setSyntaxStyles( const UnorderedMap<std::string, Style>& styles );
|
||||
|
||||
void setSyntaxStyle( const std::string& type, const Style& style );
|
||||
|
||||
@@ -67,7 +67,7 @@ class EE_API SyntaxColorScheme {
|
||||
|
||||
const Color& getEditorColor( const std::string& type ) const;
|
||||
|
||||
void setEditorSyntaxStyles( const std::unordered_map<std::string, Style>& styles );
|
||||
void setEditorSyntaxStyles( const UnorderedMap<std::string, Style>& styles );
|
||||
|
||||
void setEditorSyntaxStyle( const std::string& type, const Style& style );
|
||||
|
||||
@@ -77,9 +77,9 @@ class EE_API SyntaxColorScheme {
|
||||
|
||||
protected:
|
||||
std::string mName;
|
||||
std::unordered_map<std::string, Style> mSyntaxColors;
|
||||
std::unordered_map<std::string, Style> mEditorColors;
|
||||
mutable std::unordered_map<std::string, Style> mStyleCache;
|
||||
UnorderedMap<std::string, Style> mSyntaxColors;
|
||||
UnorderedMap<std::string, Style> mEditorColors;
|
||||
mutable UnorderedMap<std::string, Style> mStyleCache;
|
||||
};
|
||||
|
||||
}}} // namespace EE::UI::Doc
|
||||
|
||||
@@ -112,20 +112,31 @@ void Text::create( Font* font, const String& text, Color FontColor, Color FontSh
|
||||
invalidate();
|
||||
}
|
||||
|
||||
void Text::onNewString() {
|
||||
mColorsNeedUpdate = true;
|
||||
mGeometryNeedUpdate = true;
|
||||
mCachedWidthNeedUpdate = true;
|
||||
mContainsColorEmoji = false;
|
||||
if ( FontManager::instance()->getColorEmojiFont() != nullptr ) {
|
||||
if ( mFontStyleConfig.Font->getType() == FontType::TTF ) {
|
||||
FontTrueType* fontTrueType = static_cast<FontTrueType*>( mFontStyleConfig.Font );
|
||||
if ( fontTrueType->isColorEmojiFont() || !fontTrueType->isEmojiFont() )
|
||||
mContainsColorEmoji = Font::containsEmojiCodePoint( mString );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Text::setString( const String& string ) {
|
||||
if ( mString != string ) {
|
||||
mString = string;
|
||||
mColorsNeedUpdate = true;
|
||||
mGeometryNeedUpdate = true;
|
||||
mCachedWidthNeedUpdate = true;
|
||||
mContainsColorEmoji = false;
|
||||
if ( FontManager::instance()->getColorEmojiFont() != nullptr ) {
|
||||
if ( mFontStyleConfig.Font->getType() == FontType::TTF ) {
|
||||
FontTrueType* fontTrueType = static_cast<FontTrueType*>( mFontStyleConfig.Font );
|
||||
if ( fontTrueType->isColorEmojiFont() || !fontTrueType->isEmojiFont() )
|
||||
mContainsColorEmoji = Font::containsEmojiCodePoint( string );
|
||||
}
|
||||
}
|
||||
onNewString();
|
||||
}
|
||||
}
|
||||
|
||||
void Text::setString( String&& string ) {
|
||||
if ( mString != string ) {
|
||||
mString = std::move( string );
|
||||
onNewString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ SyntaxColorScheme SyntaxColorScheme::getDefault() {
|
||||
|
||||
SyntaxColorScheme::Style parseStyle(
|
||||
const std::string& value, bool* colorWasSet = nullptr,
|
||||
const std::unordered_map<std::string, SyntaxColorScheme::Style>* syntaxColors = nullptr ) {
|
||||
const UnorderedMap<std::string, SyntaxColorScheme::Style>* syntaxColors = nullptr ) {
|
||||
auto values = String::split( value, ',' );
|
||||
SyntaxColorScheme::Style style;
|
||||
bool colorSet = false;
|
||||
@@ -192,8 +192,8 @@ std::vector<SyntaxColorScheme> SyntaxColorScheme::loadFromPack( Pack* pack,
|
||||
SyntaxColorScheme::SyntaxColorScheme() {}
|
||||
|
||||
SyntaxColorScheme::SyntaxColorScheme( const std::string& name,
|
||||
const std::unordered_map<std::string, Style>& syntaxColors,
|
||||
const std::unordered_map<std::string, Style>& editorColors ) :
|
||||
const UnorderedMap<std::string, Style>& syntaxColors,
|
||||
const UnorderedMap<std::string, Style>& editorColors ) :
|
||||
mName( name ), mSyntaxColors( syntaxColors ), mEditorColors( editorColors ) {}
|
||||
|
||||
static const SyntaxColorScheme::Style StyleEmpty = { Color::Transparent };
|
||||
@@ -230,7 +230,7 @@ bool SyntaxColorScheme::hasSyntaxStyle( const std::string& type ) const {
|
||||
return mSyntaxColors.find( type ) != mSyntaxColors.end();
|
||||
}
|
||||
|
||||
void SyntaxColorScheme::setSyntaxStyles( const std::unordered_map<std::string, Style>& styles ) {
|
||||
void SyntaxColorScheme::setSyntaxStyles( const UnorderedMap<std::string, Style>& styles ) {
|
||||
mSyntaxColors.insert( styles.begin(), styles.end() );
|
||||
}
|
||||
|
||||
@@ -279,7 +279,7 @@ const Color& SyntaxColorScheme::getEditorColor( const std::string& type ) const
|
||||
}
|
||||
|
||||
void SyntaxColorScheme::setEditorSyntaxStyles(
|
||||
const std::unordered_map<std::string, Style>& styles ) {
|
||||
const UnorderedMap<std::string, Style>& styles ) {
|
||||
mEditorColors.insert( styles.begin(), styles.end() );
|
||||
}
|
||||
|
||||
|
||||
@@ -616,8 +616,7 @@ void UICodeEditor::setShowIndentationGuides( bool showIndentationGuides ) {
|
||||
UICodeEditor* UICodeEditor::setFontSize( const Float& size ) {
|
||||
if ( mFontStyleConfig.CharacterSize != size ) {
|
||||
mFontStyleConfig.CharacterSize =
|
||||
eeabs( size - (int)size ) == 0.5f || (int)size == size ? size
|
||||
: eefloor( size );
|
||||
eeabs( size - (int)size ) == 0.5f || (int)size == size ? size : eefloor( size );
|
||||
mFontSize = mFontStyleConfig.CharacterSize;
|
||||
udpateGlyphWidth();
|
||||
invalidateDraw();
|
||||
@@ -3050,6 +3049,7 @@ void UICodeEditor::drawLineNumbers( const std::pair<int, int>& lineRange,
|
||||
primitives.drawRectangle( Rectf( screenStart, Sizef( lineNumberWidth, mSize.getHeight() ) ) );
|
||||
TextRange selection = mDoc->getSelection( true );
|
||||
Float lineOffset = getLineOffset();
|
||||
Text& line = mLineTextCache;
|
||||
|
||||
for ( int i = lineRange.first; i <= lineRange.second; i++ ) {
|
||||
String pos;
|
||||
@@ -3059,11 +3059,12 @@ void UICodeEditor::drawLineNumbers( const std::pair<int, int>& lineRange,
|
||||
} else {
|
||||
pos = String( String::toString( i + 1 ) ).padLeft( lineNumberDigits, ' ' );
|
||||
}
|
||||
Text line( std::move( pos ), mFont, fontSize );
|
||||
line.setStyleConfig( mFontStyleConfig );
|
||||
line.setFontSize( fontSize );
|
||||
line.setColor( ( i >= selection.start().line() && i <= selection.end().line() )
|
||||
? mLineNumberActiveFontColor
|
||||
: mLineNumberFontColor );
|
||||
line.setString( std::move( pos ) );
|
||||
line.draw( screenStart.x + mLineNumberPaddingLeft,
|
||||
startScroll.y + lineHeight * (double)i + lineOffset );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user