Skip to content

Commit

Permalink
Merge pull request #97173 from timothyqiu/drag-preview-translation
Browse files Browse the repository at this point in the history
Set auto translate mode for drag previews
  • Loading branch information
akien-mga committed Sep 19, 2024
2 parents 6a1ab24 + 14321b8 commit d788205
Show file tree
Hide file tree
Showing 18 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions editor/action_map_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ Variant ActionMapEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from
Label *label = memnew(Label(name));
label->set_theme_type_variation("HeaderSmall");
label->set_modulate(Color(1, 1, 1, 1.0f));
label->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
action_tree->set_drag_preview(label);

Dictionary drag_data;
Expand Down
1 change: 1 addition & 0 deletions editor/animation_track_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3241,6 +3241,7 @@ Variant AnimationTrackEdit::get_drag_data(const Point2 &p_point) {
tb->set_flat(true);
tb->set_text(path_cache);
tb->set_icon(icon_cache);
tb->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
tb->add_theme_constant_override("icon_max_width", get_theme_constant("class_icon_size", EditorStringName(Editor)));
set_drag_preview(tb);

Expand Down
1 change: 1 addition & 0 deletions editor/create_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,7 @@ Variant CreateDialog::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
tb->set_flat(true);
tb->set_icon(ti->get_icon(0));
tb->set_text(ti->get_text(0));
tb->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
favorites->set_drag_preview(tb);

return d;
Expand Down
3 changes: 3 additions & 0 deletions editor/editor_audio_buses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,7 @@ Variant EditorAudioBus::get_drag_data_fw(const Point2 &p_point, Control *p_from)

Label *l = memnew(Label);
l->set_text(item->get_text(0));
l->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
effects->set_drag_preview(l);

return fxd;
Expand Down Expand Up @@ -929,6 +930,7 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) {
hb->add_child(scale);

effects = memnew(Tree);
effects->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
effects->set_hide_root(true);
effects->set_custom_minimum_size(Size2(0, 80) * EDSCALE);
effects->set_hide_folding(true);
Expand All @@ -954,6 +956,7 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) {
set_focus_mode(FOCUS_CLICK);

effect_options = memnew(PopupMenu);
effect_options->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED); // Don't translate class names.
effect_options->connect("index_pressed", callable_mp(this, &EditorAudioBus::_effect_add));
add_child(effect_options);
List<StringName> effect_list;
Expand Down
1 change: 1 addition & 0 deletions editor/editor_autoload_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,7 @@ Variant EditorAutoloadSettings::get_drag_data_fw(const Point2 &p_point, Control
for (int i = 0; i < max_size; i++) {
Label *label = memnew(Label(autoloads[i]));
label->set_self_modulate(Color(1, 1, 1, Math::lerp(1, 0, float(i) / PREVIEW_LIST_MAX_SIZE)));
label->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);

preview->add_child(label);
}
Expand Down
1 change: 1 addition & 0 deletions editor/editor_inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,7 @@ Variant EditorProperty::get_drag_data(const Point2 &p_point) {

Label *drag_label = memnew(Label);
drag_label->set_text(property);
drag_label->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED); // Don't translate raw property name.
set_drag_preview(drag_label);
return dp;
}
Expand Down
2 changes: 2 additions & 0 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5663,6 +5663,7 @@ Dictionary EditorNode::drag_resource(const Ref<Resource> &p_res, Control *p_from
Control *drag_control = memnew(Control);
TextureRect *drag_preview = memnew(TextureRect);
Label *label = memnew(Label);
label->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);

Ref<Texture2D> preview;

Expand Down Expand Up @@ -5715,6 +5716,7 @@ Dictionary EditorNode::drag_files_and_dirs(const Vector<String> &p_paths, Contro
HBoxContainer *hbox = memnew(HBoxContainer);
TextureRect *icon = memnew(TextureRect);
Label *label = memnew(Label);
label->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);

