Always use a dark background for 3D editor overlays even with light theme
This results in better readability against mixed-color backgrounds, as what you see in the 3D editor doesn't change depending on your editor theme. This also tweaks the viewport zoom/speed label for better readability by using a bold font and thicker outline.
This commit is contained in:
@@ -3135,6 +3135,16 @@ void Node3DEditorViewport::_project_settings_changed() {
|
||||
viewport->set_anisotropic_filtering_level(anisotropic_filtering_level);
|
||||
}
|
||||
|
||||
static void override_label_colors(Control *p_control) {
|
||||
p_control->begin_bulk_theme_override();
|
||||
p_control->add_theme_color_override(SceneStringName(font_color), p_control->get_theme_color(SNAME("font_dark_background_color"), EditorStringName(Editor)));
|
||||
p_control->add_theme_color_override("font_hover_color", p_control->get_theme_color(SNAME("font_dark_background_hover_color"), EditorStringName(Editor)));
|
||||
p_control->add_theme_color_override("font_focus_color", p_control->get_theme_color(SNAME("font_dark_background_focus_color"), EditorStringName(Editor)));
|
||||
p_control->add_theme_color_override("font_pressed_color", p_control->get_theme_color(SNAME("font_dark_background_pressed_color"), EditorStringName(Editor)));
|
||||
p_control->add_theme_color_override("font_hover_pressed_color", p_control->get_theme_color(SNAME("font_dark_background_hover_pressed_color"), EditorStringName(Editor)));
|
||||
p_control->end_bulk_theme_override();
|
||||
}
|
||||
|
||||
static void override_button_stylebox(Button *p_button, const Ref<StyleBox> p_stylebox) {
|
||||
p_button->begin_bulk_theme_override();
|
||||
p_button->add_theme_style_override(CoreStringName(normal), p_stylebox);
|
||||
@@ -3542,21 +3552,25 @@ void Node3DEditorViewport::_notification(int p_what) {
|
||||
case NOTIFICATION_THEME_CHANGED: {
|
||||
_update_centered_labels();
|
||||
|
||||
view_display_menu->set_button_icon(get_editor_theme_icon(SNAME("GuiTabMenuHl")));
|
||||
preview_camera->set_button_icon(get_editor_theme_icon(SNAME("Camera3D")));
|
||||
view_display_menu->set_button_icon(get_editor_theme_icon(SNAME("GuiTabMenuHlDarkBackground")));
|
||||
preview_camera->set_button_icon(get_editor_theme_icon(SNAME("Camera3DDarkBackground")));
|
||||
Control *gui_base = EditorNode::get_singleton()->get_gui_base();
|
||||
|
||||
const Ref<StyleBox> &information_3d_stylebox = gui_base->get_theme_stylebox(SNAME("Information3dViewport"), EditorStringName(EditorStyles));
|
||||
|
||||
override_button_stylebox(view_display_menu, information_3d_stylebox);
|
||||
override_label_colors(view_display_menu);
|
||||
override_button_stylebox(translation_preview_button, information_3d_stylebox);
|
||||
override_label_colors(translation_preview_button);
|
||||
override_button_stylebox(preview_camera, information_3d_stylebox);
|
||||
override_label_colors(preview_camera);
|
||||
|
||||
frame_time_gradient->set_color(0, get_theme_color(SNAME("success_color"), EditorStringName(Editor)));
|
||||
frame_time_gradient->set_color(1, get_theme_color(SNAME("warning_color"), EditorStringName(Editor)));
|
||||
frame_time_gradient->set_color(2, get_theme_color(SNAME("error_color"), EditorStringName(Editor)));
|
||||
frame_time_gradient->set_color(0, get_theme_color(SNAME("success_color_dark_background"), EditorStringName(Editor)));
|
||||
frame_time_gradient->set_color(1, get_theme_color(SNAME("warning_color_dark_background"), EditorStringName(Editor)));
|
||||
frame_time_gradient->set_color(2, get_theme_color(SNAME("error_color_dark_background"), EditorStringName(Editor)));
|
||||
|
||||
info_panel->add_theme_style_override(SceneStringName(panel), information_3d_stylebox);
|
||||
override_label_colors(info_label);
|
||||
|
||||
frame_time_panel->add_theme_style_override(SceneStringName(panel), information_3d_stylebox);
|
||||
// Set a minimum width to prevent the width from changing all the time
|
||||
@@ -3614,7 +3628,7 @@ static void draw_indicator_bar(Control &p_surface, real_t p_fill, const Ref<Text
|
||||
p_surface.draw_texture(p_icon, icon_pos, p_color);
|
||||
|
||||
// Draw text below the bar (for speed/zoom information).
|
||||
p_surface.draw_string_outline(p_font, Vector2(icon_pos.x, icon_pos.y + icon_size.y + 16 * EDSCALE), p_text, HORIZONTAL_ALIGNMENT_LEFT, -1.f, p_font_size, Math::round(2 * EDSCALE), Color(0, 0, 0));
|
||||
p_surface.draw_string_outline(p_font, Vector2(icon_pos.x, icon_pos.y + icon_size.y + 16 * EDSCALE), p_text, HORIZONTAL_ALIGNMENT_LEFT, -1.f, p_font_size, Math::round(4 * EDSCALE), Color(0, 0, 0));
|
||||
p_surface.draw_string(p_font, Vector2(icon_pos.x, icon_pos.y + icon_size.y + 16 * EDSCALE), p_text, HORIZONTAL_ALIGNMENT_LEFT, -1.f, p_font_size, p_color);
|
||||
}
|
||||
|
||||
@@ -3820,7 +3834,7 @@ void Node3DEditorViewport::_draw() {
|
||||
*surface,
|
||||
1.0 - logscale_t,
|
||||
get_editor_theme_icon(SNAME("ViewportSpeed")),
|
||||
get_theme_font(SceneStringName(font), SNAME("Label")),
|
||||
get_theme_font("bold", EditorStringName(EditorFonts)),
|
||||
get_theme_font_size(SceneStringName(font_size), SNAME("Label")),
|
||||
vformat("%s m/s", String::num(freelook_speed).pad_decimals(precision)),
|
||||
Color(1.0, 0.95, 0.7));
|
||||
@@ -3843,7 +3857,7 @@ void Node3DEditorViewport::_draw() {
|
||||
*surface,
|
||||
logscale_t,
|
||||
get_editor_theme_icon(SNAME("ViewportZoom")),
|
||||
get_theme_font(SceneStringName(font), SNAME("Label")),
|
||||
get_theme_font("bold", EditorStringName(EditorFonts)),
|
||||
get_theme_font_size(SceneStringName(font_size), SNAME("Label")),
|
||||
vformat("%s m", String::num(cursor.distance).pad_decimals(precision)),
|
||||
Color(0.7, 0.95, 1.0));
|
||||
|
||||
Reference in New Issue
Block a user