diff options
author | Meriipu <Meriipu@users.noreply.github.com> | 2019-07-07 16:18:36 +0200 |
---|---|---|
committer | Meriipu <Meriipu@users.noreply.github.com> | 2019-07-07 16:18:36 +0200 |
commit | fe9ec58028ff5f89aa1db1d4faa1ec7af00b6c3d (patch) | |
tree | 6b8b219e2035fb21b76d6cd721ea86ec5c4394e2 /scene | |
parent | 1fa26b969c296ca62462debf01c22e2cc0aa059e (diff) |
TreeItem: Added a setter for the disabled-property of buttons
Diffstat (limited to 'scene')
-rw-r--r-- | scene/gui/tree.cpp | 8 | ||||
-rw-r--r-- | scene/gui/tree.h | 1 |
2 files changed, 9 insertions, 0 deletions
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index c2493ab321..8624baa005 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -571,7 +571,14 @@ int TreeItem::get_button_by_id(int p_column, int p_id) const { return -1; } +void TreeItem::set_disable_button(int p_column, int p_idx, bool p_disabled) { + ERR_FAIL_INDEX(p_column, cells.size()); + ERR_FAIL_INDEX(p_idx, cells[p_column].buttons.size()); + + cells.write[p_column].buttons.write[p_idx].disabled = p_disabled; + _changed_notify(p_column); +} bool TreeItem::is_button_disabled(int p_column, int p_idx) const { ERR_FAIL_INDEX_V(p_column, cells.size(), false); @@ -786,6 +793,7 @@ void TreeItem::_bind_methods() { ClassDB::bind_method(D_METHOD("set_button", "column", "button_idx", "button"), &TreeItem::set_button); ClassDB::bind_method(D_METHOD("erase_button", "column", "button_idx"), &TreeItem::erase_button); ClassDB::bind_method(D_METHOD("is_button_disabled", "column", "button_idx"), &TreeItem::is_button_disabled); + ClassDB::bind_method(D_METHOD("set_disable_button", "column", "button_idx", "disabled"), &TreeItem::set_disable_button); ClassDB::bind_method(D_METHOD("set_expand_right", "column", "enable"), &TreeItem::set_expand_right); ClassDB::bind_method(D_METHOD("get_expand_right", "column"), &TreeItem::get_expand_right); diff --git a/scene/gui/tree.h b/scene/gui/tree.h index 45d451eb72..6e5e2c1eba 100644 --- a/scene/gui/tree.h +++ b/scene/gui/tree.h @@ -212,6 +212,7 @@ public: bool is_button_disabled(int p_column, int p_idx) const; void set_button(int p_column, int p_idx, const Ref<Texture> &p_button); void set_button_color(int p_column, int p_idx, const Color &p_color); + void set_disable_button(int p_column, int p_idx, bool p_disabled); /* range works for mode number or mode combo */ |