Skip to content

Commit b2b449d

Browse files
committed
Merge pull request #107540 from Mickeon/rename-TreeItem-accessibility-alt-text-to-description
Rename TreeItem's `alt_text` to `description` for consistency with Accessibility API
2 parents de0f3dd + 76a7c31 commit b2b449d

File tree

3 files changed

+49
-49
lines changed

3 files changed

+49
-49
lines changed

doc/classes/TreeItem.xml

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
<param index="2" name="id" type="int" default="-1" />
1919
<param index="3" name="disabled" type="bool" default="false" />
2020
<param index="4" name="tooltip_text" type="String" default="&quot;&quot;" />
21-
<param index="5" name="alt_text" type="String" default="&quot;&quot;" />
21+
<param index="5" name="description" type="String" default="&quot;&quot;" />
2222
<description>
23-
Adds a button with [Texture2D] [param button] to the end of the cell at column [param column]. The [param id] is used to identify the button in the according [signal Tree.button_clicked] signal and can be different from the buttons index. If not specified, the next available index is used, which may be retrieved by calling [method get_button_count] immediately before this method. Optionally, the button can be [param disabled] and have a [param tooltip_text]. [param alt_text] is used as the button description for assistive apps.
23+
Adds a button with [Texture2D] [param button] to the end of the cell at column [param column]. The [param id] is used to identify the button in the according [signal Tree.button_clicked] signal and can be different from the buttons index. If not specified, the next available index is used, which may be retrieved by calling [method get_button_count] immediately before this method. Optionally, the button can be [param disabled] and have a [param tooltip_text]. [param description] is used as the button description for assistive apps.
2424
</description>
2525
</method>
2626
<method name="add_child">
@@ -80,13 +80,6 @@
8080
Removes the button at index [param button_index] in column [param column].
8181
</description>
8282
</method>
83-
<method name="get_alt_text" qualifiers="const">
84-
<return type="String" />
85-
<param index="0" name="column" type="int" />
86-
<description>
87-
Returns the given column's alternative text.
88-
</description>
89-
</method>
9083
<method name="get_auto_translate_mode" qualifiers="const">
9184
<return type="int" enum="Node.AutoTranslateMode" />
9285
<param index="0" name="column" type="int" />
@@ -210,6 +203,13 @@
210203
Returns custom font size used to draw text in the column [param column].
211204
</description>
212205
</method>
206+
<method name="get_description" qualifiers="const">
207+
<return type="String" />
208+
<param index="0" name="column" type="int" />
209+
<description>
210+
Returns the given column's description for assistive apps.
211+
</description>
212+
</method>
213213
<method name="get_expand_right" qualifiers="const">
214214
<return type="bool" />
215215
<param index="0" name="column" type="int" />
@@ -514,14 +514,6 @@
514514
Selects the given [param column].
515515
</description>
516516
</method>
517-
<method name="set_alt_text">
518-
<return type="void" />
519-
<param index="0" name="column" type="int" />
520-
<param index="1" name="text" type="String" />
521-
<description>
522-
Sets the given column's alternative (description) text for assistive apps.
523-
</description>
524-
</method>
525517
<method name="set_auto_translate_mode">
526518
<return type="void" />
527519
<param index="0" name="column" type="int" />
@@ -548,22 +540,22 @@
548540
Sets the given column's button [Texture2D] at index [param button_index] to [param button].
549541
</description>
550542
</method>
551-
<method name="set_button_alt_text">
543+
<method name="set_button_color">
552544
<return type="void" />
553545
<param index="0" name="column" type="int" />
554546
<param index="1" name="button_index" type="int" />
555-
<param index="2" name="alt_text" type="String" />
547+
<param index="2" name="color" type="Color" />
556548
<description>
557-
Sets the given column's button alternative text (description) at index [param button_index] for assistive apps.
549+
Sets the given column's button color at index [param button_index] to [param color].
558550
</description>
559551
</method>
560-
<method name="set_button_color">
552+
<method name="set_button_description">
561553
<return type="void" />
562554
<param index="0" name="column" type="int" />
563555
<param index="1" name="button_index" type="int" />
564-
<param index="2" name="color" type="Color" />
556+
<param index="2" name="description" type="String" />
565557
<description>
566-
Sets the given column's button color at index [param button_index] to [param color].
558+
Sets the given column's button description at index [param button_index] for assistive apps.
567559
</description>
568560
</method>
569561
<method name="set_button_disabled">
@@ -667,6 +659,14 @@
667659
Sets custom font size used to draw text in the given [param column].
668660
</description>
669661
</method>
662+
<method name="set_description">
663+
<return type="void" />
664+
<param index="0" name="column" type="int" />
665+
<param index="1" name="description" type="String" />
666+
<description>
667+
Sets the given column's description for assistive apps.
668+
</description>
669+
</method>
670670
<method name="set_edit_multiline">
671671
<return type="void" />
672672
<param index="0" name="column" type="int" />

