summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/input/input_event.cpp22
-rw-r--r--core/input/input_event.h6
-rw-r--r--core/math/math_funcs.h4
-rw-r--r--core/variant/callable.cpp20
-rw-r--r--core/variant/callable.h3
-rw-r--r--core/variant/variant_call.cpp79
-rw-r--r--core/variant/variant_utility.cpp5
-rw-r--r--doc/classes/@GlobalScope.xml25
-rw-r--r--doc/classes/Callable.xml16
-rw-r--r--doc/classes/InputEventMouseButton.xml2
-rw-r--r--doc/classes/ScrollContainer.xml6
-rw-r--r--editor/editor_about.cpp29
-rw-r--r--editor/editor_about.h3
-rw-r--r--editor/editor_log.cpp258
-rw-r--r--editor/editor_log.h108
-rw-r--r--editor/editor_node.cpp41
-rw-r--r--editor/editor_node.h4
-rw-r--r--editor/editor_properties.cpp2
-rw-r--r--editor/editor_spin_slider.cpp3
-rw-r--r--editor/icons/CombineLines.svg1
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp2
-rw-r--r--editor/project_manager.cpp32
-rw-r--r--editor/project_manager.h2
-rw-r--r--modules/visual_script/visual_script_builtin_funcs.cpp2
-rw-r--r--modules/visual_script/visual_script_editor.cpp2
-rw-r--r--platform/android/display_server_android.cpp2
-rw-r--r--platform/iphone/display_server_iphone.h2
-rw-r--r--platform/iphone/display_server_iphone.mm2
-rw-r--r--platform/javascript/display_server_javascript.cpp4
-rw-r--r--platform/linuxbsd/display_server_x11.cpp4
-rw-r--r--platform/osx/display_server_osx.mm2
-rw-r--r--platform/windows/display_server_windows.cpp8
-rw-r--r--scene/gui/gradient_edit.cpp2
-rw-r--r--scene/gui/item_list.cpp4
-rw-r--r--scene/gui/line_edit.cpp16
-rw-r--r--scene/gui/line_edit.h2
-rw-r--r--scene/gui/rich_text_label.cpp16
-rw-r--r--scene/gui/rich_text_label.h2
-rw-r--r--scene/gui/scroll_container.cpp115
-rw-r--r--scene/gui/scroll_container.h22
-rw-r--r--scene/gui/text_edit.cpp6
-rw-r--r--scene/gui/tree.cpp12
-rw-r--r--scene/gui/tree.h2
43 files changed, 714 insertions, 186 deletions
diff --git a/core/input/input_event.cpp b/core/input/input_event.cpp
index 99cc51b95e..46629d742e 100644
--- a/core/input/input_event.cpp
+++ b/core/input/input_event.cpp
@@ -545,12 +545,12 @@ bool InputEventMouseButton::is_pressed() const {
return pressed;
}
-void InputEventMouseButton::set_doubleclick(bool p_doubleclick) {
- doubleclick = p_doubleclick;
+void InputEventMouseButton::set_double_click(bool p_double_click) {
+ double_click = p_double_click;
}
-bool InputEventMouseButton::is_doubleclick() const {
- return doubleclick;
+bool InputEventMouseButton::is_double_click() const {
+ return double_click;
}
Ref<InputEvent> InputEventMouseButton::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const {
@@ -569,7 +569,7 @@ Ref<InputEvent> InputEventMouseButton::xformed_by(const Transform2D &p_xform, co
mb->set_button_mask(get_button_mask());
mb->set_pressed(pressed);
- mb->set_doubleclick(doubleclick);
+ mb->set_double_click(double_click);
mb->set_factor(factor);
mb->set_button_index(button_index);
@@ -636,7 +636,7 @@ String InputEventMouseButton::as_text() const {
}
// Double Click
- if (doubleclick) {
+ if (double_click) {
full_string += " (" + RTR("Double Click") + ")";
}
@@ -645,7 +645,7 @@ String InputEventMouseButton::as_text() const {
String InputEventMouseButton::to_string() {
String p = is_pressed() ? "true" : "false";
- String d = doubleclick ? "true" : "false";
+ String d = double_click ? "true" : "false";
int idx = get_button_index();
String button_string = itos(idx);
@@ -671,7 +671,7 @@ String InputEventMouseButton::to_string() {
// Work around the fact vformat can only take 5 substitutions but 6 need to be passed.
String index_and_mods = vformat("button_index=%s mods=%s", button_index, mods);
- return vformat("InputEventMouseButton: %s pressed=%s position=(%s) button_mask=%s doubleclick=%s", index_and_mods, p, String(get_position()), itos(get_button_mask()), d);
+ return vformat("InputEventMouseButton: %s pressed=%s position=(%s) button_mask=%s double_click=%s", index_and_mods, p, String(get_position()), itos(get_button_mask()), d);
}
void InputEventMouseButton::_bind_methods() {
@@ -684,13 +684,13 @@ void InputEventMouseButton::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_pressed", "pressed"), &InputEventMouseButton::set_pressed);
// ClassDB::bind_method(D_METHOD("is_pressed"), &InputEventMouseButton::is_pressed);
- ClassDB::bind_method(D_METHOD("set_doubleclick", "doubleclick"), &InputEventMouseButton::set_doubleclick);
- ClassDB::bind_method(D_METHOD("is_doubleclick"), &InputEventMouseButton::is_doubleclick);
+ ClassDB::bind_method(D_METHOD("set_double_click", "double_click"), &InputEventMouseButton::set_double_click);
+ ClassDB::bind_method(D_METHOD("is_double_click"), &InputEventMouseButton::is_double_click);
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "factor"), "set_factor", "get_factor");
ADD_PROPERTY(PropertyInfo(Variant::INT, "button_index"), "set_button_index", "get_button_index");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "pressed"), "set_pressed", "is_pressed");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "doubleclick"), "set_doubleclick", "is_doubleclick");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "double_click"), "set_double_click", "is_double_click");
}
///////////////////////////////////
diff --git a/core/input/input_event.h b/core/input/input_event.h
index 94aa68db33..5a33ee7b9c 100644
--- a/core/input/input_event.h
+++ b/core/input/input_event.h
@@ -294,7 +294,7 @@ class InputEventMouseButton : public InputEventMouse {
float factor = 1;
int button_index = 0;
bool pressed = false; //otherwise released
- bool doubleclick = false; //last even less than doubleclick time
+ bool double_click = false; //last even less than double click time
protected:
static void _bind_methods();
@@ -309,8 +309,8 @@ public:
void set_pressed(bool p_pressed);
virtual bool is_pressed() const override;
- void set_doubleclick(bool p_doubleclick);
- bool is_doubleclick() const;
+ void set_double_click(bool p_double_click);
+ bool is_double_click() const;
virtual Ref<InputEvent> xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const override;
virtual bool action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float *p_raw_strength, float p_deadzone) const override;
diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h
index 8cf13efdb6..c0d7649b65 100644
--- a/core/math/math_funcs.h
+++ b/core/math/math_funcs.h
@@ -218,8 +218,8 @@ public:
return value;
}
- static _ALWAYS_INLINE_ int posmod(int p_x, int p_y) {
- int value = p_x % p_y;
+ static _ALWAYS_INLINE_ int64_t posmod(int64_t p_x, int64_t p_y) {
+ int64_t value = p_x % p_y;
if ((value < 0 && p_y > 0) || (value > 0 && p_y < 0)) {
value += p_y;
}
diff --git a/core/variant/callable.cpp b/core/variant/callable.cpp
index a1d9c5ed2f..e06b3e07ef 100644
--- a/core/variant/callable.cpp
+++ b/core/variant/callable.cpp
@@ -54,6 +54,20 @@ void Callable::call(const Variant **p_arguments, int p_argcount, Variant &r_retu
}
}
+void Callable::rpc(int p_id, const Variant **p_arguments, int p_argcount, CallError &r_call_error) const {
+ if (is_null()) {
+ r_call_error.error = CallError::CALL_ERROR_INSTANCE_IS_NULL;
+ r_call_error.argument = 0;
+ r_call_error.expected = 0;
+ } else if (!is_custom()) {
+ r_call_error.error = CallError::CALL_ERROR_INVALID_METHOD;
+ r_call_error.argument = 0;
+ r_call_error.expected = 0;
+ } else {
+ custom->rpc(p_id, p_arguments, p_argcount, r_call_error);
+ }
+}
+
Callable Callable::bind(const Variant **p_arguments, int p_argcount) const {
Vector<Variant> args;
args.resize(p_argcount);
@@ -283,6 +297,12 @@ Callable::~Callable() {
}
}
+void CallableCustom::rpc(int p_peer_id, const Variant **p_arguments, int p_argcount, Callable::CallError &r_call_error) const {
+ r_call_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
+ r_call_error.argument = 0;
+ r_call_error.expected = 0;
+}
+
const Callable *CallableCustom::get_base_comparator() const {
return nullptr;
}
diff --git a/core/variant/callable.h b/core/variant/callable.h
index 090fd888e2..d91bebfa5f 100644
--- a/core/variant/callable.h
+++ b/core/variant/callable.h
@@ -70,6 +70,8 @@ public:
void call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, CallError &r_call_error) const;
void call_deferred(const Variant **p_arguments, int p_argcount) const;
+ void rpc(int p_id, const Variant **p_arguments, int p_argcount, CallError &r_call_error) const;
+
_FORCE_INLINE_ bool is_null() const {
return method == StringName() && object == 0;
}
@@ -124,6 +126,7 @@ public:
virtual CompareLessFunc get_compare_less_func() const = 0;
virtual ObjectID get_object() const = 0; //must always be able to provide an object
virtual void call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, Callable::CallError &r_call_error) const = 0;
+ virtual void rpc(int p_peer_id, const Variant **p_arguments, int p_argcount, Callable::CallError &r_call_error) const;
virtual const Callable *get_base_comparator() const;
CallableCustom();
diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp
index deaccc6304..455e924568 100644
--- a/core/variant/variant_call.cpp
+++ b/core/variant/variant_call.cpp
@@ -493,6 +493,58 @@ static _FORCE_INLINE_ void vc_ptrcall(void (*method)(T *, P...), void *p_base, c
} \
};
+#define VARARG_CLASS1(m_class, m_method_name, m_method_ptr, m_arg_type) \
+ struct Method_##m_class##_##m_method_name { \
+ static void call(Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) { \
+ m_method_ptr(base, p_args, p_argcount, r_ret, r_error); \
+ } \
+ static void validated_call(Variant *base, const Variant **p_args, int p_argcount, Variant *r_ret) { \
+ Callable::CallError ce; \
+ m_method_ptr(base, p_args, p_argcount, *r_ret, ce); \
+ } \
+ static void ptrcall(void *p_base, const void **p_args, void *r_ret, int p_argcount) { \
+ LocalVector<Variant> vars; \
+ vars.resize(p_argcount); \
+ LocalVector<const Variant *> vars_ptrs; \
+ vars_ptrs.resize(p_argcount); \
+ for (int i = 0; i < p_argcount; i++) { \
+ vars[i] = PtrToArg<Variant>::convert(p_args[i]); \
+ vars_ptrs[i] = &vars[i]; \
+ } \
+ Variant base = PtrToArg<m_class>::convert(p_base); \
+ Variant ret; \
+ Callable::CallError ce; \
+ m_method_ptr(&base, (const Variant **)&vars_ptrs[0], p_argcount, ret, ce); \
+ } \
+ static int get_argument_count() { \
+ return 1; \
+ } \
+ static Variant::Type get_argument_type(int p_arg) { \
+ return m_arg_type; \
+ } \
+ static Variant::Type get_return_type() { \
+ return Variant::NIL; \
+ } \
+ static bool has_return_type() { \
+ return false; \
+ } \
+ static bool is_const() { \
+ return true; \
+ } \
+ static bool is_static() { \
+ return false; \
+ } \
+ static bool is_vararg() { \
+ return true; \
+ } \
+ static Variant::Type get_base_type() { \
+ return GetTypeInfo<m_class>::VARIANT_TYPE; \
+ } \
+ static StringName get_name() { \
+ return #m_method_name; \
+ } \
+ };
+
struct _VariantCall {
static String func_PackedByteArray_get_string_from_ascii(PackedByteArray *p_instance) {
String s;
@@ -792,6 +844,27 @@ struct _VariantCall {
callable->call_deferred(p_args, p_argcount);
}
+ static void func_Callable_rpc(Variant *v, const Variant **p_args, int p_argcount, Variant &r_ret, Callable::CallError &r_error) {
+ Callable *callable = VariantGetInternalPtr<Callable>::get_ptr(v);
+ callable->rpc(0, p_args, p_argcount, r_error);
+ }
+
+ static void func_Callable_rpc_id(Variant *v, const Variant **p_args, int p_argcount, Variant &r_ret, Callable::CallError &r_error) {
+ if (p_argcount == 0) {
+ r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
+ r_error.argument = 0;
+ r_error.expected = 1;
+
+ } else if (p_args[0]->get_type() != Variant::INT) {
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.argument = 0;
+ r_error.expected = Variant::INT;
+ } else {
+ Callable *callable = VariantGetInternalPtr<Callable>::get_ptr(v);
+ callable->rpc(*p_args[0], &p_args[1], p_argcount - 1, r_error);
+ }
+ }
+
static void func_Callable_bind(Variant *v, const Variant **p_args, int p_argcount, Variant &r_ret, Callable::CallError &r_error) {
Callable *callable = VariantGetInternalPtr<Callable>::get_ptr(v);
r_ret = callable->bind(p_args, p_argcount);
@@ -1219,6 +1292,10 @@ Variant Variant::get_constant_value(Variant::Type p_type, const StringName &p_va
VARARG_CLASS(m_type, m_name, m_method, m_has_return, m_ret_type) \
register_builtin_method<Method_##m_type##_##m_name>(sarray(), Vector<Variant>());
+#define bind_custom1(m_type, m_name, m_method, m_arg_type, m_arg_name) \
+ VARARG_CLASS1(m_type, m_name, m_method, m_arg_type) \
+ register_builtin_method<Method_##m_type##_##m_name>(sarray(m_arg_name), Vector<Variant>());
+
static void _register_variant_builtin_methods() {
_VariantCall::constant_data = memnew_arr(_VariantCall::ConstantData, Variant::VARIANT_MAX);
builtin_method_info = memnew_arr(BuiltinMethodMap, Variant::VARIANT_MAX);
@@ -1532,6 +1609,8 @@ static void _register_variant_builtin_methods() {
bind_custom(Callable, call, _VariantCall::func_Callable_call, true, Variant);
bind_custom(Callable, call_deferred, _VariantCall::func_Callable_call_deferred, false, Variant);
+ bind_custom(Callable, rpc, _VariantCall::func_Callable_rpc, false, Variant);
+ bind_custom1(Callable, rpc_id, _VariantCall::func_Callable_rpc_id, Variant::INT, "peer_id");
bind_custom(Callable, bind, _VariantCall::func_Callable_bind, true, Callable);
/* Signal */
diff --git a/core/variant/variant_utility.cpp b/core/variant/variant_utility.cpp
index f154ab1ed6..553f2b23a2 100644
--- a/core/variant/variant_utility.cpp
+++ b/core/variant/variant_utility.cpp
@@ -93,6 +93,10 @@ struct VariantUtilityFunctions {
return Math::fposmod(b, r);
}
+ static inline int64_t posmod(int64_t b, int64_t r) {
+ return Math::posmod(b, r);
+ }
+
static inline double floor(double x) {
return Math::floor(x);
}
@@ -1154,6 +1158,7 @@ void Variant::_register_variant_utility_functions() {
FUNCBINDR(sqrt, sarray("x"), Variant::UTILITY_FUNC_TYPE_MATH);
FUNCBINDR(fmod, sarray("x", "y"), Variant::UTILITY_FUNC_TYPE_MATH);
FUNCBINDR(fposmod, sarray("x", "y"), Variant::UTILITY_FUNC_TYPE_MATH);
+ FUNCBINDR(posmod, sarray("x", "y"), Variant::UTILITY_FUNC_TYPE_MATH);
FUNCBINDR(floor, sarray("x"), Variant::UTILITY_FUNC_TYPE_MATH);
FUNCBINDR(ceil, sarray("x"), Variant::UTILITY_FUNC_TYPE_MATH);
FUNCBINDR(round, sarray("x"), Variant::UTILITY_FUNC_TYPE_MATH);
diff --git a/doc/classes/@GlobalScope.xml b/doc/classes/@GlobalScope.xml
index 95108f1613..af66a11fe5 100644
--- a/doc/classes/@GlobalScope.xml
+++ b/doc/classes/@GlobalScope.xml
@@ -652,6 +652,31 @@
Converts a 2D point expressed in the polar coordinate system (a distance from the origin [code]r[/code] and an angle [code]th[/code]) to the cartesian coordinate system (X and Y axis).
</description>
</method>
+ <method name="posmod">
+ <return type="int">
+ </return>
+ <argument index="0" name="x" type="int">
+ </argument>
+ <argument index="1" name="y" type="int">
+ </argument>
+ <description>
+ Returns the integer modulus of [code]x/y[/code] that wraps equally in positive and negative.
+ [codeblock]
+ for i in range(-3, 4):
+ print("%2d %2d %2d" % [i, i % 3, posmod(i, 3)])
+ [/codeblock]
+ Produces:
+ [codeblock]
+ -3 0 0
+ -2 -2 1
+ -1 -1 2
+ 0 0 0
+ 1 1 1
+ 2 2 2
+ 3 0 0
+ [/codeblock]
+ </description>
+ </method>
<method name="pow">
<return type="float">
</return>
diff --git a/doc/classes/Callable.xml b/doc/classes/Callable.xml
index 0cfbd0270c..cbab1a8f50 100644
--- a/doc/classes/Callable.xml
+++ b/doc/classes/Callable.xml
@@ -151,6 +151,22 @@
Returns [code]true[/code] if both [Callable]s invoke the same custom target.
</description>
</method>
+ <method name="rpc" qualifiers="vararg const">
+ <return type="void">
+ </return>
+ <description>
+ Perform an RPC (Remote Procedure Call). This is used for multiplayer and is normally not available unless the function being called has been marked as [i]RPC[/i]. Calling it on unsupported functions will result in an error.
+ </description>
+ </method>
+ <method name="rpc_id" qualifiers="vararg const">
+ <return type="void">
+ </return>
+ <argument index="0" name="peer_id" type="int">
+ </argument>
+ <description>
+ Perform an RPC (Remote Procedure Call) on a specific peer ID (see multiplayer documentation for reference). This is used for multiplayer and is normally not available unless the function being called has been marked as [i]RPC[/i]. Calling it on unsupported functions will result in an error.
+ </description>
+ </method>
<method name="unbind" qualifiers="const">
<return type="Callable">
</return>
diff --git a/doc/classes/InputEventMouseButton.xml b/doc/classes/InputEventMouseButton.xml
index d7e92f8bca..be71b42567 100644
--- a/doc/classes/InputEventMouseButton.xml
+++ b/doc/classes/InputEventMouseButton.xml
@@ -15,7 +15,7 @@
<member name="button_index" type="int" setter="set_button_index" getter="get_button_index" default="0">
The mouse button identifier, one of the [enum MouseButton] button or button wheel constants.
</member>
- <member name="doubleclick" type="bool" setter="set_doubleclick" getter="is_doubleclick" default="false">
+ <member name="double_click" type="bool" setter="set_double_click" getter="is_double_click" default="false">
If [code]true[/code], the mouse button's state is a double-click.
</member>
<member name="factor" type="float" setter="set_factor" getter="get_factor" default="1.0">
diff --git a/doc/classes/ScrollContainer.xml b/doc/classes/ScrollContainer.xml
index 9c5634f43a..40e29ac74b 100644
--- a/doc/classes/ScrollContainer.xml
+++ b/doc/classes/ScrollContainer.xml
@@ -39,12 +39,18 @@
<member name="scroll_horizontal_enabled" type="bool" setter="set_enable_h_scroll" getter="is_h_scroll_enabled" default="true">
If [code]true[/code], enables horizontal scrolling.
</member>
+ <member name="scroll_horizontal_visible" type="bool" setter="set_h_scroll_visible" getter="is_h_scroll_visible" default="true">
+ If [code]false[/code], hides the horizontal scrollbar.
+ </member>
<member name="scroll_vertical" type="int" setter="set_v_scroll" getter="get_v_scroll" default="0">
The current vertical scroll value.
</member>
<member name="scroll_vertical_enabled" type="bool" setter="set_enable_v_scroll" getter="is_v_scroll_enabled" default="true">
If [code]true[/code], enables vertical scrolling.
</member>
+ <member name="scroll_vertical_visible" type="bool" setter="set_v_scroll_visible" getter="is_v_scroll_visible" default="true">
+ If [code]false[/code], hides the vertical scrollbar.
+ </member>
</members>
<signals>
<signal name="scroll_ended">
diff --git a/editor/editor_about.cpp b/editor/editor_about.cpp
index d962658484..7527514dca 100644
--- a/editor/editor_about.cpp
+++ b/editor/editor_about.cpp
@@ -37,6 +37,9 @@
#include "core/version.h"
#include "core/version_hash.gen.h"
+// The metadata key used to store and retrieve the version text to copy to the clipboard.
+static const String META_TEXT_TO_COPY = "text_to_copy";
+
void EditorAbout::_theme_changed() {
const Ref<Font> font = get_theme_font("source", "EditorFonts");
const int font_size = get_theme_font_size("source_size", "EditorFonts");
@@ -63,7 +66,12 @@ void EditorAbout::_license_tree_selected() {
_tpl_text->set_text(selected->get_metadata(0));
}
+void EditorAbout::_version_button_pressed() {
+ DisplayServer::get_singleton()->clipboard_set(version_btn->get_meta(META_TEXT_TO_COPY));
+}
+
void EditorAbout::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("_version_button_pressed"), &EditorAbout::_version_button_pressed);
}
TextureRect *EditorAbout::get_logo() const {
@@ -124,17 +132,32 @@ EditorAbout::EditorAbout() {
_logo = memnew(TextureRect);
hbc->add_child(_logo);
+ VBoxContainer *version_info_vbc = memnew(VBoxContainer);
+
+ // Add a dummy control node for spacing.
+ Control *v_spacer = memnew(Control);
+ version_info_vbc->add_child(v_spacer);
+
+ version_btn = memnew(LinkButton);
String hash = String(VERSION_HASH);
if (hash.length() != 0) {
hash = "." + hash.left(9);
}
+ version_btn->set_text(VERSION_FULL_NAME + hash);
+ // Set the text to copy in metadata as it slightly differs from the button's text.
+ version_btn->set_meta(META_TEXT_TO_COPY, "v" VERSION_FULL_BUILD + hash);
+ version_btn->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
+ version_btn->set_tooltip(TTR("Click to copy."));
+ version_btn->connect("pressed", callable_mp(this, &EditorAbout::_version_button_pressed));
+ version_info_vbc->add_child(version_btn);
Label *about_text = memnew(Label);
about_text->set_v_size_flags(Control::SIZE_SHRINK_CENTER);
- about_text->set_text(VERSION_FULL_NAME + hash +
- String::utf8("\n\xc2\xa9 2007-2021 Juan Linietsky, Ariel Manzur.\n\xc2\xa9 2014-2021 ") +
+ about_text->set_text(String::utf8("\xc2\xa9 2007-2021 Juan Linietsky, Ariel Manzur.\n\xc2\xa9 2014-2021 ") +
TTR("Godot Engine contributors") + "\n");
- hbc->add_child(about_text);
+ version_info_vbc->add_child(about_text);
+
+ hbc->add_child(version_info_vbc);
TabContainer *tc = memnew(TabContainer);
tc->set_custom_minimum_size(Size2(950, 400) * EDSCALE);
diff --git a/editor/editor_about.h b/editor/editor_about.h
index 2823220a8a..b76a2ada34 100644
--- a/editor/editor_about.h
+++ b/editor/editor_about.h
@@ -34,6 +34,7 @@
#include "scene/gui/control.h"
#include "scene/gui/dialogs.h"
#include "scene/gui/item_list.h"
+#include "scene/gui/link_button.h"
#include "scene/gui/rich_text_label.h"
#include "scene/gui/scroll_container.h"
#include "scene/gui/separator.h"
@@ -53,8 +54,10 @@ class EditorAbout : public AcceptDialog {
private:
void _license_tree_selected();
+ void _version_button_pressed();
ScrollContainer *_populate_list(const String &p_name, const List<String> &p_sections, const char *const *const p_src[], const int p_flag_single_column = 0);
+ LinkButton *version_btn;
Tree *_tpl_tree;
RichTextLabel *_license_text;
RichTextLabel *_tpl_text;
diff --git a/editor/editor_log.cpp b/editor/editor_log.cpp
index 7b94016fb6..9f188b53c4 100644
--- a/editor/editor_log.cpp
+++ b/editor/editor_log.cpp
@@ -63,6 +63,18 @@ void EditorLog::_notification(int p_what) {
log->add_theme_font_override("normal_font", get_theme_font("output_source", "EditorFonts"));
log->add_theme_font_size_override("normal_font_size", get_theme_font_size("output_source_size", "EditorFonts"));
log->add_theme_color_override("selection_color", get_theme_color("accent_color", "Editor") * Color(1, 1, 1, 0.4));
+ log->add_theme_font_override("bold_font", get_theme_font("bold", "EditorFonts"));
+
+ type_filter_map[MSG_TYPE_STD]->toggle_button->set_icon(get_theme_icon("Popup", "EditorIcons"));
+ type_filter_map[MSG_TYPE_ERROR]->toggle_button->set_icon(get_theme_icon("StatusError", "EditorIcons"));
+ type_filter_map[MSG_TYPE_WARNING]->toggle_button->set_icon(get_theme_icon("StatusWarning", "EditorIcons"));
+ type_filter_map[MSG_TYPE_EDITOR]->toggle_button->set_icon(get_theme_icon("Edit", "EditorIcons"));
+
+ clear_button->set_icon(get_theme_icon("Clear", "EditorIcons"));
+ copy_button->set_icon(get_theme_icon("ActionCopy", "EditorIcons"));
+ collapse_button->set_icon(get_theme_icon("CombineLines", "EditorIcons"));
+ show_search_button->set_icon(get_theme_icon("Search", "EditorIcons"));
+
} else if (p_what == NOTIFICATION_THEME_CHANGED) {
Ref<Font> df_output_code = get_theme_font("output_source", "EditorFonts");
if (df_output_code.is_valid()) {
@@ -75,8 +87,15 @@ void EditorLog::_notification(int p_what) {
}
}
+void EditorLog::_set_collapse(bool p_collapse) {
+ collapse = p_collapse;
+ _rebuild_log();
+}
+
void EditorLog::_clear_request() {
log->clear();
+ messages.clear();
+ _reset_message_counts();
tool_button->set_icon(Ref<Texture2D>());
}
@@ -96,13 +115,83 @@ void EditorLog::clear() {
_clear_request();
}
-void EditorLog::copy() {
- _copy_request();
+void EditorLog::_process_message(const String &p_msg, MessageType p_type) {
+ if (messages.size() > 0 && messages[messages.size() - 1].text == p_msg) {
+ // If previous message is the same as the new one, increase previous count rather than adding another
+ // instance to the messages list.
+ LogMessage &previous = messages.write[messages.size() - 1];
+ previous.count++;
+
+ _add_log_line(previous, collapse);
+ } else {
+ // Different message to the previous one received.
+ LogMessage message(p_msg, p_type);
+ _add_log_line(message);
+ messages.push_back(message);
+ }
+
+ type_filter_map[p_type]->set_message_count(type_filter_map[p_type]->get_message_count() + 1);
}
void EditorLog::add_message(const String &p_msg, MessageType p_type) {
- bool restore = p_type != MSG_TYPE_STD;
- switch (p_type) {
+ // Make text split by new lines their own message.
+ // See #41321 for reasoning. At time of writing, multiple print()'s in running projects
+ // get grouped together and sent to the editor log as one message. This can mess with the
+ // search functionality (see the comments on the PR above for more details). This behaviour
+ // also matches that of other IDE's.
+ Vector<String> lines = p_msg.split("\n", false);
+
+ for (int i = 0; i < lines.size(); i++) {
+ _process_message(lines[i], p_type);
+ }
+}
+
+void EditorLog::set_tool_button(Button *p_tool_button) {
+ tool_button = p_tool_button;
+}
+
+void EditorLog::_undo_redo_cbk(void *p_self, const String &p_name) {
+ EditorLog *self = (EditorLog *)p_self;
+ self->add_message(p_name, EditorLog::MSG_TYPE_EDITOR);
+}
+
+void EditorLog::_rebuild_log() {
+ log->clear();
+
+ for (int msg_idx = 0; msg_idx < messages.size(); msg_idx++) {
+ LogMessage msg = messages[msg_idx];
+
+ if (collapse) {
+ // If collapsing, only log one instance of the message.
+ _add_log_line(msg);
+ } else {
+ // If not collapsing, log each instance on a line.
+ for (int i = 0; i < msg.count; i++) {
+ _add_log_line(msg);
+ }
+ }
+ }
+}
+
+void EditorLog::_add_log_line(LogMessage &p_message, bool p_replace_previous) {
+ // Only add the message to the log if it passes the filters.
+ bool filter_active = type_filter_map[p_message.type]->active;
+ String search_text = search_box->get_text();
+ bool search_match = search_text == String() || p_message.text.findn(search_text) > -1;
+
+ if (!filter_active || !search_match) {
+ return;
+ }
+
+ if (p_replace_previous) {
+ // Remove last line if replacing, as it will be replace by the next added line.
+ log->remove_line(log->get_line_count() - 1);
+ log->increment_line_count();
+ } else {
+ log->add_newline();
+ }
+
+ switch (p_message.type) {
case MSG_TYPE_STD: {
} break;
case MSG_TYPE_ERROR: {
@@ -125,21 +214,42 @@ void EditorLog::add_message(const String &p_msg, MessageType p_type) {
} break;
}
- log->add_text(p_msg);
- log->add_newline();
+ // If collapsing, add the count of this message in bold at the start of the line.
+ if (collapse && p_message.count > 1) {
+ log->push_bold();
+ log->add_text(vformat("(%s) ", itos(p_message.count)));
+ log->pop();
+ }
- if (restore) {
+ log->add_text(p_message.text);
+
+ // Need to use pop() to exit out of the RichTextLabels current "push" stack.
+ // We only "push" in the above switch when message type != STD, so only pop when that is the case.
+ if (p_message.type != MSG_TYPE_STD) {
log->pop();
}
}
-void EditorLog::set_tool_button(Button *p_tool_button) {
- tool_button = p_tool_button;
+void EditorLog::_set_filter_active(bool p_active, MessageType p_message_type) {
+ type_filter_map[p_message_type]->active = p_active;
+ _rebuild_log();
}
-void EditorLog::_undo_redo_cbk(void *p_self, const String &p_name) {
- EditorLog *self = (EditorLog *)p_self;
- self->add_message(p_name, EditorLog::MSG_TYPE_EDITOR);
+void EditorLog::_set_search_visible(bool p_visible) {
+ search_box->set_visible(p_visible);
+ if (p_visible) {
+ search_box->grab_focus();
+ }
+}
+
+void EditorLog::_search_changed(const String &p_text) {
+ _rebuild_log();
+}
+
+void EditorLog::_reset_message_counts() {
+ for (Map<MessageType, LogFilter *>::Element *E = type_filter_map.front(); E; E = E->next()) {
+ E->value()->set_message_count(0);
+ }
}
void EditorLog::_bind_methods() {
@@ -148,37 +258,108 @@ void EditorLog::_bind_methods() {
}
EditorLog::EditorLog() {
- VBoxContainer *vb = this;
-
- HBoxContainer *hb = memnew(HBoxContainer);
- vb->add_child(hb);
- title = memnew(Label);
- title->set_text(TTR("Output:"));
- title->set_h_size_flags(SIZE_EXPAND_FILL);
- hb->add_child(title);
-
- copybutton = memnew(Button);
- hb->add_child(copybutton);
- copybutton->set_text(TTR("Copy"));
- copybutton->set_shortcut(ED_SHORTCUT("editor/copy_output", TTR("Copy Selection"), KEY_MASK_CMD | KEY_C));
- copybutton->set_shortcut_context(this);
- copybutton->connect("pressed", callable_mp(this, &EditorLog::_copy_request));
-
- clearbutton = memnew(Button);
- hb->add_child(clearbutton);
- clearbutton->set_text(TTR("Clear"));
- clearbutton->set_shortcut(ED_SHORTCUT("editor/clear_output", TTR("Clear Output"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_K));
- clearbutton->set_shortcut_context(this);
- clearbutton->connect("pressed", callable_mp(this, &EditorLog::_clear_request));
+ HBoxContainer *hb = this;
+ VBoxContainer *vb_left = memnew(VBoxContainer);
+ vb_left->set_custom_minimum_size(Size2(0, 180) * EDSCALE);
+ vb_left->set_v_size_flags(SIZE_EXPAND_FILL);
+ vb_left->set_h_size_flags(SIZE_EXPAND_FILL);
+ hb->add_child(vb_left);
+
+ // Log - Rich Text Label.
log = memnew(RichTextLabel);
log->set_scroll_follow(true);
log->set_selection_enabled(true);
log->set_focus_mode(FOCUS_CLICK);
- log->set_custom_minimum_size(Size2(0, 180) * EDSCALE);
log->set_v_size_flags(SIZE_EXPAND_FILL);
log->set_h_size_flags(SIZE_EXPAND_FILL);
- vb->add_child(log);
+ vb_left->add_child(log);
+
+ // Search box
+ search_box = memnew(LineEdit);
+ search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ search_box->set_placeholder(TTR("Filter messages"));
+ search_box->set_right_icon(get_theme_icon("Search", "EditorIcons"));
+ search_box->set_clear_button_enabled(true);
+ search_box->set_visible(true);
+ search_box->connect("text_changed", callable_mp(this, &EditorLog::_search_changed));
+ vb_left->add_child(search_box);
+
+ VBoxContainer *vb_right = memnew(VBoxContainer);
+ hb->add_child(vb_right);
+
+ // Tools grid
+ HBoxContainer *hb_tools = memnew(HBoxContainer);
+ hb_tools->set_h_size_flags(SIZE_SHRINK_CENTER);
+ vb_right->add_child(hb_tools);
+
+ // Clear.
+ clear_button = memnew(Button);
+ clear_button->set_flat(true);
+ clear_button->set_focus_mode(FOCUS_NONE);
+ clear_button->set_shortcut(ED_SHORTCUT("editor/clear_output", TTR("Clear Output"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_K));
+ clear_button->set_shortcut_context(this);
+ clear_button->connect("pressed", callable_mp(this, &EditorLog::_clear_request));
+ hb_tools->add_child(clear_button);
+
+ // Copy.
+ copy_button = memnew(Button);
+ copy_button->set_flat(true);
+ copy_button->set_focus_mode(FOCUS_NONE);
+ copy_button->set_shortcut(ED_SHORTCUT("editor/copy_output", TTR("Copy Selection"), KEY_MASK_CMD | KEY_C));
+ copy_button->set_shortcut_context(this);
+ copy_button->connect("pressed", callable_mp(this, &EditorLog::_copy_request));
+ hb_tools->add_child(copy_button);
+
+ // A second hbox to make a 2x2 grid of buttons.
+ HBoxContainer *hb_tools2 = memnew(HBoxContainer);
+ hb_tools2->set_h_size_flags(SIZE_SHRINK_CENTER);
+ vb_right->add_child(hb_tools2);
+
+ // Collapse.
+ collapse_button = memnew(Button);
+ collapse_button->set_flat(true);
+ collapse_button->set_focus_mode(FOCUS_NONE);
+ collapse_button->set_tooltip(TTR("Collapse duplicate messages into one log entry. Shows number of occurences."));
+ collapse_button->set_toggle_mode(true);
+ collapse_button->set_pressed(false);
+ collapse_button->connect("toggled", callable_mp(this, &EditorLog::_set_collapse));
+ hb_tools2->add_child(collapse_button);
+
+ // Show Search.
+ show_search_button = memnew(Button);
+ show_search_button->set_flat(true);
+ show_search_button->set_focus_mode(FOCUS_NONE);
+ show_search_button->set_toggle_mode(true);
+ show_search_button->set_pressed(true);
+ show_search_button->set_shortcut(ED_SHORTCUT("editor/open_search", TTR("Open the search box."), KEY_MASK_CMD | KEY_F));
+ show_search_button->set_shortcut_context(this);
+ show_search_button->connect("toggled", callable_mp(this, &EditorLog::_set_search_visible));
+ hb_tools2->add_child(show_search_button);
+
+ // Message Type Filters.
+ vb_right->add_child(memnew(HSeparator));
+
+ LogFilter *std_filter = memnew(LogFilter(MSG_TYPE_STD));
+ std_filter->initialize_button("Toggle visibility of standard output messages.", callable_mp(this, &EditorLog::_set_filter_active));
+ vb_right->add_child(std_filter->toggle_button);
+ type_filter_map.insert(MSG_TYPE_STD, std_filter);
+
+ LogFilter *error_filter = memnew(LogFilter(MSG_TYPE_ERROR));
+ error_filter->initialize_button("Toggle visibility of errors.", callable_mp(this, &EditorLog::_set_filter_active));
+ vb_right->add_child(error_filter->toggle_button);
+ type_filter_map.insert(MSG_TYPE_ERROR, error_filter);
+
+ LogFilter *warning_filter = memnew(LogFilter(MSG_TYPE_WARNING));
+ warning_filter->initialize_button("Toggle visibility of warnings.", callable_mp(this, &EditorLog::_set_filter_active));
+ vb_right->add_child(warning_filter->toggle_button);
+ type_filter_map.insert(MSG_TYPE_WARNING, warning_filter);
+
+ LogFilter *editor_filter = memnew(LogFilter(MSG_TYPE_EDITOR));
+ editor_filter->initialize_button("Toggle visibility of editor messages.", callable_mp(this, &EditorLog::_set_filter_active));
+ vb_right->add_child(editor_filter->toggle_button);
+ type_filter_map.insert(MSG_TYPE_EDITOR, editor_filter);
+
add_message(VERSION_FULL_NAME " (c) 2007-2021 Juan Linietsky, Ariel Manzur & Godot Contributors.");
eh.errfunc = _error_handler;
@@ -187,8 +368,6 @@ EditorLog::EditorLog() {
current = Thread::get_caller_id();
- add_theme_constant_override("separation", get_theme_constant("separation", "VBoxContainer"));
-
EditorNode::get_undo_redo()->set_commit_notify_callback(_undo_redo_cbk, this);
}
@@ -197,4 +376,7 @@ void EditorLog::deinit() {
}
EditorLog::~EditorLog() {
+ for (Map<MessageType, LogFilter *>::Element *E = type_filter_map.front(); E; E = E->next()) {
+ memdelete(E->get());
+ }
}
diff --git a/editor/editor_log.h b/editor/editor_log.h
index 79dfb3ffaa..89d00d0fa0 100644
--- a/editor/editor_log.h
+++ b/editor/editor_log.h
@@ -36,19 +36,92 @@
#include "scene/gui/button.h"
#include "scene/gui/control.h"
#include "scene/gui/label.h"
+#include "scene/gui/line_edit.h"
#include "scene/gui/panel_container.h"
#include "scene/gui/rich_text_label.h"
#include "scene/gui/texture_button.h"
#include "scene/gui/texture_rect.h"
-class EditorLog : public VBoxContainer {
- GDCLASS(EditorLog, VBoxContainer);
+class EditorLog : public HBoxContainer {
+ GDCLASS(EditorLog, HBoxContainer);
+
+public:
+ enum MessageType {
+ MSG_TYPE_STD,
+ MSG_TYPE_ERROR,
+ MSG_TYPE_WARNING,
+ MSG_TYPE_EDITOR,
+ };
+
+private:
+ struct LogMessage {
+ String text;
+ MessageType type;
+ int count = 1;
+
+ LogMessage() {}
+
+ LogMessage(const String p_text, MessageType p_type) :
+ text(p_text),
+ type(p_type) {
+ }
+ };
+
+ // Encapsulates all data and functionality regarding filters.
+ struct LogFilter {
+ private:
+ // Force usage of set method since it has functionality built-in.
+ int message_count = 0;
+
+ public:
+ MessageType type;
+ Button *toggle_button = nullptr;
+ bool active = true;
+
+ void initialize_button(const String &p_tooltip, Callable p_toggled_callback) {
+ toggle_button = memnew(Button);
+ toggle_button->set_toggle_mode(true);
+ toggle_button->set_pressed(true);
+ toggle_button->set_text(itos(message_count));
+ toggle_button->set_tooltip(TTR(p_tooltip));
+ // Don't tint the icon even when in "pressed" state.
+ toggle_button->add_theme_color_override("icon_color_pressed", Color(1, 1, 1, 1));
+ toggle_button->set_focus_mode(FOCUS_NONE);
+ // When toggled call the callback and pass the MessageType this button is for.
+ toggle_button->connect("toggled", p_toggled_callback, varray(type));
+ }
+
+ int get_message_count() {
+ return message_count;
+ }
+
+ void set_message_count(int p_count) {
+ message_count = p_count;
+ toggle_button->set_text(itos(message_count));
+ }
+
+ LogFilter(MessageType p_type) :
+ type(p_type) {
+ }
+ };
+
+ Vector<LogMessage> messages;
+ // Maps MessageTypes to LogFilters for convenient access and storage (don't need 1 member per filter).
+ Map<MessageType, LogFilter *> type_filter_map;
- Button *clearbutton;
- Button *copybutton;
- Label *title;
RichTextLabel *log;
- HBoxContainer *title_hb;
+
+ Button *clear_button;
+ Button *copy_button;
+
+ Button *collapse_button;
+ bool collapse = false;
+
+ Button *show_search_button;
+ LineEdit *search_box;
+
+ // Reference to the "Output" button on the toolbar so we can update it's icon when
+ // Warnings or Errors are encounetered.
Button *tool_button;
static void _error_handler(void *p_self, const char *p_func, const char *p_file, int p_line, const char *p_error, const char *p_errorexp, ErrorHandlerType p_type);
@@ -62,26 +135,33 @@ class EditorLog : public VBoxContainer {
void _copy_request();
static void _undo_redo_cbk(void *p_self, const String &p_name);
+ void _rebuild_log();
+ void _add_log_line(LogMessage &p_message, bool p_replace_previous = false);
+
+ void _set_filter_active(bool p_active, MessageType p_message_type);
+ void _set_search_visible(bool p_visible);
+ void _search_changed(const String &p_text);
+
+ void _process_message(const String &p_msg, MessageType p_type);
+ void _reset_message_counts();
+
+ void _set_collapse(bool p_collapse);
+
protected:
static void _bind_methods();
void _notification(int p_what);
public:
- enum MessageType {
- MSG_TYPE_STD,
- MSG_TYPE_ERROR,
- MSG_TYPE_WARNING,
- MSG_TYPE_EDITOR
- };
-
void add_message(const String &p_msg, MessageType p_type = MSG_TYPE_STD);
void set_tool_button(Button *p_tool_button);
void deinit();
void clear();
- void copy();
+
EditorLog();
~EditorLog();
};
+VARIANT_ENUM_CAST(EditorLog::MessageType);
+
#endif // EDITOR_LOG_H
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 6137617564..0f0b2da6ab 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -46,11 +46,13 @@
#include "core/string/print_string.h"
#include "core/string/translation.h"
#include "core/version.h"
+#include "core/version_hash.gen.h"
#include "main/main.h"
#include "scene/gui/center_container.h"
#include "scene/gui/control.h"
#include "scene/gui/dialogs.h"
#include "scene/gui/file_dialog.h"
+#include "scene/gui/link_button.h"
#include "scene/gui/menu_button.h"
#include "scene/gui/panel.h"
#include "scene/gui/panel_container.h"
@@ -184,6 +186,9 @@
EditorNode *EditorNode::singleton = nullptr;
+// The metadata key used to store and retrieve the version text to copy to the clipboard.
+static const String META_TEXT_TO_COPY = "text_to_copy";
+
void EditorNode::disambiguate_filenames(const Vector<String> p_full_paths, Vector<String> &r_filenames) {
// Keep track of a list of "index sets," i.e. sets of indices
// within disambiguated_scene_names which contain the same name.
@@ -989,6 +994,10 @@ void EditorNode::_reload_project_settings() {
void EditorNode::_vp_resized() {
}
+void EditorNode::_version_button_pressed() {
+ DisplayServer::get_singleton()->clipboard_set(version_btn->get_meta(META_TEXT_TO_COPY));
+}
+
void EditorNode::_node_renamed() {
if (get_inspector()) {
get_inspector()->update_tree();
@@ -4855,7 +4864,7 @@ void EditorNode::_scene_tab_input(const Ref<InputEvent> &p_input) {
_scene_tab_closed(scene_tabs->get_hovered_tab());
}
} else {
- if ((mb->get_button_index() == MOUSE_BUTTON_LEFT && mb->is_doubleclick()) || (mb->get_button_index() == MOUSE_BUTTON_MIDDLE && mb->is_pressed())) {
+ if ((mb->get_button_index() == MOUSE_BUTTON_LEFT && mb->is_double_click()) || (mb->get_button_index() == MOUSE_BUTTON_MIDDLE && mb->is_pressed())) {
_menu_option_confirm(FILE_NEW_SCENE, true);
}
}
@@ -5559,6 +5568,8 @@ void EditorNode::_bind_methods() {
ClassDB::bind_method("_screenshot", &EditorNode::_screenshot);
ClassDB::bind_method("_save_screenshot", &EditorNode::_save_screenshot);
+ ClassDB::bind_method("_version_button_pressed", &EditorNode::_version_button_pressed);
+
ADD_SIGNAL(MethodInfo("play_pressed"));
ADD_SIGNAL(MethodInfo("pause_pressed"));
ADD_SIGNAL(MethodInfo("stop_pressed"));
@@ -6617,11 +6628,31 @@ EditorNode::EditorNode() {
bottom_panel_hb_editors->set_h_size_flags(Control::SIZE_EXPAND_FILL);
bottom_panel_hb->add_child(bottom_panel_hb_editors);
- version_label = memnew(Label);
- version_label->set_text(VERSION_FULL_CONFIG);
+ VBoxContainer *version_info_vbc = memnew(VBoxContainer);
+ bottom_panel_hb->add_child(version_info_vbc);
+
+ // Add a dummy control node for vertical spacing.
+ Control *v_spacer = memnew(Control);
+ version_info_vbc->add_child(v_spacer);
+
+ version_btn = memnew(LinkButton);
+ version_btn->set_text(VERSION_FULL_CONFIG);
+ String hash = String(VERSION_HASH);
+ if (hash.length() != 0) {
+ hash = "." + hash.left(9);
+ }
+ // Set the text to copy in metadata as it slightly differs from the button's text.
+ version_btn->set_meta(META_TEXT_TO_COPY, "v" VERSION_FULL_BUILD + hash);
// Fade out the version label to be less prominent, but still readable
- version_label->set_self_modulate(Color(1, 1, 1, 0.6));
- bottom_panel_hb->add_child(version_label);
+ version_btn->set_self_modulate(Color(1, 1, 1, 0.65));
+ version_btn->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
+ version_btn->set_tooltip(TTR("Click to copy."));
+ version_btn->connect("pressed", callable_mp(this, &EditorNode::_version_button_pressed));
+ version_info_vbc->add_child(version_btn);
+
+ // Add a dummy control node for horizontal spacing.
+ Control *h_spacer = memnew(Control);
+ bottom_panel_hb->add_child(h_spacer);
bottom_panel_raise = memnew(Button);
bottom_panel_raise->set_flat(true);
diff --git a/editor/editor_node.h b/editor/editor_node.h
index 7e16936f5d..d06851cb4f 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -40,6 +40,7 @@
#include "editor/inspector_dock.h"
#include "editor/property_editor.h"
#include "editor/scene_tree_dock.h"
+#include "scene/gui/link_button.h"
typedef void (*EditorNodeInitCallback)();
typedef void (*EditorPluginInitializeCallback)();
@@ -424,7 +425,7 @@ private:
HBoxContainer *bottom_panel_hb;
HBoxContainer *bottom_panel_hb_editors;
VBoxContainer *bottom_panel_vb;
- Label *version_label;
+ LinkButton *version_btn;
Button *bottom_panel_raise;
Tree *disk_changed_list;
@@ -477,6 +478,7 @@ private:
void _close_messages();
void _show_messages();
void _vp_resized();
+ void _version_button_pressed();
int _save_external_resources();
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index 652deb1804..47c0e31da6 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -929,7 +929,7 @@ EditorPropertyFloat::EditorPropertyFloat() {
void EditorPropertyEasing::_drag_easing(const Ref<InputEvent> &p_ev) {
const Ref<InputEventMouseButton> mb = p_ev;
if (mb.is_valid()) {
- if (mb->is_doubleclick() && mb->get_button_index() == MOUSE_BUTTON_LEFT) {
+ if (mb->is_double_click() && mb->get_button_index() == MOUSE_BUTTON_LEFT) {
_setup_spin();
}
diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp
index 8577ccb9db..dba53a9708 100644
--- a/editor/editor_spin_slider.cpp
+++ b/editor/editor_spin_slider.cpp
@@ -70,7 +70,6 @@ void EditorSpinSlider::_gui_input(const Ref<InputEvent> &p_event) {
grabbing_spinner_dist_cache = 0;
pre_grab_value = get_value();
grabbing_spinner = false;
- grabbing_spinner_mouse_pos = Input::get_singleton()->get_mouse_position();
}
} else {
if (grabbing_spinner_attempt) {
@@ -283,6 +282,8 @@ void EditorSpinSlider::_notification(int p_what) {
Rect2 grabber_rect = Rect2(ofs + gofs, svofs + 1, grabber_w, 2 * EDSCALE);
draw_rect(grabber_rect, c);
+ grabbing_spinner_mouse_pos = get_global_position() + grabber_rect.position + grabber_rect.size * 0.5;
+
bool display_grabber = (mouse_over_spin || mouse_over_grabber) && !grabbing_spinner && !value_input_popup->is_visible();
if (grabber->is_visible() != display_grabber) {
if (display_grabber) {
diff --git a/editor/icons/CombineLines.svg b/editor/icons/CombineLines.svg
new file mode 100644
index 0000000000..124814ae88
--- /dev/null
+++ b/editor/icons/CombineLines.svg
@@ -0,0 +1 @@
+<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="M1 2v2h14V2zm7 5v2h7V7zm0 5v2h7v-2zM4.976 14V9h2l-1.5-2-1.5-2-1.5 2-1.5 2h2v5z" fill="#e0e0e0"/></svg>
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 6ac47595dc..261621e10a 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -1654,7 +1654,7 @@ bool CanvasItemEditor::_gui_input_open_scene_on_double_click(const Ref<InputEven
Ref<InputEventMouseButton> b = p_event;
// Open a sub-scene on double-click
- if (b.is_valid() && b->get_button_index() == MOUSE_BUTTON_LEFT && b->is_pressed() && b->is_doubleclick() && tool == TOOL_SELECT) {
+ if (b.is_valid() && b->get_button_index() == MOUSE_BUTTON_LEFT && b->is_pressed() && b->is_double_click() && tool == TOOL_SELECT) {
List<CanvasItem *> selection = _get_edited_canvas_items();
if (selection.size() == 1) {
CanvasItem *canvas_item = selection[0];
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index e51e8ee82e..2b75144ac7 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -1762,7 +1762,7 @@ void ProjectList::_panel_input(const Ref<InputEvent> &p_ev, Node *p_hb) {
emit_signal(SIGNAL_SELECTION_CHANGED);
- if (!mb->get_control() && mb->is_doubleclick()) {
+ if (!mb->get_control() && mb->is_double_click()) {
emit_signal(SIGNAL_PROJECT_ASK_OPEN);
}
}
@@ -2371,6 +2371,7 @@ void ProjectManager::_on_search_term_changed(const String &p_term) {
void ProjectManager::_bind_methods() {
ClassDB::bind_method("_unhandled_key_input", &ProjectManager::_unhandled_key_input);
ClassDB::bind_method("_update_project_buttons", &ProjectManager::_update_project_buttons);
+ ClassDB::bind_method("_version_button_pressed", &ProjectManager::_version_button_pressed);
}
void ProjectManager::_open_asset_library() {
@@ -2378,6 +2379,10 @@ void ProjectManager::_open_asset_library() {
tabs->set_current_tab(1);
}
+void ProjectManager::_version_button_pressed() {
+ DisplayServer::get_singleton()->clipboard_set(version_btn->get_text());
+}
+
ProjectManager::ProjectManager() {
// load settings
if (!EditorSettings::get_singleton()) {
@@ -2601,15 +2606,30 @@ ProjectManager::ProjectManager() {
settings_hb->set_h_grow_direction(Control::GROW_DIRECTION_BEGIN);
settings_hb->set_anchors_and_offsets_preset(Control::PRESET_TOP_RIGHT);
- Label *version_label = memnew(Label);
+ // A VBoxContainer that contains a dummy Control node to adjust the LinkButton's vertical position.
+ VBoxContainer *spacer_vb = memnew(VBoxContainer);
+ settings_hb->add_child(spacer_vb);
+
+ Control *v_spacer = memnew(Control);
+ spacer_vb->add_child(v_spacer);
+
+ version_btn = memnew(LinkButton);
String hash = String(VERSION_HASH);
if (hash.length() != 0) {
hash = "." + hash.left(9);
}
- version_label->set_text("v" VERSION_FULL_BUILD "" + hash);
- version_label->set_self_modulate(Color(1, 1, 1, 0.6));
- version_label->set_align(Label::ALIGN_CENTER);
- settings_hb->add_child(version_label);
+ version_btn->set_text("v" VERSION_FULL_BUILD + hash);
+ // Fade the version label to be less prominent, but still readable.
+ version_btn->set_self_modulate(Color(1, 1, 1, 0.6));
+ version_btn->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
+ version_btn->set_tooltip(TTR("Click to copy."));
+ version_btn->connect("pressed", callable_mp(this, &ProjectManager::_version_button_pressed));
+ spacer_vb->add_child(version_btn);
+
+ // Add a small horizontal spacer between the version and language buttons
+ // to distinguish them.
+ Control *h_spacer = memnew(Control);
+ settings_hb->add_child(h_spacer);
language_btn = memnew(OptionButton);
language_btn->set_flat(true);
diff --git a/editor/project_manager.h b/editor/project_manager.h
index a66b7c4ab6..0fc69bd313 100644
--- a/editor/project_manager.h
+++ b/editor/project_manager.h
@@ -89,6 +89,7 @@ class ProjectManager : public Control {
ProjectDialog *npdialog;
OptionButton *language_btn;
+ LinkButton *version_btn;
void _open_asset_library();
void _scan_projects();
@@ -123,6 +124,7 @@ class ProjectManager : public Control {
void _unhandled_key_input(const Ref<InputEvent> &p_ev);
void _files_dropped(PackedStringArray p_files, int p_screen);
+ void _version_button_pressed();
void _on_order_option_changed(int p_idx);
void _on_tab_changed(int p_tab);
void _on_search_term_changed(const String &p_term);
diff --git a/modules/visual_script/visual_script_builtin_funcs.cpp b/modules/visual_script/visual_script_builtin_funcs.cpp
index 7ca14fbca8..3b24de433c 100644
--- a/modules/visual_script/visual_script_builtin_funcs.cpp
+++ b/modules/visual_script/visual_script_builtin_funcs.cpp
@@ -723,7 +723,7 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in
case VisualScriptBuiltinFunc::MATH_POSMOD: {
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
- *r_return = Math::posmod((int)*p_inputs[0], (int)*p_inputs[1]);
+ *r_return = Math::posmod((int64_t)*p_inputs[0], (int64_t)*p_inputs[1]);
} break;
case VisualScriptBuiltinFunc::MATH_FLOOR: {
VALIDATE_ARG_NUM(0);
diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp
index 02ec9ccd06..527eb0abc9 100644
--- a/modules/visual_script/visual_script_editor.cpp
+++ b/modules/visual_script/visual_script_editor.cpp
@@ -1875,7 +1875,7 @@ void VisualScriptEditor::_members_gui_input(const Ref<InputEvent> &p_event) {
}
Ref<InputEventMouseButton> btn = p_event;
- if (btn.is_valid() && btn->is_doubleclick()) {
+ if (btn.is_valid() && btn->is_double_click()) {
TreeItem *ti = members->get_selected();
if (ti && ti->get_parent() == members->get_root()->get_children()) { // to check if it's a function
_center_on_node(script->get_function_node_id(ti->get_metadata(0)));
diff --git a/platform/android/display_server_android.cpp b/platform/android/display_server_android.cpp
index dd001baba9..51cea39a43 100644
--- a/platform/android/display_server_android.cpp
+++ b/platform/android/display_server_android.cpp
@@ -778,7 +778,7 @@ void DisplayServerAndroid::process_double_tap(int event_android_button_mask, Poi
ev->set_pressed(event_button_mask != 0);
ev->set_button_index(_button_index_from_mask(event_button_mask));
ev->set_button_mask(event_button_mask);
- ev->set_doubleclick(true);
+ ev->set_double_click(true);
Input::get_singleton()->accumulate_input_event(ev);
}
diff --git a/platform/iphone/display_server_iphone.h b/platform/iphone/display_server_iphone.h
index 31a44723a5..7bf1557873 100644
--- a/platform/iphone/display_server_iphone.h
+++ b/platform/iphone/display_server_iphone.h
@@ -99,7 +99,7 @@ public:
// MARK: Touches
- void touch_press(int p_idx, int p_x, int p_y, bool p_pressed, bool p_doubleclick);
+ void touch_press(int p_idx, int p_x, int p_y, bool p_pressed, bool p_double_click);
void touch_drag(int p_idx, int p_prev_x, int p_prev_y, int p_x, int p_y);
void touches_cancelled(int p_idx);
diff --git a/platform/iphone/display_server_iphone.mm b/platform/iphone/display_server_iphone.mm
index b590ce065c..a852bea207 100644
--- a/platform/iphone/display_server_iphone.mm
+++ b/platform/iphone/display_server_iphone.mm
@@ -222,7 +222,7 @@ void DisplayServerIPhone::_window_callback(const Callable &p_callable, const Var
// MARK: Touches
-void DisplayServerIPhone::touch_press(int p_idx, int p_x, int p_y, bool p_pressed, bool p_doubleclick) {
+void DisplayServerIPhone::touch_press(int p_idx, int p_x, int p_y, bool p_pressed, bool p_double_click) {
if (!GLOBAL_DEF("debug/disable_touch", false)) {
Ref<InputEventScreenTouch> ev;
ev.instance();
diff --git a/platform/javascript/display_server_javascript.cpp b/platform/javascript/display_server_javascript.cpp
index 0031650360..234e42376d 100644
--- a/platform/javascript/display_server_javascript.cpp
+++ b/platform/javascript/display_server_javascript.cpp
@@ -215,14 +215,14 @@ EM_BOOL DisplayServerJavaScript::mouse_button_callback(int p_event_type, const E
display->last_click_ms = 0;
display->last_click_pos = Point2(-100, -100);
display->last_click_button_index = -1;
- ev->set_doubleclick(true);
+ ev->set_double_click(true);
}
} else {
display->last_click_button_index = ev->get_button_index();
}
- if (!ev->is_doubleclick()) {
+ if (!ev->is_double_click()) {
display->last_click_ms += diff;
display->last_click_pos = ev->get_position();
}
diff --git a/platform/linuxbsd/display_server_x11.cpp b/platform/linuxbsd/display_server_x11.cpp
index 8dc1b41702..12f030bd58 100644
--- a/platform/linuxbsd/display_server_x11.cpp
+++ b/platform/linuxbsd/display_server_x11.cpp
@@ -3162,14 +3162,14 @@ void DisplayServerX11::process_events() {
last_click_ms = 0;
last_click_pos = Point2i(-100, -100);
last_click_button_index = -1;
- mb->set_doubleclick(true);
+ mb->set_double_click(true);
}
} else if (mb->get_button_index() < 4 || mb->get_button_index() > 7) {
last_click_button_index = mb->get_button_index();
}
- if (!mb->is_doubleclick()) {
+ if (!mb->is_double_click()) {
last_click_ms += diff;
last_click_pos = Point2i(event.xbutton.x, event.xbutton.y);
}
diff --git a/platform/osx/display_server_osx.mm b/platform/osx/display_server_osx.mm
index 61bb26c2a8..473ae95036 100644
--- a/platform/osx/display_server_osx.mm
+++ b/platform/osx/display_server_osx.mm
@@ -830,7 +830,7 @@ static void _mouseDownEvent(DisplayServer::WindowID window_id, NSEvent *event, i
mb->set_global_position(pos);
mb->set_button_mask(DS_OSX->last_button_state);
if (index == MOUSE_BUTTON_LEFT && pressed) {
- mb->set_doubleclick([event clickCount] == 2);
+ mb->set_double_click([event clickCount] == 2);
}
Input::get_singleton()->accumulate_input_event(mb);
diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp
index 8789e6dfb4..4b859da340 100644
--- a/platform/windows/display_server_windows.cpp
+++ b/platform/windows/display_server_windows.cpp
@@ -2412,17 +2412,17 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
case WM_LBUTTONDBLCLK: {
mb->set_pressed(true);
mb->set_button_index(1);
- mb->set_doubleclick(true);
+ mb->set_double_click(true);
} break;
case WM_RBUTTONDBLCLK: {
mb->set_pressed(true);
mb->set_button_index(2);
- mb->set_doubleclick(true);
+ mb->set_double_click(true);
} break;
case WM_MBUTTONDBLCLK: {
mb->set_pressed(true);
mb->set_button_index(3);
- mb->set_doubleclick(true);
+ mb->set_double_click(true);
} break;
case WM_MOUSEWHEEL: {
mb->set_pressed(true);
@@ -2470,7 +2470,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
mb->set_button_index(MOUSE_BUTTON_XBUTTON1);
else
mb->set_button_index(MOUSE_BUTTON_XBUTTON2);
- mb->set_doubleclick(true);
+ mb->set_double_click(true);
} break;
default: {
return 0;
diff --git a/scene/gui/gradient_edit.cpp b/scene/gui/gradient_edit.cpp
index e72709e847..ebefb2938f 100644
--- a/scene/gui/gradient_edit.cpp
+++ b/scene/gui/gradient_edit.cpp
@@ -107,7 +107,7 @@ void GradientEdit::_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseButton> mb = p_event;
//Show color picker on double click.
- if (mb.is_valid() && mb->get_button_index() == 1 && mb->is_doubleclick() && mb->is_pressed()) {
+ if (mb.is_valid() && mb->get_button_index() == 1 && mb->is_double_click() && mb->is_pressed()) {
grabbed = _get_point_from_pos(mb->get_position().x);
_show_color_picker();
accept_event();
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp
index 86d070f9b1..4fddb4b661 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -600,7 +600,7 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) {
emit_signal("item_rmb_selected", i, get_local_mouse_position());
}
} else {
- if (!mb->is_doubleclick() && !mb->get_command() && select_mode == SELECT_MULTI && items[i].selectable && !items[i].disabled && items[i].selected && mb->get_button_index() == MOUSE_BUTTON_LEFT) {
+ if (!mb->is_double_click() && !mb->get_command() && select_mode == SELECT_MULTI && items[i].selectable && !items[i].disabled && items[i].selected && mb->get_button_index() == MOUSE_BUTTON_LEFT) {
defer_select_single = i;
return;
}
@@ -622,7 +622,7 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) {
if (mb->get_button_index() == MOUSE_BUTTON_RIGHT) {
emit_signal("item_rmb_selected", i, get_local_mouse_position());
- } else if (/*select_mode==SELECT_SINGLE &&*/ mb->is_doubleclick()) {
+ } else if (/*select_mode==SELECT_SINGLE &&*/ mb->is_double_click()) {
emit_signal("item_activated", i);
}
}
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index 1aff5d5390..eb836b3bf7 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -260,15 +260,15 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
} else {
if (selecting_enabled) {
- if (!b->is_doubleclick() && (OS::get_singleton()->get_ticks_msec() - selection.last_dblclk) < 600) {
+ if (!b->is_double_click() && (OS::get_singleton()->get_ticks_msec() - selection.last_dblclk) < 600) {
// Triple-click select all.
selection.enabled = true;
selection.begin = 0;
selection.end = text.length();
- selection.doubleclick = true;
+ selection.double_click = true;
selection.last_dblclk = 0;
caret_column = selection.begin;
- } else if (b->is_doubleclick()) {
+ } else if (b->is_double_click()) {
// Double-click select word.
Vector<Vector2i> words = TS->shaped_text_get_word_breaks(text_rid);
for (int i = 0; i < words.size(); i++) {
@@ -276,7 +276,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
selection.enabled = true;
selection.begin = words[i].x;
selection.end = words[i].y;
- selection.doubleclick = true;
+ selection.double_click = true;
selection.last_dblclk = OS::get_singleton()->get_ticks_msec();
caret_column = selection.end;
break;
@@ -308,11 +308,11 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
}
}
- if ((!selection.creating) && (!selection.doubleclick)) {
+ if ((!selection.creating) && (!selection.double_click)) {
deselect();
}
selection.creating = false;
- selection.doubleclick = false;
+ selection.double_click = false;
show_virtual_keyboard();
}
@@ -1532,7 +1532,7 @@ void LineEdit::deselect() {
selection.start_column = 0;
selection.enabled = false;
selection.creating = false;
- selection.doubleclick = false;
+ selection.double_click = false;
update();
}
@@ -1659,7 +1659,7 @@ void LineEdit::select(int p_from, int p_to) {
selection.begin = p_from;
selection.end = p_to;
selection.creating = false;
- selection.doubleclick = false;
+ selection.double_click = false;
update();
}
diff --git a/scene/gui/line_edit.h b/scene/gui/line_edit.h
index f4f0ff0629..12fec2f98b 100644
--- a/scene/gui/line_edit.h
+++ b/scene/gui/line_edit.h
@@ -134,7 +134,7 @@ private:
int start_column = 0;
bool enabled = false;
bool creating = false;
- bool doubleclick = false;
+ bool double_click = false;
bool drag_attempt = false;
uint64_t last_dblclk = 0;
} selection;
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index c763ae6bd6..e8a908c30e 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -1482,7 +1482,7 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) {
}
if (b->get_button_index() == MOUSE_BUTTON_LEFT) {
- if (b->is_pressed() && !b->is_doubleclick()) {
+ if (b->is_pressed() && !b->is_double_click()) {
scroll_updated = false;
ItemFrame *c_frame = nullptr;
int c_line = 0;
@@ -1514,8 +1514,8 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) {
}
}
}
- } else if (b->is_pressed() && b->is_doubleclick() && selection.enabled) {
- //doubleclick: select word
+ } else if (b->is_pressed() && b->is_double_click() && selection.enabled) {
+ //double_click: select word
ItemFrame *c_frame = nullptr;
int c_line = 0;
@@ -1549,7 +1549,7 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) {
} else if (!b->is_pressed()) {
selection.click_item = nullptr;
- if (!b->is_doubleclick() && !scroll_updated) {
+ if (!b->is_double_click() && !scroll_updated) {
Item *c_item = nullptr;
bool outside = true;
@@ -2612,6 +2612,14 @@ void RichTextLabel::pop() {
current = current->parent;
}
+// Creates a new line without adding an ItemNewline to the previous line.
+// Useful when wanting to calling remove_line and add a new line immediately after.
+void RichTextLabel::increment_line_count() {
+ _validate_line_caches(main);
+ current_frame->lines.resize(current_frame->lines.size() + 1);
+ _invalidate_current_line(current_frame);
+}
+
void RichTextLabel::clear() {
main->_clear_children();
current = main;
diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h
index e3e457d1f2..afc88e070a 100644
--- a/scene/gui/rich_text_label.h
+++ b/scene/gui/rich_text_label.h
@@ -483,6 +483,8 @@ public:
void push_cell();
void pop();
+ void increment_line_count();
+
void clear();
void set_offset(int p_pixel);
diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp
index 73c6371658..67dcf458b0 100644
--- a/scene/gui/scroll_container.cpp
+++ b/scene/gui/scroll_container.cpp
@@ -299,7 +299,7 @@ void ScrollContainer::_update_dimensions() {
child_max_size.x = MAX(child_max_size.x, minsize.x);
child_max_size.y = MAX(child_max_size.y, minsize.y);
- Rect2 r = Rect2(-scroll, minsize);
+ Rect2 r = Rect2(-Size2(get_h_scroll(), get_v_scroll()), minsize);
if (!scroll_h || (!h_scroll->is_visible_in_tree() && c->get_h_size_flags() & SIZE_EXPAND)) {
r.position.x = 0;
if (c->get_h_size_flags() & SIZE_EXPAND) {
@@ -434,40 +434,16 @@ void ScrollContainer::update_scrollbars() {
Size2 min = child_max_size;
- bool hide_scroll_v = !scroll_v || min.height <= size.height;
- bool hide_scroll_h = !scroll_h || min.width <= size.width;
-
- v_scroll->set_max(min.height);
- if (hide_scroll_v) {
- v_scroll->set_page(size.height);
- v_scroll->hide();
- scroll.y = 0;
- } else {
- v_scroll->show();
- if (hide_scroll_h) {
- v_scroll->set_page(size.height);
- } else {
- v_scroll->set_page(size.height - hmin.height);
- }
-
- scroll.y = v_scroll->get_value();
- }
+ bool hide_scroll_h = !scroll_h || min.width <= size.width || !h_scroll_visible;
+ bool hide_scroll_v = !scroll_v || min.height <= size.height || !v_scroll_visible;
h_scroll->set_max(min.width);
- if (hide_scroll_h) {
- h_scroll->set_page(size.width);
- h_scroll->hide();
- scroll.x = 0;
- } else {
- h_scroll->show();
- if (hide_scroll_v) {
- h_scroll->set_page(size.width);
- } else {
- h_scroll->set_page(size.width - vmin.width);
- }
+ h_scroll->set_page(size.width - (hide_scroll_v ? 0 : vmin.width));
+ h_scroll->set_visible(!hide_scroll_h);
- scroll.x = h_scroll->get_value();
- }
+ v_scroll->set_max(min.height);
+ v_scroll->set_page(size.height - (hide_scroll_h ? 0 : hmin.height));
+ v_scroll->set_visible(!hide_scroll_v);
// Avoid scrollbar overlapping.
h_scroll->set_anchor_and_offset(SIDE_RIGHT, ANCHOR_END, hide_scroll_v ? 0 : -vmin.width);
@@ -475,13 +451,28 @@ void ScrollContainer::update_scrollbars() {
}
void ScrollContainer::_scroll_moved(float) {
- scroll.x = h_scroll->get_value();
- scroll.y = v_scroll->get_value();
queue_sort();
-
update();
};
+void ScrollContainer::set_h_scroll(int p_pos) {
+ h_scroll->set_value(p_pos);
+ _cancel_drag();
+}
+
+int ScrollContainer::get_h_scroll() const {
+ return h_scroll->get_value();
+}
+
+void ScrollContainer::set_v_scroll(int p_pos) {
+ v_scroll->set_value(p_pos);
+ _cancel_drag();
+}
+
+int ScrollContainer::get_v_scroll() const {
+ return v_scroll->get_value();
+}
+
void ScrollContainer::set_enable_h_scroll(bool p_enable) {
if (scroll_h == p_enable) {
return;
@@ -510,22 +501,30 @@ bool ScrollContainer::is_v_scroll_enabled() const {
return scroll_v;
}
-int ScrollContainer::get_v_scroll() const {
- return v_scroll->get_value();
+void ScrollContainer::set_h_scroll_visible(bool p_visible) {
+ if (h_scroll_visible == p_visible) {
+ return;
+ }
+
+ h_scroll_visible = p_visible;
+ update_scrollbars();
}
-void ScrollContainer::set_v_scroll(int p_pos) {
- v_scroll->set_value(p_pos);
- _cancel_drag();
+bool ScrollContainer::is_h_scroll_visible() const {
+ return h_scroll_visible;
}
-int ScrollContainer::get_h_scroll() const {
- return h_scroll->get_value();
+void ScrollContainer::set_v_scroll_visible(bool p_visible) {
+ if (v_scroll_visible == p_visible) {
+ return;
+ }
+
+ v_scroll_visible = p_visible;
+ update_scrollbars();
}
-void ScrollContainer::set_h_scroll(int p_pos) {
- h_scroll->set_value(p_pos);
- _cancel_drag();
+bool ScrollContainer::is_v_scroll_visible() const {
+ return v_scroll_visible;
}
int ScrollContainer::get_deadzone() const {
@@ -581,17 +580,29 @@ VScrollBar *ScrollContainer::get_v_scrollbar() {
void ScrollContainer::_bind_methods() {
ClassDB::bind_method(D_METHOD("_gui_input"), &ScrollContainer::_gui_input);
- ClassDB::bind_method(D_METHOD("set_enable_h_scroll", "enable"), &ScrollContainer::set_enable_h_scroll);
- ClassDB::bind_method(D_METHOD("is_h_scroll_enabled"), &ScrollContainer::is_h_scroll_enabled);
- ClassDB::bind_method(D_METHOD("set_enable_v_scroll", "enable"), &ScrollContainer::set_enable_v_scroll);
- ClassDB::bind_method(D_METHOD("is_v_scroll_enabled"), &ScrollContainer::is_v_scroll_enabled);
ClassDB::bind_method(D_METHOD("_update_scrollbar_position"), &ScrollContainer::_update_scrollbar_position);
+
ClassDB::bind_method(D_METHOD("set_h_scroll", "value"), &ScrollContainer::set_h_scroll);
ClassDB::bind_method(D_METHOD("get_h_scroll"), &ScrollContainer::get_h_scroll);
+
ClassDB::bind_method(D_METHOD("set_v_scroll", "value"), &ScrollContainer::set_v_scroll);
ClassDB::bind_method(D_METHOD("get_v_scroll"), &ScrollContainer::get_v_scroll);
+
+ ClassDB::bind_method(D_METHOD("set_enable_h_scroll", "enable"), &ScrollContainer::set_enable_h_scroll);
+ ClassDB::bind_method(D_METHOD("is_h_scroll_enabled"), &ScrollContainer::is_h_scroll_enabled);
+
+ ClassDB::bind_method(D_METHOD("set_enable_v_scroll", "enable"), &ScrollContainer::set_enable_v_scroll);
+ ClassDB::bind_method(D_METHOD("is_v_scroll_enabled"), &ScrollContainer::is_v_scroll_enabled);
+
+ ClassDB::bind_method(D_METHOD("set_h_scroll_visible", "visible"), &ScrollContainer::set_h_scroll_visible);
+ ClassDB::bind_method(D_METHOD("is_h_scroll_visible"), &ScrollContainer::is_h_scroll_visible);
+
+ ClassDB::bind_method(D_METHOD("set_v_scroll_visible", "visible"), &ScrollContainer::set_v_scroll_visible);
+ ClassDB::bind_method(D_METHOD("is_v_scroll_visible"), &ScrollContainer::is_v_scroll_visible);
+
ClassDB::bind_method(D_METHOD("set_deadzone", "deadzone"), &ScrollContainer::set_deadzone);
ClassDB::bind_method(D_METHOD("get_deadzone"), &ScrollContainer::get_deadzone);
+
ClassDB::bind_method(D_METHOD("set_follow_focus", "enabled"), &ScrollContainer::set_follow_focus);
ClassDB::bind_method(D_METHOD("is_following_focus"), &ScrollContainer::is_following_focus);
@@ -604,10 +615,12 @@ void ScrollContainer::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "follow_focus"), "set_follow_focus", "is_following_focus");
ADD_GROUP("Scroll", "scroll_");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "scroll_horizontal_enabled"), "set_enable_h_scroll", "is_h_scroll_enabled");
ADD_PROPERTY(PropertyInfo(Variant::INT, "scroll_horizontal"), "set_h_scroll", "get_h_scroll");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "scroll_vertical_enabled"), "set_enable_v_scroll", "is_v_scroll_enabled");
ADD_PROPERTY(PropertyInfo(Variant::INT, "scroll_vertical"), "set_v_scroll", "get_v_scroll");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "scroll_horizontal_enabled"), "set_enable_h_scroll", "is_h_scroll_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "scroll_vertical_enabled"), "set_enable_v_scroll", "is_v_scroll_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "scroll_horizontal_visible"), "set_h_scroll_visible", "is_h_scroll_visible");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "scroll_vertical_visible"), "set_v_scroll_visible", "is_v_scroll_visible");
ADD_PROPERTY(PropertyInfo(Variant::INT, "scroll_deadzone"), "set_deadzone", "get_deadzone");
GLOBAL_DEF("gui/common/default_scroll_deadzone", 0);
diff --git a/scene/gui/scroll_container.h b/scene/gui/scroll_container.h
index e7d73bab0a..f61df70b85 100644
--- a/scene/gui/scroll_container.h
+++ b/scene/gui/scroll_container.h
@@ -42,7 +42,6 @@ class ScrollContainer : public Container {
VScrollBar *v_scroll;
Size2 child_max_size;
- Size2 scroll;
void update_scrollbars();
@@ -50,16 +49,17 @@ class ScrollContainer : public Container {
Vector2 drag_accum;
Vector2 drag_from;
Vector2 last_drag_accum;
- float last_drag_time = 0.0;
- float time_since_motion = 0.0;
+ float time_since_motion = 0.0f;
bool drag_touching = false;
bool drag_touching_deaccel = false;
- bool click_handled = false;
bool beyond_deadzone = false;
bool scroll_h = true;
bool scroll_v = true;
+ bool h_scroll_visible = true;
+ bool v_scroll_visible = true;
+
int deadzone = 0;
bool follow_focus = false;
@@ -80,11 +80,11 @@ protected:
void _ensure_focused_visible(Control *p_node);
public:
- int get_v_scroll() const;
- void set_v_scroll(int p_pos);
-
- int get_h_scroll() const;
void set_h_scroll(int p_pos);
+ int get_h_scroll() const;
+
+ void set_v_scroll(int p_pos);
+ int get_v_scroll() const;
void set_enable_h_scroll(bool p_enable);
bool is_h_scroll_enabled() const;
@@ -92,6 +92,12 @@ public:
void set_enable_v_scroll(bool p_enable);
bool is_v_scroll_enabled() const;
+ void set_h_scroll_visible(bool p_visible);
+ bool is_h_scroll_visible() const;
+
+ void set_v_scroll_visible(bool p_visible);
+ bool is_v_scroll_visible() const;
+
int get_deadzone() const;
void set_deadzone(int p_deadzone);
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 0713df9955..ded912591f 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -2903,7 +2903,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
completion_current = completion_options[completion_index];
update();
- if (mb->is_doubleclick()) {
+ if (mb->is_double_click()) {
_confirm_completion();
}
}
@@ -3026,12 +3026,12 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
selection.selecting_column = col;
}
- if (!mb->is_doubleclick() && (OS::get_singleton()->get_ticks_msec() - last_dblclk) < 600 && cursor.line == prev_line) {
+ if (!mb->is_double_click() && (OS::get_singleton()->get_ticks_msec() - last_dblclk) < 600 && cursor.line == prev_line) {
// Triple-click select line.
selection.selecting_mode = SelectionMode::SELECTION_MODE_LINE;
_update_selection_mode_line();
last_dblclk = 0;
- } else if (mb->is_doubleclick() && text[cursor.line].length()) {
+ } else if (mb->is_double_click() && text[cursor.line].length()) {
// Double-click select word.
selection.selecting_mode = SelectionMode::SELECTION_MODE_WORD;
_update_selection_mode_word();
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 73fd9dbcd7..6404f6fc0d 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -1388,7 +1388,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
}
}
- if ((select_mode == SELECT_ROW && selected_item == p_item) || p_item->cells[i].selected) {
+ if ((select_mode == SELECT_ROW && selected_item == p_item) || p_item->cells[i].selected || !p_item->has_meta("__focus_rect")) {
Rect2i r(cell_rect.position, cell_rect.size);
p_item->set_meta("__focus_rect", Rect2(r.position, r.size));
@@ -1866,7 +1866,7 @@ void Tree::_range_click_timeout() {
}
}
-int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool p_doubleclick, TreeItem *p_item, int p_button, const Ref<InputEventWithModifiers> &p_mod) {
+int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool p_double_click, TreeItem *p_item, int p_button, const Ref<InputEventWithModifiers> &p_mod) {
int item_h = compute_item_height(p_item) + cache.vseparation;
bool skip = (p_item == root && hide_root);
@@ -1963,7 +1963,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
if (p_button == MOUSE_BUTTON_LEFT || (p_button == MOUSE_BUTTON_RIGHT && allow_rmb_select)) {
/* process selection */
- if (p_doubleclick && (!c.editable || c.mode == TreeItem::CELL_MODE_CUSTOM || c.mode == TreeItem::CELL_MODE_ICON /*|| c.mode==TreeItem::CELL_MODE_CHECK*/)) { //it's confusing for check
+ if (p_double_click && (!c.editable || c.mode == TreeItem::CELL_MODE_CUSTOM || c.mode == TreeItem::CELL_MODE_ICON /*|| c.mode==TreeItem::CELL_MODE_CHECK*/)) { //it's confusing for check
propagate_mouse_activated = true;
@@ -2167,7 +2167,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
TreeItem *c = p_item->children;
while (c) {
- int child_h = propagate_mouse_event(new_pos, x_ofs, y_ofs, p_doubleclick, c, p_button, p_mod);
+ int child_h = propagate_mouse_event(new_pos, x_ofs, y_ofs, p_double_click, c, p_button, p_mod);
if (child_h < 0) {
return -1; // break, stop propagating, no need to anymore
@@ -2846,7 +2846,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
propagate_mouse_activated = false;
blocked++;
- propagate_mouse_event(pos + cache.offset, 0, 0, b->is_doubleclick(), root, b->get_button_index(), b);
+ propagate_mouse_event(pos + cache.offset, 0, 0, b->is_double_click(), root, b->get_button_index(), b);
blocked--;
if (pressing_for_editor) {
@@ -4262,7 +4262,7 @@ void Tree::_bind_methods() {
ADD_SIGNAL(MethodInfo("item_custom_button_pressed"));
ADD_SIGNAL(MethodInfo("item_double_clicked"));
ADD_SIGNAL(MethodInfo("item_collapsed", PropertyInfo(Variant::OBJECT, "item", PROPERTY_HINT_RESOURCE_TYPE, "TreeItem")));
- //ADD_SIGNAL( MethodInfo("item_doubleclicked" ) );
+ //ADD_SIGNAL( MethodInfo("item_double_clicked" ) );
ADD_SIGNAL(MethodInfo("button_pressed", PropertyInfo(Variant::OBJECT, "item", PROPERTY_HINT_RESOURCE_TYPE, "TreeItem"), PropertyInfo(Variant::INT, "column"), PropertyInfo(Variant::INT, "id")));
ADD_SIGNAL(MethodInfo("custom_popup_edited", PropertyInfo(Variant::BOOL, "arrow_clicked")));
ADD_SIGNAL(MethodInfo("item_activated"));
diff --git a/scene/gui/tree.h b/scene/gui/tree.h
index d1407e24d4..a40817b752 100644
--- a/scene/gui/tree.h
+++ b/scene/gui/tree.h
@@ -390,7 +390,7 @@ private:
void draw_item_rect(TreeItem::Cell &p_cell, const Rect2i &p_rect, const Color &p_color, const Color &p_icon_color, int p_ol_size, const Color &p_ol_color);
int draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 &p_draw_size, TreeItem *p_item);
void select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_col, TreeItem *p_prev = nullptr, bool *r_in_range = nullptr, bool p_force_deselect = false);
- int propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool p_doubleclick, TreeItem *p_item, int p_button, const Ref<InputEventWithModifiers> &p_mod);
+ int propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool p_double_click, TreeItem *p_item, int p_button, const Ref<InputEventWithModifiers> &p_mod);
void _text_editor_enter(String p_text);
void _text_editor_modal_close();
void value_editor_changed(double p_value);