1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-05 12:10:55 +00:00

Selectively apply FOCUS_ACCESSIBILITY to the Labels instead of setting it by default.

This commit is contained in:
Pāvels Nadtočajevs
2025-04-22 11:57:16 +03:00
parent 1696ab0cb6
commit 5b49fd4207
84 changed files with 159 additions and 14 deletions

View File

@@ -762,6 +762,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id, bool
// Add hint label.
Label *frame_hint_label = memnew(Label);
frame_hint_label->set_focus_mode(Control::FOCUS_ACCESSIBILITY);
node->add_child(frame_hint_label);
frame_hint_label->set_horizontal_alignment(HorizontalAlignment::HORIZONTAL_ALIGNMENT_CENTER);
frame_hint_label->set_vertical_alignment(VerticalAlignment::VERTICAL_ALIGNMENT_CENTER);
@@ -878,6 +879,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id, bool
String prop_name = dp.name.strip_edges();
if (!prop_name.is_empty()) {
Label *label = memnew(Label);
label->set_focus_mode(Control::FOCUS_ACCESSIBILITY);
label->set_auto_translate_mode(Node::AUTO_TRANSLATE_MODE_DISABLED); // TODO: Implement proper translation switch.
label->set_text(prop_name + ":");
hbox->add_child(label);
@@ -1151,6 +1153,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id, bool
hb->add_child(remove_btn);
} else {
Label *label = memnew(Label);
label->set_focus_mode(Control::FOCUS_ACCESSIBILITY);
label->set_auto_translate_mode(Node::AUTO_TRANSLATE_MODE_DISABLED); // TODO: Implement proper translation switch.
label->set_text(name_left);
label->add_theme_style_override(CoreStringName(normal), editor->get_theme_stylebox(SNAME("label_style"), SNAME("VShaderEditor")));
@@ -1158,6 +1161,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id, bool
if (vsnode->is_input_port_default(j, mode) && !port_left_used) {
Label *hint_label = memnew(Label);
hint_label->set_focus_mode(Control::FOCUS_ACCESSIBILITY);
hint_label->set_text(TTR("[default]"));
hint_label->add_theme_color_override(SceneStringName(font_color), editor->get_theme_color(SNAME("font_readonly_color"), SNAME("TextEdit")));
hint_label->add_theme_style_override(CoreStringName(normal), editor->get_theme_stylebox(SNAME("label_style"), SNAME("VShaderEditor")));
@@ -1201,6 +1205,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id, bool
type_box->connect(SceneStringName(item_selected), callable_mp(editor, &VisualShaderEditor::_change_output_port_type).bind(p_id, i), CONNECT_DEFERRED);
} else {
Label *label = memnew(Label);
label->set_focus_mode(Control::FOCUS_ACCESSIBILITY);
label->set_auto_translate_mode(Node::AUTO_TRANSLATE_MODE_DISABLED); // TODO: Implement proper translation switch.
label->set_text(name_right);
label->add_theme_style_override(CoreStringName(normal), editor->get_theme_stylebox(SNAME("label_style"), SNAME("VShaderEditor"))); //more compact
@@ -1369,6 +1374,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id, bool
}
if (!error.is_empty()) {
Label *error_label = memnew(Label);
error_label->set_focus_mode(Control::FOCUS_ACCESSIBILITY);
error_label->add_theme_color_override(SceneStringName(font_color), editor->get_theme_color(SNAME("error_color"), EditorStringName(Editor)));
error_label->set_text(error);
error_label->set_autowrap_mode(TextServer::AUTOWRAP_WORD);
@@ -6142,6 +6148,7 @@ Variant VisualShaderEditor::get_drag_data_fw(const Point2 &p_point, Control *p_f
d["id"] = id;
Label *label = memnew(Label);
label->set_focus_mode(Control::FOCUS_ACCESSIBILITY);
label->set_text(it->get_text(0));
label->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
set_drag_preview(label);
@@ -6525,6 +6532,7 @@ VisualShaderEditor::VisualShaderEditor() {
graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_SAMPLER, VisualShaderNode::PORT_TYPE_SAMPLER);
info_label = memnew(Label);
info_label->set_focus_mode(Control::FOCUS_ACCESSIBILITY);
info_label->set_text(vformat(TTR("Hold %s Key To Swap Connections"), keycode_get_string((Key)KeyModifierMask::CMD_OR_CTRL)));
info_label->set_anchors_and_offsets_preset(Control::PRESET_BOTTOM_WIDE, PRESET_MODE_MINSIZE, 20);
info_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
@@ -6689,6 +6697,7 @@ VisualShaderEditor::VisualShaderEditor() {
error_panel->set_visible(false);
error_label = memnew(Label);
error_label->set_focus_mode(Control::FOCUS_ACCESSIBILITY);
error_panel->add_child(error_label);
error_label->set_autowrap_mode(TextServer::AUTOWRAP_WORD_SMART);
@@ -6842,6 +6851,7 @@ VisualShaderEditor::VisualShaderEditor() {
desc_hbox->add_spacer();
highend_label = memnew(Label);
highend_label->set_focus_mode(Control::FOCUS_ACCESSIBILITY);
desc_hbox->add_child(highend_label);
highend_label->set_visible(false);
highend_label->set_text("Vulkan");
@@ -6908,6 +6918,7 @@ VisualShaderEditor::VisualShaderEditor() {
varying_mode->connect(SceneStringName(item_selected), callable_mp(this, &VisualShaderEditor::_varying_mode_changed));
varying_error_label = memnew(Label);
varying_error_label->set_focus_mode(Control::FOCUS_ACCESSIBILITY);
vb->add_child(varying_error_label);
varying_error_label->set_h_size_flags(SIZE_EXPAND_FILL);
@@ -7999,6 +8010,7 @@ public:
add_child(hbox);
Label *prop_name = memnew(Label);
prop_name->set_focus_mode(Control::FOCUS_ACCESSIBILITY);
String prop_name_str = p_names[i];
if (p_overrided_names.has(p_names[i])) {
prop_name_str = p_overrided_names[p_names[i]] + ":";