scene/gui/tree.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -400,24 +400,24 @@ String TreeItem::get_text(int p_column) const {
400400
return cells[p_column].text;
401401
}
402402

403-
void TreeItem::set_alt_text(int p_column, String p_text) {
403+
void TreeItem::set_description(int p_column, String p_text) {
404404
ERR_FAIL_INDEX(p_column, cells.size());
405405

406-
if (cells[p_column].alt_text == p_text) {
406+
if (cells[p_column].description == p_text) {
407407
return;
408408
}
409409

410-
cells.write[p_column].alt_text = p_text;
410+
cells.write[p_column].description = p_text;
411411

412412
_changed_notify(p_column);
413413
if (get_tree()) {
414414
get_tree()->update_configuration_warnings();
415415
}
416416
}
417417

418-
String TreeItem::get_alt_text(int p_column) const {
418+
String TreeItem::get_description(int p_column) const {
419419
ERR_FAIL_INDEX_V(p_column, cells.size(), "");
420-
return cells[p_column].alt_text;
420+
return cells[p_column].description;
421421
}
422422

423423
void TreeItem::set_text_direction(int p_column, Control::TextDirection p_text_direction) {
@@ -1330,7 +1330,7 @@ void TreeItem::clear_buttons() {
13301330
}
13311331
}
13321332

1333-
void TreeItem::add_button(int p_column, const Ref<Texture2D> &p_button, int p_id, bool p_disabled, const String &p_tooltip, const String &p_alt_text) {
1333+
void TreeItem::add_button(int p_column, const Ref<Texture2D> &p_button, int p_id, bool p_disabled, const String &p_tooltip, const String &p_description) {
13341334
ERR_FAIL_INDEX(p_column, cells.size());
13351335
ERR_FAIL_COND(p_button.is_null());
13361336
TreeItem::Cell::Button button;
@@ -1341,7 +1341,7 @@ void TreeItem::add_button(int p_column, const Ref<Texture2D> &p_button, int p_id
13411341
button.id = p_id;
13421342
button.disabled = p_disabled;
13431343
button.tooltip = p_tooltip;
1344-
button.alt_text = p_alt_text;
1344+
button.description = p_description;
13451345
cells.write[p_column].buttons.push_back(button);
13461346
cells.write[p_column].cached_minimum_size_dirty = true;
13471347

@@ -1427,15 +1427,15 @@ void TreeItem::set_button(int p_column, int p_index, const Ref<Texture2D> &p_but
14271427
_changed_notify(p_column);
14281428
}
14291429

1430-
void TreeItem::set_button_alt_text(int p_column, int p_index, const String &p_alt_text) {
1430+
void TreeItem::set_button_description(int p_column, int p_index, const String &p_description) {
14311431
ERR_FAIL_INDEX(p_column, cells.size());
14321432
ERR_FAIL_INDEX(p_index, cells[p_column].buttons.size());
14331433

1434-
if (cells[p_column].buttons[p_index].alt_text == p_alt_text) {
1434+
if (cells[p_column].buttons[p_index].description == p_description) {
14351435
return;
14361436
}
14371437

1438-
cells.write[p_column].buttons.write[p_index].alt_text = p_alt_text;
1438+
cells.write[p_column].buttons.write[p_index].description = p_description;
14391439
_changed_notify(p_column);
14401440
if (get_tree()) {
14411441
get_tree()->update_configuration_warnings();
@@ -1775,8 +1775,8 @@ void TreeItem::_bind_methods() {
17751775
ClassDB::bind_method(D_METHOD("set_text", "column", "text"), &TreeItem::set_text);
17761776
ClassDB::bind_method(D_METHOD("get_text", "column"), &TreeItem::get_text);
17771777

1778-
ClassDB::bind_method(D_METHOD("set_alt_text", "column", "text"), &TreeItem::set_alt_text);
1779-
ClassDB::bind_method(D_METHOD("get_alt_text", "column"), &TreeItem::get_alt_text);
1778+
ClassDB::bind_method(D_METHOD("set_description", "column", "description"), &TreeItem::set_description);
1779+
ClassDB::bind_method(D_METHOD("get_description", "column"), &TreeItem::get_description);
17801780

17811781
ClassDB::bind_method(D_METHOD("set_text_direction", "column", "direction"), &TreeItem::set_text_direction);
17821782
ClassDB::bind_method(D_METHOD("get_text_direction", "column"), &TreeItem::get_text_direction);
@@ -1871,7 +1871,7 @@ void TreeItem::_bind_methods() {
18711871
ClassDB::bind_method(D_METHOD("is_custom_set_as_button", "column"), &TreeItem::is_custom_set_as_button);
18721872

18731873
ClassDB::bind_method(D_METHOD("clear_buttons"), &TreeItem::clear_buttons);
1874-
ClassDB::bind_method(D_METHOD("add_button", "column", "button", "id", "disabled", "tooltip_text", "alt_text"), &TreeItem::add_button, DEFVAL(-1), DEFVAL(false), DEFVAL(""), DEFVAL(""));
1874+
ClassDB::bind_method(D_METHOD("add_button", "column", "button", "id", "disabled", "tooltip_text", "description"), &TreeItem::add_button, DEFVAL(-1), DEFVAL(false), DEFVAL(""), DEFVAL(""));
18751875
ClassDB::bind_method(D_METHOD("get_button_count", "column"), &TreeItem::get_button_count);
18761876
ClassDB::bind_method(D_METHOD("get_button_tooltip_text", "column", "button_index"), &TreeItem::get_button_tooltip_text);
18771877
ClassDB::bind_method(D_METHOD("get_button_id", "column", "button_index"), &TreeItem::get_button_id);
@@ -1881,7 +1881,7 @@ void TreeItem::_bind_methods() {
18811881
ClassDB::bind_method(D_METHOD("set_button_tooltip_text", "column", "button_index", "tooltip"), &TreeItem::set_button_tooltip_text);
18821882
ClassDB::bind_method(D_METHOD("set_button", "column", "button_index", "button"), &TreeItem::set_button);
18831883
ClassDB::bind_method(D_METHOD("erase_button", "column", "button_index"), &TreeItem::erase_button);
1884-
ClassDB::bind_method(D_METHOD("set_button_alt_text", "column", "button_index", "alt_text"), &TreeItem::set_button_alt_text);
1884+
ClassDB::bind_method(D_METHOD("set_button_description", "column", "button_index", "description"), &TreeItem::set_button_description);
18851885
ClassDB::bind_method(D_METHOD("set_button_disabled", "column", "button_index", "disabled"), &TreeItem::set_button_disabled);
18861886
ClassDB::bind_method(D_METHOD("set_button_color", "column", "button_index", "color"), &TreeItem::set_button_color);
18871887
ClassDB::bind_method(D_METHOD("is_button_disabled", "column", "button_index"), &TreeItem::is_button_disabled);
@@ -4538,11 +4538,11 @@ int Tree::_get_title_button_height() const {
45384538
void Tree::_check_item_accessibility(TreeItem *p_item, PackedStringArray &r_warnings, int &r_row) const {
45394539
for (int i = 0; i < p_item->cells.size(); i++) {
45404540
const TreeItem::Cell &cell = p_item->cells[i];
4541-
if (cell.alt_text.strip_edges().is_empty() && cell.text.strip_edges().is_empty()) {
4541+
if (cell.description.strip_edges().is_empty() && cell.text.strip_edges().is_empty()) {
45424542
r_warnings.push_back(vformat(RTR("Cell %d x %d: either text or alternative text must not be empty."), r_row, i));
45434543
}
45444544
for (int j = 0; j < cell.buttons.size(); j++) {
4545-
if (cell.buttons[j].alt_text.strip_edges().is_empty()) {
4545+
if (cell.buttons[j].description.strip_edges().is_empty()) {
45464546
r_warnings.push_back(vformat(RTR("Button %d in %d x %d: alternative text must not be empty."), j, r_row, i));
45474547
}
45484548
}
@@ -4732,10 +4732,10 @@ void Tree::_accessibility_update_item(Point2 &r_ofs, TreeItem *p_item, int &r_ro
47324732

47334733
DisplayServer::get_singleton()->accessibility_update_set_table_cell_position(cell.accessibility_cell_element, r_row, i);
47344734
DisplayServer::get_singleton()->accessibility_update_set_list_item_selected(cell.accessibility_cell_element, cell.selected);
4735-
if (cell.alt_text.is_empty()) {
4735+
if (cell.description.is_empty()) {
47364736
DisplayServer::get_singleton()->accessibility_update_set_name(cell.accessibility_cell_element, cell.xl_text);
47374737
} else {
4738-
DisplayServer::get_singleton()->accessibility_update_set_name(cell.accessibility_cell_element, cell.alt_text);
4738+
DisplayServer::get_singleton()->accessibility_update_set_name(cell.accessibility_cell_element, cell.description);
47394739
}
47404740

47414741
DisplayServer::get_singleton()->accessibility_update_set_text_align(cell.accessibility_cell_element, cell.text_alignment);
@@ -4784,10 +4784,10 @@ void Tree::_accessibility_update_item(Point2 &r_ofs, TreeItem *p_item, int &r_ro
47844784
DisplayServer::get_singleton()->accessibility_update_add_action(cell.buttons[j].accessibility_button_element, DisplayServer::AccessibilityAction::ACTION_CLICK, callable_mp(this, &Tree::_accessibility_action_button_press).bind(p_item, i, j));
47854785
DisplayServer::get_singleton()->accessibility_update_set_flag(cell.buttons[j].accessibility_button_element, DisplayServer::AccessibilityFlags::FLAG_DISABLED, cell.buttons[j].disabled);
47864786
DisplayServer::get_singleton()->accessibility_update_set_tooltip(cell.buttons[j].accessibility_button_element, cell.buttons[j].tooltip);
4787-
if (cell.buttons[j].alt_text.is_empty()) {
4787+
if (cell.buttons[j].description.is_empty()) {
47884788
DisplayServer::get_singleton()->accessibility_update_set_name(cell.buttons[j].accessibility_button_element, cell.buttons[j].tooltip);
47894789
} else {
4790-
DisplayServer::get_singleton()->accessibility_update_set_name(cell.buttons[j].accessibility_button_element, cell.buttons[j].alt_text);
4790+
DisplayServer::get_singleton()->accessibility_update_set_name(cell.buttons[j].accessibility_button_element, cell.buttons[j].description);
47914791
}
47924792

47934793
Ref<Texture2D> b = cell.buttons[j].texture;

scene/gui/tree.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class TreeItem : public Object {
6868
String text;
6969
String xl_text;
7070
Node::AutoTranslateMode auto_translate_mode = Node::AUTO_TRANSLATE_MODE_INHERIT;
71-
String alt_text;
71+
String description;
7272
bool edit_multiline = false;
7373
String suffix;
7474
Ref<TextParagraph> text_buf;
@@ -115,7 +115,7 @@ class TreeItem : public Object {
115115
Ref<Texture2D> texture;
116116
Color color = Color(1, 1, 1, 1);
117117
String tooltip;
118-
String alt_text;
118+
String description;
119119
};
120120

121121
Vector<Button> buttons;
@@ -271,8 +271,8 @@ class TreeItem : public Object {
271271
void set_text(int p_column, String p_text);
272272
String get_text(int p_column) const;
273273

274-
void set_alt_text(int p_column, String p_text);
275-
String get_alt_text(int p_column) const;
274+
void set_description(int p_column, String p_text);
275+
String get_description(int p_column) const;
276276

277277
void set_text_direction(int p_column, Control::TextDirection p_text_direction);
278278
Control::TextDirection get_text_direction(int p_column) const;
@@ -311,7 +311,7 @@ class TreeItem : public Object {
311311
int get_icon_max_width(int p_column) const;
312312

313313
void clear_buttons();
314-
void add_button(int p_column, const Ref<Texture2D> &p_button, int p_id = -1, bool p_disabled = false, const String &p_tooltip = "", const String &p_alt_text = "");
314+
void add_button(int p_column, const Ref<Texture2D> &p_button, int p_id = -1, bool p_disabled = false, const String &p_tooltip = "", const String &p_description = "");
315315
int get_button_count(int p_column) const;
316316
String get_button_tooltip_text(int p_column, int p_index) const;
317317
Ref<Texture2D> get_button(int p_column, int p_index) const;
@@ -321,7 +321,7 @@ class TreeItem : public Object {
321321
Color get_button_color(int p_column, int p_index) const;
322322
void set_button_tooltip_text(int p_column, int p_index, const String &p_tooltip);
323323
void set_button(int p_column, int p_index, const Ref<Texture2D> &p_button);
324-
void set_button_alt_text(int p_column, int p_index, const String &p_alt_text);
324+
void set_button_description(int p_column, int p_index, const String &p_description);
325325
void set_button_color(int p_column, int p_index, const Color &p_color);
326326
void set_button_disabled(int p_column, int p_index, bool p_disabled);
327327
bool is_button_disabled(int p_column, int p_index) const;

0 commit comments

Comments
 (0)