Skip to content

Commit

Permalink
Make the frame time and info boxes have same margins
Browse files Browse the repository at this point in the history
  • Loading branch information
passivestar committed Jun 29, 2024
1 parent 25de53e commit 4201c7d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
27 changes: 16 additions & 11 deletions editor/plugins/node_3d_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2903,8 +2903,8 @@ void Node3DEditorViewport::_notification(int p_what) {
}

bool show_info = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_INFORMATION));
if (show_info != info_label->is_visible()) {
info_label->set_visible(show_info);
if (show_info != info_panel->is_visible()) {
info_panel->set_visible(show_info);
}

Camera3D *current_camera;
Expand Down Expand Up @@ -3087,7 +3087,7 @@ void Node3DEditorViewport::_notification(int p_what) {
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), information_3d_stylebox);
info_panel->add_theme_style_override(SceneStringName(panel), information_3d_stylebox);

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
Expand Down Expand Up @@ -5382,15 +5382,19 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, int p
bottom_center_vbox->set_v_grow_direction(GROW_DIRECTION_BEGIN);
surface->add_child(bottom_center_vbox);

info_panel = memnew(PanelContainer);
info_panel->set_anchor_and_offset(SIDE_LEFT, ANCHOR_END, -90 * EDSCALE);
info_panel->set_anchor_and_offset(SIDE_TOP, ANCHOR_END, -90 * EDSCALE);
info_panel->set_anchor_and_offset(SIDE_RIGHT, ANCHOR_END, -10 * EDSCALE);
info_panel->set_anchor_and_offset(SIDE_BOTTOM, ANCHOR_END, -10 * EDSCALE);
info_panel->set_h_grow_direction(GROW_DIRECTION_BEGIN);
info_panel->set_v_grow_direction(GROW_DIRECTION_BEGIN);
info_panel->set_mouse_filter(MOUSE_FILTER_IGNORE);
surface->add_child(info_panel);
info_panel->hide();

info_label = memnew(Label);
info_label->set_anchor_and_offset(SIDE_LEFT, ANCHOR_END, -90 * EDSCALE);
info_label->set_anchor_and_offset(SIDE_TOP, ANCHOR_END, -90 * EDSCALE);
info_label->set_anchor_and_offset(SIDE_RIGHT, ANCHOR_END, -10 * EDSCALE);
info_label->set_anchor_and_offset(SIDE_BOTTOM, ANCHOR_END, -10 * EDSCALE);
info_label->set_h_grow_direction(GROW_DIRECTION_BEGIN);
info_label->set_v_grow_direction(GROW_DIRECTION_BEGIN);
surface->add_child(info_label);
info_label->hide();
info_panel->add_child(info_label);

cinema_label = memnew(Label);
cinema_label->set_anchor_and_offset(SIDE_TOP, ANCHOR_BEGIN, 10 * EDSCALE);
Expand Down Expand Up @@ -5475,6 +5479,7 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, int p
top_right_vbox->add_child(rotation_control);

frame_time_panel = memnew(PanelContainer);
frame_time_panel->set_mouse_filter(MOUSE_FILTER_IGNORE);
top_right_vbox->add_child(frame_time_panel);
frame_time_panel->hide();

Expand Down
1 change: 1 addition & 0 deletions editor/plugins/node_3d_editor_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ class Node3DEditorViewport : public Control {
real_t freelook_speed;
Vector2 previous_mouse_position;

PanelContainer *info_panel = nullptr;
Label *info_label = nullptr;
Label *cinema_label = nullptr;
Label *locked_label = nullptr;
Expand Down

0 comments on commit 4201c7d

Please sign in to comment.