Allow negative indices in TreeItem's set_button_*() methods
This commit is contained in:
@@ -1474,6 +1474,9 @@ void TreeItem::set_button_tooltip_text(int p_column, int p_index, const String &
|
||||
void TreeItem::set_button(int p_column, int p_index, const Ref<Texture2D> &p_button) {
|
||||
ERR_FAIL_COND(p_button.is_null());
|
||||
ERR_FAIL_INDEX(p_column, cells.size());
|
||||
if (p_index < 0) {
|
||||
p_index += cells[p_column].buttons.size();
|
||||
}
|
||||
ERR_FAIL_INDEX(p_index, cells[p_column].buttons.size());
|
||||
|
||||
if (cells[p_column].buttons[p_index].texture == p_button) {
|
||||
@@ -1488,6 +1491,9 @@ void TreeItem::set_button(int p_column, int p_index, const Ref<Texture2D> &p_but
|
||||
|
||||
void TreeItem::set_button_description(int p_column, int p_index, const String &p_description) {
|
||||
ERR_FAIL_INDEX(p_column, cells.size());
|
||||
if (p_index < 0) {
|
||||
p_index += cells[p_column].buttons.size();
|
||||
}
|
||||
ERR_FAIL_INDEX(p_index, cells[p_column].buttons.size());
|
||||
|
||||
if (cells[p_column].buttons[p_index].description == p_description) {
|
||||
@@ -1503,6 +1509,9 @@ void TreeItem::set_button_description(int p_column, int p_index, const String &p
|
||||
|
||||
void TreeItem::set_button_color(int p_column, int p_index, const Color &p_color) {
|
||||
ERR_FAIL_INDEX(p_column, cells.size());
|
||||
if (p_index < 0) {
|
||||
p_index += cells[p_column].buttons.size();
|
||||
}
|
||||
ERR_FAIL_INDEX(p_index, cells[p_column].buttons.size());
|
||||
|
||||
if (cells[p_column].buttons[p_index].color == p_color) {
|
||||
@@ -1515,6 +1524,9 @@ void TreeItem::set_button_color(int p_column, int p_index, const Color &p_color)
|
||||
|
||||
void TreeItem::set_button_disabled(int p_column, int p_index, bool p_disabled) {
|
||||
ERR_FAIL_INDEX(p_column, cells.size());
|
||||
if (p_index < 0) {
|
||||
p_index += cells[p_column].buttons.size();
|
||||
}
|
||||
ERR_FAIL_INDEX(p_index, cells[p_column].buttons.size());
|
||||
|
||||
if (cells[p_column].buttons[p_index].disabled == p_disabled) {
|
||||
|
||||
Reference in New Issue
Block a user