summaryrefslogtreecommitdiffstats
path: root/editor/editor_help.cpp
diff options
context:
space:
mode:
authorDanil Alexeev <danil@alexeev.xyz>2023-06-15 17:06:22 +0300
committerDanil Alexeev <danil@alexeev.xyz>2023-06-15 17:23:02 +0300
commiteb391d3302167157b02b007777dd552d0b4bcd70 (patch)
treebd26bf6312ca95a67ea5e0128b2356fc13056f6f /editor/editor_help.cpp
parent824820d73a7a709f61950e74ff72392ab3f8be60 (diff)
downloadredot-engine-eb391d3302167157b02b007777dd552d0b4bcd70.tar.gz
Display `BitField[Enum]` in docs to distinguish from `Enum`
Diffstat (limited to 'editor/editor_help.cpp')
-rw-r--r--editor/editor_help.cpp24
1 files changed, 18 insertions, 6 deletions
diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp
index e709371ec6..991807ccbb 100644
--- a/editor/editor_help.cpp
+++ b/editor/editor_help.cpp
@@ -293,7 +293,7 @@ void EditorHelp::_class_desc_resized(bool p_force_update_theme) {
}
}
-void EditorHelp::_add_type(const String &p_type, const String &p_enum) {
+void EditorHelp::_add_type(const String &p_type, const String &p_enum, bool p_is_bitfield) {
if (p_type.is_empty() || p_type == "void") {
class_desc->push_color(Color(theme_cache.type_color, 0.5));
class_desc->push_hint(TTR("No return value."));
@@ -304,6 +304,7 @@ void EditorHelp::_add_type(const String &p_type, const String &p_enum) {
}
bool is_enum_type = !p_enum.is_empty();
+ bool is_bitfield = p_is_bitfield && is_enum_type;
bool can_ref = !p_type.contains("*") || is_enum_type;
String link_t = p_type; // For links in metadata
@@ -327,6 +328,13 @@ void EditorHelp::_add_type(const String &p_type, const String &p_enum) {
class_desc->add_text("Array");
class_desc->pop();
class_desc->add_text("[");
+ } else if (is_bitfield) {
+ class_desc->push_color(Color(theme_cache.type_color, 0.5));
+ class_desc->push_hint(TTR("This value is an integer composed as a bitmask of the following flags."));
+ class_desc->add_text("BitField");
+ class_desc->pop();
+ class_desc->add_text("[");
+ class_desc->pop();
}
if (is_enum_type) {
@@ -340,6 +348,10 @@ void EditorHelp::_add_type(const String &p_type, const String &p_enum) {
class_desc->pop(); // Pushed meta above.
if (add_array) {
class_desc->add_text("]");
+ } else if (is_bitfield) {
+ class_desc->push_color(Color(theme_cache.type_color, 0.5));
+ class_desc->add_text("]");
+ class_desc->pop();
}
}
class_desc->pop();
@@ -403,7 +415,7 @@ void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview
_add_bulletpoint();
}
- _add_type(p_method.return_type, p_method.return_enum);
+ _add_type(p_method.return_type, p_method.return_enum, p_method.return_is_bitfield);
if (p_overview) {
class_desc->pop(); // align
@@ -437,7 +449,7 @@ void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview
_add_text(p_method.arguments[j].name);
class_desc->add_text(": ");
- _add_type(p_method.arguments[j].type, p_method.arguments[j].enumeration);
+ _add_type(p_method.arguments[j].type, p_method.arguments[j].enumeration, p_method.arguments[j].is_bitfield);
if (!p_method.arguments[j].default_value.is_empty()) {
class_desc->push_color(theme_cache.symbol_color);
class_desc->add_text(" = ");
@@ -953,7 +965,7 @@ void EditorHelp::_update_doc() {
class_desc->push_cell();
class_desc->push_paragraph(HORIZONTAL_ALIGNMENT_RIGHT, Control::TEXT_DIRECTION_AUTO, "");
_push_code_font();
- _add_type(cd.properties[i].type, cd.properties[i].enumeration);
+ _add_type(cd.properties[i].type, cd.properties[i].enumeration, cd.properties[i].is_bitfield);
_pop_code_font();
class_desc->pop();
class_desc->pop(); // cell
@@ -1252,7 +1264,7 @@ void EditorHelp::_update_doc() {
_add_text(cd.signals[i].arguments[j].name);
class_desc->add_text(": ");
- _add_type(cd.signals[i].arguments[j].type, cd.signals[i].arguments[j].enumeration);
+ _add_type(cd.signals[i].arguments[j].type, cd.signals[i].arguments[j].enumeration, cd.signals[i].arguments[j].is_bitfield);
if (!cd.signals[i].arguments[j].default_value.is_empty()) {
class_desc->push_color(theme_cache.symbol_color);
class_desc->add_text(" = ");
@@ -1630,7 +1642,7 @@ void EditorHelp::_update_doc() {
_push_code_font();
_add_bulletpoint();
- _add_type(cd.properties[i].type, cd.properties[i].enumeration);
+ _add_type(cd.properties[i].type, cd.properties[i].enumeration, cd.properties[i].is_bitfield);
class_desc->add_text(" ");
_pop_code_font();
class_desc->pop(); // cell