Initial editor accessibility.

This commit is contained in:
Pāvels Nadtočajevs
2025-03-21 09:55:22 +02:00
parent 4310cb82b8
commit 302fa831cc
137 changed files with 1544 additions and 93 deletions

View File

@@ -236,6 +236,7 @@ EditorPropertyMultilineText::EditorPropertyMultilineText(bool p_expression) {
hb->add_child(text);
text->set_h_size_flags(SIZE_EXPAND_FILL);
open_big_text = memnew(Button);
open_big_text->set_accessibility_name(TTRC("Open Text Edit Dialog"));
open_big_text->set_flat(true);
open_big_text->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyMultilineText::_open_big_text));
hb->add_child(open_big_text);
@@ -373,6 +374,7 @@ EditorPropertyTextEnum::EditorPropertyTextEnum() {
hb->add_child(edit_custom_layout);
option_button = memnew(OptionButton);
option_button->set_accessibility_name(TTRC("Enum Options"));
option_button->set_h_size_flags(SIZE_EXPAND_FILL);
option_button->set_clip_text(true);
option_button->set_flat(true);
@@ -381,22 +383,26 @@ EditorPropertyTextEnum::EditorPropertyTextEnum() {
option_button->connect(SceneStringName(item_selected), callable_mp(this, &EditorPropertyTextEnum::_option_selected));
edit_button = memnew(Button);
edit_button->set_accessibility_name(TTRC("Edit"));
edit_button->set_flat(true);
edit_button->hide();
default_layout->add_child(edit_button);
edit_button->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyTextEnum::_edit_custom_value));
custom_value_edit = memnew(LineEdit);
custom_value_edit->set_accessibility_name(TTRC("Custom Value"));
custom_value_edit->set_h_size_flags(SIZE_EXPAND_FILL);
edit_custom_layout->add_child(custom_value_edit);
custom_value_edit->connect(SceneStringName(text_submitted), callable_mp(this, &EditorPropertyTextEnum::_custom_value_submitted));
accept_button = memnew(Button);
accept_button->set_accessibility_name(TTRC("Accept Custom Value Edit"));
accept_button->set_flat(true);
edit_custom_layout->add_child(accept_button);
accept_button->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyTextEnum::_custom_value_accepted));
cancel_button = memnew(Button);
cancel_button->set_accessibility_name(TTRC("Cancel Custom Value Edit"));
cancel_button->set_flat(true);
edit_custom_layout->add_child(cancel_button);
cancel_button->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyTextEnum::_custom_value_canceled));
@@ -453,12 +459,14 @@ EditorPropertyLocale::EditorPropertyLocale() {
HBoxContainer *locale_hb = memnew(HBoxContainer);
add_child(locale_hb);
locale = memnew(LineEdit);
locale->set_accessibility_name(TTRC("Locale"));
locale_hb->add_child(locale);
locale->connect(SceneStringName(text_submitted), callable_mp(this, &EditorPropertyLocale::_locale_selected));
locale->connect(SceneStringName(focus_exited), callable_mp(this, &EditorPropertyLocale::_locale_focus_exited));
locale->set_h_size_flags(SIZE_EXPAND_FILL);
locale_edit = memnew(Button);
locale_edit->set_accessibility_name(TTRC("Edit"));
locale_edit->set_clip_text(true);
locale_hb->add_child(locale_edit);
add_focusable(locale);
@@ -606,6 +614,7 @@ EditorPropertyPath::EditorPropertyPath() {
HBoxContainer *path_hb = memnew(HBoxContainer);
add_child(path_hb);
path = memnew(LineEdit);
path->set_accessibility_name(TTRC("Path"));
SET_DRAG_FORWARDING_CDU(path, EditorPropertyPath);
path->set_structured_text_bidi_override(TextServer::STRUCTURED_TEXT_FILE);
path_hb->add_child(path);
@@ -614,6 +623,7 @@ EditorPropertyPath::EditorPropertyPath() {
path->set_h_size_flags(SIZE_EXPAND_FILL);
path_edit = memnew(Button);
path_edit->set_accessibility_name(TTRC("Edit"));
path_edit->set_clip_text(true);
path_hb->add_child(path_edit);
add_focusable(path);
@@ -993,6 +1003,15 @@ void EditorPropertyLayersGrid::gui_input(const Ref<InputEvent> &p_ev) {
void EditorPropertyLayersGrid::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ACCESSIBILITY_UPDATE: {
RID ae = get_accessibility_element();
ERR_FAIL_COND(ae.is_null());
//TODO
DisplayServer::get_singleton()->accessibility_update_set_role(ae, DisplayServer::AccessibilityRole::ROLE_STATIC_TEXT);
DisplayServer::get_singleton()->accessibility_update_set_value(ae, TTR(vformat("The %s is not accessible at this time.", "Layers grid property editor")));
} break;
case NOTIFICATION_DRAW: {
Size2 grid_size = get_grid_size();
grid_size.x = get_size().x;
@@ -1300,6 +1319,7 @@ EditorPropertyLayers::EditorPropertyLayers() {
hb->add_child(grid);
button = memnew(TextureButton);
button->set_accessibility_name(TTRC("Layers"));
button->set_stretch_mode(TextureButton::STRETCH_KEEP_CENTERED);
button->set_toggle_mode(true);
button->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyLayers::_button_pressed));
@@ -1391,6 +1411,7 @@ void EditorPropertyObjectID::setup(const String &p_base_type) {
EditorPropertyObjectID::EditorPropertyObjectID() {
edit = memnew(Button);
edit->set_accessibility_name(TTRC("Edit"));
add_child(edit);
add_focusable(edit);
edit->set_text_overrun_behavior(TextServer::OVERRUN_TRIM_ELLIPSIS);
@@ -1416,6 +1437,7 @@ void EditorPropertySignal::update_property() {
EditorPropertySignal::EditorPropertySignal() {
edit = memnew(Button);
edit->set_accessibility_name(TTRC("Edit"));
add_child(edit);
add_focusable(edit);
edit->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertySignal::_edit_pressed));
@@ -1435,6 +1457,7 @@ void EditorPropertyCallable::update_property() {
EditorPropertyCallable::EditorPropertyCallable() {
edit = memnew(Button);
edit->set_accessibility_name(TTRC("Edit"));
add_child(edit);
add_focusable(edit);
}
@@ -1766,6 +1789,7 @@ EditorPropertyRect2::EditorPropertyRect2(bool p_force_wide) {
for (int i = 0; i < 4; i++) {
spin[i] = memnew(EditorSpinSlider);
spin[i]->set_label(desc[i]);
spin[i]->set_accessibility_name(desc[i]);
spin[i]->set_flat(true);
if (grid) {
@@ -1860,6 +1884,7 @@ EditorPropertyRect2i::EditorPropertyRect2i(bool p_force_wide) {
for (int i = 0; i < 4; i++) {
spin[i] = memnew(EditorSpinSlider);
spin[i]->set_label(desc[i]);
spin[i]->set_accessibility_name(desc[i]);
spin[i]->set_flat(true);
if (grid) {
@@ -1951,6 +1976,7 @@ EditorPropertyPlane::EditorPropertyPlane(bool p_force_wide) {
spin[i] = memnew(EditorSpinSlider);
spin[i]->set_flat(true);
spin[i]->set_label(desc[i]);
spin[i]->set_accessibility_name(desc[i]);
bc->add_child(spin[i]);
add_focusable(spin[i]);
spin[i]->connect(SceneStringName(value_changed), callable_mp(this, &EditorPropertyPlane::_value_changed).bind(desc[i]));
@@ -2121,6 +2147,7 @@ EditorPropertyQuaternion::EditorPropertyQuaternion() {
spin[i] = memnew(EditorSpinSlider);
spin[i]->set_flat(true);
spin[i]->set_label(desc[i]);
spin[i]->set_accessibility_name(desc[i]);
default_layout->add_child(spin[i]);
add_focusable(spin[i]);
spin[i]->connect(SceneStringName(value_changed), callable_mp(this, &EditorPropertyQuaternion::_value_changed).bind(desc[i]));
@@ -2148,6 +2175,7 @@ EditorPropertyQuaternion::EditorPropertyQuaternion() {
euler[i] = memnew(EditorSpinSlider);
euler[i]->set_flat(true);
euler[i]->set_label(desc[i]);
euler[i]->set_accessibility_name(vformat(TTR("Temporary Euler %s"), desc[i]));
edit_custom_layout->add_child(euler[i]);
add_focusable(euler[i]);
euler[i]->connect(SceneStringName(value_changed), callable_mp(this, &EditorPropertyQuaternion::_custom_value_changed));
@@ -2157,6 +2185,7 @@ EditorPropertyQuaternion::EditorPropertyQuaternion() {
}
edit_button = memnew(Button);
edit_button->set_accessibility_name(TTRC("Edit"));
edit_button->set_flat(true);
edit_button->set_toggle_mode(true);
default_layout->add_child(edit_button);
@@ -2231,6 +2260,7 @@ EditorPropertyAABB::EditorPropertyAABB() {
for (int i = 0; i < 6; i++) {
spin[i] = memnew(EditorSpinSlider);
spin[i]->set_label(desc[i]);
spin[i]->set_accessibility_name(desc[i]);
spin[i]->set_flat(true);
g->add_child(spin[i]);
@@ -2311,6 +2341,7 @@ EditorPropertyTransform2D::EditorPropertyTransform2D(bool p_include_origin) {
for (int i = 0; i < 6; i++) {
spin[i] = memnew(EditorSpinSlider);
spin[i]->set_label(desc[i]);
spin[i]->set_accessibility_name(desc[i]);
spin[i]->set_flat(true);
if (p_include_origin || i % 3 != 2) {
g->add_child(spin[i]);
@@ -2393,6 +2424,7 @@ EditorPropertyBasis::EditorPropertyBasis() {
for (int i = 0; i < 9; i++) {
spin[i] = memnew(EditorSpinSlider);
spin[i]->set_label(desc[i]);
spin[i]->set_accessibility_name(desc[i]);
spin[i]->set_flat(true);
g->add_child(spin[i]);
spin[i]->set_h_size_flags(SIZE_EXPAND_FILL);
@@ -2482,6 +2514,7 @@ EditorPropertyTransform3D::EditorPropertyTransform3D() {
for (int i = 0; i < 12; i++) {
spin[i] = memnew(EditorSpinSlider);
spin[i]->set_label(desc[i]);
spin[i]->set_accessibility_name(desc[i]);
spin[i]->set_flat(true);
g->add_child(spin[i]);
spin[i]->set_h_size_flags(SIZE_EXPAND_FILL);
@@ -2579,6 +2612,7 @@ EditorPropertyProjection::EditorPropertyProjection() {
for (int i = 0; i < 16; i++) {
spin[i] = memnew(EditorSpinSlider);
spin[i]->set_label(desc[i]);
spin[i]->set_accessibility_name(desc[i]);
spin[i]->set_flat(true);
g->add_child(spin[i]);
spin[i]->set_h_size_flags(SIZE_EXPAND_FILL);
@@ -2964,6 +2998,7 @@ EditorPropertyNodePath::EditorPropertyNodePath() {
hbc->add_theme_constant_override("separation", 0);
add_child(hbc);
assign = memnew(Button);
assign->set_accessibility_name(TTRC("Assign Node"));
assign->set_flat(true);
assign->set_h_size_flags(SIZE_EXPAND_FILL);
assign->set_clip_text(true);
@@ -2986,6 +3021,7 @@ EditorPropertyNodePath::EditorPropertyNodePath() {
menu->get_popup()->connect(SceneStringName(id_pressed), callable_mp(this, &EditorPropertyNodePath::_menu_option));
edit = memnew(LineEdit);
edit->set_accessibility_name(TTRC("Node Path"));
edit->set_h_size_flags(SIZE_EXPAND_FILL);
edit->hide();
edit->connect(SceneStringName(focus_exited), callable_mp(this, &EditorPropertyNodePath::_accept_text));