26 #include "eng3d/interface.hpp"
27 #include "eng3d/profiler.hpp"
28 #include "eng3d/color.hpp"
29 #include "eng3d/ui/widget.hpp"
30 #include "eng3d/ui/components.hpp"
31 #include "eng3d/state.hpp"
32 #include "eng3d/string.hpp"
35 :
UI::Window(0, 0, 240, _s.width, nullptr),
49 auto& fps_lab = this->make_widget<UI::Label>(10, 0,
"?");
53 fps_lab.on_update(fps_lab);
55 auto& task_chart = this->make_widget<UI::BarChart>(20, 20, this->
width - 40, 20);
56 task_chart.on_update = ([
this](
UI::Widget& w) {
58 std::vector<UI::ChartData> data;
59 const auto& tasks = this->profiler.
get_tasks();
60 std::transform(tasks.cbegin(), tasks.cend(), std::back_inserter(data), [](
const auto& e) {
61 return UI::ChartData(e->get_average_time_ms(), e->name, Eng3D::Color::get_random(e->color).get_value());
65 task_chart.on_update(task_chart);
68 auto current_tasks = this->profiler.
get_tasks();
69 auto& current_views = this->task_views;
70 if(current_views.size() < current_tasks.size()) {
71 for(
size_t i = current_views.size(); i < current_tasks.size(); i++)
73 }
else if(current_views.size() > current_tasks.size()) {
74 for(
size_t i = current_tasks.size(); i < current_views.size(); i++)
75 current_views[i]->
kill();
76 current_views.erase(current_views.begin() + current_tasks.size(), current_views.end());
78 for(
size_t i = 0; i < current_views.size(); i++)
79 current_views[i]->set_task(*current_tasks[i]);
84 UI::Group(_x, _y, 300, 25, profiler_view)
86 this->color_box = &this->make_widget<UI::Div>(0, 0, 20, 20);
87 this->label = &this->make_widget<UI::Label>(30, 0,
" ");
93 auto format_time = std::to_string((
int)time);
94 format_time = std::string(3 - glm::min<size_t>(3, format_time.length()),
'0') + format_time;
95 this->label->set_text(format_time +
" ms " + profiler_view.
name);
float get_average_time_ms()
ProfilerTaskView(ProfilerView *profiler_view, int x, int y)
void set_task(Eng3D::BenchmarkTask &profiler_view)
ProfilerView(Eng3D::State &s, Eng3D::Profiler &profiler)
Bar chart that draws horizontal bar chart.
void set_close_btn_function(std::function< void(Widget &)> on_click)
std::string translate(const std::string_view str)
std::string translate_format(const std::string_view format, Args &&... args)
String formatter, with translation.
constexpr static Color rgb32(uint32_t argb)
Create a color from RGB32 components.
const std::vector< BenchmarkTask * > get_tasks()