mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:07:47 +00:00
Profiler: Allow scaling the timeline with Ctrl+MouseWheel :^)
This commit is contained in:
parent
3dfc3e362b
commit
62819df713
5 changed files with 33 additions and 1 deletions
|
@ -20,6 +20,11 @@ TimelineContainer::TimelineContainer(GUI::Widget& header_container, TimelineView
|
||||||
timeline_view.move_to_back();
|
timeline_view.move_to_back();
|
||||||
update_widget_sizes();
|
update_widget_sizes();
|
||||||
update_widget_positions();
|
update_widget_positions();
|
||||||
|
|
||||||
|
m_timeline_view->on_scale_change = [this] {
|
||||||
|
update_widget_positions();
|
||||||
|
update_widget_sizes();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
TimelineContainer::~TimelineContainer()
|
TimelineContainer::~TimelineContainer()
|
||||||
|
|
|
@ -22,7 +22,7 @@ TimelineTrack::TimelineTrack(TimelineView const& view, Profile const& profile, P
|
||||||
set_fill_with_background_color(true);
|
set_fill_with_background_color(true);
|
||||||
set_background_role(Gfx::ColorRole::Base);
|
set_background_role(Gfx::ColorRole::Base);
|
||||||
set_fixed_height(40);
|
set_fixed_height(40);
|
||||||
set_fixed_width(m_profile.length_in_ms() / 10);
|
set_scale(view.scale());
|
||||||
set_frame_thickness(1);
|
set_frame_thickness(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,6 +30,11 @@ TimelineTrack::~TimelineTrack()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TimelineTrack::set_scale(float scale)
|
||||||
|
{
|
||||||
|
set_fixed_width(m_profile.length_in_ms() / scale);
|
||||||
|
}
|
||||||
|
|
||||||
void TimelineTrack::event(Core::Event& event)
|
void TimelineTrack::event(Core::Event& event)
|
||||||
{
|
{
|
||||||
switch (event.type()) {
|
switch (event.type()) {
|
||||||
|
|
|
@ -20,6 +20,8 @@ class TimelineTrack final : public GUI::Frame {
|
||||||
public:
|
public:
|
||||||
virtual ~TimelineTrack() override;
|
virtual ~TimelineTrack() override;
|
||||||
|
|
||||||
|
void set_scale(float);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void event(Core::Event&) override;
|
virtual void event(Core::Event&) override;
|
||||||
virtual void paint_event(GUI::PaintEvent&) override;
|
virtual void paint_event(GUI::PaintEvent&) override;
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include "TimelineView.h"
|
#include "TimelineView.h"
|
||||||
#include "Profile.h"
|
#include "Profile.h"
|
||||||
|
#include "TimelineTrack.h"
|
||||||
#include <LibGUI/BoxLayout.h>
|
#include <LibGUI/BoxLayout.h>
|
||||||
|
|
||||||
namespace Profiler {
|
namespace Profiler {
|
||||||
|
@ -62,4 +63,18 @@ void TimelineView::mouseup_event(GUI::MouseEvent& event)
|
||||||
m_profile.clear_timestamp_filter_range();
|
m_profile.clear_timestamp_filter_range();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TimelineView::mousewheel_event(GUI::MouseEvent& event)
|
||||||
|
{
|
||||||
|
if (event.modifiers() == Mod_Ctrl) {
|
||||||
|
event.accept();
|
||||||
|
m_scale += event.wheel_delta();
|
||||||
|
m_scale = clamp(m_scale, 1.0f, 100.0f);
|
||||||
|
for_each_child_of_type<TimelineTrack>([&](auto& track) {
|
||||||
|
track.set_scale(m_scale);
|
||||||
|
return IterationDecision::Continue;
|
||||||
|
});
|
||||||
|
on_scale_change();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,9 @@ public:
|
||||||
virtual ~TimelineView() override;
|
virtual ~TimelineView() override;
|
||||||
|
|
||||||
Function<void()> on_selection_change;
|
Function<void()> on_selection_change;
|
||||||
|
Function<void()> on_scale_change;
|
||||||
|
|
||||||
|
float scale() const { return m_scale; }
|
||||||
|
|
||||||
bool is_selecting() const { return m_selecting; }
|
bool is_selecting() const { return m_selecting; }
|
||||||
u64 select_start_time() const { return m_select_start_time; }
|
u64 select_start_time() const { return m_select_start_time; }
|
||||||
|
@ -65,6 +68,7 @@ private:
|
||||||
virtual void mousedown_event(GUI::MouseEvent&) override;
|
virtual void mousedown_event(GUI::MouseEvent&) override;
|
||||||
virtual void mousemove_event(GUI::MouseEvent&) override;
|
virtual void mousemove_event(GUI::MouseEvent&) override;
|
||||||
virtual void mouseup_event(GUI::MouseEvent&) override;
|
virtual void mouseup_event(GUI::MouseEvent&) override;
|
||||||
|
virtual void mousewheel_event(GUI::MouseEvent&) override;
|
||||||
|
|
||||||
explicit TimelineView(Profile&);
|
explicit TimelineView(Profile&);
|
||||||
|
|
||||||
|
@ -75,6 +79,7 @@ private:
|
||||||
u64 m_select_start_time { 0 };
|
u64 m_select_start_time { 0 };
|
||||||
u64 m_select_end_time { 0 };
|
u64 m_select_end_time { 0 };
|
||||||
u64 m_hover_time { 0 };
|
u64 m_hover_time { 0 };
|
||||||
|
float m_scale { 10 };
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue