diff options
author | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2022-03-13 18:57:28 +0100 |
---|---|---|
committer | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2022-03-13 18:57:28 +0100 |
commit | 6f76aaec82edb865b938155545db2031c689d623 (patch) | |
tree | 5bdad827d1c0475a263e9d0044bab42973d6dbb8 /editor/plugins | |
parent | 47c35f5b9665a04bdddccb0d34fc7983dd78be3d (diff) |
Improve display of freelook/zoom speed indicator bars in the 3D editor
- Use a different color for freelook and zoom speed bars.
- Use an outline for the text to make it readable on any background.
Diffstat (limited to 'editor/plugins')
-rw-r--r-- | editor/plugins/node_3d_editor_plugin.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index 3927aaa438..a857a7509e 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -2690,27 +2690,27 @@ void Node3DEditorViewport::_notification(int p_what) { } } -static void draw_indicator_bar(Control &surface, real_t fill, const Ref<Texture2D> icon, const Ref<Font> font, int font_size, const String &text) { +static void draw_indicator_bar(Control &p_surface, real_t p_fill, const Ref<Texture2D> p_icon, const Ref<Font> p_font, int p_font_size, const String &p_text, const Color &p_color) { // Adjust bar size from control height - const Vector2 surface_size = surface.get_size(); + const Vector2 surface_size = p_surface.get_size(); const real_t h = surface_size.y / 2.0; const real_t y = (surface_size.y - h) / 2.0; const Rect2 r(10 * EDSCALE, y, 6 * EDSCALE, h); - const real_t sy = r.size.y * fill; + const real_t sy = r.size.y * p_fill; // Note: because this bar appears over the viewport, it has to stay readable for any background color // Draw both neutral dark and bright colors to account this - surface.draw_rect(r, Color(1, 1, 1, 0.2)); - surface.draw_rect(Rect2(r.position.x, r.position.y + r.size.y - sy, r.size.x, sy), Color(1, 1, 1, 0.6)); - surface.draw_rect(r.grow(1), Color(0, 0, 0, 0.7), false, Math::round(EDSCALE)); + p_surface.draw_rect(r, p_color * Color(1, 1, 1, 0.2)); + p_surface.draw_rect(Rect2(r.position.x, r.position.y + r.size.y - sy, r.size.x, sy), p_color * Color(1, 1, 1, 0.6)); + p_surface.draw_rect(r.grow(1), Color(0, 0, 0, 0.7), false, Math::round(EDSCALE)); - const Vector2 icon_size = icon->get_size(); + const Vector2 icon_size = p_icon->get_size(); const Vector2 icon_pos = Vector2(r.position.x - (icon_size.x - r.size.x) / 2, r.position.y + r.size.y + 2 * EDSCALE); - surface.draw_texture(icon, icon_pos); + p_surface.draw_texture(p_icon, icon_pos, p_color); // Draw text below the bar (for speed/zoom information). - surface.draw_string(font, Vector2(icon_pos.x, icon_pos.y + icon_size.y + 16 * EDSCALE), text, HORIZONTAL_ALIGNMENT_LEFT, -1.f, font_size); + 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, Math::round(2 * EDSCALE), Color(0, 0, 0)); } void Node3DEditorViewport::_draw() { @@ -2828,7 +2828,8 @@ void Node3DEditorViewport::_draw() { get_theme_icon(SNAME("ViewportSpeed"), SNAME("EditorIcons")), get_theme_font(SNAME("font"), SNAME("Label")), get_theme_font_size(SNAME("font_size"), SNAME("Label")), - vformat("%s u/s", String::num(freelook_speed).pad_decimals(precision))); + vformat("%s u/s", String::num(freelook_speed).pad_decimals(precision)), + Color(1.0, 0.95, 0.7)); } } else { @@ -2850,7 +2851,8 @@ void Node3DEditorViewport::_draw() { get_theme_icon(SNAME("ViewportZoom"), SNAME("EditorIcons")), get_theme_font(SNAME("font"), SNAME("Label")), get_theme_font_size(SNAME("font_size"), SNAME("Label")), - vformat("%s u", String::num(cursor.distance).pad_decimals(precision))); + vformat("%s u", String::num(cursor.distance).pad_decimals(precision)), + Color(0.7, 0.95, 1.0)); } } } |