mirror of
https://github.com/godotengine/godot.git
synced 2024-11-22 04:06:14 +00:00
Signals: Port more uses of connect_compat
Those were problematic as they call a method of their parent class, but callable_mp does not allow that unless it's public. To solve it, we declare a local class that calls the parent class' method, which now needs to be protected to be accessible in the derived class.
This commit is contained in:
parent
b8f08b42e7
commit
09a6a2d8f8
@ -134,10 +134,17 @@ void ConnectDialog::ok_pressed() {
|
||||
}
|
||||
|
||||
void ConnectDialog::_cancel_pressed() {
|
||||
|
||||
hide();
|
||||
}
|
||||
|
||||
void ConnectDialog::_item_activated() {
|
||||
_ok_pressed(); // From AcceptDialog.
|
||||
}
|
||||
|
||||
void ConnectDialog::_text_entered(const String &p_text) {
|
||||
_ok_pressed(); // From AcceptDialog.
|
||||
}
|
||||
|
||||
/*
|
||||
* Called each time a target node is selected within the target node tree.
|
||||
*/
|
||||
@ -386,7 +393,7 @@ ConnectDialog::ConnectDialog() {
|
||||
|
||||
tree = memnew(SceneTreeEditor(false));
|
||||
tree->set_connecting_signal(true);
|
||||
tree->get_scene_tree()->connect_compat("item_activated", this, "_ok");
|
||||
tree->get_scene_tree()->connect("item_activated", callable_mp(this, &ConnectDialog::_item_activated));
|
||||
tree->connect("node_selected", callable_mp(this, &ConnectDialog::_tree_node_selected));
|
||||
tree->set_connect_to_script_mode(true);
|
||||
|
||||
@ -445,7 +452,7 @@ ConnectDialog::ConnectDialog() {
|
||||
|
||||
dst_method = memnew(LineEdit);
|
||||
dst_method->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
dst_method->connect_compat("text_entered", this, "_builtin_text_entered");
|
||||
dst_method->connect("text_entered", callable_mp(this, &ConnectDialog::_text_entered));
|
||||
dstm_hb->add_child(dst_method);
|
||||
|
||||
advanced = memnew(CheckButton);
|
||||
@ -861,7 +868,6 @@ void ConnectionsDock::_notification(int p_what) {
|
||||
|
||||
void ConnectionsDock::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method("_close", &ConnectionsDock::_close);
|
||||
ClassDB::bind_method("update_tree", &ConnectionsDock::update_tree);
|
||||
}
|
||||
|
||||
|
@ -105,6 +105,8 @@ private:
|
||||
|
||||
void ok_pressed();
|
||||
void _cancel_pressed();
|
||||
void _item_activated();
|
||||
void _text_entered(const String &_text);
|
||||
void _tree_node_selected();
|
||||
void _add_bind();
|
||||
void _remove_bind();
|
||||
|
@ -561,6 +561,10 @@ void CreateDialog::_item_selected() {
|
||||
get_ok()->set_disabled(false);
|
||||
}
|
||||
|
||||
void CreateDialog::_hide_requested() {
|
||||
_closed(); // From WindowDialog.
|
||||
}
|
||||
|
||||
void CreateDialog::_favorite_toggled() {
|
||||
|
||||
TreeItem *item = search_options->get_selected();
|
||||
@ -804,7 +808,7 @@ CreateDialog::CreateDialog() {
|
||||
|
||||
help_bit = memnew(EditorHelpBit);
|
||||
vbc->add_margin_child(TTR("Description:"), help_bit);
|
||||
help_bit->connect_compat("request_hide", this, "_closed");
|
||||
help_bit->connect("request_hide", callable_mp(this, &CreateDialog::_hide_requested));
|
||||
|
||||
type_blacklist.insert("PluginScript"); // PluginScript must be initialized before use, which is not possible here
|
||||
type_blacklist.insert("ScriptCreateDialog"); // This is an exposed editor Node that doesn't have an Editor prefix.
|
||||
|
@ -60,6 +60,7 @@ class CreateDialog : public ConfirmationDialog {
|
||||
Set<StringName> type_blacklist;
|
||||
|
||||
void _item_selected();
|
||||
void _hide_requested();
|
||||
|
||||
void _update_search();
|
||||
void _update_favorite_list();
|
||||
|
@ -121,6 +121,10 @@ void EditorDirDialog::_item_collapsed(Object *p_item) {
|
||||
opened_paths.insert(item->get_metadata(0));
|
||||
}
|
||||
|
||||
void EditorDirDialog::_item_activated() {
|
||||
_ok_pressed(); // From AcceptDialog.
|
||||
}
|
||||
|
||||
void EditorDirDialog::ok_pressed() {
|
||||
|
||||
TreeItem *ti = tree->get_selected();
|
||||
@ -182,7 +186,7 @@ EditorDirDialog::EditorDirDialog() {
|
||||
tree = memnew(Tree);
|
||||
add_child(tree);
|
||||
|
||||
tree->connect_compat("item_activated", this, "_ok");
|
||||
tree->connect("item_activated", callable_mp(this, &EditorDirDialog::_item_activated));
|
||||
|
||||
makedir = add_button(TTR("Create Folder"), OS::get_singleton()->get_swap_ok_cancel(), "makedir");
|
||||
makedir->connect("pressed", callable_mp(this, &EditorDirDialog::_make_dir));
|
||||
|
@ -50,6 +50,7 @@ class EditorDirDialog : public ConfirmationDialog {
|
||||
bool updating;
|
||||
|
||||
void _item_collapsed(Object *p_item);
|
||||
void _item_activated();
|
||||
void _update_dir(TreeItem *p_item, EditorFileSystemDirectory *p_dir, const String &p_select_path = String());
|
||||
|
||||
void _make_dir();
|
||||
|
@ -131,6 +131,10 @@ void EditorSubScene::_item_multi_selected(Object *p_object, int p_cell, bool p_s
|
||||
}
|
||||
}
|
||||
|
||||
void EditorSubScene::_item_activated() {
|
||||
_ok_pressed(); // From AcceptDialog.
|
||||
}
|
||||
|
||||
void EditorSubScene::_remove_selection_child(Node *p_node) {
|
||||
if (p_node->get_child_count() > 0) {
|
||||
for (int i = 0; i < p_node->get_child_count(); i++) {
|
||||
@ -251,7 +255,7 @@ EditorSubScene::EditorSubScene() {
|
||||
//tree->connect("nothing_selected", this, "_deselect_items");
|
||||
tree->connect("cell_selected", callable_mp(this, &EditorSubScene::_selected_changed));
|
||||
|
||||
tree->connect_compat("item_activated", this, "_ok", make_binds(), CONNECT_DEFERRED);
|
||||
tree->connect("item_activated", callable_mp(this, &EditorSubScene::_item_activated), make_binds(), CONNECT_DEFERRED);
|
||||
|
||||
file_dialog = memnew(EditorFileDialog);
|
||||
List<String> extensions;
|
||||
|
@ -50,6 +50,7 @@ class EditorSubScene : public ConfirmationDialog {
|
||||
void _fill_tree(Node *p_node, TreeItem *p_parent);
|
||||
void _selected_changed();
|
||||
void _item_multi_selected(Object *p_object, int p_cell, bool p_selected);
|
||||
void _item_activated();
|
||||
void _remove_selection_child(Node *p_node);
|
||||
void _reown(Node *p_node, List<Node *> *p_to_reown);
|
||||
|
||||
|
@ -945,7 +945,10 @@ void ProjectExportDialog::_export_project() {
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure that signal is connected if previous attempt left it disconnected with _validate_export_path
|
||||
// Ensure that signal is connected if previous attempt left it disconnected
|
||||
// with _validate_export_path.
|
||||
// FIXME: This is a hack, we should instead change EditorFileDialog to allow
|
||||
// disabling validation by the "text_entered" signal.
|
||||
if (!export_project->get_line_edit()->is_connected_compat("text_entered", export_project, "_file_entered")) {
|
||||
export_project->get_ok()->set_disabled(false);
|
||||
export_project->get_line_edit()->connect_compat("text_entered", export_project, "_file_entered");
|
||||
|
@ -389,6 +389,10 @@ void PropertySelector::_item_selected() {
|
||||
help_bit->set_text(text);
|
||||
}
|
||||
|
||||
void PropertySelector::_hide_requested() {
|
||||
_closed(); // From WindowDialog.
|
||||
}
|
||||
|
||||
void PropertySelector::_notification(int p_what) {
|
||||
|
||||
if (p_what == NOTIFICATION_ENTER_TREE) {
|
||||
@ -568,5 +572,5 @@ PropertySelector::PropertySelector() {
|
||||
|
||||
help_bit = memnew(EditorHelpBit);
|
||||
vbc->add_margin_child(TTR("Description:"), help_bit);
|
||||
help_bit->connect_compat("request_hide", this, "_closed");
|
||||
help_bit->connect("request_hide", callable_mp(this, &PropertySelector::_hide_requested));
|
||||
}
|
||||
|
@ -41,12 +41,12 @@ class PropertySelector : public ConfirmationDialog {
|
||||
LineEdit *search_box;
|
||||
Tree *search_options;
|
||||
|
||||
void _update_search();
|
||||
|
||||
void _sbox_input(const Ref<InputEvent> &p_ie);
|
||||
|
||||
void _confirmed();
|
||||
void _text_changed(const String &p_newtext);
|
||||
void _sbox_input(const Ref<InputEvent> &p_ie);
|
||||
void _update_search();
|
||||
void _confirmed();
|
||||
void _item_selected();
|
||||
void _hide_requested();
|
||||
|
||||
EditorHelpBit *help_bit;
|
||||
|
||||
@ -58,8 +58,6 @@ class PropertySelector : public ConfirmationDialog {
|
||||
Object *instance;
|
||||
bool virtuals_only;
|
||||
|
||||
void _item_selected();
|
||||
|
||||
Vector<Variant::Type> type_filter;
|
||||
|
||||
protected:
|
||||
|
@ -518,6 +518,10 @@ void VisualScriptPropertySelector::_item_selected() {
|
||||
help_bit->set_text(text);
|
||||
}
|
||||
|
||||
void VisualScriptPropertySelector::_hide_requested() {
|
||||
_closed(); // From WindowDialog.
|
||||
}
|
||||
|
||||
void VisualScriptPropertySelector::_notification(int p_what) {
|
||||
|
||||
if (p_what == NOTIFICATION_ENTER_TREE) {
|
||||
@ -716,7 +720,7 @@ VisualScriptPropertySelector::VisualScriptPropertySelector() {
|
||||
seq_connect = false;
|
||||
help_bit = memnew(EditorHelpBit);
|
||||
vbc->add_margin_child(TTR("Description:"), help_bit);
|
||||
help_bit->connect_compat("request_hide", this, "_closed");
|
||||
help_bit->connect("request_hide", callable_mp(this, &VisualScriptPropertySelector::_hide_requested));
|
||||
search_options->set_columns(3);
|
||||
search_options->set_column_expand(1, false);
|
||||
search_options->set_column_expand(2, false);
|
||||
|
@ -41,16 +41,16 @@ class VisualScriptPropertySelector : public ConfirmationDialog {
|
||||
LineEdit *search_box;
|
||||
Tree *search_options;
|
||||
|
||||
void _text_changed(const String &p_newtext);
|
||||
void _sbox_input(const Ref<InputEvent> &p_ie);
|
||||
void _update_search();
|
||||
|
||||
void create_visualscript_item(const String &name, TreeItem *const root, const String &search_input, const String &text);
|
||||
|
||||
void get_visual_node_names(const String &root_filter, const Set<String> &p_modifiers, bool &found, TreeItem *const root, LineEdit *const search_box);
|
||||
|
||||
void _sbox_input(const Ref<InputEvent> &p_ie);
|
||||
|
||||
void _confirmed();
|
||||
void _text_changed(const String &p_newtext);
|
||||
void _item_selected();
|
||||
void _hide_requested();
|
||||
|
||||
EditorHelpBit *help_bit;
|
||||
|
||||
@ -65,8 +65,6 @@ class VisualScriptPropertySelector : public ConfirmationDialog {
|
||||
bool virtuals_only;
|
||||
bool seq_connect;
|
||||
|
||||
void _item_selected();
|
||||
|
||||
Vector<Variant::Type> type_filter;
|
||||
|
||||
protected:
|
||||
|
@ -333,9 +333,6 @@ void SpriteBase3D::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_item_rect"), &SpriteBase3D::get_item_rect);
|
||||
ClassDB::bind_method(D_METHOD("generate_triangle_mesh"), &SpriteBase3D::generate_triangle_mesh);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_queue_update"), &SpriteBase3D::_queue_update);
|
||||
ClassDB::bind_method(D_METHOD("_im_update"), &SpriteBase3D::_im_update);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "centered"), "set_centered", "is_centered");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "offset"), "set_offset", "get_offset");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "flip_h"), "set_flip_h", "is_flipped_h");
|
||||
@ -525,16 +522,20 @@ void Sprite3D::_draw() {
|
||||
VS::get_singleton()->immediate_end(immediate);
|
||||
}
|
||||
|
||||
void Sprite3D::_texture_changed() {
|
||||
_queue_update();
|
||||
}
|
||||
|
||||
void Sprite3D::set_texture(const Ref<Texture2D> &p_texture) {
|
||||
|
||||
if (p_texture == texture)
|
||||
return;
|
||||
if (texture.is_valid()) {
|
||||
texture->disconnect_compat(CoreStringNames::get_singleton()->changed, this, SceneStringNames::get_singleton()->_queue_update);
|
||||
texture->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Sprite3D::_texture_changed));
|
||||
}
|
||||
texture = p_texture;
|
||||
if (texture.is_valid()) {
|
||||
texture->connect_compat(CoreStringNames::get_singleton()->changed, this, SceneStringNames::get_singleton()->_queue_update);
|
||||
texture->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Sprite3D::_texture_changed));
|
||||
}
|
||||
_queue_update();
|
||||
}
|
||||
|
@ -157,6 +157,8 @@ class Sprite3D : public SpriteBase3D {
|
||||
int vframes;
|
||||
int hframes;
|
||||
|
||||
void _texture_changed();
|
||||
|
||||
protected:
|
||||
virtual void _draw();
|
||||
static void _bind_methods();
|
||||
|
@ -338,8 +338,6 @@ void WindowDialog::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_resizable"), &WindowDialog::get_resizable);
|
||||
ClassDB::bind_method(D_METHOD("get_close_button"), &WindowDialog::get_close_button);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_closed"), &WindowDialog::_closed); // Still used by some connect_compat.
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "window_title", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT_INTL), "set_title", "get_title");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "resizable", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT_INTL), "set_resizable", "get_resizable");
|
||||
}
|
||||
@ -398,7 +396,7 @@ void AcceptDialog::_notification(int p_what) {
|
||||
}
|
||||
}
|
||||
|
||||
void AcceptDialog::_builtin_text_entered(const String &p_text) {
|
||||
void AcceptDialog::_text_entered(const String &p_text) {
|
||||
|
||||
_ok_pressed();
|
||||
}
|
||||
@ -410,11 +408,18 @@ void AcceptDialog::_ok_pressed() {
|
||||
ok_pressed();
|
||||
emit_signal("confirmed");
|
||||
}
|
||||
|
||||
void AcceptDialog::_close_pressed() {
|
||||
|
||||
cancel_pressed();
|
||||
}
|
||||
|
||||
// FIXME: This is redundant with _closed_pressed, but there's a slight behavior
|
||||
// change (WindowDialog's _closed() also calls hide()) which should be assessed.
|
||||
void AcceptDialog::_on_close_pressed() {
|
||||
_closed(); // From WindowDialog.
|
||||
}
|
||||
|
||||
String AcceptDialog::get_text() const {
|
||||
|
||||
return label->get_text();
|
||||
@ -449,7 +454,7 @@ void AcceptDialog::register_text_enter(Node *p_line_edit) {
|
||||
ERR_FAIL_NULL(p_line_edit);
|
||||
LineEdit *line_edit = Object::cast_to<LineEdit>(p_line_edit);
|
||||
if (line_edit)
|
||||
line_edit->connect("text_entered", callable_mp(this, &AcceptDialog::_builtin_text_entered));
|
||||
line_edit->connect("text_entered", callable_mp(this, &AcceptDialog::_text_entered));
|
||||
}
|
||||
|
||||
void AcceptDialog::_update_child_rects() {
|
||||
@ -546,7 +551,7 @@ Button *AcceptDialog::add_cancel(const String &p_cancel) {
|
||||
if (p_cancel == "")
|
||||
c = RTR("Cancel");
|
||||
Button *b = swap_ok_cancel ? add_button(c, true) : add_button(c);
|
||||
b->connect_compat("pressed", this, "_closed");
|
||||
b->connect("pressed", callable_mp(this, &AcceptDialog::_on_close_pressed));
|
||||
return b;
|
||||
}
|
||||
|
||||
@ -564,9 +569,6 @@ void AcceptDialog::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_autowrap", "autowrap"), &AcceptDialog::set_autowrap);
|
||||
ClassDB::bind_method(D_METHOD("has_autowrap"), &AcceptDialog::has_autowrap);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_ok"), &AcceptDialog::_ok_pressed); // Still used by some connect_compat.
|
||||
ClassDB::bind_method(D_METHOD("_builtin_text_entered"), &AcceptDialog::_builtin_text_entered); // Still used by some connect_compat.
|
||||
|
||||
ADD_SIGNAL(MethodInfo("confirmed"));
|
||||
ADD_SIGNAL(MethodInfo("custom_action", PropertyInfo(Variant::STRING_NAME, "action")));
|
||||
|
||||
|
@ -64,7 +64,6 @@ class WindowDialog : public Popup {
|
||||
#endif
|
||||
|
||||
void _gui_input(const Ref<InputEvent> &p_event);
|
||||
void _closed();
|
||||
int _drag_hit_test(const Point2 &pos) const;
|
||||
|
||||
protected:
|
||||
@ -75,6 +74,9 @@ protected:
|
||||
void _notification(int p_what);
|
||||
static void _bind_methods();
|
||||
|
||||
// Not private since used by derived classes signal.
|
||||
void _closed();
|
||||
|
||||
public:
|
||||
TextureButton *get_close_button();
|
||||
|
||||
@ -113,9 +115,7 @@ class AcceptDialog : public WindowDialog {
|
||||
bool hide_on_ok;
|
||||
|
||||
void _custom_action(const String &p_action);
|
||||
void _ok_pressed();
|
||||
void _close_pressed();
|
||||
void _builtin_text_entered(const String &p_text);
|
||||
void _update_child_rects();
|
||||
|
||||
static bool swap_ok_cancel;
|
||||
@ -128,6 +128,11 @@ protected:
|
||||
virtual void cancel_pressed() {}
|
||||
virtual void custom_action(const String &) {}
|
||||
|
||||
// Not private since used by derived classes signal.
|
||||
void _text_entered(const String &p_text);
|
||||
void _ok_pressed();
|
||||
void _on_close_pressed();
|
||||
|
||||
public:
|
||||
Size2 get_minimum_size() const;
|
||||
|
||||
|
@ -162,7 +162,6 @@ SceneStringNames::SceneStringNames() {
|
||||
can_drop_data = StaticCString::create("can_drop_data");
|
||||
|
||||
_im_update = StaticCString::create("_im_update"); // Sprite3D
|
||||
_queue_update = StaticCString::create("_queue_update"); // Sprite3D
|
||||
|
||||
baked_light_changed = StaticCString::create("baked_light_changed");
|
||||
_baked_light_changed = StaticCString::create("_baked_light_changed");
|
||||
|
@ -174,7 +174,6 @@ public:
|
||||
StringName _get_minimum_size;
|
||||
|
||||
StringName _im_update;
|
||||
StringName _queue_update;
|
||||
|
||||
StringName baked_light_changed;
|
||||
StringName _baked_light_changed;
|
||||
|
Loading…
Reference in New Issue
Block a user