Merge pull request #56910 from pycbouh/control-rtl-gives-me-no-space
This commit is contained in:
commit
4979d9fc7b
4 changed files with 71 additions and 43 deletions
|
@ -44,18 +44,25 @@
|
|||
|
||||
DocTools *EditorHelp::doc = nullptr;
|
||||
|
||||
void EditorHelp::_init_colors() {
|
||||
title_color = get_theme_color(SNAME("accent_color"), SNAME("Editor"));
|
||||
text_color = get_theme_color(SNAME("default_color"), SNAME("RichTextLabel"));
|
||||
headline_color = get_theme_color(SNAME("headline_color"), SNAME("EditorHelp"));
|
||||
base_type_color = title_color.lerp(text_color, 0.5);
|
||||
comment_color = text_color * Color(1, 1, 1, 0.6);
|
||||
symbol_color = comment_color;
|
||||
value_color = text_color * Color(1, 1, 1, 0.6);
|
||||
qualifier_color = text_color * Color(1, 1, 1, 0.8);
|
||||
type_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")).lerp(text_color, 0.5);
|
||||
class_desc->add_theme_color_override("selection_color", get_theme_color(SNAME("accent_color"), SNAME("Editor")) * Color(1, 1, 1, 0.4));
|
||||
class_desc->add_theme_constant_override("line_separation", Math::round(5 * EDSCALE));
|
||||
void EditorHelp::_update_theme() {
|
||||
text_color = get_theme_color("text_color", "EditorHelp");
|
||||
title_color = get_theme_color("title_color", "EditorHelp");
|
||||
headline_color = get_theme_color("headline_color", "EditorHelp");
|
||||
comment_color = get_theme_color("comment_color", "EditorHelp");
|
||||
symbol_color = get_theme_color("symbol_color", "EditorHelp");
|
||||
value_color = get_theme_color("value_color", "EditorHelp");
|
||||
qualifier_color = get_theme_color("qualifier_color", "EditorHelp");
|
||||
type_color = get_theme_color("type_color", "EditorHelp");
|
||||
|
||||
class_desc->add_theme_color_override("selection_color", get_theme_color("selection_color", "EditorHelp"));
|
||||
class_desc->add_theme_constant_override("line_separation", get_theme_constant("line_separation", "EditorHelp"));
|
||||
class_desc->add_theme_constant_override("table_hseparation", get_theme_constant("table_hseparation", "EditorHelp"));
|
||||
class_desc->add_theme_constant_override("table_vseparation", get_theme_constant("table_vseparation", "EditorHelp"));
|
||||
|
||||
doc_font = get_theme_font(SNAME("doc"), SNAME("EditorFonts"));
|
||||
doc_bold_font = get_theme_font(SNAME("doc_bold"), SNAME("EditorFonts"));
|
||||
doc_title_font = get_theme_font(SNAME("doc_title"), SNAME("EditorFonts"));
|
||||
doc_code_font = get_theme_font(SNAME("doc_source"), SNAME("EditorFonts"));
|
||||
}
|
||||
|
||||
void EditorHelp::_search(bool p_search_previous) {
|
||||
|
@ -184,8 +191,7 @@ void EditorHelp::_add_type(const String &p_type, const String &p_enum) {
|
|||
t = p_enum.get_slice(".", 0);
|
||||
}
|
||||
}
|
||||
const Color text_color = get_theme_color(SNAME("default_color"), SNAME("RichTextLabel"));
|
||||
const Color type_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")).lerp(text_color, 0.5);
|
||||
|
||||
class_desc->push_color(type_color);
|
||||
bool add_array = false;
|
||||
if (can_ref) {
|
||||
|
@ -496,16 +502,11 @@ void EditorHelp::_update_doc() {
|
|||
method_line.clear();
|
||||
section_line.clear();
|
||||
|
||||
_init_colors();
|
||||
|
||||
DocData::ClassDoc cd = doc->class_list[edited_class]; //make a copy, so we can sort without worrying
|
||||
|
||||
Ref<Font> doc_font = get_theme_font(SNAME("doc"), SNAME("EditorFonts"));
|
||||
Ref<Font> doc_bold_font = get_theme_font(SNAME("doc_bold"), SNAME("EditorFonts"));
|
||||
Ref<Font> doc_title_font = get_theme_font(SNAME("doc_title"), SNAME("EditorFonts"));
|
||||
Ref<Font> doc_code_font = get_theme_font(SNAME("doc_source"), SNAME("EditorFonts"));
|
||||
_update_theme();
|
||||
String link_color_text = title_color.to_html(false);
|
||||
|
||||
DocData::ClassDoc cd = doc->class_list[edited_class]; // Make a copy, so we can sort without worrying.
|
||||
|
||||
// Class name
|
||||
section_line.push_back(Pair<String, int>(TTR("Top"), 0));
|
||||
class_desc->push_font(doc_title_font);
|
||||
|
@ -1476,11 +1477,9 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) {
|
|||
Ref<Font> doc_kbd_font = p_rt->get_theme_font(SNAME("doc_keyboard"), SNAME("EditorFonts"));
|
||||
|
||||
Color headline_color = p_rt->get_theme_color(SNAME("headline_color"), SNAME("EditorHelp"));
|
||||
Color accent_color = p_rt->get_theme_color(SNAME("accent_color"), SNAME("Editor"));
|
||||
Color property_color = p_rt->get_theme_color(SNAME("property_color"), SNAME("Editor"));
|
||||
Color link_color = accent_color.lerp(headline_color, 0.8);
|
||||
Color code_color = accent_color.lerp(headline_color, 0.6);
|
||||
Color kbd_color = accent_color.lerp(property_color, 0.6);
|
||||
Color link_color = p_rt->get_theme_color(SNAME("link_color"), SNAME("EditorHelp"));
|
||||
Color code_color = p_rt->get_theme_color(SNAME("code_color"), SNAME("EditorHelp"));
|
||||
Color kbd_color = p_rt->get_theme_color(SNAME("kbd_color"), SNAME("EditorHelp"));
|
||||
|
||||
String bbcode = p_bbcode.dedent().replace("\t", "").replace("\r", "").strip_edges();
|
||||
|
||||
|
@ -1941,16 +1940,16 @@ void EditorHelpBit::_bind_methods() {
|
|||
|
||||
void EditorHelpBit::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_ENTER_TREE:
|
||||
case NOTIFICATION_THEME_CHANGED: {
|
||||
rich_text->add_theme_color_override("selection_color", get_theme_color(SNAME("selection_color"), SNAME("EditorHelp")));
|
||||
} break;
|
||||
|
||||
case NOTIFICATION_READY: {
|
||||
rich_text->clear();
|
||||
_add_text_to_rt(text, rich_text);
|
||||
|
||||
} break;
|
||||
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
|
||||
rich_text->add_theme_color_override("selection_color", get_theme_color(SNAME("accent_color"), SNAME("Editor")) * Color(1, 1, 1, 0.4));
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1964,7 +1963,6 @@ EditorHelpBit::EditorHelpBit() {
|
|||
rich_text = memnew(RichTextLabel);
|
||||
add_child(rich_text);
|
||||
rich_text->connect("meta_clicked", callable_mp(this, &EditorHelpBit::_meta_clicked));
|
||||
rich_text->add_theme_color_override("selection_color", get_theme_color(SNAME("accent_color"), SNAME("Editor")) * Color(1, 1, 1, 0.4));
|
||||
rich_text->set_override_selected_font_color(false);
|
||||
set_custom_minimum_size(Size2(0, 70 * EDSCALE));
|
||||
}
|
||||
|
|
|
@ -126,17 +126,21 @@ class EditorHelp : public VBoxContainer {
|
|||
|
||||
String base_path;
|
||||
|
||||
Color title_color;
|
||||
Color text_color;
|
||||
Color title_color;
|
||||
Color headline_color;
|
||||
Color base_type_color;
|
||||
Color type_color;
|
||||
Color comment_color;
|
||||
Color symbol_color;
|
||||
Color value_color;
|
||||
Color qualifier_color;
|
||||
Color type_color;
|
||||
|
||||
void _init_colors();
|
||||
Ref<Font> doc_font;
|
||||
Ref<Font> doc_bold_font;
|
||||
Ref<Font> doc_title_font;
|
||||
Ref<Font> doc_code_font;
|
||||
|
||||
void _update_theme();
|
||||
void _help_callback(const String &p_topic);
|
||||
|
||||
void _add_text(const String &p_bbcode);
|
||||
|
|
|
@ -1219,7 +1219,22 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
|
|||
theme->set_stylebox("focus", "RichTextLabel", make_empty_stylebox());
|
||||
theme->set_stylebox("normal", "RichTextLabel", style_tree_bg);
|
||||
|
||||
// Editor help.
|
||||
theme->set_color("title_color", "EditorHelp", accent_color);
|
||||
theme->set_color("headline_color", "EditorHelp", mono_color);
|
||||
theme->set_color("text_color", "EditorHelp", font_color);
|
||||
theme->set_color("comment_color", "EditorHelp", font_color * Color(1, 1, 1, 0.6));
|
||||
theme->set_color("symbol_color", "EditorHelp", font_color * Color(1, 1, 1, 0.6));
|
||||
theme->set_color("value_color", "EditorHelp", font_color * Color(1, 1, 1, 0.6));
|
||||
theme->set_color("qualifier_color", "EditorHelp", font_color * Color(1, 1, 1, 0.8));
|
||||
theme->set_color("type_color", "EditorHelp", accent_color.lerp(font_color, 0.5));
|
||||
theme->set_color("selection_color", "EditorHelp", accent_color * Color(1, 1, 1, 0.4));
|
||||
theme->set_color("link_color", "EditorHelp", accent_color.lerp(mono_color, 0.8));
|
||||
theme->set_color("code_color", "EditorHelp", accent_color.lerp(mono_color, 0.6));
|
||||
theme->set_color("kbd_color", "EditorHelp", accent_color.lerp(property_color, 0.6));
|
||||
theme->set_constant("line_separation", "EditorHelp", Math::round(6 * EDSCALE));
|
||||
theme->set_constant("table_hseparation", "EditorHelp", 16 * EDSCALE);
|
||||
theme->set_constant("table_vseparation", "EditorHelp", 6 * EDSCALE);
|
||||
|
||||
// Panel
|
||||
theme->set_stylebox("panel", "Panel", make_flat_stylebox(dark_color_1, 6, 4, 6, 4, corner_width));
|
||||
|
|
|
@ -325,13 +325,16 @@ void RichTextLabel::_resize_line(ItemFrame *p_frame, int p_line, const Ref<Font>
|
|||
table->columns.write[column].width = MAX(table->columns.write[column].width, ceil(frame->lines[i].text_buf->get_size().x));
|
||||
|
||||
if (i > 0) {
|
||||
frame->lines.write[i].offset.y = frame->lines[i - 1].offset.y + frame->lines[i - 1].text_buf->get_size().y;
|
||||
frame->lines.write[i].offset.y = frame->lines[i - 1].offset.y + frame->lines[i - 1].text_buf->get_size().y + get_theme_constant(SNAME("line_separation"));
|
||||
} else {
|
||||
frame->lines.write[i].offset.y = 0;
|
||||
}
|
||||
frame->lines.write[i].offset += offset;
|
||||
|
||||
float h = frame->lines[i].text_buf->get_size().y;
|
||||
float h = frame->lines[i].text_buf->get_size().y + (frame->lines[i].text_buf->get_line_count() - 1) * get_theme_constant(SNAME("line_separation"));
|
||||
if (i > 0) {
|
||||
h += get_theme_constant(SNAME("line_separation"));
|
||||
}
|
||||
if (frame->min_size_over.y > 0) {
|
||||
h = MAX(h, frame->min_size_over.y);
|
||||
}
|
||||
|
@ -570,13 +573,16 @@ void RichTextLabel::_shape_line(ItemFrame *p_frame, int p_line, const Ref<Font>
|
|||
table->columns.write[column].width = MAX(table->columns.write[column].width, ceil(frame->lines[i].text_buf->get_size().x));
|
||||
|
||||
if (i > 0) {
|
||||
frame->lines.write[i].offset.y = frame->lines[i - 1].offset.y + frame->lines[i - 1].text_buf->get_size().y;
|
||||
frame->lines.write[i].offset.y = frame->lines[i - 1].offset.y + frame->lines[i - 1].text_buf->get_size().y + get_theme_constant(SNAME("line_separation"));
|
||||
} else {
|
||||
frame->lines.write[i].offset.y = 0;
|
||||
}
|
||||
frame->lines.write[i].offset += offset;
|
||||
|
||||
float h = frame->lines[i].text_buf->get_size().y;
|
||||
float h = frame->lines[i].text_buf->get_size().y + (frame->lines[i].text_buf->get_line_count() - 1) * get_theme_constant(SNAME("line_separation"));
|
||||
if (i > 0) {
|
||||
h += get_theme_constant(SNAME("line_separation"));
|
||||
}
|
||||
if (frame->min_size_over.y > 0) {
|
||||
h = MAX(h, frame->min_size_over.y);
|
||||
}
|
||||
|
@ -622,11 +628,12 @@ void RichTextLabel::_shape_line(ItemFrame *p_frame, int p_line, const Ref<Font>
|
|||
}
|
||||
|
||||
int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_ofs, int p_width, const Color &p_base_color, int p_outline_size, const Color &p_outline_color, const Color &p_font_shadow_color, int p_shadow_outline_size, const Point2 &p_shadow_ofs, int &r_processed_glyphs) {
|
||||
Vector2 off;
|
||||
|
||||
ERR_FAIL_COND_V(p_frame == nullptr, 0);
|
||||
ERR_FAIL_COND_V(p_line < 0 || p_line >= p_frame->lines.size(), 0);
|
||||
|
||||
Vector2 off;
|
||||
int line_spacing = get_theme_constant(SNAME("line_separation"));
|
||||
|
||||
Line &l = p_frame->lines.write[p_line];
|
||||
|
||||
Item *it_from = l.from;
|
||||
|
@ -712,6 +719,10 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o
|
|||
Size2 ctrl_size = get_size();
|
||||
// Draw text.
|
||||
for (int line = 0; line < l.text_buf->get_line_count(); line++) {
|
||||
if (line > 0) {
|
||||
off.y += line_spacing;
|
||||
}
|
||||
|
||||
RID rid = l.text_buf->get_line_rid(line);
|
||||
if (p_ofs.y + off.y >= ctrl_size.height) {
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue