summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/object/object.cpp2
-rw-r--r--doc/classes/Object.xml16
-rw-r--r--doc/classes/RichTextLabel.xml6
-rwxr-xr-xdoc/tools/make_rst.py319
-rw-r--r--drivers/gles3/shaders/canvas.glsl12
-rw-r--r--drivers/gles3/shaders/stdlib_inc.glsl19
-rw-r--r--editor/code_editor.cpp263
-rw-r--r--editor/plugins/animation_player_editor_plugin.cpp4
-rw-r--r--editor/plugins/node_3d_editor_plugin.cpp16
-rw-r--r--editor/plugins/node_3d_editor_plugin.h2
-rw-r--r--editor/shader_globals_editor.cpp43
-rw-r--r--modules/raycast/SCsub7
-rw-r--r--modules/raycast/config.py14
-rw-r--r--platform/linuxbsd/os_linuxbsd.cpp2
-rw-r--r--platform/linuxbsd/os_linuxbsd.h6
-rw-r--r--platform/windows/detect.py11
-rw-r--r--scene/3d/xr_nodes.cpp40
-rw-r--r--scene/3d/xr_nodes.h2
-rw-r--r--scene/animation/animation_player.cpp2
-rw-r--r--scene/gui/graph_node.cpp66
-rw-r--r--scene/gui/rich_text_label.cpp31
-rw-r--r--scene/gui/rich_text_label.h2
22 files changed, 580 insertions, 305 deletions
diff --git a/core/object/object.cpp b/core/object/object.cpp
index d27e0d7621..105f9560d6 100644
--- a/core/object/object.cpp
+++ b/core/object/object.cpp
@@ -1473,6 +1473,8 @@ void Object::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_indexed", "property_path"), &Object::_get_indexed_bind);
ClassDB::bind_method(D_METHOD("get_property_list"), &Object::_get_property_list_bind);
ClassDB::bind_method(D_METHOD("get_method_list"), &Object::_get_method_list_bind);
+ ClassDB::bind_method(D_METHOD("property_can_revert", "property"), &Object::property_can_revert);
+ ClassDB::bind_method(D_METHOD("property_get_revert", "property"), &Object::property_get_revert);
ClassDB::bind_method(D_METHOD("notification", "what", "reversed"), &Object::notification, DEFVAL(false));
ClassDB::bind_method(D_METHOD("to_string"), &Object::to_string);
ClassDB::bind_method(D_METHOD("get_instance_id"), &Object::get_instance_id);
diff --git a/doc/classes/Object.xml b/doc/classes/Object.xml
index bf15f96291..5e834b3d91 100644
--- a/doc/classes/Object.xml
+++ b/doc/classes/Object.xml
@@ -764,6 +764,22 @@
Emits the [signal property_list_changed] signal. This is mainly used to refresh the editor, so that the Inspector and editor plugins are properly updated.
</description>
</method>
+ <method name="property_can_revert" qualifiers="const">
+ <return type="bool" />
+ <param index="0" name="property" type="StringName" />
+ <description>
+ Returns [code]true[/code] if the given [param property] has a custom default value. Use [method property_get_revert] to get the [param property]'s default value.
+ [b]Note:[/b] This method is used by the Inspector dock to display a revert icon. The object must implement [method _property_can_revert] to customize the default value. If [method _property_can_revert] is not implemented, this method returns [code]false[/code].
+ </description>
+ </method>
+ <method name="property_get_revert" qualifiers="const">
+ <return type="Variant" />
+ <param index="0" name="property" type="StringName" />
+ <description>
+ Returns the custom default value of the given [param property]. Use [method property_can_revert] to check if the [param property] has a custom default value.
+ [b]Note:[/b] This method is used by the Inspector dock to display a revert icon. The object must implement [method _property_get_revert] to customize the default value. If [method _property_get_revert] is not implemented, this method returns [code]null[/code].
+ </description>
+ </method>
<method name="remove_meta">
<return type="void" />
<param index="0" name="name" type="StringName" />
diff --git a/doc/classes/RichTextLabel.xml b/doc/classes/RichTextLabel.xml
index cb2481f705..e222894647 100644
--- a/doc/classes/RichTextLabel.xml
+++ b/doc/classes/RichTextLabel.xml
@@ -399,6 +399,12 @@
Scrolls the window's top line to match first line of the [param paragraph].
</description>
</method>
+ <method name="scroll_to_selection">
+ <return type="void" />
+ <description>
+ Scrolls to the beginning of the current selection.
+ </description>
+ </method>
<method name="select_all">
<return type="void" />
<description>
diff --git a/doc/tools/make_rst.py b/doc/tools/make_rst.py
index e5a0bbb008..8960c66acc 100755
--- a/doc/tools/make_rst.py
+++ b/doc/tools/make_rst.py
@@ -240,7 +240,7 @@ class State:
enum_def = class_def.enums[enum]
else:
- enum_def = EnumDef(enum, is_bitfield)
+ enum_def = EnumDef(enum, TypeName("int", enum), is_bitfield)
class_def.enums[enum] = enum_def
enum_def.values[constant_name] = constant_def
@@ -458,9 +458,10 @@ class ConstantDef(DefinitionBase):
class EnumDef(DefinitionBase):
- def __init__(self, name: str, bitfield: bool) -> None:
+ def __init__(self, name: str, type_name: TypeName, bitfield: bool) -> None:
super().__init__("enum", name)
+ self.type_name = type_name
self.values: OrderedDict[str, ConstantDef] = OrderedDict()
self.is_bitfield = bitfield
@@ -754,7 +755,8 @@ def make_rst_class(class_def: ClassDef, state: State, dry_run: bool, output_dir:
f.write(f".. _class_{class_name}:\n\n")
f.write(make_heading(class_name, "=", False))
- # Inheritance tree
+ ### INHERITANCE TREE ###
+
# Ascendants
if class_def.inherits:
inherits = class_def.inherits.strip()
@@ -788,6 +790,8 @@ def make_rst_class(class_def: ClassDef, state: State, dry_run: bool, output_dir:
f.write(make_type(child, state))
f.write("\n\n")
+ ### INTRODUCTION ###
+
has_description = False
# Brief description
@@ -800,7 +804,9 @@ def make_rst_class(class_def: ClassDef, state: State, dry_run: bool, output_dir:
if class_def.description is not None and class_def.description.strip() != "":
has_description = True
+ f.write(".. rst-class:: classref-introduction-group\n\n")
f.write(make_heading("Description", "-"))
+
f.write(f"{format_text_block(class_def.description.strip(), class_def, state)}\n\n")
if not has_description:
@@ -814,14 +820,22 @@ def make_rst_class(class_def: ClassDef, state: State, dry_run: bool, output_dir:
# Online tutorials
if len(class_def.tutorials) > 0:
+ f.write(".. rst-class:: classref-introduction-group\n\n")
f.write(make_heading("Tutorials", "-"))
+
for url, title in class_def.tutorials:
f.write(f"- {make_link(url, title)}\n\n")
- # Properties overview
+ ### REFERENCE TABLES ###
+
+ # Reused container for reference tables.
ml: List[Tuple[Optional[str], ...]] = []
+
+ # Properties reference table
if len(class_def.properties) > 0:
+ f.write(".. rst-class:: classref-reftable-group\n\n")
f.write(make_heading("Properties", "-"))
+
ml = []
for property_def in class_def.properties.values():
type_rst = property_def.type_name.to_rst(state)
@@ -833,76 +847,108 @@ def make_rst_class(class_def: ClassDef, state: State, dry_run: bool, output_dir:
else:
ref = f":ref:`{property_def.name}<class_{class_name}_property_{property_def.name}>`"
ml.append((type_rst, ref, default))
+
format_table(f, ml, True)
- # Constructors, Methods, Operators overview
+ # Constructors, Methods, Operators reference tables
if len(class_def.constructors) > 0:
+ f.write(".. rst-class:: classref-reftable-group\n\n")
f.write(make_heading("Constructors", "-"))
+
ml = []
for method_list in class_def.constructors.values():
for m in method_list:
ml.append(make_method_signature(class_def, m, "constructor", state))
+
format_table(f, ml)
if len(class_def.methods) > 0:
+ f.write(".. rst-class:: classref-reftable-group\n\n")
f.write(make_heading("Methods", "-"))
+
ml = []
for method_list in class_def.methods.values():
for m in method_list:
ml.append(make_method_signature(class_def, m, "method", state))
+
format_table(f, ml)
if len(class_def.operators) > 0:
+ f.write(".. rst-class:: classref-reftable-group\n\n")
f.write(make_heading("Operators", "-"))
+
ml = []
for method_list in class_def.operators.values():
for m in method_list:
ml.append(make_method_signature(class_def, m, "operator", state))
+
format_table(f, ml)
- # Theme properties
+ # Theme properties reference table
if len(class_def.theme_items) > 0:
+ f.write(".. rst-class:: classref-reftable-group\n\n")
f.write(make_heading("Theme Properties", "-"))
- pl: List[Tuple[Optional[str], ...]] = []
+
+ ml = []
for theme_item_def in class_def.theme_items.values():
ref = f":ref:`{theme_item_def.name}<class_{class_name}_theme_{theme_item_def.data_name}_{theme_item_def.name}>`"
- pl.append((theme_item_def.type_name.to_rst(state), ref, theme_item_def.default_value))
- format_table(f, pl, True)
+ ml.append((theme_item_def.type_name.to_rst(state), ref, theme_item_def.default_value))
+
+ format_table(f, ml, True)
- # Signals
+ ### DETAILED DESCRIPTIONS ###
+
+ # Signal descriptions
if len(class_def.signals) > 0:
+ f.write(make_separator(True))
+ f.write(".. rst-class:: classref-descriptions-group\n\n")
f.write(make_heading("Signals", "-"))
+
index = 0
for signal in class_def.signals.values():
if index != 0:
- f.write("----\n\n")
+ f.write(make_separator())
+
+ # Create signal signature and anchor point.
f.write(f".. _class_{class_name}_signal_{signal.name}:\n\n")
+ f.write(".. rst-class:: classref-signal\n\n")
+
_, signature = make_method_signature(class_def, signal, "", state)
- f.write(f"- {signature}\n\n")
+ f.write(f"{signature}\n\n")
+
+ # Add signal description, or a call to action if it's missing.
if signal.description is not None and signal.description.strip() != "":
f.write(f"{format_text_block(signal.description.strip(), signal, state)}\n\n")
+ else:
+ f.write(".. container:: contribute\n\n\t")
+ f.write(
+ translate(
+ "There is currently no description for this signal. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!"
+ )
+ + "\n\n"
+ )
index += 1
- # Enums
+ # Enumeration descriptions
if len(class_def.enums) > 0:
+ f.write(make_separator(True))
+ f.write(".. rst-class:: classref-descriptions-group\n\n")
f.write(make_heading("Enumerations", "-"))
+
index = 0
for e in class_def.enums.values():
if index != 0:
- f.write("----\n\n")
+ f.write(make_separator())
+
+ # Create enumeration signature and anchor point.
f.write(f".. _enum_{class_name}_{e.name}:\n\n")
- # Sphinx seems to divide the bullet list into individual <ul> tags if we weave the labels into it.
- # As such I'll put them all above the list. Won't be perfect but better than making the list visually broken.
- # As to why I'm not modifying the reference parser to directly link to the _enum label:
- # If somebody gets annoyed enough to fix it, all existing references will magically improve.
- for value in e.values.values():
- f.write(f".. _class_{class_name}_constant_{value.name}:\n\n")
+ f.write(".. rst-class:: classref-enumeration\n\n")
if e.is_bitfield:
f.write(f"flags **{e.name}**:\n\n")
@@ -910,45 +956,66 @@ def make_rst_class(class_def: ClassDef, state: State, dry_run: bool, output_dir:
f.write(f"enum **{e.name}**:\n\n")
for value in e.values.values():
- f.write(f"- **{value.name}** = **{value.value}**")
+ # Also create signature and anchor point for each enum constant.
+
+ f.write(f".. _class_{class_name}_constant_{value.name}:\n\n")
+ f.write(".. rst-class:: classref-enumeration-constant\n\n")
+
+ f.write(f"{e.type_name.to_rst(state)} **{value.name}** = ``{value.value}``\n\n")
+
+ # Add enum constant description.
+
if value.text is not None and value.text.strip() != "":
- # If value.text contains a bullet point list, each entry needs additional indentation
- f.write(f" --- {indent_bullets(format_text_block(value.text.strip(), value, state))}")
+ f.write(f"{format_text_block(value.text.strip(), value, state)}")
f.write("\n\n")
index += 1
- # Constants
+ # Constant descriptions
if len(class_def.constants) > 0:
+ f.write(make_separator(True))
+ f.write(".. rst-class:: classref-descriptions-group\n\n")
f.write(make_heading("Constants", "-"))
- # Sphinx seems to divide the bullet list into individual <ul> tags if we weave the labels into it.
- # As such I'll put them all above the list. Won't be perfect but better than making the list visually broken.
+
for constant in class_def.constants.values():
+ # Create constant signature and anchor point.
+
f.write(f".. _class_{class_name}_constant_{constant.name}:\n\n")
+ f.write(".. rst-class:: classref-constant\n\n")
+
+ f.write(f"**{constant.name}** = ``{constant.value}``\n\n")
+
+ # Add enum constant description.
- for constant in class_def.constants.values():
- f.write(f"- **{constant.name}** = **{constant.value}**")
if constant.text is not None and constant.text.strip() != "":
- f.write(f" --- {format_text_block(constant.text.strip(), constant, state)}")
+ f.write(f"{format_text_block(constant.text.strip(), constant, state)}")
f.write("\n\n")
- # Annotations
+ # Annotation descriptions
if len(class_def.annotations) > 0:
+ f.write(make_separator(True))
f.write(make_heading("Annotations", "-"))
+
index = 0
for method_list in class_def.annotations.values(): # type: ignore
for i, m in enumerate(method_list):
if index != 0:
- f.write("----\n\n")
+ f.write(make_separator())
+
+ # Create annotation signature and anchor point.
if i == 0:
f.write(f".. _class_{class_name}_annotation_{m.name}:\n\n")
+ f.write(".. rst-class:: classref-annotation\n\n")
+
_, signature = make_method_signature(class_def, m, "", state)
- f.write(f"- {signature}\n\n")
+ f.write(f"{signature}\n\n")
+
+ # Add annotation description, or a call to action if it's missing.
if m.description is not None and m.description.strip() != "":
f.write(f"{format_text_block(m.description.strip(), m, state)}\n\n")
@@ -965,7 +1032,10 @@ def make_rst_class(class_def: ClassDef, state: State, dry_run: bool, output_dir:
# Property descriptions
if any(not p.overrides for p in class_def.properties.values()) > 0:
+ f.write(make_separator(True))
+ f.write(".. rst-class:: classref-descriptions-group\n\n")
f.write(make_heading("Property Descriptions", "-"))
+
index = 0
for property_def in class_def.properties.values():
@@ -973,22 +1043,36 @@ def make_rst_class(class_def: ClassDef, state: State, dry_run: bool, output_dir:
continue
if index != 0:
- f.write("----\n\n")
+ f.write(make_separator())
+
+ # Create property signature and anchor point.
f.write(f".. _class_{class_name}_property_{property_def.name}:\n\n")
- f.write(f"- {property_def.type_name.to_rst(state)} **{property_def.name}**\n\n")
+ f.write(".. rst-class:: classref-property\n\n")
- info: List[Tuple[Optional[str], ...]] = []
- # Not using translate() for now as it breaks table formatting.
+ property_default = ""
if property_def.default_value is not None:
- info.append(("*Default*", property_def.default_value))
+ property_default = f" = {property_def.default_value}"
+ f.write(f"{property_def.type_name.to_rst(state)} **{property_def.name}**{property_default}\n\n")
+
+ # Create property setter and getter records.
+
+ property_setget = ""
+
if property_def.setter is not None and not property_def.setter.startswith("_"):
- info.append(("*Setter*", f"{property_def.setter}(value)"))
+ property_setter = make_setter_signature(class_def, property_def, state)
+ property_setget += f"- {property_setter}\n"
+
if property_def.getter is not None and not property_def.getter.startswith("_"):
- info.append(("*Getter*", f"{property_def.getter}()"))
+ property_getter = make_getter_signature(class_def, property_def, state)
+ property_setget += f"- {property_getter}\n"
+
+ if property_setget != "":
+ f.write(".. rst-class:: classref-property-setget\n\n")
+ f.write(property_setget)
+ f.write("\n")
- if len(info) > 0:
- format_table(f, info)
+ # Add property description, or a call to action if it's missing.
if property_def.text is not None and property_def.text.strip() != "":
f.write(f"{format_text_block(property_def.text.strip(), property_def, state)}\n\n")
@@ -1005,19 +1089,28 @@ def make_rst_class(class_def: ClassDef, state: State, dry_run: bool, output_dir:
# Constructor, Method, Operator descriptions
if len(class_def.constructors) > 0:
+ f.write(make_separator(True))
+ f.write(".. rst-class:: classref-descriptions-group\n\n")
f.write(make_heading("Constructor Descriptions", "-"))
+
index = 0
for method_list in class_def.constructors.values():
for i, m in enumerate(method_list):
if index != 0:
- f.write("----\n\n")
+ f.write(make_separator())
+
+ # Create constructor signature and anchor point.
if i == 0:
f.write(f".. _class_{class_name}_constructor_{m.name}:\n\n")
+ f.write(".. rst-class:: classref-constructor\n\n")
+
ret_type, signature = make_method_signature(class_def, m, "", state)
- f.write(f"- {ret_type} {signature}\n\n")
+ f.write(f"{ret_type} {signature}\n\n")
+
+ # Add constructor description, or a call to action if it's missing.
if m.description is not None and m.description.strip() != "":
f.write(f"{format_text_block(m.description.strip(), m, state)}\n\n")
@@ -1033,19 +1126,28 @@ def make_rst_class(class_def: ClassDef, state: State, dry_run: bool, output_dir:
index += 1
if len(class_def.methods) > 0:
+ f.write(make_separator(True))
+ f.write(".. rst-class:: classref-descriptions-group\n\n")
f.write(make_heading("Method Descriptions", "-"))
+
index = 0
for method_list in class_def.methods.values():
for i, m in enumerate(method_list):
if index != 0:
- f.write("----\n\n")
+ f.write(make_separator())
+
+ # Create method signature and anchor point.
if i == 0:
f.write(f".. _class_{class_name}_method_{m.name}:\n\n")
+ f.write(".. rst-class:: classref-method\n\n")
+
ret_type, signature = make_method_signature(class_def, m, "", state)
- f.write(f"- {ret_type} {signature}\n\n")
+ f.write(f"{ret_type} {signature}\n\n")
+
+ # Add method description, or a call to action if it's missing.
if m.description is not None and m.description.strip() != "":
f.write(f"{format_text_block(m.description.strip(), m, state)}\n\n")
@@ -1061,20 +1163,31 @@ def make_rst_class(class_def: ClassDef, state: State, dry_run: bool, output_dir:
index += 1
if len(class_def.operators) > 0:
+ f.write(make_separator(True))
+ f.write(".. rst-class:: classref-descriptions-group\n\n")
f.write(make_heading("Operator Descriptions", "-"))
+
index = 0
for method_list in class_def.operators.values():
for i, m in enumerate(method_list):
if index != 0:
- f.write("----\n\n")
- out = f".. _class_{class_name}_operator_{sanitize_operator_name(m.name, state)}"
+ f.write(make_separator())
+
+ # Create operator signature and anchor point.
+
+ operator_anchor = f".. _class_{class_name}_operator_{sanitize_operator_name(m.name, state)}"
for parameter in m.parameters:
- out += f"_{parameter.type_name.type_name}"
- out += f":\n\n"
- f.write(out)
+ operator_anchor += f"_{parameter.type_name.type_name}"
+ operator_anchor += f":\n\n"
+ f.write(operator_anchor)
+
+ f.write(".. rst-class:: classref-operator\n\n")
+
ret_type, signature = make_method_signature(class_def, m, "", state)
- f.write(f"- {ret_type} {signature}\n\n")
+ f.write(f"{ret_type} {signature}\n\n")
+
+ # Add operator description, or a call to action if it's missing.
if m.description is not None and m.description.strip() != "":
f.write(f"{format_text_block(m.description.strip(), m, state)}\n\n")
@@ -1091,23 +1204,27 @@ def make_rst_class(class_def: ClassDef, state: State, dry_run: bool, output_dir:
# Theme property descriptions
if len(class_def.theme_items) > 0:
+ f.write(make_separator(True))
+ f.write(".. rst-class:: classref-descriptions-group\n\n")
f.write(make_heading("Theme Property Descriptions", "-"))
+
index = 0
for theme_item_def in class_def.theme_items.values():
if index != 0:
- f.write("----\n\n")
+ f.write(make_separator())
+
+ # Create theme property signature and anchor point.
f.write(f".. _class_{class_name}_theme_{theme_item_def.data_name}_{theme_item_def.name}:\n\n")
- f.write(f"- {theme_item_def.type_name.to_rst(state)} **{theme_item_def.name}**\n\n")
+ f.write(".. rst-class:: classref-themeproperty\n\n")
- info = []
+ theme_item_default = ""
if theme_item_def.default_value is not None:
- # Not using translate() for now as it breaks table formatting.
- info.append(("*Default*", theme_item_def.default_value))
+ theme_item_default = f" = {theme_item_def.default_value}"
+ f.write(f"{theme_item_def.type_name.to_rst(state)} **{theme_item_def.name}**{theme_item_default}\n\n")
- if len(info) > 0:
- format_table(f, info)
+ # Add theme property description, or a call to action if it's missing.
if theme_item_def.text is not None and theme_item_def.text.strip() != "":
f.write(f"{format_text_block(theme_item_def.text.strip(), theme_item_def, state)}\n\n")
@@ -1216,6 +1333,39 @@ def make_method_signature(
return ret_type, out
+def make_setter_signature(class_def: ClassDef, property_def: PropertyDef, state: State) -> str:
+ if property_def.setter is None:
+ return ""
+
+ # If setter is a method available as a method definition, we use that.
+ if property_def.setter in class_def.methods:
+ setter = class_def.methods[property_def.setter][0]
+ # Otherwise we fake it with the information we have available.
+ else:
+ setter_params: List[ParameterDef] = []
+ setter_params.append(ParameterDef("value", property_def.type_name, None))
+ setter = MethodDef(property_def.setter, TypeName("void"), setter_params, None, None)
+
+ ret_type, signature = make_method_signature(class_def, setter, "", state)
+ return f"{ret_type} {signature}"
+
+
+def make_getter_signature(class_def: ClassDef, property_def: PropertyDef, state: State) -> str:
+ if property_def.getter is None:
+ return ""
+
+ # If getter is a method available as a method definition, we use that.
+ if property_def.getter in class_def.methods:
+ getter = class_def.methods[property_def.getter][0]
+ # Otherwise we fake it with the information we have available.
+ else:
+ getter_params: List[ParameterDef] = []
+ getter = MethodDef(property_def.getter, property_def.type_name, getter_params, None, None)
+
+ ret_type, signature = make_method_signature(class_def, getter, "", state)
+ return f"{ret_type} {signature}"
+
+
def make_heading(title: str, underline: str, l10n: bool = True) -> str:
if l10n:
new_title = translate(title)
@@ -1247,6 +1397,14 @@ def make_footer() -> str:
)
+def make_separator(section_level: bool = False) -> str:
+ separator_class = "item"
+ if section_level:
+ separator_class = "section"
+
+ return f".. rst-class:: classref-{separator_class}-separator\n\n----\n\n"
+
+
def make_link(url: str, title: str) -> str:
match = GODOT_DOCS_PATTERN.search(url)
if match:
@@ -1409,8 +1567,8 @@ def format_text_block(
# Tag is a reference to a class.
if tag_text in state.classes:
if tag_text == state.current_class:
- # Don't create a link to the same class, format it as inline code.
- tag_text = f"``{tag_text}``"
+ # Don't create a link to the same class, format it as strong emphasis.
+ tag_text = f"**{tag_text}**"
else:
tag_text = make_type(tag_text, state)
escape_pre = True
@@ -1872,6 +2030,11 @@ def format_table(f: TextIO, data: List[Tuple[Optional[str], ...]], remove_empty_
if len(data) == 0:
return
+ f.write(".. table::\n")
+ f.write(" :widths: auto\n\n")
+
+ # Calculate the width of each column first, we will use this information
+ # to properly format RST-style tables.
column_sizes = [0] * len(data[0])
for row in data:
for i, text in enumerate(row):
@@ -1879,14 +2042,21 @@ def format_table(f: TextIO, data: List[Tuple[Optional[str], ...]], remove_empty_
if text_length > column_sizes[i]:
column_sizes[i] = text_length
+ # Each table row is wrapped in two separators, consecutive rows share the same separator.
+ # All separators, or rather borders, have the same shape and content. We compose it once,
+ # then reuse it.
+
sep = ""
for size in column_sizes:
if size == 0 and remove_empty_columns:
continue
- sep += "+" + "-" * (size + 2)
+ sep += "+" + "-" * (size + 2) # Content of each cell is padded by 1 on each side.
sep += "+\n"
- f.write(sep)
+ # Draw the first separator.
+ f.write(f" {sep}")
+
+ # Draw each row and close it with a separator.
for row in data:
row_text = "|"
for i, text in enumerate(row):
@@ -1894,8 +2064,10 @@ def format_table(f: TextIO, data: List[Tuple[Optional[str], ...]], remove_empty_
continue
row_text += f' {(text or "").ljust(column_sizes[i])} |'
row_text += "\n"
- f.write(row_text)
- f.write(sep)
+
+ f.write(f" {row_text}")
+ f.write(f" {sep}")
+
f.write("\n")
@@ -1957,24 +2129,5 @@ def sanitize_operator_name(dirty_name: str, state: State) -> str:
return clear_name
-def indent_bullets(text: str) -> str:
- # Take the text and check each line for a bullet point represented by "-".
- # Where found, indent the given line by a further "\t".
- # Used to properly indent bullet points contained in the description for enum values.
- # Ignore the first line - text will be prepended to it so bullet points wouldn't work anyway.
- bullet_points = "-"
-
- lines = text.splitlines(keepends=True)
- for line_index, line in enumerate(lines[1:], start=1):
- pos = 0
- while pos < len(line) and line[pos] == "\t":
- pos += 1
-
- if pos < len(line) and line[pos] in bullet_points:
- lines[line_index] = f"{line[:pos]}\t{line[pos:]}"
-
- return "".join(lines)
-
-
if __name__ == "__main__":
main()
diff --git a/drivers/gles3/shaders/canvas.glsl b/drivers/gles3/shaders/canvas.glsl
index 60139de472..a61ea1587d 100644
--- a/drivers/gles3/shaders/canvas.glsl
+++ b/drivers/gles3/shaders/canvas.glsl
@@ -288,11 +288,9 @@ vec3 light_normal_compute(vec3 light_vec, vec3 normal, vec3 base_color, vec3 lig
#endif
-#define SHADOW_TEST(m_uv) \
- { \
- highp float sd = SHADOW_DEPTH(m_uv); \
- shadow += step(sd, shadow_uv.z / shadow_uv.w); \
- }
+/* clang-format off */
+#define SHADOW_TEST(m_uv) { highp float sd = SHADOW_DEPTH(m_uv); shadow += step(sd, shadow_uv.z / shadow_uv.w); }
+/* clang-format on */
//float distance = length(shadow_pos);
vec4 light_shadow_compute(uint light_base, vec4 light_color, vec4 shadow_uv
@@ -332,7 +330,7 @@ vec4 light_shadow_compute(uint light_base, vec4 light_color, vec4 shadow_uv
shadow /= 13.0;
}
- vec4 shadow_color = unpackUnorm4x8(light_array[light_base].shadow_color);
+ vec4 shadow_color = godot_unpackUnorm4x8(light_array[light_base].shadow_color);
#ifdef LIGHT_CODE_USED
shadow_color.rgb *= shadow_modulate;
#endif
@@ -499,7 +497,7 @@ void main() {
if (specular_shininess_used || (using_light && normal_used && bool(draw_data[draw_data_instance].flags & FLAGS_DEFAULT_SPECULAR_MAP_USED))) {
specular_shininess = texture(specular_texture, uv);
- specular_shininess *= unpackUnorm4x8(draw_data[draw_data_instance].specular_shininess);
+ specular_shininess *= godot_unpackUnorm4x8(draw_data[draw_data_instance].specular_shininess);
specular_shininess_used = true;
} else {
specular_shininess = vec4(1.0);
diff --git a/drivers/gles3/shaders/stdlib_inc.glsl b/drivers/gles3/shaders/stdlib_inc.glsl
index d819940b1d..8d4a24cc1f 100644
--- a/drivers/gles3/shaders/stdlib_inc.glsl
+++ b/drivers/gles3/shaders/stdlib_inc.glsl
@@ -39,23 +39,32 @@ vec2 unpackSnorm2x16(uint p) {
return clamp((v - 32767.0) * vec2(0.00003051851), vec2(-1.0), vec2(1.0));
}
-uint packUnorm4x8(vec4 v) {
+#endif
+
+// Compatibility renames. These are exposed with the "godot_" prefix
+// to work around an Adreno bug which was exposing these ES310 functions
+// in ES300 shaders. Internally, we must use the "godot_" prefix, but user shaders
+// will be mapped automatically.
+uint godot_packUnorm4x8(vec4 v) {
uvec4 uv = uvec4(round(clamp(v, vec4(0.0), vec4(1.0)) * 255.0));
return uv.x | (uv.y << uint(8)) | (uv.z << uint(16)) | (uv.w << uint(24));
}
-vec4 unpackUnorm4x8(uint p) {
+vec4 godot_unpackUnorm4x8(uint p) {
return vec4(float(p & uint(0xff)), float((p >> uint(8)) & uint(0xff)), float((p >> uint(16)) & uint(0xff)), float(p >> uint(24))) * 0.00392156862; // 1.0 / 255.0
}
-uint packSnorm4x8(vec4 v) {
+uint godot_packSnorm4x8(vec4 v) {
uvec4 uv = uvec4(round(clamp(v, vec4(-1.0), vec4(1.0)) * 127.0) + 127.0);
return uv.x | uv.y << uint(8) | uv.z << uint(16) | uv.w << uint(24);
}
-vec4 unpackSnorm4x8(uint p) {
+vec4 godot_unpackSnorm4x8(uint p) {
vec4 v = vec4(float(p & uint(0xff)), float((p >> uint(8)) & uint(0xff)), float((p >> uint(16)) & uint(0xff)), float(p >> uint(24)));
return clamp((v - vec4(127.0)) * vec4(0.00787401574), vec4(-1.0), vec4(1.0));
}
-#endif
+#define packUnorm4x8 godot_packUnorm4x8
+#define unpackUnorm4x8 godot_unpackUnorm4x8
+#define packSnorm4x8 godot_packSnorm4x8
+#define unpackSnorm4x8 godot_unpackSnorm4x8
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index 65cb083ac7..926c01b334 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -33,6 +33,7 @@
#include "core/input/input.h"
#include "core/os/keyboard.h"
#include "core/string/string_builder.h"
+#include "core/templates/pair.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/plugins/script_editor_plugin.h"
@@ -1290,90 +1291,98 @@ void CodeTextEditor::convert_case(CaseStyle p_case) {
void CodeTextEditor::move_lines_up() {
text_editor->begin_complex_operation();
- Vector<int> carets_to_remove;
-
Vector<int> caret_edit_order = text_editor->get_caret_index_edit_order();
+
+ // Lists of carets representing each group
+ Vector<Vector<int>> caret_groups;
+ Vector<Pair<int, int>> group_borders;
+
+ // Search for groups of carets and their selections residing on the same lines
for (int i = 0; i < caret_edit_order.size(); i++) {
int c = caret_edit_order[i];
- int cl = text_editor->get_caret_line(c);
- bool swaped_caret = false;
- for (int j = i + 1; j < caret_edit_order.size(); j++) {
- if (text_editor->has_selection(caret_edit_order[j])) {
- if (text_editor->get_selection_from_line() == cl) {
- carets_to_remove.push_back(caret_edit_order[j]);
- continue;
- }
+ Vector<int> new_group{ c };
+ Pair<int, int> group_border;
+ if (text_editor->has_selection(c)) {
+ group_border.first = text_editor->get_selection_from_line(c);
+ group_border.second = text_editor->get_selection_to_line(c);
+ } else {
+ group_border.first = text_editor->get_caret_line(c);
+ group_border.second = text_editor->get_caret_line(c);
+ }
- if (text_editor->get_selection_to_line() == cl) {
- if (text_editor->has_selection(c)) {
- if (text_editor->get_selection_to_line(c) != cl) {
- text_editor->select(cl + 1, 0, text_editor->get_selection_to_line(c), text_editor->get_selection_to_column(c), c);
- break;
- }
- }
+ for (int j = i; j < caret_edit_order.size() - 1; j++) {
+ int c_current = caret_edit_order[j];
+ int c_next = caret_edit_order[j + 1];
- carets_to_remove.push_back(c);
- i = j - 1;
- swaped_caret = true;
- break;
- }
+ int next_start_pos = text_editor->has_selection(c_next) ? text_editor->get_selection_from_line(c_next) : text_editor->get_caret_line(c_next);
+ int next_end_pos = text_editor->has_selection(c_next) ? text_editor->get_selection_to_line(c_next) : text_editor->get_caret_line(c_next);
+
+ int current_start_pos = text_editor->has_selection(c_current) ? text_editor->get_selection_from_line(c_current) : text_editor->get_caret_line(c_current);
+
+ i = j;
+ if (next_end_pos != current_start_pos && next_end_pos + 1 != current_start_pos) {
break;
}
-
- if (text_editor->get_caret_line(caret_edit_order[j]) == cl) {
- carets_to_remove.push_back(caret_edit_order[j]);
- i = j;
- continue;
+ group_border.first = next_start_pos;
+ new_group.push_back(c_next);
+ // If the last caret is added to the current group there is no need to process it again
+ if (j + 1 == caret_edit_order.size() - 1) {
+ i++;
}
- break;
}
+ group_borders.push_back(group_border);
+ caret_groups.push_back(new_group);
+ }
- if (swaped_caret) {
+ for (int i = group_borders.size() - 1; i >= 0; i--) {
+ if (group_borders[i].first - 1 < 0) {
continue;
}
- if (text_editor->has_selection(c)) {
+ // If the group starts overlapping with the upper group don't move it
+ if (i < group_borders.size() - 1 && group_borders[i].first - 1 <= group_borders[i + 1].second) {
+ continue;
+ }
+
+ // We have to remember caret positions and selections prior to line swapping
+ Vector<Vector<int>> caret_group_parameters;
+
+ for (int j = 0; j < caret_groups[i].size(); j++) {
+ int c = caret_groups[i][j];
+ int cursor_line = text_editor->get_caret_line(c);
+ int cursor_column = text_editor->get_caret_column(c);
+
+ if (!text_editor->has_selection(c)) {
+ caret_group_parameters.push_back(Vector<int>{ -1, -1, -1, -1, cursor_line, cursor_column });
+ continue;
+ }
int from_line = text_editor->get_selection_from_line(c);
int from_col = text_editor->get_selection_from_column(c);
int to_line = text_editor->get_selection_to_line(c);
int to_column = text_editor->get_selection_to_column(c);
- int cursor_line = text_editor->get_caret_line(c);
-
- for (int j = from_line; j <= to_line; j++) {
- int line_id = j;
- int next_id = j - 1;
+ caret_group_parameters.push_back(Vector<int>{ from_line, from_col, to_line, to_column, cursor_line, cursor_column });
+ }
- if (line_id == 0 || next_id < 0) {
- return;
- }
+ for (int line_id = group_borders[i].first; line_id <= group_borders[i].second; line_id++) {
+ text_editor->unfold_line(line_id);
+ text_editor->unfold_line(line_id - 1);
- text_editor->unfold_line(line_id);
- text_editor->unfold_line(next_id);
+ text_editor->swap_lines(line_id - 1, line_id);
+ }
- text_editor->swap_lines(line_id, next_id);
- text_editor->set_caret_line(next_id, c == 0, true, 0, c);
- }
- int from_line_up = from_line > 0 ? from_line - 1 : from_line;
- int to_line_up = to_line > 0 ? to_line - 1 : to_line;
- int cursor_line_up = cursor_line > 0 ? cursor_line - 1 : cursor_line;
- text_editor->select(from_line_up, from_col, to_line_up, to_column, c);
- text_editor->set_caret_line(cursor_line_up, c == 0, true, 0, c);
- } else {
- int line_id = text_editor->get_caret_line(c);
- int next_id = line_id - 1;
+ for (int j = 0; j < caret_groups[i].size(); j++) {
+ int c = caret_groups[i][j];
+ Vector<int> caret_parameters = caret_group_parameters[j];
+ text_editor->set_caret_line(caret_parameters[4] - 1, c == 0, true, 0, c);
+ text_editor->set_caret_column(caret_parameters[5], c == 0, c);
- if (line_id == 0 || next_id < 0) {
- return;
+ if (caret_parameters[0] >= 0) {
+ text_editor->select(caret_parameters[0] - 1, caret_parameters[1], caret_parameters[2] - 1, caret_parameters[3], c);
}
-
- text_editor->unfold_line(line_id);
- text_editor->unfold_line(next_id);
-
- text_editor->swap_lines(line_id, next_id);
- text_editor->set_caret_line(next_id, c == 0, true, 0, c);
}
}
+
text_editor->end_complex_operation();
text_editor->merge_overlapping_carets();
text_editor->queue_redraw();
@@ -1382,95 +1391,97 @@ void CodeTextEditor::move_lines_up() {
void CodeTextEditor::move_lines_down() {
text_editor->begin_complex_operation();
- Vector<int> carets_to_remove;
-
Vector<int> caret_edit_order = text_editor->get_caret_index_edit_order();
+
+ // Lists of carets representing each group
+ Vector<Vector<int>> caret_groups;
+ Vector<Pair<int, int>> group_borders;
+
+ // Search for groups of carets and their selections residing on the same lines
for (int i = 0; i < caret_edit_order.size(); i++) {
int c = caret_edit_order[i];
- int cl = text_editor->get_caret_line(c);
- bool swaped_caret = false;
- for (int j = i + 1; j < caret_edit_order.size(); j++) {
- if (text_editor->has_selection(caret_edit_order[j])) {
- if (text_editor->get_selection_from_line() == cl) {
- carets_to_remove.push_back(caret_edit_order[j]);
- continue;
- }
+ Vector<int> new_group{ c };
+ Pair<int, int> group_border;
+ if (text_editor->has_selection(c)) {
+ group_border.first = text_editor->get_selection_from_line(c);
+ group_border.second = text_editor->get_selection_to_line(c);
+ } else {
+ group_border.first = text_editor->get_caret_line(c);
+ group_border.second = text_editor->get_caret_line(c);
+ }
- if (text_editor->get_selection_to_line() == cl) {
- if (text_editor->has_selection(c)) {
- if (text_editor->get_selection_to_line(c) != cl) {
- text_editor->select(cl + 1, 0, text_editor->get_selection_to_line(c), text_editor->get_selection_to_column(c), c);
- break;
- }
- }
+ for (int j = i; j < caret_edit_order.size() - 1; j++) {
+ int c_current = caret_edit_order[j];
+ int c_next = caret_edit_order[j + 1];
- carets_to_remove.push_back(c);
- i = j - 1;
- swaped_caret = true;
- break;
+ int next_start_pos = text_editor->has_selection(c_next) ? text_editor->get_selection_from_line(c_next) : text_editor->get_caret_line(c_next);
+ int next_end_pos = text_editor->has_selection(c_next) ? text_editor->get_selection_to_line(c_next) : text_editor->get_caret_line(c_next);
+
+ int current_start_pos = text_editor->has_selection(c_current) ? text_editor->get_selection_from_line(c_current) : text_editor->get_caret_line(c_current);
+
+ i = j;
+ if (next_end_pos == current_start_pos || next_end_pos + 1 == current_start_pos) {
+ group_border.first = next_start_pos;
+ new_group.push_back(c_next);
+ // If the last caret is added to the current group there is no need to process it again
+ if (j + 1 == caret_edit_order.size() - 1) {
+ i++;
}
+ } else {
break;
}
-
- if (text_editor->get_caret_line(caret_edit_order[j]) == cl) {
- carets_to_remove.push_back(caret_edit_order[j]);
- i = j;
- continue;
- }
- break;
}
+ group_borders.push_back(group_border);
+ caret_groups.push_back(new_group);
+ }
- if (swaped_caret) {
+ for (int i = 0; i < group_borders.size(); i++) {
+ if (group_borders[i].second + 1 > text_editor->get_line_count() - 1) {
continue;
}
- if (text_editor->has_selection(c)) {
- int from_line = text_editor->get_selection_from_line(c);
- int from_col = text_editor->get_selection_from_column(c);
- int to_line = text_editor->get_selection_to_line(c);
- int to_column = text_editor->get_selection_to_column(c);
- int cursor_line = text_editor->get_caret_line(c);
-
- for (int l = to_line; l >= from_line; l--) {
- int line_id = l;
- int next_id = l + 1;
-
- if (line_id == text_editor->get_line_count() - 1 || next_id > text_editor->get_line_count()) {
- continue;
- }
-
- text_editor->unfold_line(line_id);
- text_editor->unfold_line(next_id);
+ // If the group starts overlapping with the upper group don't move it
+ if (i > 0 && group_borders[i].second + 1 >= group_borders[i - 1].first) {
+ continue;
+ }
- text_editor->swap_lines(line_id, next_id);
- text_editor->set_caret_line(next_id, c == 0, true, 0, c);
- }
- int from_line_down = from_line < text_editor->get_line_count() ? from_line + 1 : from_line;
- int to_line_down = to_line < text_editor->get_line_count() ? to_line + 1 : to_line;
- int cursor_line_down = cursor_line < text_editor->get_line_count() ? cursor_line + 1 : cursor_line;
- text_editor->select(from_line_down, from_col, to_line_down, to_column, c);
- text_editor->set_caret_line(cursor_line_down, c == 0, true, 0, c);
- } else {
- int line_id = text_editor->get_caret_line(c);
- int next_id = line_id + 1;
+ // We have to remember caret positions and selections prior to line swapping
+ Vector<Vector<int>> caret_group_parameters;
- if (line_id == text_editor->get_line_count() - 1 || next_id > text_editor->get_line_count()) {
- continue;
+ for (int j = 0; j < caret_groups[i].size(); j++) {
+ int c = caret_groups[i][j];
+ int cursor_line = text_editor->get_caret_line(c);
+ int cursor_column = text_editor->get_caret_column(c);
+
+ if (text_editor->has_selection(c)) {
+ int from_line = text_editor->get_selection_from_line(c);
+ int from_col = text_editor->get_selection_from_column(c);
+ int to_line = text_editor->get_selection_to_line(c);
+ int to_column = text_editor->get_selection_to_column(c);
+ caret_group_parameters.push_back(Vector<int>{ from_line, from_col, to_line, to_column, cursor_line, cursor_column });
+ } else {
+ caret_group_parameters.push_back(Vector<int>{ -1, -1, -1, -1, cursor_line, cursor_column });
}
+ }
+ for (int line_id = group_borders[i].second; line_id >= group_borders[i].first; line_id--) {
text_editor->unfold_line(line_id);
- text_editor->unfold_line(next_id);
+ text_editor->unfold_line(line_id + 1);
- text_editor->swap_lines(line_id, next_id);
- text_editor->set_caret_line(next_id, c == 0, true, 0, c);
+ text_editor->swap_lines(line_id + 1, line_id);
}
- }
- // Sort and remove backwards to preserve indexes.
- carets_to_remove.sort();
- for (int i = carets_to_remove.size() - 1; i >= 0; i--) {
- text_editor->remove_caret(carets_to_remove[i]);
+ for (int j = 0; j < caret_groups[i].size(); j++) {
+ int c = caret_groups[i][j];
+ Vector<int> caret_parameters = caret_group_parameters[j];
+ text_editor->set_caret_line(caret_parameters[4] + 1, c == 0, true, 0, c);
+ text_editor->set_caret_column(caret_parameters[5], c == 0, c);
+
+ if (caret_parameters[0] >= 0) {
+ text_editor->select(caret_parameters[0] + 1, caret_parameters[1], caret_parameters[2] + 1, caret_parameters[3], c);
+ }
+ }
}
text_editor->merge_overlapping_carets();
diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp
index 338688f274..5183a738ae 100644
--- a/editor/plugins/animation_player_editor_plugin.cpp
+++ b/editor/plugins/animation_player_editor_plugin.cpp
@@ -216,8 +216,8 @@ void AnimationPlayerEditor::_play_from_pressed() {
player->stop(); //so it won't blend with itself
}
ERR_FAIL_COND_EDMSG(!_validate_tracks(player->get_animation(current)), "Animation tracks may have any invalid key, abort playing.");
- player->play(current);
player->seek(time);
+ player->play(current);
}
//unstop
@@ -254,8 +254,8 @@ void AnimationPlayerEditor::_play_bw_from_pressed() {
player->stop(); //so it won't blend with itself
}
ERR_FAIL_COND_EDMSG(!_validate_tracks(player->get_animation(current)), "Animation tracks may have any invalid key, abort playing.");
- player->play(current, -1, -1, true);
player->seek(time);
+ player->play(current, -1, -1, true);
}
//unstop
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp
index 4194fd831b..c97de80a76 100644
--- a/editor/plugins/node_3d_editor_plugin.cpp
+++ b/editor/plugins/node_3d_editor_plugin.cpp
@@ -92,6 +92,9 @@ void ViewportNavigationControl::_notification(int p_what) {
if (!is_connected("mouse_exited", callable_mp(this, &ViewportNavigationControl::_on_mouse_exited))) {
connect("mouse_exited", callable_mp(this, &ViewportNavigationControl::_on_mouse_exited));
}
+ if (!is_connected("mouse_entered", callable_mp(this, &ViewportNavigationControl::_on_mouse_entered))) {
+ connect("mouse_entered", callable_mp(this, &ViewportNavigationControl::_on_mouse_entered));
+ }
} break;
case NOTIFICATION_DRAW: {
@@ -112,7 +115,7 @@ void ViewportNavigationControl::_draw() {
float radius = get_size().x / 2.0;
const bool focused = focused_index != -1;
- draw_circle(center, radius, Color(0.5, 0.5, 0.5, focused ? 0.25 : 0.05));
+ draw_circle(center, radius, Color(0.5, 0.5, 0.5, focused || hovered ? 0.35 : 0.15));
const Color c = focused ? Color(0.9, 0.9, 0.9, 0.9) : Color(0.5, 0.5, 0.5, 0.25);
@@ -123,6 +126,9 @@ void ViewportNavigationControl::_draw() {
}
void ViewportNavigationControl::_process_click(int p_index, Vector2 p_position, bool p_pressed) {
+ hovered = false;
+ queue_redraw();
+
if (focused_index != -1 && focused_index != p_index) {
return;
}
@@ -233,7 +239,13 @@ void ViewportNavigationControl::_update_navigation() {
}
}
+void ViewportNavigationControl::_on_mouse_entered() {
+ hovered = true;
+ queue_redraw();
+}
+
void ViewportNavigationControl::_on_mouse_exited() {
+ hovered = false;
queue_redraw();
}
@@ -5133,7 +5145,7 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, int p
// Prevent visible spacing between frame time labels.
top_right_vbox->add_theme_constant_override("separation", 0);
- const int navigation_control_size = 200;
+ const int navigation_control_size = 150;
position_control = memnew(ViewportNavigationControl);
position_control->set_navigation_mode(Node3DEditorViewport::NAVIGATION_MOVE);
diff --git a/editor/plugins/node_3d_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h
index 04fc030f2b..ed555d86c3 100644
--- a/editor/plugins/node_3d_editor_plugin.h
+++ b/editor/plugins/node_3d_editor_plugin.h
@@ -930,6 +930,7 @@ class ViewportNavigationControl : public Control {
Node3DEditorViewport *viewport = nullptr;
Vector2i focused_mouse_start;
Vector2 focused_pos;
+ bool hovered = false;
int focused_index = -1;
Node3DEditorViewport::NavigationMode nav_mode = Node3DEditorViewport::NavigationMode::NAVIGATION_NONE;
@@ -939,6 +940,7 @@ protected:
void _notification(int p_what);
virtual void gui_input(const Ref<InputEvent> &p_event) override;
void _draw();
+ void _on_mouse_entered();
void _on_mouse_exited();
void _process_click(int p_index, Vector2 p_position, bool p_pressed);
void _process_drag(int p_index, Vector2 p_position, Vector2 p_relative_position);
diff --git a/editor/shader_globals_editor.cpp b/editor/shader_globals_editor.cpp
index 22a1d49422..b778262fed 100644
--- a/editor/shader_globals_editor.cpp
+++ b/editor/shader_globals_editor.cpp
@@ -69,28 +69,12 @@ static const char *global_var_type_names[RS::GLOBAL_VAR_TYPE_MAX] = {
class ShaderGlobalsEditorInterface : public Object {
GDCLASS(ShaderGlobalsEditorInterface, Object)
- void _var_changed() {
- emit_signal(SNAME("var_changed"));
- }
-
-protected:
- static void _bind_methods() {
- ClassDB::bind_method("_var_changed", &ShaderGlobalsEditorInterface::_var_changed);
- ADD_SIGNAL(MethodInfo("var_changed"));
- }
-
- bool _set(const StringName &p_name, const Variant &p_value) {
- Variant existing = RS::get_singleton()->global_shader_parameter_get(p_name);
-
- if (existing.get_type() == Variant::NIL) {
- return false;
- }
-
+ void _set_var(const StringName &p_name, const Variant &p_value, const Variant &p_prev_value) {
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
undo_redo->create_action(TTR("Set Shader Global Variable"));
undo_redo->add_do_method(RS::get_singleton(), "global_shader_parameter_set", p_name, p_value);
- undo_redo->add_undo_method(RS::get_singleton(), "global_shader_parameter_set", p_name, existing);
+ undo_redo->add_undo_method(RS::get_singleton(), "global_shader_parameter_set", p_name, p_prev_value);
RS::GlobalShaderParameterType type = RS::get_singleton()->global_shader_parameter_get_type(p_name);
Dictionary gv;
gv["type"] = global_var_type_names[type];
@@ -111,8 +95,29 @@ protected:
undo_redo->add_do_method(this, "_var_changed");
undo_redo->add_undo_method(this, "_var_changed");
block_update = true;
- undo_redo->commit_action(false);
+ undo_redo->commit_action();
block_update = false;
+ }
+
+ void _var_changed() {
+ emit_signal(SNAME("var_changed"));
+ }
+
+protected:
+ static void _bind_methods() {
+ ClassDB::bind_method("_set_var", &ShaderGlobalsEditorInterface::_set_var);
+ ClassDB::bind_method("_var_changed", &ShaderGlobalsEditorInterface::_var_changed);
+ ADD_SIGNAL(MethodInfo("var_changed"));
+ }
+
+ bool _set(const StringName &p_name, const Variant &p_value) {
+ Variant existing = RS::get_singleton()->global_shader_parameter_get(p_name);
+
+ if (existing.get_type() == Variant::NIL) {
+ return false;
+ }
+
+ call_deferred("_set_var", p_name, p_value, existing);
return true;
}
diff --git a/modules/raycast/SCsub b/modules/raycast/SCsub
index 20b05816e1..51d75d45b0 100644
--- a/modules/raycast/SCsub
+++ b/modules/raycast/SCsub
@@ -67,7 +67,7 @@ if env["builtin_embree"]:
env_raycast.AppendUnique(CPPDEFINES=["NDEBUG"]) # No assert() even in debug builds.
if not env.msvc:
- if env["arch"] == "x86_64":
+ if env["arch"] in ["x86_64", "x86_32"]:
env_raycast.Append(CPPFLAGS=["-msse2", "-mxsave"])
if env["platform"] == "windows":
@@ -87,10 +87,13 @@ if env["builtin_embree"]:
env_thirdparty.disable_warnings()
env_thirdparty.add_source_files(thirdparty_obj, thirdparty_sources)
- if env["arch"] == "arm64" or env.msvc:
+ if env["arch"] != "x86_64" or env.msvc:
# Embree needs those, it will automatically use SSE2NEON in ARM
env_thirdparty.Append(CPPDEFINES=["__SSE2__", "__SSE__"])
+ if env["platform"] == "web":
+ env_thirdparty.Append(CPPFLAGS=["-msimd128"])
+
if not env.msvc:
env_thirdparty.Append(
CPPFLAGS=[
diff --git a/modules/raycast/config.py b/modules/raycast/config.py
index 833ad50018..f4243f01c5 100644
--- a/modules/raycast/config.py
+++ b/modules/raycast/config.py
@@ -1,9 +1,13 @@
def can_build(env, platform):
- # Depends on Embree library, which only supports x86_64 and arm64.
- if platform == "windows":
- return env["arch"] == "x86_64" # TODO build for Windows on ARM
-
- return env["arch"] in ["x86_64", "arm64"]
+ # Supported architectures depend on the Embree library.
+ # No ARM32 support planned.
+ if env["arch"] == "arm32":
+ return False
+ # x86_32 only seems supported on Windows for now.
+ if env["arch"] == "x86_32" and platform != "windows":
+ return False
+ # The rest works, even wasm32!
+ return True
def configure(env):
diff --git a/platform/linuxbsd/os_linuxbsd.cpp b/platform/linuxbsd/os_linuxbsd.cpp
index 25cb575199..d5a75edeea 100644
--- a/platform/linuxbsd/os_linuxbsd.cpp
+++ b/platform/linuxbsd/os_linuxbsd.cpp
@@ -616,6 +616,7 @@ Vector<String> OS_LinuxBSD::get_system_fonts() const {
#endif
}
+#ifdef FONTCONFIG_ENABLED
int OS_LinuxBSD::_weight_to_fc(int p_weight) const {
if (p_weight < 150) {
return FC_WEIGHT_THIN;
@@ -665,6 +666,7 @@ int OS_LinuxBSD::_stretch_to_fc(int p_stretch) const {
return FC_WIDTH_ULTRAEXPANDED;
}
}
+#endif // FONTCONFIG_ENABLED
Vector<String> OS_LinuxBSD::get_system_font_path_for_text(const String &p_font_name, const String &p_text, const String &p_locale, const String &p_script, int p_weight, int p_stretch, bool p_italic) const {
#ifdef FONTCONFIG_ENABLED
diff --git a/platform/linuxbsd/os_linuxbsd.h b/platform/linuxbsd/os_linuxbsd.h
index ef830a069b..bf469af568 100644
--- a/platform/linuxbsd/os_linuxbsd.h
+++ b/platform/linuxbsd/os_linuxbsd.h
@@ -51,6 +51,9 @@ class OS_LinuxBSD : public OS_Unix {
bool font_config_initialized = false;
FcConfig *config = nullptr;
FcObjectSet *object_set = nullptr;
+
+ int _weight_to_fc(int p_weight) const;
+ int _stretch_to_fc(int p_stretch) const;
#endif
#ifdef JOYDEV_ENABLED
@@ -73,9 +76,6 @@ class OS_LinuxBSD : public OS_Unix {
MainLoop *main_loop = nullptr;
- int _weight_to_fc(int p_weight) const;
- int _stretch_to_fc(int p_stretch) const;
-
String get_systemd_os_release_info_value(const String &key) const;
Vector<String> lspci_device_filter(Vector<String> vendor_device_id_mapping, String class_suffix, String check_column, String whitelist) const;
diff --git a/platform/windows/detect.py b/platform/windows/detect.py
index 705e83dace..1b55574b19 100644
--- a/platform/windows/detect.py
+++ b/platform/windows/detect.py
@@ -188,6 +188,7 @@ def get_opts():
BoolVariable("use_llvm", "Use the LLVM compiler", False),
BoolVariable("use_static_cpp", "Link MinGW/MSVC C++ runtime libraries statically", True),
BoolVariable("use_asan", "Use address sanitizer (ASAN)", False),
+ BoolVariable("debug_crt", "Compile with MSVC's debug CRT (/MDd)", False),
]
@@ -339,10 +340,14 @@ def configure_msvc(env, vcvars_msvc_config):
## Compile/link flags
- if env["use_static_cpp"]:
- env.AppendUnique(CCFLAGS=["/MT"])
+ if env["debug_crt"]:
+ # Always use dynamic runtime, static debug CRT breaks thread_local.
+ env.AppendUnique(CCFLAGS=["/MDd"])
else:
- env.AppendUnique(CCFLAGS=["/MD"])
+ if env["use_static_cpp"]:
+ env.AppendUnique(CCFLAGS=["/MT"])
+ else:
+ env.AppendUnique(CCFLAGS=["/MD"])
if env["arch"] == "x86_32":
env["x86_libtheora_opt_vc"] = True
diff --git a/scene/3d/xr_nodes.cpp b/scene/3d/xr_nodes.cpp
index ca7d1dfc1d..05fc73306c 100644
--- a/scene/3d/xr_nodes.cpp
+++ b/scene/3d/xr_nodes.cpp
@@ -627,7 +627,9 @@ void XROrigin3D::set_world_scale(real_t p_world_scale) {
xr_server->set_world_scale(p_world_scale);
}
-void XROrigin3D::set_current(bool p_enabled) {
+void XROrigin3D::_set_current(bool p_enabled, bool p_update_others) {
+ // We run this logic even if current already equals p_enabled as we may have set this previously before we entered our tree.
+ // This is then called a second time on NOTIFICATION_ENTER_TREE where we actually process activating this origin node.
current = p_enabled;
if (!is_inside_tree() || Engine::get_singleton()->is_editor_hint()) {
@@ -638,30 +640,38 @@ void XROrigin3D::set_current(bool p_enabled) {
set_notify_local_transform(current);
set_notify_transform(current);
+ // update XRServer with our current position
if (current) {
- for (int i = 0; i < origin_nodes.size(); i++) {
- if (origin_nodes[i] != this) {
- origin_nodes[i]->set_current(false);
- }
- }
-
- // update XRServer with our current position
XRServer *xr_server = XRServer::get_singleton();
ERR_FAIL_NULL(xr_server);
xr_server->set_world_origin(get_global_transform());
- } else {
- bool found = false;
- // We no longer have a current origin so find the first one we can make current
- for (int i = 0; !found && i < origin_nodes.size(); i++) {
- if (origin_nodes[i] != this) {
- origin_nodes[i]->set_current(true);
- found = true;
+ }
+
+ // Check if we need to update our other origin nodes accordingly
+ if (p_update_others) {
+ if (current) {
+ for (int i = 0; i < origin_nodes.size(); i++) {
+ if (origin_nodes[i] != this && origin_nodes[i]->current) {
+ origin_nodes[i]->_set_current(false, false);
+ }
+ }
+ } else {
+ // We no longer have a current origin so find the first one we can make current
+ for (int i = 0; i < origin_nodes.size(); i++) {
+ if (origin_nodes[i] != this) {
+ origin_nodes[i]->_set_current(true, false);
+ return; // we are done.
+ }
}
}
}
}
+void XROrigin3D::set_current(bool p_enabled) {
+ _set_current(p_enabled, true);
+}
+
bool XROrigin3D::is_current() const {
if (Engine::get_singleton()->is_editor_hint()) {
// return as is
diff --git a/scene/3d/xr_nodes.h b/scene/3d/xr_nodes.h
index 990fb61983..ec8e151a08 100644
--- a/scene/3d/xr_nodes.h
+++ b/scene/3d/xr_nodes.h
@@ -183,6 +183,8 @@ private:
bool current = false;
static Vector<XROrigin3D *> origin_nodes; // all origin nodes in tree
+ void _set_current(bool p_enabled, bool p_update_others);
+
protected:
void _notification(int p_what);
static void _bind_methods();
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp
index ca1befc135..f7baa7facc 100644
--- a/scene/animation/animation_player.cpp
+++ b/scene/animation/animation_player.cpp
@@ -955,7 +955,7 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, double
break;
}
- if (player->is_playing() || p_seeked) {
+ if (player->is_playing()) {
player->play(anim_name);
player->seek(at_anim_pos);
nc->animation_playing = true;
diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp
index 5df4c066e4..83c789f3d5 100644
--- a/scene/gui/graph_node.cpp
+++ b/scene/gui/graph_node.cpp
@@ -366,38 +366,46 @@ void GraphNode::_notification(int p_what) {
close_rect = Rect2();
}
- for (const KeyValue<int, Slot> &E : slot_info) {
- if (E.key < 0 || E.key >= cache_y.size()) {
- continue;
- }
- if (!slot_info.has(E.key)) {
- continue;
- }
- const Slot &s = slot_info[E.key];
- // Left port.
- if (s.enable_left) {
- Ref<Texture2D> p = port;
- if (s.custom_slot_left.is_valid()) {
- p = s.custom_slot_left;
+ if (get_child_count() > 0) {
+ for (const KeyValue<int, Slot> &E : slot_info) {
+ if (E.key < 0 || E.key >= cache_y.size()) {
+ continue;
}
- p->draw(get_canvas_item(), icofs + Point2(edgeofs, cache_y[E.key]), s.color_left);
- }
- // Right port.
- if (s.enable_right) {
- Ref<Texture2D> p = port;
- if (s.custom_slot_right.is_valid()) {
- p = s.custom_slot_right;
+ if (!slot_info.has(E.key)) {
+ continue;
+ }
+ const Slot &s = slot_info[E.key];
+ // Left port.
+ if (s.enable_left) {
+ Ref<Texture2D> p = port;
+ if (s.custom_slot_left.is_valid()) {
+ p = s.custom_slot_left;
+ }
+ p->draw(get_canvas_item(), icofs + Point2(edgeofs, cache_y[E.key]), s.color_left);
+ }
+ // Right port.
+ if (s.enable_right) {
+ Ref<Texture2D> p = port;
+ if (s.custom_slot_right.is_valid()) {
+ p = s.custom_slot_right;
+ }
+ p->draw(get_canvas_item(), icofs + Point2(get_size().x - edgeofs, cache_y[E.key]), s.color_right);
}
- p->draw(get_canvas_item(), icofs + Point2(get_size().x - edgeofs, cache_y[E.key]), s.color_right);
- }
- // Draw slot stylebox.
- if (s.draw_stylebox) {
- Control *c = Object::cast_to<Control>(get_child(E.key));
- Rect2 c_rect = c->get_rect();
- c_rect.position.x = sb->get_margin(SIDE_LEFT);
- c_rect.size.width = w;
- draw_style_box(sb_slot, c_rect);
+ // Draw slot stylebox.
+ if (s.draw_stylebox) {
+ Control *c = Object::cast_to<Control>(get_child(E.key));
+ if (!c || !c->is_visible_in_tree()) {
+ continue;
+ }
+ if (c->is_set_as_top_level()) {
+ continue;
+ }
+ Rect2 c_rect = c->get_rect();
+ c_rect.position.x = sb->get_margin(SIDE_LEFT);
+ c_rect.size.width = w;
+ draw_style_box(sb_slot, c_rect);
+ }
}
}
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index df41863e74..60d107cce6 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -4528,6 +4528,30 @@ void RichTextLabel::append_text(const String &p_bbcode) {
}
}
+void RichTextLabel::scroll_to_selection() {
+ if (selection.active && selection.from_frame && selection.from_line >= 0 && selection.from_line < (int)selection.from_frame->lines.size()) {
+ // Selected frame paragraph offset.
+ float line_offset = selection.from_frame->lines[selection.from_line].offset.y;
+
+ // Add wrapped line offset.
+ for (int i = 0; i < selection.from_frame->lines[selection.from_line].text_buf->get_line_count(); i++) {
+ Vector2i range = selection.from_frame->lines[selection.from_line].text_buf->get_line_range(i);
+ if (range.x <= selection.from_char && range.y >= selection.from_char) {
+ break;
+ }
+ line_offset += selection.from_frame->lines[selection.from_line].text_buf->get_line_size(i).y + theme_cache.line_separation;
+ }
+
+ // Add nested frame (e.g. table cell) offset.
+ ItemFrame *it = selection.from_frame;
+ while (it->parent_frame != nullptr) {
+ line_offset += it->parent_frame->lines[it->line].offset.y;
+ it = it->parent_frame;
+ }
+ vscroll->set_value(line_offset);
+ }
+}
+
void RichTextLabel::scroll_to_paragraph(int p_paragraph) {
_validate_line_caches();
@@ -4772,7 +4796,7 @@ bool RichTextLabel::search(const String &p_string, bool p_from_selection, bool p
char_idx = p_search_previous ? selection.from_char - 1 : selection.to_char;
if (!(p_search_previous && char_idx < 0) &&
_search_line(selection.from_frame, selection.from_line, p_string, char_idx, p_search_previous)) {
- scroll_to_line(selection.from_frame->line + selection.from_line);
+ scroll_to_selection();
queue_redraw();
return true;
}
@@ -4797,7 +4821,7 @@ bool RichTextLabel::search(const String &p_string, bool p_from_selection, bool p
// Search for next element
if (_search_table(parent_table, parent_element, p_string, p_search_previous)) {
- scroll_to_line(selection.from_frame->line + selection.from_line);
+ scroll_to_selection();
queue_redraw();
return true;
}
@@ -4821,7 +4845,7 @@ bool RichTextLabel::search(const String &p_string, bool p_from_selection, bool p
}
if (_search_line(main, current_line, p_string, char_idx, p_search_previous)) {
- scroll_to_line(current_line);
+ scroll_to_selection();
queue_redraw();
return true;
}
@@ -5309,6 +5333,7 @@ void RichTextLabel::_bind_methods() {
ClassDB::bind_method(D_METHOD("scroll_to_line", "line"), &RichTextLabel::scroll_to_line);
ClassDB::bind_method(D_METHOD("scroll_to_paragraph", "paragraph"), &RichTextLabel::scroll_to_paragraph);
+ ClassDB::bind_method(D_METHOD("scroll_to_selection"), &RichTextLabel::scroll_to_selection);
ClassDB::bind_method(D_METHOD("set_tab_size", "spaces"), &RichTextLabel::set_tab_size);
ClassDB::bind_method(D_METHOD("get_tab_size"), &RichTextLabel::get_tab_size);
diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h
index d30baaa8d3..b00cc3d055 100644
--- a/scene/gui/rich_text_label.h
+++ b/scene/gui/rich_text_label.h
@@ -657,6 +657,8 @@ public:
int get_content_height() const;
int get_content_width() const;
+ void scroll_to_selection();
+
VScrollBar *get_v_scroll_bar() { return vscroll; }
virtual CursorShape get_cursor_shape(const Point2 &p_pos) const override;