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

Fix profiler seek line color in light modes, update on theme change #92389

Merged
merged 1 commit into from
May 28, 2024
Merged
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
14 changes: 12 additions & 2 deletions editor/debugger/editor_profiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "editor/editor_settings.h"
#include "editor/editor_string_names.h"
#include "editor/themes/editor_scale.h"
#include "editor/themes/editor_theme_manager.h"
#include "scene/resources/image_texture.h"

void EditorProfiler::_make_metric_ptrs(Metric &m) {
Expand Down Expand Up @@ -423,6 +424,15 @@ void EditorProfiler::_notification(int p_what) {
case NOTIFICATION_TRANSLATION_CHANGED: {
Calinou marked this conversation as resolved.
Show resolved Hide resolved
activate->set_icon(get_editor_theme_icon(SNAME("Play")));
clear_button->set_icon(get_editor_theme_icon(SNAME("Clear")));

theme_cache.seek_line_color = get_theme_color(SNAME("font_color"), EditorStringName(Editor));
theme_cache.seek_line_color.a = 0.8;
theme_cache.seek_line_hover_color = theme_cache.seek_line_color;
theme_cache.seek_line_hover_color.a = 0.4;

if (total_metrics > 0) {
_update_plot();
}
} break;
}
}
Expand All @@ -434,11 +444,11 @@ void EditorProfiler::_graph_tex_draw() {
if (seeking) {
int frame = cursor_metric_edit->get_value() - _get_frame_metric(0).frame_number;
int cur_x = (2 * frame + 1) * graph->get_size().x / (2 * frame_metrics.size()) + 1;
graph->draw_line(Vector2(cur_x, 0), Vector2(cur_x, graph->get_size().y), Color(1, 1, 1, 0.8));
graph->draw_line(Vector2(cur_x, 0), Vector2(cur_x, graph->get_size().y), theme_cache.seek_line_color);
}
if (hover_metric > -1 && hover_metric < total_metrics) {
int cur_x = (2 * hover_metric + 1) * graph->get_size().x / (2 * frame_metrics.size()) + 1;
graph->draw_line(Vector2(cur_x, 0), Vector2(cur_x, graph->get_size().y), Color(1, 1, 1, 0.4));
graph->draw_line(Vector2(cur_x, 0), Vector2(cur_x, graph->get_size().y), theme_cache.seek_line_hover_color);
}
}

Expand Down
5 changes: 5 additions & 0 deletions editor/debugger/editor_profiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ class EditorProfiler : public VBoxContainer {
};

private:
struct ThemeCache {
Color seek_line_color;
Color seek_line_hover_color;
} theme_cache;

Button *activate = nullptr;
Button *clear_button = nullptr;
TextureRect *graph = nullptr;
Expand Down
Loading