diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-02-17 09:56:25 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-02-17 09:56:25 +0100 |
commit | 83db92c69b303ca0e45c1deea46beb2e7e7375cd (patch) | |
tree | f81142a57be3f0e73f0df12f9a8ce17e8f3bcff9 | |
parent | cefe1e065475e82351e3d735f52da75bc4024967 (diff) | |
parent | 7246b229e136d0fc918b4ac98472fa92114d1a02 (diff) |
Merge pull request #73486 from bruvzg/dash_size
Set RTL minimal dash size to 2.0, add invalid dash size error to the `draw_dashed_line`.
-rw-r--r-- | scene/gui/rich_text_label.cpp | 6 | ||||
-rw-r--r-- | scene/main/canvas_item.cpp | 3 |
2 files changed, 5 insertions, 4 deletions
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 2c1c44322a..973b02b3a3 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -1179,7 +1179,7 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o dot_ul_started = false; float y_off = TS->shaped_text_get_underline_position(rid); float underline_width = TS->shaped_text_get_underline_thickness(rid) * theme_cache.base_scale; - draw_dashed_line(dot_ul_start + Vector2(0, y_off), p_ofs + Vector2(off.x, off.y + y_off), dot_ul_color, underline_width, underline_width * 2); + draw_dashed_line(dot_ul_start + Vector2(0, y_off), p_ofs + Vector2(off.x, off.y + y_off), dot_ul_color, underline_width, MAX(2.0, underline_width * 2)); } if (_find_strikethrough(it)) { if (!st_started) { @@ -1341,7 +1341,7 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o dot_ul_started = false; float y_off = TS->shaped_text_get_underline_position(rid); float underline_width = TS->shaped_text_get_underline_thickness(rid) * theme_cache.base_scale; - draw_dashed_line(dot_ul_start + Vector2(0, y_off), p_ofs + Vector2(off.x, off.y + y_off), dot_ul_color, underline_width, underline_width * 2); + draw_dashed_line(dot_ul_start + Vector2(0, y_off), p_ofs + Vector2(off.x, off.y + y_off), dot_ul_color, underline_width, MAX(2.0, underline_width * 2)); } if (st_started) { st_started = false; @@ -1363,7 +1363,7 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o dot_ul_started = false; float y_off = TS->shaped_text_get_underline_position(rid); float underline_width = TS->shaped_text_get_underline_thickness(rid) * theme_cache.base_scale; - draw_dashed_line(dot_ul_start + Vector2(0, y_off), p_ofs + Vector2(off.x, off.y + y_off), dot_ul_color, underline_width, underline_width * 2); + draw_dashed_line(dot_ul_start + Vector2(0, y_off), p_ofs + Vector2(off.x, off.y + y_off), dot_ul_color, underline_width, MAX(2.0, underline_width * 2)); } if (st_started) { st_started = false; diff --git a/scene/main/canvas_item.cpp b/scene/main/canvas_item.cpp index 1c7d42ad36..b36353158b 100644 --- a/scene/main/canvas_item.cpp +++ b/scene/main/canvas_item.cpp @@ -513,11 +513,12 @@ bool CanvasItem::is_y_sort_enabled() const { void CanvasItem::draw_dashed_line(const Point2 &p_from, const Point2 &p_to, const Color &p_color, real_t p_width, real_t p_dash, bool p_aligned) { ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal."); + ERR_FAIL_COND(p_dash <= 0.0); float length = (p_to - p_from).length(); Vector2 step = p_dash * (p_to - p_from).normalized(); - if (length < p_dash || step == Vector2() || p_dash <= 0.0) { + if (length < p_dash || step == Vector2()) { RenderingServer::get_singleton()->canvas_item_add_line(canvas_item, p_from, p_to, p_color, p_width); return; } |