Merge pull request #83094 from dalexeev/editor-fix-some-editor-help-tooltip-issues
Editor: Fix some issues with `EditorHelpTooltip`
This commit is contained in:
commit
87460bdc3c
|
@ -2264,7 +2264,12 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt, Control
|
|||
p_rt->push_strikethrough();
|
||||
pos = brk_end + 1;
|
||||
tag_stack.push_front(tag);
|
||||
|
||||
} else if (tag == "lb") {
|
||||
p_rt->add_text("[");
|
||||
pos = brk_end + 1;
|
||||
} else if (tag == "rb") {
|
||||
p_rt->add_text("]");
|
||||
pos = brk_end + 1;
|
||||
} else if (tag == "url") {
|
||||
int end = bbcode.find("[", brk_end);
|
||||
if (end == -1) {
|
||||
|
@ -2850,7 +2855,7 @@ void EditorHelpTooltip::_notification(int p_what) {
|
|||
// `p_text` is expected to be something like these:
|
||||
// - `class|Control||`;
|
||||
// - `property|Control|size|`;
|
||||
// - `signal|Control|gui_input|(event: InputEvent)`
|
||||
// - `signal|Control|gui_input|(event: InputEvent)`.
|
||||
void EditorHelpTooltip::parse_tooltip(const String &p_text) {
|
||||
tooltip_text = p_text;
|
||||
|
||||
|
@ -2895,7 +2900,7 @@ void EditorHelpTooltip::parse_tooltip(const String &p_text) {
|
|||
}
|
||||
|
||||
// Metadata special handling replaces "Property:" with "Metadata": above.
|
||||
formatted_text += " [u][b]" + title.trim_prefix("metadata/") + "[/b][/u]" + property_args + "\n";
|
||||
formatted_text += " [u][b]" + title.trim_prefix("metadata/") + "[/b][/u]" + property_args.replace("[", "[lb]") + "\n";
|
||||
formatted_text += description.is_empty() ? "[i]" + TTR("No description available.") + "[/i]" : description;
|
||||
set_text(formatted_text);
|
||||
}
|
||||
|
|
|
@ -906,12 +906,24 @@ void EditorProperty::_update_pin_flags() {
|
|||
}
|
||||
|
||||
Control *EditorProperty::make_custom_tooltip(const String &p_text) const {
|
||||
EditorHelpTooltip *tooltip = memnew(EditorHelpTooltip(p_text));
|
||||
EditorHelpBit *tooltip = nullptr;
|
||||
|
||||
if (has_doc_tooltip) {
|
||||
tooltip = memnew(EditorHelpTooltip(p_text));
|
||||
}
|
||||
|
||||
if (object->has_method("_get_property_warning")) {
|
||||
String warn = object->call("_get_property_warning", property);
|
||||
if (!warn.is_empty()) {
|
||||
tooltip->set_text(tooltip->get_rich_text()->get_text() + "\n[b][color=" + get_theme_color(SNAME("warning_color")).to_html(false) + "]" + warn + "[/color][/b]");
|
||||
String prev_text;
|
||||
if (tooltip == nullptr) {
|
||||
tooltip = memnew(EditorHelpBit());
|
||||
tooltip->set_text(p_text);
|
||||
tooltip->get_rich_text()->set_custom_minimum_size(Size2(360 * EDSCALE, 0));
|
||||
} else {
|
||||
prev_text = tooltip->get_rich_text()->get_text() + "\n";
|
||||
}
|
||||
tooltip->set_text(prev_text + "[b][color=" + get_theme_color(SNAME("warning_color")).to_html(false) + "]" + warn + "[/color][/b]");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1148,8 +1160,7 @@ void EditorInspectorCategory::_notification(int p_what) {
|
|||
}
|
||||
|
||||
Control *EditorInspectorCategory::make_custom_tooltip(const String &p_text) const {
|
||||
// Far from perfect solution, as there's nothing that prevents a category from having a name that starts with that.
|
||||
return p_text.begins_with("class|") ? memnew(EditorHelpTooltip(p_text)) : nullptr;
|
||||
return doc_class_name.is_empty() ? nullptr : memnew(EditorHelpTooltip(p_text));
|
||||
}
|
||||
|
||||
Size2 EditorInspectorCategory::get_minimum_size() const {
|
||||
|
@ -3316,6 +3327,7 @@ void EditorInspector::update_tree() {
|
|||
} else {
|
||||
ep->set_tooltip_text("theme_item|" + classname + "|" + theme_item_name + "|");
|
||||
}
|
||||
ep->has_doc_tooltip = true;
|
||||
}
|
||||
|
||||
ep->set_doc_path(doc_path);
|
||||
|
|
|
@ -74,6 +74,7 @@ private:
|
|||
StringName property;
|
||||
String property_path;
|
||||
String doc_path;
|
||||
bool has_doc_tooltip = false;
|
||||
|
||||
int property_usage;
|
||||
|
||||
|
|
Loading…
Reference in New Issue