|
@@ -374,7 +374,8 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
|
|
font_color_shadow = _find_color(text, p_font_color_shadow);
|
|
font_color_shadow = _find_color(text, p_font_color_shadow);
|
|
if (_find_underline(text) || (_find_meta(text, &meta) && underline_meta)) {
|
|
if (_find_underline(text) || (_find_meta(text, &meta) && underline_meta)) {
|
|
underline = true;
|
|
underline = true;
|
|
- } else if (_find_strikethrough(text)) {
|
|
|
|
|
|
+ }
|
|
|
|
+ if (_find_strikethrough(text)) {
|
|
strikethrough = true;
|
|
strikethrough = true;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -448,11 +449,18 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
|
|
line_descent = MAX(line_descent, descent);
|
|
line_descent = MAX(line_descent, descent);
|
|
fh = line_ascent + line_descent;
|
|
fh = line_ascent + line_descent;
|
|
|
|
|
|
|
|
+ float align_spacing = 0.0f;
|
|
|
|
+ bool is_at_line_wrap = false;
|
|
if (end && c[end - 1] == ' ') {
|
|
if (end && c[end - 1] == ' ') {
|
|
if (align == ALIGN_FILL && p_mode != PROCESS_CACHE) {
|
|
if (align == ALIGN_FILL && p_mode != PROCESS_CACHE) {
|
|
int ln = MIN(l.offset_caches.size() - 1, line);
|
|
int ln = MIN(l.offset_caches.size() - 1, line);
|
|
if (l.space_caches[ln]) {
|
|
if (l.space_caches[ln]) {
|
|
- align_ofs = spaces * l.offset_caches[ln] / l.space_caches[ln];
|
|
|
|
|
|
+ align_spacing = l.offset_caches[ln] / l.space_caches[ln];
|
|
|
|
+ align_ofs = spaces * align_spacing;
|
|
|
|
+
|
|
|
|
+ if (l.space_caches[ln] == spaces) {
|
|
|
|
+ is_at_line_wrap = true;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
spaces++;
|
|
spaces++;
|
|
@@ -613,24 +621,28 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+#ifdef TOOLS_ENABLED
|
|
|
|
+ const float line_width = EDSCALE;
|
|
|
|
+#else
|
|
|
|
+ const float line_width = 1.0f;
|
|
|
|
+#endif
|
|
if (underline) {
|
|
if (underline) {
|
|
Color uc = color;
|
|
Color uc = color;
|
|
uc.a *= 0.5;
|
|
uc.a *= 0.5;
|
|
- int uy = y + lh - line_descent + 2;
|
|
|
|
- float underline_width = 1.0;
|
|
|
|
-#ifdef TOOLS_ENABLED
|
|
|
|
- underline_width *= EDSCALE;
|
|
|
|
-#endif
|
|
|
|
- VS::get_singleton()->canvas_item_add_line(ci, p_ofs + Point2(align_ofs + wofs, uy), p_ofs + Point2(align_ofs + wofs + w, uy), uc, underline_width);
|
|
|
|
- } else if (strikethrough) {
|
|
|
|
|
|
+
|
|
|
|
+ const int line_y = y + lh - (line_descent - 2);
|
|
|
|
+ const Point2 from = p_ofs + Point2(align_ofs + wofs, line_y);
|
|
|
|
+ const Point2 to = from + Point2(w + (is_at_line_wrap ? 0 : align_spacing), 0);
|
|
|
|
+ VS::get_singleton()->canvas_item_add_line(ci, from, to, uc, line_width);
|
|
|
|
+ }
|
|
|
|
+ if (strikethrough) {
|
|
Color uc = color;
|
|
Color uc = color;
|
|
uc.a *= 0.5;
|
|
uc.a *= 0.5;
|
|
- int uy = y + lh - (line_ascent + line_descent) / 2;
|
|
|
|
- float strikethrough_width = 1.0;
|
|
|
|
-#ifdef TOOLS_ENABLED
|
|
|
|
- strikethrough_width *= EDSCALE;
|
|
|
|
-#endif
|
|
|
|
- VS::get_singleton()->canvas_item_add_line(ci, p_ofs + Point2(align_ofs + wofs, uy), p_ofs + Point2(align_ofs + wofs + w, uy), uc, strikethrough_width);
|
|
|
|
|
|
+
|
|
|
|
+ const int line_y = y + lh - (line_ascent + line_descent) / 2;
|
|
|
|
+ const Point2 from = p_ofs + Point2(align_ofs + wofs, line_y);
|
|
|
|
+ const Point2 to = from + Point2(w + (is_at_line_wrap ? 0 : align_spacing), 0);
|
|
|
|
+ VS::get_singleton()->canvas_item_add_line(ci, from, to, uc, line_width);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1655,6 +1667,7 @@ void RichTextLabel::_remove_item(Item *p_item, const int p_line, const int p_sub
|
|
_remove_item(p_item->subitems.front()->get(), p_line, p_subitem_line);
|
|
_remove_item(p_item->subitems.front()->get(), p_line, p_subitem_line);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ memdelete(p_item);
|
|
}
|
|
}
|
|
|
|
|
|
void RichTextLabel::add_image(const Ref<Texture> &p_image, const int p_width, const int p_height) {
|
|
void RichTextLabel::add_image(const Ref<Texture> &p_image, const int p_width, const int p_height) {
|