Skip to content

Commit

Permalink
Merge pull request #93361 from passivestar/viewport-buttons-styles
Browse files Browse the repository at this point in the history
Add missing style overrides for viewport overlay buttons
  • Loading branch information
akien-mga committed Jun 21, 2024
2 parents 31f3969 + 8307871 commit 4a9dc72
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 19 deletions.
46 changes: 32 additions & 14 deletions editor/plugins/node_3d_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3043,38 +3043,54 @@ void Node3DEditorViewport::_notification(int p_what) {
preview_camera->set_icon(get_editor_theme_icon(SNAME("Camera3D")));
Control *gui_base = EditorNode::get_singleton()->get_gui_base();

const Ref<StyleBox> &information_3d_stylebox = gui_base->get_theme_stylebox(SNAME("Information3dViewport"), EditorStringName(EditorStyles));

view_menu->begin_bulk_theme_override();
view_menu->add_theme_style_override(CoreStringName(normal), gui_base->get_theme_stylebox(SNAME("Information3dViewport"), EditorStringName(EditorStyles)));
view_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), EditorStringName(EditorStyles)));
view_menu->add_theme_style_override(SceneStringName(pressed), gui_base->get_theme_stylebox(SNAME("Information3dViewport"), EditorStringName(EditorStyles)));
view_menu->add_theme_style_override("focus", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), EditorStringName(EditorStyles)));
view_menu->add_theme_style_override("disabled", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), EditorStringName(EditorStyles)));
view_menu->add_theme_style_override(CoreStringName(normal), information_3d_stylebox);
view_menu->add_theme_style_override("normal_mirrored", information_3d_stylebox);
view_menu->add_theme_style_override("hover", information_3d_stylebox);
view_menu->add_theme_style_override("hover_mirrored", information_3d_stylebox);
view_menu->add_theme_style_override("hover_pressed", information_3d_stylebox);
view_menu->add_theme_style_override("hover_pressed_mirrored", information_3d_stylebox);
view_menu->add_theme_style_override(SceneStringName(pressed), information_3d_stylebox);
view_menu->add_theme_style_override("pressed_mirrored", information_3d_stylebox);
view_menu->add_theme_style_override("focus", information_3d_stylebox);
view_menu->add_theme_style_override("focus_mirrored", information_3d_stylebox);
view_menu->add_theme_style_override("disabled", information_3d_stylebox);
view_menu->add_theme_style_override("disabled_mirrored", information_3d_stylebox);
view_menu->end_bulk_theme_override();

preview_camera->begin_bulk_theme_override();
preview_camera->add_theme_style_override(CoreStringName(normal), gui_base->get_theme_stylebox(SNAME("Information3dViewport"), EditorStringName(EditorStyles)));
preview_camera->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), EditorStringName(EditorStyles)));
preview_camera->add_theme_style_override(SceneStringName(pressed), gui_base->get_theme_stylebox(SNAME("Information3dViewport"), EditorStringName(EditorStyles)));
preview_camera->add_theme_style_override("focus", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), EditorStringName(EditorStyles)));
preview_camera->add_theme_style_override("disabled", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), EditorStringName(EditorStyles)));
preview_camera->add_theme_style_override(CoreStringName(normal), information_3d_stylebox);
preview_camera->add_theme_style_override("normal_mirrored", information_3d_stylebox);
preview_camera->add_theme_style_override("hover", information_3d_stylebox);
preview_camera->add_theme_style_override("hover_mirrored", information_3d_stylebox);
preview_camera->add_theme_style_override("hover_pressed", information_3d_stylebox);
preview_camera->add_theme_style_override("hover_pressed_mirrored", information_3d_stylebox);
preview_camera->add_theme_style_override(SceneStringName(pressed), information_3d_stylebox);
preview_camera->add_theme_style_override("pressed_mirrored", information_3d_stylebox);
preview_camera->add_theme_style_override("focus", information_3d_stylebox);
preview_camera->add_theme_style_override("focus_mirrored", information_3d_stylebox);
preview_camera->add_theme_style_override("disabled", information_3d_stylebox);
preview_camera->add_theme_style_override("disabled_mirrored", information_3d_stylebox);
preview_camera->end_bulk_theme_override();

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)));

