From 77fd9e4dd332e01e1f6df8eaa3446ffb5aa46798 Mon Sep 17 00:00:00 2001 From: Eric M Date: Mon, 17 Aug 2020 15:52:42 +1000 Subject: Improve output log performance. Added method to create a new line in RichTextLabel without adding an ItemNewline to the previous line. Previously, removing a line then adding a newline was adding unnecessary ItemNewline instances to the previous line, significantly the remove_line method. --- scene/gui/rich_text_label.cpp | 7 +++++++ scene/gui/rich_text_label.h | 2 ++ 2 files changed, 9 insertions(+) (limited to 'scene') diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index c763ae6bd6..843e7ef6e2 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -2612,6 +2612,13 @@ void RichTextLabel::pop() { current = current->parent; } +// Creates a new line without adding an ItemNewline to the previous line. +// Useful when wanting to calling remove_line and add a new line immediately after. +void RichTextLabel::increment_line_count() { + current_frame->lines.resize(current_frame->lines.size() + 1); + _invalidate_current_line(current_frame); +} + void RichTextLabel::clear() { main->_clear_children(); current = main; diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h index e3e457d1f2..afc88e070a 100644 --- a/scene/gui/rich_text_label.h +++ b/scene/gui/rich_text_label.h @@ -483,6 +483,8 @@ public: void push_cell(); void pop(); + void increment_line_count(); + void clear(); void set_offset(int p_pixel); -- cgit v1.2.3