Skip to content

Commit 2607a7f

Browse files
committed
Merge pull request godotengine#87686 from radzo73/get_button_color
[TreeItem] Add `get_button_color()`
2 parents e4372b1 + dcf1dc1 commit 2607a7f

3 files changed

Lines changed: 16 additions & 0 deletions

File tree

doc/classes/TreeItem.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@
9696
Returns the button index if there is a button with ID [param id] in column [param column], otherwise returns -1.
9797
</description>
9898
</method>
99+
<method name="get_button_color" qualifiers="const">
100+
<return type="Color" />
101+
<param index="0" name="column" type="int" />
102+
<param index="1" name="id" type="int" />
103+
<description>
104+
Returns the color of the button with ID [param id] in column [param column]. If the specified button does not exist, returns [constant Color.BLACK].
105+
</description>
106+
</method>
99107
<method name="get_button_count" qualifiers="const">
100108
<return type="int" />
101109
<param index="0" name="column" type="int" />

scene/gui/tree.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,6 +1222,12 @@ int TreeItem::get_button_by_id(int p_column, int p_id) const {
12221222
return -1;
12231223
}
12241224

1225+
Color TreeItem::get_button_color(int p_column, int p_index) const {
1226+
ERR_FAIL_INDEX_V(p_column, cells.size(), Color());
1227+
ERR_FAIL_INDEX_V(p_index, cells[p_column].buttons.size(), Color());
1228+
return cells[p_column].buttons[p_index].color;
1229+
}
1230+
12251231
void TreeItem::set_button_tooltip_text(int p_column, int p_index, const String &p_tooltip) {
12261232
ERR_FAIL_INDEX(p_column, cells.size());
12271233
ERR_FAIL_INDEX(p_index, cells[p_column].buttons.size());
@@ -1662,6 +1668,7 @@ void TreeItem::_bind_methods() {
16621668
ClassDB::bind_method(D_METHOD("get_button_tooltip_text", "column", "button_index"), &TreeItem::get_button_tooltip_text);
16631669
ClassDB::bind_method(D_METHOD("get_button_id", "column", "button_index"), &TreeItem::get_button_id);
16641670
ClassDB::bind_method(D_METHOD("get_button_by_id", "column", "id"), &TreeItem::get_button_by_id);
1671+
ClassDB::bind_method(D_METHOD("get_button_color", "column", "id"), &TreeItem::get_button_color);
16651672
ClassDB::bind_method(D_METHOD("get_button", "column", "button_index"), &TreeItem::get_button);
16661673
ClassDB::bind_method(D_METHOD("set_button_tooltip_text", "column", "button_index", "tooltip"), &TreeItem::set_button_tooltip_text);
16671674
ClassDB::bind_method(D_METHOD("set_button", "column", "button_index", "button"), &TreeItem::set_button);

scene/gui/tree.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ class TreeItem : public Object {
266266
int get_button_id(int p_column, int p_index) const;
267267
void erase_button(int p_column, int p_index);
268268
int get_button_by_id(int p_column, int p_id) const;
269+
Color get_button_color(int p_column, int p_index) const;
269270
void set_button_tooltip_text(int p_column, int p_index, const String &p_tooltip);
270271
void set_button(int p_column, int p_index, const Ref<Texture2D> &p_button);
271272
void set_button_color(int p_column, int p_index, const Color &p_color);

0 commit comments

Comments
 (0)