/* * Copyright (c) 2021, Nicholas Hollett * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include "Profile.h" #include #include #include #include #include #include namespace Profiler { class FlameGraphView final : public GUI::Widget , GUI::ModelClient { C_OBJECT(FlameGraphView); public: virtual ~FlameGraphView() override = default; Function on_hover_change; GUI::ModelIndex const hovered_index() const; protected: virtual void model_did_update(unsigned flags) override; virtual void mousemove_event(GUI::MouseEvent&) override; virtual void mousedown_event(GUI::MouseEvent&) override; virtual void resize_event(GUI::ResizeEvent&) override; virtual void paint_event(GUI::PaintEvent&) override; private: explicit FlameGraphView(GUI::Model&, int text_column, int width_column); struct StackBar { GUI::ModelIndex const index; Gfx::IntRect rect; bool selected; }; void layout_bars(); void layout_children(GUI::ModelIndex& parent, int depth, int left, int right, Vector& selected); GUI::Model& m_model; int m_text_column { -1 }; int m_width_column { -1 }; Vector m_colors; Vector m_bars; StackBar* m_hovered_bar {}; Vector m_selected_indexes; }; }