Initial editor accessibility.

This commit is contained in:
Pāvels Nadtočajevs 2025-03-21 09:55:22 +02:00
parent 4310cb82b8
commit 302fa831cc
No known key found for this signature in database
GPG key ID: 8413210218EF35D2
137 changed files with 1544 additions and 93 deletions

View file

@ -1653,7 +1653,14 @@ Variant SpriteFramesEditor::get_drag_data_fw(const Point2 &p_point, Control *p_f
return false;
}
int idx = frame_list->get_item_at_position(p_point, true);
int idx = -1;
if (p_point == Vector2(INFINITY, INFINITY)) {
if (frame_list->is_anything_selected()) {
idx = frame_list->get_selected_items()[0];
}
} else {
idx = frame_list->get_item_at_position(p_point, true);
}
if (idx < 0 || idx >= frames->get_frame_count(edited_anim)) {
return Variant();
@ -1728,7 +1735,14 @@ void SpriteFramesEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
return;
}
int at_pos = frame_list->get_item_at_position(p_point, true);
int at_pos = -1;
if (p_point == Vector2(INFINITY, INFINITY)) {
if (frame_list->is_anything_selected()) {
at_pos = frame_list->get_selected_items()[0];
}
} else {
at_pos = frame_list->get_item_at_position(p_point, true);
}
if (String(d["type"]) == "resource" && d.has("resource")) {
Ref<Resource> r = d["resource"];
@ -1946,16 +1960,19 @@ SpriteFramesEditor::SpriteFramesEditor() {
add_anim = memnew(Button);
add_anim->set_theme_type_variation(SceneStringName(FlatButton));
add_anim->set_accessibility_name(TTRC("Add Animation"));
hbc_animlist->add_child(add_anim);
add_anim->connect(SceneStringName(pressed), callable_mp(this, &SpriteFramesEditor::_animation_add));
duplicate_anim = memnew(Button);
duplicate_anim->set_theme_type_variation(SceneStringName(FlatButton));
duplicate_anim->set_accessibility_name(TTRC("Duplicate Animation"));
hbc_animlist->add_child(duplicate_anim);
duplicate_anim->connect(SceneStringName(pressed), callable_mp(this, &SpriteFramesEditor::_animation_duplicate));
delete_anim = memnew(Button);
delete_anim->set_theme_type_variation(SceneStringName(FlatButton));
delete_anim->set_accessibility_name(TTRC("Delete Animation"));
hbc_animlist->add_child(delete_anim);
delete_anim->set_disabled(true);
delete_anim->connect(SceneStringName(pressed), callable_mp(this, &SpriteFramesEditor::_animation_remove));
@ -1967,6 +1984,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
autoplay = memnew(Button);
autoplay->set_theme_type_variation(SceneStringName(FlatButton));
autoplay->set_accessibility_name(TTRC("Autoplay on Load"));
autoplay->set_tooltip_text(TTR("Autoplay on Load"));
autoplay_container->add_child(autoplay);
@ -1975,6 +1993,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
anim_loop = memnew(Button);
anim_loop->set_toggle_mode(true);
anim_loop->set_theme_type_variation(SceneStringName(FlatButton));
anim_loop->set_accessibility_name(TTRC("Animation Looping"));
anim_loop->set_tooltip_text(TTR("Animation Looping"));
anim_loop->connect(SceneStringName(pressed), callable_mp(this, &SpriteFramesEditor::_animation_loop_changed));
hbc_animlist->add_child(anim_loop);
@ -1986,6 +2005,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
anim_speed->set_step(0.01);
anim_speed->set_custom_arrow_step(1);
anim_speed->set_tooltip_text(TTR("Animation Speed"));
anim_speed->set_accessibility_name(TTRC("Animation Speed"));
anim_speed->get_line_edit()->set_expand_to_text_length_enabled(true);
anim_speed->get_line_edit()->connect(SceneStringName(resized), callable_mp(this, &SpriteFramesEditor::_animation_speed_resized));
anim_speed->connect(SceneStringName(value_changed), callable_mp(this, &SpriteFramesEditor::_animation_speed_changed));
@ -1995,6 +2015,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
sub_vb->add_child(anim_search_box);
anim_search_box->set_h_size_flags(SIZE_EXPAND_FILL);
anim_search_box->set_placeholder(TTR("Filter Animations"));
anim_search_box->set_accessibility_name(TTRC("Filter Animations"));
anim_search_box->set_clear_button_enabled(true);
anim_search_box->connect(SceneStringName(text_changed), callable_mp(this, &SpriteFramesEditor::_animation_search_text_changed));
@ -2042,26 +2063,31 @@ SpriteFramesEditor::SpriteFramesEditor() {
play_bw_from = memnew(Button);
play_bw_from->set_theme_type_variation(SceneStringName(FlatButton));
play_bw_from->set_tooltip_text(TTR("Play selected animation backwards from current pos. (A)"));
play_bw_from->set_accessibility_name(TTRC("Play Backwards"));
playback_container->add_child(play_bw_from);
play_bw = memnew(Button);
play_bw->set_theme_type_variation(SceneStringName(FlatButton));
play_bw->set_tooltip_text(TTR("Play selected animation backwards from end. (Shift+A)"));
play_bw->set_accessibility_name(TTRC("Play Backwards from End"));
playback_container->add_child(play_bw);
stop = memnew(Button);
stop->set_theme_type_variation(SceneStringName(FlatButton));
stop->set_tooltip_text(TTR("Pause/stop animation playback. (S)"));
stop->set_accessibility_name(TTRC("Pause/Stop"));
playback_container->add_child(stop);
play = memnew(Button);
play->set_theme_type_variation(SceneStringName(FlatButton));
play->set_tooltip_text(TTR("Play selected animation from start. (Shift+D)"));
play->set_accessibility_name(TTRC("Play from Start"));
playback_container->add_child(play);
play_from = memnew(Button);
play_from->set_theme_type_variation(SceneStringName(FlatButton));
play_from->set_tooltip_text(TTR("Play selected animation from current pos. (D)"));
play_from->set_accessibility_name(TTRC("Play"));
playback_container->add_child(play_from);
hfc->add_child(memnew(VSeparator));
@ -2078,44 +2104,53 @@ SpriteFramesEditor::SpriteFramesEditor() {
hfc->add_child(hbc_actions);
load = memnew(Button);
load->set_accessibility_name(TTRC("Load"));
load->set_theme_type_variation(SceneStringName(FlatButton));
hbc_actions->add_child(load);
load_sheet = memnew(Button);
load_sheet->set_accessibility_name(TTRC("Load Sheet"));
load_sheet->set_theme_type_variation(SceneStringName(FlatButton));
hbc_actions->add_child(load_sheet);
hbc_actions->add_child(memnew(VSeparator));
copy = memnew(Button);
copy->set_accessibility_name(TTRC("Copy"));
copy->set_theme_type_variation(SceneStringName(FlatButton));
hbc_actions->add_child(copy);
paste = memnew(Button);
paste->set_accessibility_name(TTRC("Paste"));
paste->set_theme_type_variation(SceneStringName(FlatButton));
hbc_actions->add_child(paste);
hbc_actions->add_child(memnew(VSeparator));
empty_before = memnew(Button);
empty_before->set_accessibility_name(TTRC("Empty Before"));
empty_before->set_theme_type_variation(SceneStringName(FlatButton));
hbc_actions->add_child(empty_before);
empty_after = memnew(Button);
empty_after->set_accessibility_name(TTRC("Empty After"));
empty_after->set_theme_type_variation(SceneStringName(FlatButton));
hbc_actions->add_child(empty_after);
hbc_actions->add_child(memnew(VSeparator));
move_up = memnew(Button);
move_up->set_accessibility_name(TTRC("Move Up"));
move_up->set_theme_type_variation(SceneStringName(FlatButton));
hbc_actions->add_child(move_up);
move_down = memnew(Button);
move_down->set_accessibility_name(TTRC("Move Down"));
move_down->set_theme_type_variation(SceneStringName(FlatButton));
hbc_actions->add_child(move_down);
delete_frame = memnew(Button);
delete_frame->set_accessibility_name(TTRC("Delete Frame"));
delete_frame->set_theme_type_variation(SceneStringName(FlatButton));
hbc_actions->add_child(delete_frame);
@ -2137,6 +2172,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
frame_duration->set_allow_lesser(false);
frame_duration->set_allow_greater(true);
frame_duration->connect(SceneStringName(value_changed), callable_mp(this, &SpriteFramesEditor::_frame_duration_changed));
frame_duration->set_accessibility_name(TTRC("Frame Duration"));
hbc_frame_duration->add_child(frame_duration);
// Wide empty separation control. (like BoxContainer::add_spacer())
@ -2152,18 +2188,21 @@ SpriteFramesEditor::SpriteFramesEditor() {
zoom_out->connect(SceneStringName(pressed), callable_mp(this, &SpriteFramesEditor::_zoom_out));
zoom_out->set_flat(true);
zoom_out->set_tooltip_text(TTRC("Zoom Out"));
zoom_out->set_accessibility_name(TTRC("Zoom Out"));
hbc_zoom->add_child(zoom_out);
zoom_reset = memnew(Button);
zoom_reset->connect(SceneStringName(pressed), callable_mp(this, &SpriteFramesEditor::_zoom_reset));
zoom_reset->set_flat(true);
zoom_reset->set_tooltip_text(TTRC("Zoom Reset"));
zoom_reset->set_accessibility_name(TTRC("Reset Zoom"));
hbc_zoom->add_child(zoom_reset);
zoom_in = memnew(Button);
zoom_in->connect(SceneStringName(pressed), callable_mp(this, &SpriteFramesEditor::_zoom_in));
zoom_in->set_flat(true);
zoom_in->set_tooltip_text(TTRC("Zoom In"));
zoom_in->set_accessibility_name(TTRC("Zoom In"));
hbc_zoom->add_child(zoom_in);
file = memnew(EditorFileDialog);
@ -2286,6 +2325,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
toggle_settings_button->set_theme_type_variation(SceneStringName(FlatButton));
toggle_settings_button->connect(SceneStringName(pressed), callable_mp(this, &SpriteFramesEditor::_toggle_show_settings));
toggle_settings_button->set_tooltip_text(TTR("Toggle Settings Panel"));
toggle_settings_button->set_accessibility_name(TTRC("Settings Panel"));
split_sheet_menu_hb->add_child(toggle_settings_button);
split_sheet_vb->add_child(split_sheet_menu_hb);
@ -2324,6 +2364,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
split_sheet_zoom_out->set_theme_type_variation(SceneStringName(FlatButton));
split_sheet_zoom_out->set_focus_mode(FOCUS_NONE);
split_sheet_zoom_out->set_tooltip_text(TTR("Zoom Out"));
split_sheet_zoom_out->set_accessibility_name(TTRC("Zoom Out"));
split_sheet_zoom_out->connect(SceneStringName(pressed), callable_mp(this, &SpriteFramesEditor::_sheet_zoom_out));
split_sheet_zoom_hb->add_child(split_sheet_zoom_out);
@ -2331,6 +2372,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
split_sheet_zoom_reset->set_theme_type_variation(SceneStringName(FlatButton));
split_sheet_zoom_reset->set_focus_mode(FOCUS_NONE);
split_sheet_zoom_reset->set_tooltip_text(TTR("Zoom Reset"));
split_sheet_zoom_reset->set_accessibility_name(TTRC("Reset Zoom"));
split_sheet_zoom_reset->connect(SceneStringName(pressed), callable_mp(this, &SpriteFramesEditor::_sheet_zoom_reset));
split_sheet_zoom_hb->add_child(split_sheet_zoom_reset);
@ -2338,6 +2380,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
split_sheet_zoom_in->set_theme_type_variation(SceneStringName(FlatButton));
split_sheet_zoom_in->set_focus_mode(FOCUS_NONE);
split_sheet_zoom_in->set_tooltip_text(TTR("Zoom In"));
split_sheet_zoom_in->set_accessibility_name(TTRC("Zoom In"));
split_sheet_zoom_in->connect(SceneStringName(pressed), callable_mp(this, &SpriteFramesEditor::_sheet_zoom_in));
split_sheet_zoom_hb->add_child(split_sheet_zoom_in);
@ -2357,6 +2400,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
split_sheet_h->set_max(128);
split_sheet_h->set_step(1);
split_sheet_h->set_select_all_on_focus(true);
split_sheet_h->set_accessibility_name(TTRC("Horizontal"));
split_sheet_h_hb->add_child(split_sheet_h);
split_sheet_h->connect(SceneStringName(value_changed), callable_mp(this, &SpriteFramesEditor::_sheet_spin_changed).bind(PARAM_FRAME_COUNT));
split_sheet_settings_vb->add_child(split_sheet_h_hb);
@ -2374,6 +2418,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
split_sheet_v->set_max(128);
split_sheet_v->set_step(1);
split_sheet_v->set_select_all_on_focus(true);
split_sheet_v->set_accessibility_name(TTRC("Vertical"));
split_sheet_v_hb->add_child(split_sheet_v);
split_sheet_v->connect(SceneStringName(value_changed), callable_mp(this, &SpriteFramesEditor::_sheet_spin_changed).bind(PARAM_FRAME_COUNT));
split_sheet_settings_vb->add_child(split_sheet_v_hb);
@ -2394,6 +2439,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
split_sheet_size_x->set_step(1);
split_sheet_size_x->set_suffix("px");
split_sheet_size_x->set_select_all_on_focus(true);
split_sheet_size_x->set_accessibility_name(TTRC("X Size"));
split_sheet_size_x->connect(SceneStringName(value_changed), callable_mp(this, &SpriteFramesEditor::_sheet_spin_changed).bind(PARAM_SIZE));
split_sheet_size_vb->add_child(split_sheet_size_x);
split_sheet_size_y = memnew(SpinBox);
@ -2402,6 +2448,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
split_sheet_size_y->set_step(1);
split_sheet_size_y->set_suffix("px");
split_sheet_size_y->set_select_all_on_focus(true);
split_sheet_size_y->set_accessibility_name(TTRC("Y Size"));
split_sheet_size_y->connect(SceneStringName(value_changed), callable_mp(this, &SpriteFramesEditor::_sheet_spin_changed).bind(PARAM_SIZE));
split_sheet_size_vb->add_child(split_sheet_size_y);
split_sheet_size_hb->add_child(split_sheet_size_vb);
@ -2422,6 +2469,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
split_sheet_sep_x->set_step(1);
split_sheet_sep_x->set_suffix("px");
split_sheet_sep_x->set_select_all_on_focus(true);
split_sheet_sep_x->set_accessibility_name(TTRC("X Separation"));
split_sheet_sep_x->connect(SceneStringName(value_changed), callable_mp(this, &SpriteFramesEditor::_sheet_spin_changed).bind(PARAM_USE_CURRENT));
split_sheet_sep_vb->add_child(split_sheet_sep_x);
split_sheet_sep_y = memnew(SpinBox);
@ -2429,6 +2477,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
split_sheet_sep_y->set_step(1);
split_sheet_sep_y->set_suffix("px");
split_sheet_sep_y->set_select_all_on_focus(true);
split_sheet_sep_y->set_accessibility_name(TTRC("Y Separation"));
split_sheet_sep_y->connect(SceneStringName(value_changed), callable_mp(this, &SpriteFramesEditor::_sheet_spin_changed).bind(PARAM_USE_CURRENT));
split_sheet_sep_vb->add_child(split_sheet_sep_y);
split_sheet_sep_hb->add_child(split_sheet_sep_vb);
@ -2449,6 +2498,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
split_sheet_offset_x->set_step(1);
split_sheet_offset_x->set_suffix("px");
split_sheet_offset_x->set_select_all_on_focus(true);
split_sheet_offset_x->set_accessibility_name(TTRC("X Offset"));
split_sheet_offset_x->connect(SceneStringName(value_changed), callable_mp(this, &SpriteFramesEditor::_sheet_spin_changed).bind(PARAM_USE_CURRENT));
split_sheet_offset_vb->add_child(split_sheet_offset_x);
split_sheet_offset_y = memnew(SpinBox);
@ -2456,6 +2506,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
split_sheet_offset_y->set_step(1);
split_sheet_offset_y->set_suffix("px");
split_sheet_offset_y->set_select_all_on_focus(true);
split_sheet_offset_y->set_accessibility_name(TTRC("Y Offset"));
split_sheet_offset_y->connect(SceneStringName(value_changed), callable_mp(this, &SpriteFramesEditor::_sheet_spin_changed).bind(PARAM_USE_CURRENT));
split_sheet_offset_vb->add_child(split_sheet_offset_y);
split_sheet_offset_hb->add_child(split_sheet_offset_vb);