info_label->add_theme_style_override(CoreStringName(normal), gui_base->get_theme_stylebox(SNAME("Information3dViewport"), EditorStringName(EditorStyles)));
info_label->add_theme_style_override(CoreStringName(normal), information_3d_stylebox);

frame_time_panel->add_theme_style_override(SceneStringName(panel), gui_base->get_theme_stylebox(SNAME("Information3dViewport"), EditorStringName(EditorStyles)));
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
// when numbers vary rapidly. This minimum width is set based on a
// GPU time of 999.99 ms in the current editor language.
const float min_width = get_theme_font(SNAME("main"), EditorStringName(EditorFonts))->get_string_size(vformat(TTR("GPU Time: %s ms"), 999.99)).x;
frame_time_panel->set_custom_minimum_size(Size2(min_width, 0) * EDSCALE);
frame_time_vbox->add_theme_constant_override("separation", Math::round(-1 * EDSCALE));

cinema_label->add_theme_style_override(CoreStringName(normal), gui_base->get_theme_stylebox(SNAME("Information3dViewport"), EditorStringName(EditorStyles)));
locked_label->add_theme_style_override(CoreStringName(normal), gui_base->get_theme_stylebox(SNAME("Information3dViewport"), EditorStringName(EditorStyles)));
cinema_label->add_theme_style_override(CoreStringName(normal), information_3d_stylebox);
locked_label->add_theme_style_override(CoreStringName(normal), information_3d_stylebox);
} break;

case NOTIFICATION_DRAG_END: {
Expand Down Expand Up @@ -5372,13 +5388,15 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, int p
cinema_label->set_anchor_and_offset(SIDE_TOP, ANCHOR_BEGIN, 10 * EDSCALE);
cinema_label->set_h_grow_direction(GROW_DIRECTION_END);
cinema_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
cinema_label->set_vertical_alignment(VERTICAL_ALIGNMENT_CENTER);
surface->add_child(cinema_label);
cinema_label->set_text(TTR("Cinematic Preview"));
cinema_label->hide();
previewing_cinema = false;

locked_label = memnew(Label);
locked_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
locked_label->set_vertical_alignment(VERTICAL_ALIGNMENT_CENTER);
locked_label->set_h_size_flags(SIZE_SHRINK_CENTER);
bottom_center_vbox->add_child(locked_label);
locked_label->set_text(TTR("View Rotation Locked"));
Expand Down
5 changes: 0 additions & 5 deletions editor/themes/editor_theme_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1782,11 +1782,6 @@ void EditorThemeManager::_populate_editor_styles(const Ref<EditorTheme> &p_theme
style_content_panel_vp->set_content_margin_individual(p_config.border_width * 2, p_config.base_margin * EDSCALE, p_config.border_width * 2, p_config.border_width * 2);
p_theme->set_stylebox("Content", EditorStringName(EditorStyles), style_content_panel_vp);

// 2D/CanvasItem editor
Ref<StyleBoxFlat> style_canvas_editor_info = make_flat_stylebox(Color(0.0, 0.0, 0.0, 0.2));
style_canvas_editor_info->set_expand_margin_all(4 * EDSCALE);
p_theme->set_stylebox("CanvasItemInfoOverlay", EditorStringName(EditorStyles), style_canvas_editor_info);

// 3D/Spatial editor.
Ref<StyleBoxFlat> style_info_3d_viewport = p_config.base_style->duplicate();
style_info_3d_viewport->set_bg_color(style_info_3d_viewport->get_bg_color() * Color(1, 1, 1, 0.5));
Expand Down

0 comments on commit 4a9dc72

Please sign in to comment.