Allow method binds to take Object subclasses as arguments

This commit adds a condition to VariantCaster that casts Variants of type OBJECT to any type T, if T is derived from Object.
This change enables a fair bit of code cleanup. First, the Variant implicit cast operators for Node and Control can be removed, which allows for some invalid includes to be removed. Second, helper methods in Tree whose sole purpose was to cast arguments to TreeItem * are no longer necessary.
A few small changes also had to be made to other files, due to the changes cascading down all the includes.
This commit is contained in:
TechnoPorg
2022-01-25 08:37:41 -07:00
parent 2f4d76f068
commit 051ef479c9
15 changed files with 64 additions and 78 deletions
-17
View File
@@ -609,23 +609,6 @@ private:
protected:
static void _bind_methods();
//bind helpers
TreeItem *_create_item(Object *p_parent, int p_idx = -1) {
return create_item(Object::cast_to<TreeItem>(p_parent), p_idx);
}
TreeItem *_get_next_selected(Object *p_item) {
return get_next_selected(Object::cast_to<TreeItem>(p_item));
}
Rect2 _get_item_rect(Object *p_item, int p_column) const {
return get_item_rect(Object::cast_to<TreeItem>(p_item), p_column);
}
void _scroll_to_item(Object *p_item) {
scroll_to_item(Object::cast_to<TreeItem>(p_item));
}
public:
virtual void gui_input(const Ref<InputEvent> &p_event) override;