You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-16 14:00:40 +00:00
Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks
This commit is contained in:
@@ -43,7 +43,6 @@
|
||||
DocData *EditorHelp::doc = NULL;
|
||||
|
||||
void EditorHelp::_init_colors() {
|
||||
|
||||
title_color = get_color("accent_color", "Editor");
|
||||
text_color = get_color("default_color", "RichTextLabel");
|
||||
headline_color = get_color("headline_color", "EditorHelp");
|
||||
@@ -64,14 +63,12 @@ void EditorHelp::_unhandled_key_input(const Ref<InputEvent> &p_ev) {
|
||||
Ref<InputEventKey> k = p_ev;
|
||||
|
||||
if (k.is_valid() && k->get_control() && k->get_scancode() == KEY_F) {
|
||||
|
||||
search->grab_focus();
|
||||
search->select_all();
|
||||
}
|
||||
}
|
||||
|
||||
void EditorHelp::_search(bool p_search_previous) {
|
||||
|
||||
if (p_search_previous)
|
||||
find_bar->search_prev();
|
||||
else
|
||||
@@ -79,12 +76,10 @@ void EditorHelp::_search(bool p_search_previous) {
|
||||
}
|
||||
|
||||
void EditorHelp::_class_list_select(const String &p_select) {
|
||||
|
||||
_goto_desc(p_select);
|
||||
}
|
||||
|
||||
void EditorHelp::_class_desc_select(const String &p_select) {
|
||||
|
||||
if (p_select.begins_with("$")) { //enum
|
||||
String select = p_select.substr(1, p_select.length());
|
||||
String class_name;
|
||||
@@ -181,7 +176,6 @@ void EditorHelp::_class_desc_resized() {
|
||||
}
|
||||
|
||||
void EditorHelp::_add_type(const String &p_type, const String &p_enum) {
|
||||
|
||||
String t = p_type;
|
||||
if (t.empty())
|
||||
t = "void";
|
||||
@@ -211,7 +205,6 @@ void EditorHelp::_add_type(const String &p_type, const String &p_enum) {
|
||||
}
|
||||
|
||||
String EditorHelp::_fix_constant(const String &p_constant) const {
|
||||
|
||||
if (p_constant.strip_edges() == "4294967295") {
|
||||
return "0xFFFFFFFF";
|
||||
}
|
||||
@@ -228,7 +221,6 @@ String EditorHelp::_fix_constant(const String &p_constant) const {
|
||||
}
|
||||
|
||||
void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview) {
|
||||
|
||||
method_line[p_method.name] = class_desc->get_line_count() - 2; //gets overridden if description
|
||||
|
||||
const bool is_vararg = p_method.qualifiers.find("vararg") != -1;
|
||||
@@ -273,7 +265,6 @@ void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview
|
||||
class_desc->add_text(": ");
|
||||
_add_type(p_method.arguments[j].type, p_method.arguments[j].enumeration);
|
||||
if (p_method.arguments[j].default_value != "") {
|
||||
|
||||
class_desc->push_color(symbol_color);
|
||||
class_desc->add_text(" = ");
|
||||
class_desc->pop();
|
||||
@@ -299,7 +290,6 @@ void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview
|
||||
class_desc->add_text(")");
|
||||
class_desc->pop();
|
||||
if (p_method.qualifiers != "") {
|
||||
|
||||
class_desc->push_color(qualifier_color);
|
||||
class_desc->add_text(" ");
|
||||
_add_text(p_method.qualifiers);
|
||||
@@ -311,7 +301,6 @@ void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview
|
||||
}
|
||||
|
||||
Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) {
|
||||
|
||||
if (!doc->class_list.has(p_class))
|
||||
return ERR_DOES_NOT_EXIST;
|
||||
|
||||
@@ -365,7 +354,6 @@ void EditorHelp::_update_doc() {
|
||||
|
||||
// Ascendents
|
||||
if (cd.inherits != "") {
|
||||
|
||||
class_desc->push_color(title_color);
|
||||
class_desc->push_font(doc_font);
|
||||
class_desc->add_text(TTR("Inherits:") + " ");
|
||||
@@ -389,14 +377,11 @@ void EditorHelp::_update_doc() {
|
||||
|
||||
// Descendents
|
||||
if (ClassDB::class_exists(cd.name)) {
|
||||
|
||||
bool found = false;
|
||||
bool prev = false;
|
||||
|
||||
for (Map<String, DocData::ClassDoc>::Element *E = doc->class_list.front(); E; E = E->next()) {
|
||||
|
||||
if (E->get().inherits == cd.name) {
|
||||
|
||||
if (!found) {
|
||||
class_desc->push_color(title_color);
|
||||
class_desc->push_font(doc_font);
|
||||
@@ -406,7 +391,6 @@ void EditorHelp::_update_doc() {
|
||||
}
|
||||
|
||||
if (prev) {
|
||||
|
||||
class_desc->add_text(" , ");
|
||||
}
|
||||
|
||||
@@ -426,7 +410,6 @@ void EditorHelp::_update_doc() {
|
||||
|
||||
// Brief description
|
||||
if (cd.brief_description != "") {
|
||||
|
||||
class_desc->push_color(text_color);
|
||||
class_desc->push_font(doc_bold_font);
|
||||
class_desc->push_indent(1);
|
||||
@@ -441,7 +424,6 @@ void EditorHelp::_update_doc() {
|
||||
|
||||
// Class description
|
||||
if (cd.description != "") {
|
||||
|
||||
section_line.push_back(Pair<String, int>(TTR("Description"), class_desc->get_line_count() - 2));
|
||||
description_line = class_desc->get_line_count() - 2;
|
||||
class_desc->push_color(title_color);
|
||||
@@ -501,7 +483,6 @@ void EditorHelp::_update_doc() {
|
||||
bool property_descr = false;
|
||||
|
||||
if (cd.properties.size()) {
|
||||
|
||||
section_line.push_back(Pair<String, int>(TTR("Properties"), class_desc->get_line_count() - 2));
|
||||
class_desc->push_color(title_color);
|
||||
class_desc->push_font(doc_title_font);
|
||||
@@ -601,7 +582,6 @@ void EditorHelp::_update_doc() {
|
||||
}
|
||||
|
||||
if (methods.size()) {
|
||||
|
||||
if (sort_methods)
|
||||
methods.sort();
|
||||
|
||||
@@ -675,7 +655,6 @@ void EditorHelp::_update_doc() {
|
||||
|
||||
// Theme properties
|
||||
if (cd.theme_properties.size()) {
|
||||
|
||||
section_line.push_back(Pair<String, int>(TTR("Theme Properties"), class_desc->get_line_count() - 2));
|
||||
class_desc->push_color(title_color);
|
||||
class_desc->push_font(doc_title_font);
|
||||
@@ -688,7 +667,6 @@ void EditorHelp::_update_doc() {
|
||||
class_desc->set_table_column_expand(1, 1);
|
||||
|
||||
for (int i = 0; i < cd.theme_properties.size(); i++) {
|
||||
|
||||
theme_property_line[cd.theme_properties[i].name] = class_desc->get_line_count() - 2; //gets overridden if description
|
||||
|
||||
class_desc->push_cell();
|
||||
@@ -738,7 +716,6 @@ void EditorHelp::_update_doc() {
|
||||
|
||||
// Signals
|
||||
if (cd.signals.size()) {
|
||||
|
||||
if (sort_methods) {
|
||||
cd.signals.sort();
|
||||
}
|
||||
@@ -756,7 +733,6 @@ void EditorHelp::_update_doc() {
|
||||
class_desc->push_indent(1);
|
||||
|
||||
for (int i = 0; i < cd.signals.size(); i++) {
|
||||
|
||||
signal_line[cd.signals[i].name] = class_desc->get_line_count() - 2; //gets overridden if description
|
||||
class_desc->push_font(doc_code_font); // monofont
|
||||
class_desc->push_color(headline_color);
|
||||
@@ -774,7 +750,6 @@ void EditorHelp::_update_doc() {
|
||||
class_desc->add_text(": ");
|
||||
_add_type(cd.signals[i].arguments[j].type);
|
||||
if (cd.signals[i].arguments[j].default_value != "") {
|
||||
|
||||
class_desc->push_color(symbol_color);
|
||||
class_desc->add_text(" = ");
|
||||
class_desc->pop();
|
||||
@@ -789,7 +764,6 @@ void EditorHelp::_update_doc() {
|
||||
class_desc->pop();
|
||||
class_desc->pop(); // end monofont
|
||||
if (cd.signals[i].description != "") {
|
||||
|
||||
class_desc->push_font(doc_font);
|
||||
class_desc->push_color(comment_color);
|
||||
class_desc->push_indent(1);
|
||||
@@ -808,12 +782,10 @@ void EditorHelp::_update_doc() {
|
||||
|
||||
// Constants and enums
|
||||
if (cd.constants.size()) {
|
||||
|
||||
Map<String, Vector<DocData::ConstantDoc>> enums;
|
||||
Vector<DocData::ConstantDoc> constants;
|
||||
|
||||
for (int i = 0; i < cd.constants.size(); i++) {
|
||||
|
||||
if (cd.constants[i].enumeration != String()) {
|
||||
if (!enums.has(cd.constants[i].enumeration)) {
|
||||
enums[cd.constants[i].enumeration] = Vector<DocData::ConstantDoc>();
|
||||
@@ -821,14 +793,12 @@ void EditorHelp::_update_doc() {
|
||||
|
||||
enums[cd.constants[i].enumeration].push_back(cd.constants[i]);
|
||||
} else {
|
||||
|
||||
constants.push_back(cd.constants[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Enums
|
||||
if (enums.size()) {
|
||||
|
||||
section_line.push_back(Pair<String, int>(TTR("Enumerations"), class_desc->get_line_count() - 2));
|
||||
class_desc->push_color(title_color);
|
||||
class_desc->push_font(doc_title_font);
|
||||
@@ -840,7 +810,6 @@ void EditorHelp::_update_doc() {
|
||||
class_desc->add_newline();
|
||||
|
||||
for (Map<String, Vector<DocData::ConstantDoc>>::Element *E = enums.front(); E; E = E->next()) {
|
||||
|
||||
enum_line[E->key()] = class_desc->get_line_count() - 2;
|
||||
|
||||
class_desc->push_color(title_color);
|
||||
@@ -914,7 +883,6 @@ void EditorHelp::_update_doc() {
|
||||
|
||||
// Constants
|
||||
if (constants.size()) {
|
||||
|
||||
section_line.push_back(Pair<String, int>(TTR("Constants"), class_desc->get_line_count() - 2));
|
||||
class_desc->push_color(title_color);
|
||||
class_desc->push_font(doc_title_font);
|
||||
@@ -926,7 +894,6 @@ void EditorHelp::_update_doc() {
|
||||
class_desc->add_newline();
|
||||
|
||||
for (int i = 0; i < constants.size(); i++) {
|
||||
|
||||
constant_line[constants[i].name] = class_desc->get_line_count() - 2;
|
||||
class_desc->push_font(doc_code_font);
|
||||
|
||||
@@ -973,7 +940,6 @@ void EditorHelp::_update_doc() {
|
||||
|
||||
// Property descriptions
|
||||
if (property_descr) {
|
||||
|
||||
section_line.push_back(Pair<String, int>(TTR("Property Descriptions"), class_desc->get_line_count() - 2));
|
||||
class_desc->push_color(title_color);
|
||||
class_desc->push_font(doc_title_font);
|
||||
@@ -985,7 +951,6 @@ void EditorHelp::_update_doc() {
|
||||
class_desc->add_newline();
|
||||
|
||||
for (int i = 0; i < cd.properties.size(); i++) {
|
||||
|
||||
if (cd.properties[i].overridden)
|
||||
continue;
|
||||
|
||||
@@ -1030,7 +995,6 @@ void EditorHelp::_update_doc() {
|
||||
}
|
||||
|
||||
if (cd.properties[i].setter != "") {
|
||||
|
||||
class_desc->push_cell();
|
||||
class_desc->pop(); // cell
|
||||
|
||||
@@ -1055,7 +1019,6 @@ void EditorHelp::_update_doc() {
|
||||
}
|
||||
|
||||
if (cd.properties[i].getter != "") {
|
||||
|
||||
class_desc->push_cell();
|
||||
class_desc->pop(); // cell
|
||||
|
||||
@@ -1107,7 +1070,6 @@ void EditorHelp::_update_doc() {
|
||||
|
||||
// Method descriptions
|
||||
if (method_descr) {
|
||||
|
||||
section_line.push_back(Pair<String, int>(TTR("Method Descriptions"), class_desc->get_line_count() - 2));
|
||||
class_desc->push_color(title_color);
|
||||
class_desc->push_font(doc_title_font);
|
||||
@@ -1129,7 +1091,6 @@ void EditorHelp::_update_doc() {
|
||||
}
|
||||
|
||||
for (int i = 0; i < methods_filtered.size(); i++) {
|
||||
|
||||
class_desc->push_font(doc_code_font);
|
||||
_add_method(methods_filtered[i], false);
|
||||
class_desc->pop();
|
||||
@@ -1171,7 +1132,6 @@ void EditorHelp::_request_help(const String &p_string) {
|
||||
}
|
||||
|
||||
void EditorHelp::_help_callback(const String &p_topic) {
|
||||
|
||||
String what = p_topic.get_slice(":", 0);
|
||||
String clss = p_topic.get_slice(":", 1);
|
||||
String name;
|
||||
@@ -1223,7 +1183,6 @@ void EditorHelp::_help_callback(const String &p_topic) {
|
||||
}
|
||||
|
||||
static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) {
|
||||
|
||||
DocData *doc = EditorHelp::get_doc_data();
|
||||
String base_path;
|
||||
|
||||
@@ -1247,7 +1206,6 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) {
|
||||
|
||||
int pos = 0;
|
||||
while (pos < bbcode.length()) {
|
||||
|
||||
int brk_pos = bbcode.find("[", pos);
|
||||
|
||||
if (brk_pos < 0)
|
||||
@@ -1266,7 +1224,6 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) {
|
||||
int brk_end = bbcode.find("]", brk_pos + 1);
|
||||
|
||||
if (brk_end == -1) {
|
||||
|
||||
String text = bbcode.substr(brk_pos, bbcode.length() - brk_pos);
|
||||
if (!code_tag)
|
||||
text = text.replace("\n", "\n\n");
|
||||
@@ -1281,7 +1238,6 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) {
|
||||
bool tag_ok = tag_stack.size() && tag_stack.front()->get() == tag.substr(1, tag.length());
|
||||
|
||||
if (!tag_ok) {
|
||||
|
||||
p_rt->add_text("[");
|
||||
pos = brk_pos + 1;
|
||||
continue;
|
||||
@@ -1298,12 +1254,10 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) {
|
||||
code_tag = false;
|
||||
|
||||
} else if (code_tag) {
|
||||
|
||||
p_rt->add_text("[");
|
||||
pos = brk_pos + 1;
|
||||
|
||||
} else if (tag.begins_with("method ") || tag.begins_with("member ") || tag.begins_with("signal ") || tag.begins_with("enum ") || tag.begins_with("constant ")) {
|
||||
|
||||
int tag_end = tag.find(" ");
|
||||
|
||||
String link_tag = tag.substr(0, tag_end);
|
||||
@@ -1317,7 +1271,6 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) {
|
||||
pos = brk_end + 1;
|
||||
|
||||
} else if (doc->class_list.has(tag)) {
|
||||
|
||||
p_rt->push_color(link_color);
|
||||
p_rt->push_meta("#" + tag);
|
||||
p_rt->add_text(tag);
|
||||
@@ -1326,19 +1279,16 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) {
|
||||
pos = brk_end + 1;
|
||||
|
||||
} else if (tag == "b") {
|
||||
|
||||
//use bold font
|
||||
p_rt->push_font(doc_bold_font);
|
||||
pos = brk_end + 1;
|
||||
tag_stack.push_front(tag);
|
||||
} else if (tag == "i") {
|
||||
|
||||
//use italics font
|
||||
p_rt->push_color(font_color_hl);
|
||||
pos = brk_end + 1;
|
||||
tag_stack.push_front(tag);
|
||||
} else if (tag == "code" || tag == "codeblock") {
|
||||
|
||||
//use monospace font
|
||||
p_rt->push_font(doc_code_font);
|
||||
p_rt->push_color(code_color);
|
||||
@@ -1346,31 +1296,26 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) {
|
||||
pos = brk_end + 1;
|
||||
tag_stack.push_front(tag);
|
||||
} else if (tag == "center") {
|
||||
|
||||
//align to center
|
||||
p_rt->push_align(RichTextLabel::ALIGN_CENTER);
|
||||
pos = brk_end + 1;
|
||||
tag_stack.push_front(tag);
|
||||
} else if (tag == "br") {
|
||||
|
||||
//force a line break
|
||||
p_rt->add_newline();
|
||||
pos = brk_end + 1;
|
||||
} else if (tag == "u") {
|
||||
|
||||
//use underline
|
||||
p_rt->push_underline();
|
||||
pos = brk_end + 1;
|
||||
tag_stack.push_front(tag);
|
||||
} else if (tag == "s") {
|
||||
|
||||
//use strikethrough
|
||||
p_rt->push_strikethrough();
|
||||
pos = brk_end + 1;
|
||||
tag_stack.push_front(tag);
|
||||
|
||||
} else if (tag == "url") {
|
||||
|
||||
int end = bbcode.find("[", brk_end);
|
||||
if (end == -1)
|
||||
end = bbcode.length();
|
||||
@@ -1380,13 +1325,11 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) {
|
||||
pos = brk_end + 1;
|
||||
tag_stack.push_front(tag);
|
||||
} else if (tag.begins_with("url=")) {
|
||||
|
||||
String url = tag.substr(4, tag.length());
|
||||
p_rt->push_meta(url);
|
||||
pos = brk_end + 1;
|
||||
tag_stack.push_front("url");
|
||||
} else if (tag == "img") {
|
||||
|
||||
int end = bbcode.find("[", brk_end);
|
||||
if (end == -1)
|
||||
end = bbcode.length();
|
||||
@@ -1399,7 +1342,6 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) {
|
||||
pos = end;
|
||||
tag_stack.push_front(tag);
|
||||
} else if (tag.begins_with("color=")) {
|
||||
|
||||
String col = tag.substr(6, tag.length());
|
||||
Color color;
|
||||
|
||||
@@ -1445,7 +1387,6 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) {
|
||||
tag_stack.push_front("color");
|
||||
|
||||
} else if (tag.begins_with("font=")) {
|
||||
|
||||
String fnt = tag.substr(5, tag.length());
|
||||
|
||||
Ref<Font> font = ResourceLoader::load(base_path.plus_file(fnt), "Font");
|
||||
@@ -1459,7 +1400,6 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) {
|
||||
tag_stack.push_front("font");
|
||||
|
||||
} else {
|
||||
|
||||
p_rt->add_text("["); //ignore
|
||||
pos = brk_pos + 1;
|
||||
}
|
||||
@@ -1467,12 +1407,10 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) {
|
||||
}
|
||||
|
||||
void EditorHelp::_add_text(const String &p_bbcode) {
|
||||
|
||||
_add_text_to_rt(p_bbcode, class_desc);
|
||||
}
|
||||
|
||||
void EditorHelp::generate_doc() {
|
||||
|
||||
doc = memnew(DocData);
|
||||
doc->generate(true);
|
||||
DocData compdoc;
|
||||
@@ -1481,11 +1419,9 @@ void EditorHelp::generate_doc() {
|
||||
}
|
||||
|
||||
void EditorHelp::_notification(int p_what) {
|
||||
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_READY:
|
||||
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
|
||||
|
||||
_update_doc();
|
||||
} break;
|
||||
case NOTIFICATION_THEME_CHANGED: {
|
||||
@@ -1499,12 +1435,10 @@ void EditorHelp::_notification(int p_what) {
|
||||
}
|
||||
|
||||
void EditorHelp::go_to_help(const String &p_help) {
|
||||
|
||||
_help_callback(p_help);
|
||||
}
|
||||
|
||||
void EditorHelp::go_to_class(const String &p_class, int p_scroll) {
|
||||
|
||||
_goto_desc(p_class, p_scroll);
|
||||
}
|
||||
|
||||
@@ -1523,12 +1457,10 @@ void EditorHelp::scroll_to_section(int p_section_index) {
|
||||
}
|
||||
|
||||
void EditorHelp::popup_search() {
|
||||
|
||||
find_bar->popup_search();
|
||||
}
|
||||
|
||||
String EditorHelp::get_class() {
|
||||
|
||||
return edited_class;
|
||||
}
|
||||
|
||||
@@ -1537,16 +1469,13 @@ void EditorHelp::search_again(bool p_search_previous) {
|
||||
}
|
||||
|
||||
int EditorHelp::get_scroll() const {
|
||||
|
||||
return class_desc->get_v_scroll()->get_value();
|
||||
}
|
||||
void EditorHelp::set_scroll(int p_scroll) {
|
||||
|
||||
class_desc->get_v_scroll()->set_value(p_scroll);
|
||||
}
|
||||
|
||||
void EditorHelp::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method("_class_list_select", &EditorHelp::_class_list_select);
|
||||
ClassDB::bind_method("_class_desc_select", &EditorHelp::_class_desc_select);
|
||||
ClassDB::bind_method("_class_desc_input", &EditorHelp::_class_desc_input);
|
||||
@@ -1560,7 +1489,6 @@ void EditorHelp::_bind_methods() {
|
||||
}
|
||||
|
||||
EditorHelp::EditorHelp() {
|
||||
|
||||
set_custom_minimum_size(Size2(150 * EDSCALE, 0));
|
||||
|
||||
EDITOR_DEF("text_editor/help/sort_functions_alphabetically", true);
|
||||
@@ -1592,14 +1520,12 @@ EditorHelp::~EditorHelp() {
|
||||
}
|
||||
|
||||
void EditorHelpBit::_go_to_help(String p_what) {
|
||||
|
||||
EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT);
|
||||
ScriptEditor::get_singleton()->goto_help(p_what);
|
||||
emit_signal("request_hide");
|
||||
}
|
||||
|
||||
void EditorHelpBit::_meta_clicked(String p_select) {
|
||||
|
||||
if (p_select.begins_with("$")) { //enum
|
||||
|
||||
String select = p_select.substr(1, p_select.length());
|
||||
@@ -1612,11 +1538,9 @@ void EditorHelpBit::_meta_clicked(String p_select) {
|
||||
_go_to_help("class_enum:" + class_name + ":" + select);
|
||||
return;
|
||||
} else if (p_select.begins_with("#")) {
|
||||
|
||||
_go_to_help("class_name:" + p_select.substr(1, p_select.length()));
|
||||
return;
|
||||
} else if (p_select.begins_with("@")) {
|
||||
|
||||
String m = p_select.substr(1, p_select.length());
|
||||
|
||||
if (m.find(".") != -1)
|
||||
@@ -1625,17 +1549,14 @@ void EditorHelpBit::_meta_clicked(String p_select) {
|
||||
}
|
||||
|
||||
void EditorHelpBit::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method("_meta_clicked", &EditorHelpBit::_meta_clicked);
|
||||
ClassDB::bind_method(D_METHOD("set_text", "text"), &EditorHelpBit::set_text);
|
||||
ADD_SIGNAL(MethodInfo("request_hide"));
|
||||
}
|
||||
|
||||
void EditorHelpBit::_notification(int p_what) {
|
||||
|
||||
switch (p_what) {
|
||||
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
|
||||
|
||||
rich_text->add_color_override("selection_color", get_color("accent_color", "Editor") * Color(1, 1, 1, 0.4));
|
||||
} break;
|
||||
default:
|
||||
@@ -1644,13 +1565,11 @@ void EditorHelpBit::_notification(int p_what) {
|
||||
}
|
||||
|
||||
void EditorHelpBit::set_text(const String &p_text) {
|
||||
|
||||
rich_text->clear();
|
||||
_add_text_to_rt(p_text, rich_text);
|
||||
}
|
||||
|
||||
EditorHelpBit::EditorHelpBit() {
|
||||
|
||||
rich_text = memnew(RichTextLabel);
|
||||
add_child(rich_text);
|
||||
rich_text->connect("meta_clicked", this, "_meta_clicked");
|
||||
@@ -1660,7 +1579,6 @@ EditorHelpBit::EditorHelpBit() {
|
||||
}
|
||||
|
||||
FindBar::FindBar() {
|
||||
|
||||
search_text = memnew(LineEdit);
|
||||
add_child(search_text);
|
||||
search_text->set_custom_minimum_size(Size2(100 * EDSCALE, 0));
|
||||
@@ -1695,7 +1613,6 @@ FindBar::FindBar() {
|
||||
}
|
||||
|
||||
void FindBar::popup_search() {
|
||||
|
||||
show();
|
||||
bool grabbed_focus = false;
|
||||
if (!search_text->has_focus()) {
|
||||
@@ -1713,11 +1630,9 @@ void FindBar::popup_search() {
|
||||
}
|
||||
|
||||
void FindBar::_notification(int p_what) {
|
||||
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_ENTER_TREE:
|
||||
case NOTIFICATION_THEME_CHANGED: {
|
||||
|
||||
find_prev->set_icon(get_icon("MoveUp", "EditorIcons"));
|
||||
find_next->set_icon(get_icon("MoveDown", "EditorIcons"));
|
||||
hide_button->set_normal_texture(get_icon("Close", "EditorIcons"));
|
||||
@@ -1727,14 +1642,12 @@ void FindBar::_notification(int p_what) {
|
||||
matches_label->add_color_override("font_color", results_count > 0 ? get_color("font_color", "Label") : get_color("error_color", "Editor"));
|
||||
} break;
|
||||
case NOTIFICATION_VISIBILITY_CHANGED: {
|
||||
|
||||
set_process_unhandled_input(is_visible_in_tree());
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
void FindBar::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method("_unhandled_input", &FindBar::_unhandled_input);
|
||||
|
||||
ClassDB::bind_method("_search_text_changed", &FindBar::_search_text_changed);
|
||||
@@ -1747,22 +1660,18 @@ void FindBar::_bind_methods() {
|
||||
}
|
||||
|
||||
void FindBar::set_rich_text_label(RichTextLabel *p_rich_text_label) {
|
||||
|
||||
rich_text_label = p_rich_text_label;
|
||||
}
|
||||
|
||||
bool FindBar::search_next() {
|
||||
|
||||
return _search();
|
||||
}
|
||||
|
||||
bool FindBar::search_prev() {
|
||||
|
||||
return _search(true);
|
||||
}
|
||||
|
||||
bool FindBar::_search(bool p_search_previous) {
|
||||
|
||||
String stext = search_text->get_text();
|
||||
bool keep = prev_search == stext;
|
||||
|
||||
@@ -1784,7 +1693,6 @@ bool FindBar::_search(bool p_search_previous) {
|
||||
}
|
||||
|
||||
void FindBar::_update_results_count() {
|
||||
|
||||
results_count = 0;
|
||||
|
||||
String searched = search_text->get_text();
|
||||
@@ -1806,7 +1714,6 @@ void FindBar::_update_results_count() {
|
||||
}
|
||||
|
||||
void FindBar::_update_matches_label() {
|
||||
|
||||
if (search_text->get_text().empty() || results_count == -1) {
|
||||
matches_label->hide();
|
||||
} else {
|
||||
@@ -1818,7 +1725,6 @@ void FindBar::_update_matches_label() {
|
||||
}
|
||||
|
||||
void FindBar::_hide_bar() {
|
||||
|
||||
if (search_text->has_focus())
|
||||
rich_text_label->grab_focus();
|
||||
|
||||
@@ -1826,22 +1732,16 @@ void FindBar::_hide_bar() {
|
||||
}
|
||||
|
||||
void FindBar::_unhandled_input(const Ref<InputEvent> &p_event) {
|
||||
|
||||
Ref<InputEventKey> k = p_event;
|
||||
if (k.is_valid()) {
|
||||
|
||||
if (k->is_pressed() && (rich_text_label->has_focus() || is_a_parent_of(get_focus_owner()))) {
|
||||
|
||||
bool accepted = true;
|
||||
|
||||
switch (k->get_scancode()) {
|
||||
|
||||
case KEY_ESCAPE: {
|
||||
|
||||
_hide_bar();
|
||||
} break;
|
||||
default: {
|
||||
|
||||
accepted = false;
|
||||
} break;
|
||||
}
|
||||
@@ -1854,12 +1754,10 @@ void FindBar::_unhandled_input(const Ref<InputEvent> &p_event) {
|
||||
}
|
||||
|
||||
void FindBar::_search_text_changed(const String &p_text) {
|
||||
|
||||
search_next();
|
||||
}
|
||||
|
||||
void FindBar::_search_text_entered(const String &p_text) {
|
||||
|
||||
if (Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {
|
||||
search_prev();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user