Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add header property to labels, revert non headers to regular font. #49336

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions doc/classes/Label.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@
<member name="clip_text" type="bool" setter="set_clip_text" getter="is_clipping_text" default="false">
If [code]true[/code], the Label only shows the text that fits inside its bounding rectangle. It also lets you scale the node down freely.
</member>
<member name="header_mode" type="int" setter="set_header_mode" getter="get_header_mode" enum="Label.HeaderMode" default="0">
It is possible to use a preset header size for labels, which is useful when designing user interfaces. Check the respective theme properties for which font and size will be used for each.
</member>
<member name="language" type="String" setter="set_language" getter="get_language" default="&quot;&quot;">
Language code used for line-breaking and text shaping algorithms, if left empty current locale is used instead.
</member>
Expand Down Expand Up @@ -142,6 +145,14 @@
<constant name="VALIGN_FILL" value="3" enum="VAlign">
Align the whole text by spreading the rows.
</constant>
<constant name="HEADER_DISABLED" value="0" enum="HeaderMode">
</constant>
<constant name="HEADER_SMALL" value="1" enum="HeaderMode">
</constant>
<constant name="HEADER_MEDIUM" value="2" enum="HeaderMode">
</constant>
<constant name="HEADER_LARGE" value="3" enum="HeaderMode">
</constant>
</constants>
<theme_items>
<theme_item name="font" type="Font">
Expand All @@ -150,6 +161,18 @@
<theme_item name="font_color" type="Color" default="Color( 1, 1, 1, 1 )">
Default text [Color] of the [Label].
</theme_item>
<theme_item name="font_header_large" type="Font">
</theme_item>
<theme_item name="font_header_large_size" type="int">
</theme_item>
<theme_item name="font_header_medium" type="Font">
</theme_item>
<theme_item name="font_header_medium_size" type="int">
</theme_item>
<theme_item name="font_header_small" type="Font">
</theme_item>
<theme_item name="font_header_small_size" type="int">
</theme_item>
<theme_item name="font_outline_color" type="Color" default="Color( 1, 1, 1, 1 )">
The tint of [Font]'s outline.
</theme_item>
Expand Down
3 changes: 3 additions & 0 deletions editor/action_map_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,7 @@ InputEventConfigurationDialog::InputEventConfigurationDialog() {
additional_options_container->hide();

Label *opts_label = memnew(Label);
opts_label->set_header_mode(Label::HEADER_SMALL);
opts_label->set_text("Additional Options");
additional_options_container->add_child(opts_label);

Expand All @@ -639,6 +640,7 @@ InputEventConfigurationDialog::InputEventConfigurationDialog() {
device_container->set_h_size_flags(Control::SIZE_EXPAND_FILL);

Label *device_label = memnew(Label);
device_label->set_header_mode(Label::HEADER_SMALL);
device_label->set_text("Device:");
device_container->add_child(device_label);

Expand Down Expand Up @@ -858,6 +860,7 @@ Variant ActionMapEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from

String name = selected->get_text(0);
Label *label = memnew(Label(name));
label->set_header_mode(Label::HEADER_SMALL);
label->set_modulate(Color(1, 1, 1, 1.0f));
action_tree->set_drag_preview(label);

Expand Down
2 changes: 2 additions & 0 deletions editor/debugger/script_editor_debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1698,6 +1698,8 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
VBoxContainer *vmem_vb = memnew(VBoxContainer);
HBoxContainer *vmem_hb = memnew(HBoxContainer);
Label *vmlb = memnew(Label(TTR("List of Video Memory Usage by Resource:") + " "));
vmlb->set_header_mode(Label::HEADER_SMALL);

vmlb->set_h_size_flags(SIZE_EXPAND_FILL);
vmem_hb->add_child(vmlb);
vmem_hb->add_child(memnew(Label(TTR("Total:") + " ")));
Expand Down
2 changes: 2 additions & 0 deletions editor/dependency_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ DependencyEditor::DependencyEditor() {

HBoxContainer *hbc = memnew(HBoxContainer);
Label *label = memnew(Label(TTR("Dependencies:")));
label->set_header_mode(Label::HEADER_SMALL);

hbc->add_child(label);
hbc->add_spacer();
fixdeps = memnew(Button(TTR("Fix Broken")));
Expand Down
1 change: 1 addition & 0 deletions editor/editor_about.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ ScrollContainer *EditorAbout::_populate_list(const String &p_name, const List<St
const char *const *names_ptr = p_src[i];
if (*names_ptr) {
Label *lbl = memnew(Label);
lbl->set_header_mode(Label::HEADER_SMALL);
lbl->set_text(p_sections[i]);
vbc->add_child(lbl);

Expand Down
21 changes: 17 additions & 4 deletions editor/editor_file_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1507,7 +1507,9 @@ EditorFileDialog::EditorFileDialog() {
dir_next->connect("pressed", callable_mp(this, &EditorFileDialog::_go_forward));
dir_up->connect("pressed", callable_mp(this, &EditorFileDialog::_go_up));

pathhb->add_child(memnew(Label(TTR("Path:"))));
Label *l = memnew(Label(TTR("Path:")));
l->set_header_mode(Label::HEADER_SMALL);
pathhb->add_child(l);

drives_container = memnew(HBoxContainer);
pathhb->add_child(drives_container);
Expand Down Expand Up @@ -1588,7 +1590,11 @@ EditorFileDialog::EditorFileDialog() {
fav_vb->set_v_size_flags(Control::SIZE_EXPAND_FILL);
HBoxContainer *fav_hb = memnew(HBoxContainer);
fav_vb->add_child(fav_hb);
fav_hb->add_child(memnew(Label(TTR("Favorites:"))));

l = memnew(Label(TTR("Favorites:")));
l->set_header_mode(Label::HEADER_SMALL);
fav_hb->add_child(l);

fav_hb->add_spacer();
fav_up = memnew(Button);
fav_up->set_flat(true);
Expand Down Expand Up @@ -1623,7 +1629,10 @@ EditorFileDialog::EditorFileDialog() {

VBoxContainer *list_vb = memnew(VBoxContainer);
list_vb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
list_vb->add_child(memnew(Label(TTR("Directories & Files:"))));

l = memnew(Label(TTR("Directories & Files:")));
l->set_header_mode(Label::HEADER_SMALL);
list_vb->add_child(l);
preview_hb->add_child(list_vb);

// Item (files and folders) list with context menu.
Expand All @@ -1650,7 +1659,11 @@ EditorFileDialog::EditorFileDialog() {
preview_vb->hide();

file_box = memnew(HBoxContainer);
file_box->add_child(memnew(Label(TTR("File:"))));

l = memnew(Label(TTR("File:")));
l->set_header_mode(Label::HEADER_SMALL);
file_box->add_child(l);

file = memnew(LineEdit);
file->set_structured_text_bidi_override(Control::STRUCTURED_TEXT_FILE);
file->set_stretch_ratio(4);
Expand Down
8 changes: 7 additions & 1 deletion editor/editor_fonts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,13 @@ void editor_register_fonts(Ref<Theme> p_theme) {
p_theme->set_font_size("main_button_font_size", "EditorFonts", default_font_size + 1 * EDSCALE);
p_theme->set_font("main_button_font", "EditorFonts", df_bold);

p_theme->set_font("font", "Label", df_bold);
p_theme->set_font("font", "Label", df);
p_theme->set_font("font_header_small", "Label", df_bold);
p_theme->set_font_size("font_header_small_size", "Label", default_font_size);
p_theme->set_font("font_header_medium", "Label", df_bold);
p_theme->set_font_size("font_header_medium_size", "Label", default_font_size + 1 * EDSCALE);
p_theme->set_font("font_header_large", "Label", df_bold);
p_theme->set_font_size("font_header_large_size", "Label", default_font_size + 3 * EDSCALE);

// Documentation fonts
MAKE_SOURCE_FONT(df_code);
Expand Down
4 changes: 3 additions & 1 deletion editor/editor_plugin_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@ EditorPluginSettings::EditorPluginSettings() {
add_child(plugin_config_dialog);

HBoxContainer *title_hb = memnew(HBoxContainer);
title_hb->add_child(memnew(Label(TTR("Installed Plugins:"))));
Label *l = memnew(Label(TTR("Installed Plugins:")));
l->set_header_mode(Label::HEADER_SMALL);
title_hb->add_child(l);
title_hb->add_spacer();
create_plugin = memnew(Button(TTR("Create")));
create_plugin->connect("pressed", callable_mp(this, &EditorPluginSettings::_create_clicked));
Expand Down
5 changes: 5 additions & 0 deletions editor/export_template_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,7 @@ ExportTemplateManager::ExportTemplateManager() {
main_vb->add_child(current_hb);

Label *current_label = memnew(Label);
current_label->set_header_mode(Label::HEADER_SMALL);
current_label->set_text(TTR("Current Version:"));
current_hb->add_child(current_label);

Expand All @@ -823,13 +824,16 @@ ExportTemplateManager::ExportTemplateManager() {
// Current version statuses.
// Status: Current version is missing.
current_missing_label = memnew(Label);
current_missing_label->set_header_mode(Label::HEADER_SMALL);

current_missing_label->set_h_size_flags(Control::SIZE_EXPAND_FILL);
current_missing_label->set_align(Label::ALIGN_RIGHT);
current_missing_label->set_text(TTR("Export templates are missing. Download them or install from a file."));
current_hb->add_child(current_missing_label);

// Status: Current version is installed.
current_installed_label = memnew(Label);
current_installed_label->set_header_mode(Label::HEADER_SMALL);
current_installed_label->set_h_size_flags(Control::SIZE_EXPAND_FILL);
current_installed_label->set_align(Label::ALIGN_RIGHT);
current_installed_label->set_text(TTR("Export templates are installed and ready to be used."));
Expand Down Expand Up @@ -949,6 +953,7 @@ ExportTemplateManager::ExportTemplateManager() {
HBoxContainer *installed_versions_hb = memnew(HBoxContainer);
main_vb->add_child(installed_versions_hb);
Label *installed_label = memnew(Label);
installed_label->set_header_mode(Label::HEADER_SMALL);
installed_label->set_text(TTR("Other Installed Versions:"));
installed_versions_hb->add_child(installed_label);

Expand Down
8 changes: 8 additions & 0 deletions editor/groups_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,8 @@ GroupDialog::GroupDialog() {
vbc_left->set_h_size_flags(Control::SIZE_EXPAND_FILL);

Label *group_title = memnew(Label);
group_title->set_header_mode(Label::HEADER_SMALL);

group_title->set_text(TTR("Groups"));
vbc_left->add_child(group_title);

Expand Down Expand Up @@ -458,6 +460,8 @@ GroupDialog::GroupDialog() {
vbc_add->set_h_size_flags(Control::SIZE_EXPAND_FILL);

Label *out_of_group_title = memnew(Label);
out_of_group_title->set_header_mode(Label::HEADER_SMALL);

out_of_group_title->set_text(TTR("Nodes Not in Group"));
vbc_add->add_child(out_of_group_title);

Expand Down Expand Up @@ -506,6 +510,8 @@ GroupDialog::GroupDialog() {
vbc_remove->set_h_size_flags(Control::SIZE_EXPAND_FILL);

Label *in_group_title = memnew(Label);
in_group_title->set_header_mode(Label::HEADER_SMALL);

in_group_title->set_text(TTR("Nodes in Group"));
vbc_remove->add_child(in_group_title);

Expand All @@ -528,6 +534,8 @@ GroupDialog::GroupDialog() {
remove_filter->connect("text_changed", callable_mp(this, &GroupDialog::_remove_filter_changed));

group_empty = memnew(Label());
group_empty->set_header_mode(Label::HEADER_SMALL);

group_empty->set_text(TTR("Empty groups will be automatically removed."));
group_empty->set_valign(Label::VALIGN_CENTER);
group_empty->set_align(Label::ALIGN_CENTER);
Expand Down
20 changes: 15 additions & 5 deletions editor/localization_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,9 @@ LocalizationEditor::LocalizationEditor() {
translations->add_child(tvb);

HBoxContainer *thb = memnew(HBoxContainer);
thb->add_child(memnew(Label(TTR("Translations:"))));
Label *l = memnew(Label(TTR("Translations:")));
l->set_header_mode(Label::HEADER_SMALL);
thb->add_child(l);
thb->add_spacer();
tvb->add_child(thb);

Expand Down Expand Up @@ -684,7 +686,9 @@ LocalizationEditor::LocalizationEditor() {
translations->add_child(tvb);

HBoxContainer *thb = memnew(HBoxContainer);
thb->add_child(memnew(Label(TTR("Resources:"))));
Label *l = memnew(Label(TTR("Resources:")));
l->set_header_mode(Label::HEADER_SMALL);
thb->add_child(l);
thb->add_spacer();
tvb->add_child(thb);

Expand All @@ -708,7 +712,9 @@ LocalizationEditor::LocalizationEditor() {
add_child(translation_res_file_open_dialog);

thb = memnew(HBoxContainer);
thb->add_child(memnew(Label(TTR("Remaps by Locale:"))));
l = memnew(Label(TTR("Remaps by Locale:")));
l->set_header_mode(Label::HEADER_SMALL);
thb->add_child(l);
thb->add_spacer();
tvb->add_child(thb);

Expand Down Expand Up @@ -756,7 +762,9 @@ LocalizationEditor::LocalizationEditor() {
translation_locale_filter_mode->connect("item_selected", callable_mp(this, &LocalizationEditor::_translation_filter_mode_changed));
tmc->add_margin_child(TTR("Filter mode:"), translation_locale_filter_mode);

tmc->add_child(memnew(Label(TTR("Locales:"))));
Label *l = memnew(Label(TTR("Locales:")));
l->set_header_mode(Label::HEADER_SMALL);
tmc->add_child(l);
translation_filter = memnew(Tree);
translation_filter->set_v_size_flags(Control::SIZE_EXPAND_FILL);
translation_filter->set_columns(1);
Expand All @@ -770,7 +778,9 @@ LocalizationEditor::LocalizationEditor() {
translations->add_child(tvb);

HBoxContainer *thb = memnew(HBoxContainer);
thb->add_child(memnew(Label(TTR("Files with translation strings:"))));
Label *l = memnew(Label(TTR("Files with translation strings:")));
l->set_header_mode(Label::HEADER_SMALL);
thb->add_child(l);
thb->add_spacer();
tvb->add_child(thb);

Expand Down
3 changes: 3 additions & 0 deletions editor/plugins/node_3d_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7080,6 +7080,7 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) {
sun_vb->hide();

sun_title = memnew(Label);
sun_title->set_header_mode(Label::HEADER_SMALL);
sun_vb->add_child(sun_title);
sun_title->set_text(TTR("Preview Sun"));
sun_title->set_align(Label::ALIGN_CENTER);
Expand Down Expand Up @@ -7141,6 +7142,8 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) {
environ_vb->hide();

environ_title = memnew(Label);
environ_title->set_header_mode(Label::HEADER_SMALL);

environ_vb->add_child(environ_title);
environ_title->set_text(TTR("Preview Environment"));
environ_title->set_align(Label::ALIGN_CENTER);
Expand Down
4 changes: 3 additions & 1 deletion editor/plugins/theme_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1954,7 +1954,9 @@ ThemeEditor::ThemeEditor() {
HBoxContainer *top_menu = memnew(HBoxContainer);
add_child(top_menu);

top_menu->add_child(memnew(Label(TTR("Preview:"))));
Label *l = memnew(Label(TTR("Preview:")));
l->set_header_mode(Label::HEADER_SMALL);
top_menu->add_child(l);
top_menu->add_spacer(false);

theme_edit_button = memnew(Button);
Expand Down
5 changes: 4 additions & 1 deletion editor/project_export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,10 @@ ProjectExportDialog::ProjectExportDialog() {
hbox->add_child(preset_vb);

HBoxContainer *preset_hb = memnew(HBoxContainer);
preset_hb->add_child(memnew(Label(TTR("Presets"))));
Label *l = memnew(Label(TTR("Presets")));
l->set_header_mode(Label::HEADER_SMALL);
preset_hb->add_child(l);

preset_hb->add_spacer();
preset_vb->add_child(preset_hb);

Expand Down
4 changes: 3 additions & 1 deletion editor/scene_tree_dock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1209,7 +1209,9 @@ void SceneTreeDock::_notification(int p_what) {
HBoxContainer *top_row = memnew(HBoxContainer);
top_row->set_name("NodeShortcutsTopRow");
top_row->set_h_size_flags(SIZE_EXPAND_FILL);
top_row->add_child(memnew(Label(TTR("Create Root Node:"))));
Label *l = memnew(Label(TTR("Create Root Node:")));
l->set_header_mode(Label::HEADER_SMALL);
top_row->add_child(l);
top_row->add_spacer();

Button *node_shortcuts_toggle = memnew(Button);
Expand Down
1 change: 1 addition & 0 deletions editor/scene_tree_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,7 @@ SceneTreeEditor::SceneTreeEditor(bool p_label, bool p_can_rename, bool p_can_ope

if (p_label) {
Label *label = memnew(Label);
label->set_header_mode(Label::HEADER_SMALL);
label->set_position(Point2(10, 0));
label->set_text(TTR("Scene Tree (Nodes):"));

Expand Down
1 change: 1 addition & 0 deletions scene/gui/box_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ void BoxContainer::_bind_methods() {

MarginContainer *VBoxContainer::add_margin_child(const String &p_label, Control *p_control, bool p_expand) {
Label *l = memnew(Label);
l->set_header_mode(Label::HEADER_SMALL);
l->set_text(p_label);
add_child(l);
MarginContainer *mc = memnew(MarginContainer);
Expand Down
Loading