|
|
@@ -44,23 +44,13 @@ namespace Rml {
|
|
|
static bool BuildToken(String& token, const char*& token_begin, const char* string_end, bool first_token, bool collapse_white_space, bool break_at_endline, Style::TextTransform text_transformation, bool decode_escape_characters);
|
|
|
static bool LastToken(const char* token_begin, const char* string_end, bool collapse_white_space, bool break_at_endline);
|
|
|
|
|
|
-ElementText::ElementText(const String& tag) : Element(tag), colour(255, 255, 255), opacity(1), decoration(this)
|
|
|
-{
|
|
|
- dirty_layout_on_change = true;
|
|
|
-
|
|
|
- generated_decoration = Style::TextDecoration::None;
|
|
|
- decoration_property = Style::TextDecoration::None;
|
|
|
-
|
|
|
- geometry_dirty = true;
|
|
|
+ElementText::ElementText(const String& tag) :
|
|
|
+ Element(tag), colour(255, 255, 255), opacity(1), font_handle_version(0), geometry_dirty(true), dirty_layout_on_change(true),
|
|
|
+ generated_decoration(Style::TextDecoration::None), decoration_property(Style::TextDecoration::None), font_effects_dirty(true),
|
|
|
+ font_effects_handle(0)
|
|
|
+{}
|
|
|
|
|
|
- font_effects_handle = 0;
|
|
|
- font_effects_dirty = true;
|
|
|
- font_handle_version = 0;
|
|
|
-}
|
|
|
-
|
|
|
-ElementText::~ElementText()
|
|
|
-{
|
|
|
-}
|
|
|
+ElementText::~ElementText() {}
|
|
|
|
|
|
void ElementText::SetText(const String& _text)
|
|
|
{
|
|
|
@@ -105,10 +95,19 @@ void ElementText::OnRender()
|
|
|
// Regenerate text decoration if necessary.
|
|
|
if (decoration_property != generated_decoration)
|
|
|
{
|
|
|
- decoration.Release(true);
|
|
|
+ if (decoration_property == Style::TextDecoration::None)
|
|
|
+ {
|
|
|
+ decoration.reset();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (decoration)
|
|
|
+ decoration->Release(true);
|
|
|
+ else
|
|
|
+ decoration = MakeUnique<Geometry>(this);
|
|
|
|
|
|
- if (decoration_property != Style::TextDecoration::None)
|
|
|
GenerateDecoration(font_face_handle);
|
|
|
+ }
|
|
|
|
|
|
generated_decoration = decoration_property;
|
|
|
}
|
|
|
@@ -153,8 +152,8 @@ void ElementText::OnRender()
|
|
|
geometry[i].Render(translation);
|
|
|
}
|
|
|
|
|
|
- if (decoration_property != Style::TextDecoration::None)
|
|
|
- decoration.Render(translation);
|
|
|
+ if (decoration)
|
|
|
+ decoration->Render(translation);
|
|
|
}
|
|
|
|
|
|
// Generates a token of text from this element, returning only the width.
|
|
|
@@ -316,7 +315,6 @@ void ElementText::ClearLines()
|
|
|
|
|
|
lines.clear();
|
|
|
generated_decoration = Style::TextDecoration::None;
|
|
|
- decoration.Release(true);
|
|
|
}
|
|
|
|
|
|
// Adds a new line into the text element.
|
|
|
@@ -397,6 +395,8 @@ void ElementText::OnPropertyChange(const PropertyIdSet& changed_properties)
|
|
|
if (changed_properties.Contains(PropertyId::TextDecoration))
|
|
|
{
|
|
|
decoration_property = computed.text_decoration();
|
|
|
+ if (decoration && decoration_property == Style::TextDecoration::None)
|
|
|
+ decoration.reset();
|
|
|
}
|
|
|
|
|
|
if (font_face_changed)
|
|
|
@@ -411,11 +411,14 @@ void ElementText::OnPropertyChange(const PropertyIdSet& changed_properties)
|
|
|
geometry_dirty = true;
|
|
|
|
|
|
// Re-colour the decoration geometry.
|
|
|
- Vector< Vertex >& vertices = decoration.GetVertices();
|
|
|
- for (size_t i = 0; i < vertices.size(); ++i)
|
|
|
- vertices[i].colour = colour;
|
|
|
+ if (decoration)
|
|
|
+ {
|
|
|
+ Vector<Vertex>& vertices = decoration->GetVertices();
|
|
|
+ for (size_t i = 0; i < vertices.size(); ++i)
|
|
|
+ vertices[i].colour = colour;
|
|
|
|
|
|
- decoration.Release();
|
|
|
+ decoration->Release();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -471,7 +474,6 @@ void ElementText::GenerateGeometry(const FontFaceHandle font_face_handle)
|
|
|
for (size_t i = 0; i < lines.size(); ++i)
|
|
|
GenerateGeometry(font_face_handle, lines[i]);
|
|
|
|
|
|
- decoration.Release(true);
|
|
|
generated_decoration = Style::TextDecoration::None;
|
|
|
|
|
|
geometry_dirty = false;
|
|
|
@@ -488,9 +490,10 @@ void ElementText::GenerateGeometry(const FontFaceHandle font_face_handle, Line&
|
|
|
void ElementText::GenerateDecoration(const FontFaceHandle font_face_handle)
|
|
|
{
|
|
|
RMLUI_ZoneScopedC(0xA52A2A);
|
|
|
+ RMLUI_ASSERT(decoration);
|
|
|
|
|
|
for(const Line& line : lines)
|
|
|
- GeometryUtilities::GenerateLine(font_face_handle, &decoration, line.position, line.width, decoration_property, colour);
|
|
|
+ GeometryUtilities::GenerateLine(font_face_handle, decoration.get(), line.position, line.width, decoration_property, colour);
|
|
|
}
|
|
|
|
|
|
static bool BuildToken(String& token, const char*& token_begin, const char* string_end, bool first_token, bool collapse_white_space, bool break_at_endline, Style::TextTransform text_transformation, bool decode_escape_characters)
|