if (p_paths[i].ends_with("/")) {
label->set_text(p_paths[i].substr(0, p_paths[i].length() - 1).get_file());
Expand Down
2 changes: 1 addition & 1 deletion editor/editor_settings_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ Variant EditorSettingsDialog::get_drag_data_fw(const Point2 &p_point, Control *p
return Variant();
}

String label_text = "Event " + itos(selected->get_meta("event_index"));
String label_text = vformat(TTRC("Event %d"), selected->get_meta("event_index"));
Label *label = memnew(Label(label_text));
label->set_modulate(Color(1, 1, 1, 1.0f));
shortcuts->set_drag_preview(label);
Expand Down
1 change: 1 addition & 0 deletions editor/export/project_export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@ Variant ProjectExportDialog::get_drag_data_fw(const Point2 &p_point, Control *p_
drag->add_child(tr);
Label *label = memnew(Label);
label->set_text(presets->get_item_text(pos));
label->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED); // Don't translate user input.
drag->add_child(label);

presets->set_drag_preview(drag);
Expand Down
1 change: 1 addition & 0 deletions editor/gui/scene_tree_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1361,6 +1361,7 @@ Variant SceneTreeEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from
tf->set_texture(icons[i]);
hb->add_child(tf);
Label *label = memnew(Label(selected_nodes[i]->get_name()));
label->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
hb->add_child(label);
vb->add_child(hb);
hb->set_modulate(Color(1, 1, 1, opacity_item));
Expand Down
1 change: 1 addition & 0 deletions editor/plugins/script_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3101,6 +3101,7 @@ Variant ScriptEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
drag_preview->add_child(tf);
}
Label *label = memnew(Label(preview_name));
label->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED); // Don't translate script names and class names.
drag_preview->add_child(label);
set_drag_preview(drag_preview);

Expand Down
1 change: 1 addition & 0 deletions editor/plugins/shader_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,7 @@ Variant ShaderEditorPlugin::get_drag_data_fw(const Point2 &p_point, Control *p_f
drag_preview->add_child(tf);
}
Label *label = memnew(Label(preview_name));
label->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED); // Don't translate script names.
drag_preview->add_child(label);
main_split->set_drag_preview(drag_preview);

Expand Down
1 change: 1 addition & 0 deletions editor/plugins/skeleton_3d_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,7 @@ Variant Skeleton3DEditor::get_drag_data_fw(const Point2 &p_point, Control *p_fro
tf->set_stretch_mode(TextureRect::STRETCH_KEEP_CENTERED);
hb->add_child(tf);
Label *label = memnew(Label(selected->get_text(0)));
label->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
hb->add_child(label);
vb->add_child(hb);
hb->set_modulate(Color(1, 1, 1, 1));
Expand Down
2 changes: 2 additions & 0 deletions editor/plugins/visual_shader_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5994,6 +5994,7 @@ Variant VisualShaderEditor::get_drag_data_fw(const Point2 &p_point, Control *p_f

Label *label = memnew(Label);
label->set_text(it->get_text(0));
label->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
set_drag_preview(label);
return d;
}
Expand Down Expand Up @@ -6560,6 +6561,7 @@ VisualShaderEditor::VisualShaderEditor() {
parameters->set_hide_folding(false);
parameters->set_h_size_flags(SIZE_EXPAND_FILL);
parameters->set_v_size_flags(SIZE_EXPAND_FILL);
parameters->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
parameters->connect(SceneStringName(item_selected), callable_mp(this, &VisualShaderEditor::_param_selected));
parameters->connect("nothing_selected", callable_mp(this, &VisualShaderEditor::_param_unselected));
sc->add_child(parameters);
Expand Down
1 change: 1 addition & 0 deletions scene/gui/line_edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,7 @@ Variant LineEdit::get_drag_data(const Point2 &p_point) {
String t = get_selected_text();
Label *l = memnew(Label);
l->set_text(t);
l->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED); // Don't translate user input.
set_drag_preview(l);
return t;
}
Expand Down
1 change: 1 addition & 0 deletions scene/gui/rich_text_label.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5431,6 +5431,7 @@ Variant RichTextLabel::get_drag_data(const Point2 &p_point) {
String t = get_selected_text();
Label *l = memnew(Label);
l->set_text(t);
l->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED); // Text is already translated.
set_drag_preview(l);
return t;
}
Expand Down
1 change: 1 addition & 0 deletions scene/gui/tab_bar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1250,6 +1250,7 @@ Variant TabBar::_handle_get_drag_data(const String &p_type, const Point2 &p_poin
}

Label *label = memnew(Label(get_tab_title(tab_over)));
label->set_auto_translate_mode(get_auto_translate_mode()); // Reflect how the title is displayed.
drag_preview->add_child(label);

set_drag_preview(drag_preview);
Expand Down
1 change: 1 addition & 0 deletions scene/gui/text_edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3034,6 +3034,7 @@ Variant TextEdit::get_drag_data(const Point2 &p_point) {
if (has_selection() && selection_drag_attempt) {
String t = get_selected_text();
Label *l = memnew(Label);
l->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED); // Don't translate user input.
l->set_text(t);
set_drag_preview(l);
return t;
Expand Down

0 comments on commit d788205

Please sign in to comment.