Implement automatic translation for ItemList
This commit is contained in:
parent
7f884b4e00
commit
1a1c542836
|
@ -792,6 +792,7 @@ CreateDialog::CreateDialog() {
|
|||
rec_vb->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
|
||||
recent = memnew(ItemList);
|
||||
recent->set_auto_translate(false);
|
||||
rec_vb->add_margin_child(TTR("Recent:"), recent, true);
|
||||
recent->set_allow_reselect(true);
|
||||
recent->connect("item_selected", callable_mp(this, &CreateDialog::_history_selected));
|
||||
|
|
|
@ -398,6 +398,7 @@ DependencyEditorOwners::DependencyEditorOwners() {
|
|||
file_options->connect("id_pressed", callable_mp(this, &DependencyEditorOwners::_file_option));
|
||||
|
||||
owners = memnew(ItemList);
|
||||
owners->set_auto_translate(false);
|
||||
owners->set_select_mode(ItemList::SELECT_MULTI);
|
||||
owners->connect("item_clicked", callable_mp(this, &DependencyEditorOwners::_list_rmb_clicked));
|
||||
owners->connect("item_activated", callable_mp(this, &DependencyEditorOwners::_select_file));
|
||||
|
|
|
@ -96,6 +96,7 @@ ScrollContainer *EditorAbout::_populate_list(const String &p_name, const List<St
|
|||
vbc->add_child(lbl);
|
||||
|
||||
ItemList *il = memnew(ItemList);
|
||||
il->set_auto_translate(false);
|
||||
il->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
il->set_same_column_width(true);
|
||||
il->set_auto_height(true);
|
||||
|
|
|
@ -114,6 +114,7 @@ EditorLayoutsDialog::EditorLayoutsDialog() {
|
|||
add_child(makevb);
|
||||
|
||||
layout_names = memnew(ItemList);
|
||||
layout_names->set_auto_translate(false);
|
||||
layout_names->set_auto_height(true);
|
||||
layout_names->set_custom_minimum_size(Size2(300 * EDSCALE, 50 * EDSCALE));
|
||||
layout_names->set_visible(true);
|
||||
|
|
|
@ -1162,6 +1162,7 @@ ProjectExportDialog::ProjectExportDialog() {
|
|||
preset_vb->add_child(mc);
|
||||
mc->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
presets = memnew(ItemList);
|
||||
presets->set_auto_translate(false);
|
||||
SET_DRAG_FORWARDING_GCD(presets, ProjectExportDialog);
|
||||
mc->add_child(presets);
|
||||
presets->connect("item_selected", callable_mp(this, &ProjectExportDialog::_edit_preset));
|
||||
|
|
|
@ -1879,6 +1879,7 @@ EditorFileDialog::EditorFileDialog() {
|
|||
fav_down->connect("pressed", callable_mp(this, &EditorFileDialog::_favorite_move_down));
|
||||
|
||||
favorites = memnew(ItemList);
|
||||
favorites->set_auto_translate(false);
|
||||
fav_vb->add_child(favorites);
|
||||
favorites->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
favorites->connect("item_selected", callable_mp(this, &EditorFileDialog::_favorite_selected));
|
||||
|
@ -1888,6 +1889,7 @@ EditorFileDialog::EditorFileDialog() {
|
|||
rec_vb->set_custom_minimum_size(Size2(150, 100) * EDSCALE);
|
||||
rec_vb->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
recent = memnew(ItemList);
|
||||
recent->set_auto_translate(false);
|
||||
recent->set_allow_reselect(true);
|
||||
rec_vb->add_margin_child(TTR("Recent:"), recent, true);
|
||||
recent->connect("item_selected", callable_mp(this, &EditorFileDialog::_recent_selected));
|
||||
|
@ -1911,6 +1913,7 @@ EditorFileDialog::EditorFileDialog() {
|
|||
// Item (files and folders) list with context menu.
|
||||
|
||||
item_list = memnew(ItemList);
|
||||
item_list->set_auto_translate(false);
|
||||
item_list->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
item_list->connect("item_clicked", callable_mp(this, &EditorFileDialog::_item_list_item_rmb_clicked));
|
||||
item_list->connect("empty_clicked", callable_mp(this, &EditorFileDialog::_item_list_empty_clicked));
|
||||
|
|
|
@ -248,6 +248,7 @@ HistoryDock::HistoryDock() {
|
|||
global_history_checkbox->connect("toggled", callable_mp(this, &HistoryDock::refresh_history).unbind(1));
|
||||
|
||||
action_list = memnew(ItemList);
|
||||
action_list->set_auto_translate(false);
|
||||
add_child(action_list);
|
||||
action_list->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
action_list->connect("item_selected", callable_mp(this, &HistoryDock::seek_history));
|
||||
|
|
|
@ -3865,6 +3865,7 @@ ScriptEditor::ScriptEditor(WindowWrapper *p_wrapper) {
|
|||
scripts_vbox->add_child(filter_scripts);
|
||||
|
||||
script_list = memnew(ItemList);
|
||||
script_list->set_auto_translate(false);
|
||||
scripts_vbox->add_child(script_list);
|
||||
script_list->set_custom_minimum_size(Size2(150, 60) * EDSCALE); //need to give a bit of limit to avoid it from disappearing
|
||||
script_list->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||
|
@ -3909,6 +3910,7 @@ ScriptEditor::ScriptEditor(WindowWrapper *p_wrapper) {
|
|||
overview_vbox->add_child(filter_methods);
|
||||
|
||||
members_overview = memnew(ItemList);
|
||||
members_overview->set_auto_translate(false);
|
||||
overview_vbox->add_child(members_overview);
|
||||
|
||||
members_overview->set_allow_reselect(true);
|
||||
|
@ -3917,6 +3919,7 @@ ScriptEditor::ScriptEditor(WindowWrapper *p_wrapper) {
|
|||
members_overview->set_allow_rmb_select(true);
|
||||
|
||||
help_overview = memnew(ItemList);
|
||||
help_overview->set_auto_translate(false);
|
||||
overview_vbox->add_child(help_overview);
|
||||
help_overview->set_allow_reselect(true);
|
||||
help_overview->set_custom_minimum_size(Size2(0, 60) * EDSCALE); //need to give a bit of limit to avoid it from disappearing
|
||||
|
|
|
@ -642,6 +642,7 @@ ShaderEditorPlugin::ShaderEditorPlugin() {
|
|||
}
|
||||
|
||||
shader_list = memnew(ItemList);
|
||||
shader_list->set_auto_translate(false);
|
||||
shader_list->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
vb->add_child(shader_list);
|
||||
shader_list->connect("item_selected", callable_mp(this, &ShaderEditorPlugin::_shader_selected));
|
||||
|
|
|
@ -256,6 +256,7 @@ ShaderFileEditor::ShaderFileEditor() {
|
|||
add_child(main_hs);
|
||||
|
||||
versions = memnew(ItemList);
|
||||
versions->set_auto_translate(false);
|
||||
versions->connect("item_selected", callable_mp(this, &ShaderFileEditor::_version_selected));
|
||||
versions->set_custom_minimum_size(Size2i(200 * EDSCALE, 0));
|
||||
main_hs->add_child(versions);
|
||||
|
|
|
@ -1879,6 +1879,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
|
|||
add_child(file);
|
||||
|
||||
frame_list = memnew(ItemList);
|
||||
frame_list->set_auto_translate(false);
|
||||
frame_list->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||
frame_list->set_icon_mode(ItemList::ICON_MODE_TOP);
|
||||
frame_list->set_texture_filter(TEXTURE_FILTER_NEAREST_WITH_MIPMAPS);
|
||||
|
|
|
@ -2247,6 +2247,7 @@ ThemeTypeDialog::ThemeTypeDialog() {
|
|||
add_type_vb->add_child(add_type_options_label);
|
||||
|
||||
add_type_options = memnew(ItemList);
|
||||
add_type_options->set_auto_translate(false);
|
||||
add_type_options->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
add_type_vb->add_child(add_type_options);
|
||||
add_type_options->connect("item_selected", callable_mp(this, &ThemeTypeDialog::_add_type_options_cbk));
|
||||
|
|
|
@ -311,6 +311,7 @@ AtlasMergingDialog::AtlasMergingDialog() {
|
|||
|
||||
// Atlas sources item list.
|
||||
atlas_merging_atlases_list = memnew(ItemList);
|
||||
atlas_merging_atlases_list->set_auto_translate(false);
|
||||
atlas_merging_atlases_list->set_fixed_icon_size(Size2(60, 60) * EDSCALE);
|
||||
atlas_merging_atlases_list->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
atlas_merging_atlases_list->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
|
|
|
@ -2418,6 +2418,7 @@ TileMapEditorTilesPlugin::TileMapEditorTilesPlugin() {
|
|||
sources_bottom_actions->add_child(source_sort_button);
|
||||
|
||||
sources_list = memnew(ItemList);
|
||||
sources_list->set_auto_translate(false);
|
||||
sources_list->set_fixed_icon_size(Size2(60, 60) * EDSCALE);
|
||||
sources_list->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
sources_list->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
|
@ -2457,6 +2458,7 @@ TileMapEditorTilesPlugin::TileMapEditorTilesPlugin() {
|
|||
|
||||
// Scenes collection source.
|
||||
scene_tiles_list = memnew(ItemList);
|
||||
scene_tiles_list->set_auto_translate(false);
|
||||
scene_tiles_list->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
scene_tiles_list->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
scene_tiles_list->set_select_mode(ItemList::SELECT_MULTI);
|
||||
|
@ -2482,6 +2484,7 @@ TileMapEditorTilesPlugin::TileMapEditorTilesPlugin() {
|
|||
|
||||
int thumbnail_size = 64;
|
||||
patterns_item_list = memnew(ItemList);
|
||||
patterns_item_list->set_auto_translate(false);
|
||||
patterns_item_list->set_max_columns(0);
|
||||
patterns_item_list->set_icon_mode(ItemList::ICON_MODE_TOP);
|
||||
patterns_item_list->set_fixed_column_width(thumbnail_size * 3 / 2);
|
||||
|
@ -3555,6 +3558,7 @@ TileMapEditorTerrainsPlugin::TileMapEditorTerrainsPlugin() {
|
|||
tilemap_tab_terrains->add_child(terrains_tree);
|
||||
|
||||
terrains_tile_list = memnew(ItemList);
|
||||
terrains_tile_list->set_auto_translate(false);
|
||||
terrains_tile_list->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
terrains_tile_list->set_max_columns(0);
|
||||
terrains_tile_list->set_same_column_width(true);
|
||||
|
|
|
@ -345,6 +345,7 @@ TileProxiesManagerDialog::TileProxiesManagerDialog() {
|
|||
vbox_container->add_child(source_level_label);
|
||||
|
||||
source_level_list = memnew(ItemList);
|
||||
source_level_list->set_auto_translate(false);
|
||||
source_level_list->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
source_level_list->set_select_mode(ItemList::SELECT_MULTI);
|
||||
source_level_list->set_allow_rmb_select(true);
|
||||
|
@ -356,6 +357,7 @@ TileProxiesManagerDialog::TileProxiesManagerDialog() {
|
|||
vbox_container->add_child(coords_level_label);
|
||||
|
||||
coords_level_list = memnew(ItemList);
|
||||
coords_level_list->set_auto_translate(false);
|
||||
coords_level_list->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
coords_level_list->set_select_mode(ItemList::SELECT_MULTI);
|
||||
coords_level_list->set_allow_rmb_select(true);
|
||||
|
@ -367,6 +369,7 @@ TileProxiesManagerDialog::TileProxiesManagerDialog() {
|
|||
vbox_container->add_child(alternative_level_label);
|
||||
|
||||
alternative_level_list = memnew(ItemList);
|
||||
alternative_level_list->set_auto_translate(false);
|
||||
alternative_level_list->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
alternative_level_list->set_select_mode(ItemList::SELECT_MULTI);
|
||||
alternative_level_list->set_allow_rmb_select(true);
|
||||
|
|
|
@ -855,6 +855,7 @@ TileSetEditor::TileSetEditor() {
|
|||
p->set_item_checked(TilesEditorUtils::SOURCE_SORT_ID, true);
|
||||
|
||||
sources_list = memnew(ItemList);
|
||||
sources_list->set_auto_translate(false);
|
||||
sources_list->set_fixed_icon_size(Size2(60, 60) * EDSCALE);
|
||||
sources_list->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
sources_list->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||
|
@ -934,6 +935,7 @@ TileSetEditor::TileSetEditor() {
|
|||
//// Patterns ////
|
||||
int thumbnail_size = 64;
|
||||
patterns_item_list = memnew(ItemList);
|
||||
patterns_item_list->set_auto_translate(false);
|
||||
patterns_item_list->set_max_columns(0);
|
||||
patterns_item_list->set_icon_mode(ItemList::ICON_MODE_TOP);
|
||||
patterns_item_list->set_fixed_column_width(thumbnail_size * 3 / 2);
|
||||
|
|
|
@ -550,6 +550,7 @@ TileSetScenesCollectionSourceEditor::TileSetScenesCollectionSourceEditor() {
|
|||
split_container_right_side->add_child(right_vbox_container);
|
||||
|
||||
scene_tiles_list = memnew(ItemList);
|
||||
scene_tiles_list->set_auto_translate(false);
|
||||
scene_tiles_list->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
scene_tiles_list->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||
SET_DRAG_FORWARDING_CDU(scene_tiles_list, TileSetScenesCollectionSourceEditor);
|
||||
|
|
|
@ -1316,6 +1316,7 @@ GridMapEditor::GridMapEditor() {
|
|||
EDITOR_DEF("editors/grid_map/preview_size", 64);
|
||||
|
||||
mesh_library_palette = memnew(ItemList);
|
||||
mesh_library_palette->set_auto_translate(false);
|
||||
add_child(mesh_library_palette);
|
||||
mesh_library_palette->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||
mesh_library_palette->connect("gui_input", callable_mp(this, &GridMapEditor::_mesh_library_palette_input));
|
||||
|
|
|
@ -44,7 +44,7 @@ void ItemList::_shape_text(int p_idx) {
|
|||
} else {
|
||||
item.text_buf->set_direction((TextServer::Direction)item.text_direction);
|
||||
}
|
||||
item.text_buf->add_string(item.text, theme_cache.font, theme_cache.font_size, item.language);
|
||||
item.text_buf->add_string(item.xl_text, theme_cache.font, theme_cache.font_size, item.language);
|
||||
if (icon_mode == ICON_MODE_TOP && max_text_lines > 0) {
|
||||
item.text_buf->set_break_flags(TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND | TextServer::BREAK_GRAPHEME_BOUND | TextServer::BREAK_TRIM_EDGE_SPACES);
|
||||
} else {
|
||||
|
@ -58,6 +58,7 @@ int ItemList::add_item(const String &p_item, const Ref<Texture2D> &p_texture, bo
|
|||
Item item;
|
||||
item.icon = p_texture;
|
||||
item.text = p_item;
|
||||
item.xl_text = atr(p_item);
|
||||
item.selectable = p_selectable;
|
||||
items.push_back(item);
|
||||
int item_id = items.size() - 1;
|
||||
|
@ -94,6 +95,7 @@ void ItemList::set_item_text(int p_idx, const String &p_text) {
|
|||
}
|
||||
|
||||
items.write[p_idx].text = p_text;
|
||||
items.write[p_idx].xl_text = atr(p_text);
|
||||
_shape_text(p_idx);
|
||||
queue_redraw();
|
||||
shape_changed = true;
|
||||
|
@ -1001,7 +1003,6 @@ void ItemList::_notification(int p_what) {
|
|||
} break;
|
||||
|
||||
case NOTIFICATION_LAYOUT_DIRECTION_CHANGED:
|
||||
case NOTIFICATION_TRANSLATION_CHANGED:
|
||||
case NOTIFICATION_THEME_CHANGED: {
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
_shape_text(i);
|
||||
|
@ -1009,6 +1010,14 @@ void ItemList::_notification(int p_what) {
|
|||
shape_changed = true;
|
||||
queue_redraw();
|
||||
} break;
|
||||
case NOTIFICATION_TRANSLATION_CHANGED: {
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
items.write[i].xl_text = atr(items[i].text);
|
||||
_shape_text(i);
|
||||
}
|
||||
shape_changed = true;
|
||||
queue_redraw();
|
||||
} break;
|
||||
|
||||
case NOTIFICATION_DRAW: {
|
||||
force_update_list_size();
|
||||
|
|
|
@ -57,6 +57,7 @@ private:
|
|||
Color icon_modulate = Color(1, 1, 1, 1);
|
||||
Ref<Texture2D> tag_icon;
|
||||
String text;
|
||||
String xl_text;
|
||||
Ref<TextParagraph> text_buf;
|
||||
String language;
|
||||
TextDirection text_direction = TEXT_DIRECTION_AUTO;
|
||||
|
|
Loading…
Reference in New Issue