mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:38:11 +00:00
ProfileViewer: Allow filtering samples in a specific time range
You can now select the time range you want on the profile timeline. The tree view will update automatically as you alter the range. Unfortunately this causes the treeview to collapse all of its nodes. It would be nice to solve this somehow in the future so that nodes can stay open.
This commit is contained in:
parent
a3e7c99ffe
commit
3fd2304dad
4 changed files with 109 additions and 29 deletions
|
@ -38,16 +38,50 @@ void ProfileTimelineWidget::paint_event(GPaintEvent& event)
|
|||
for (int i = 0; i < cw; ++i)
|
||||
painter.draw_line({ x + i, frame_thickness() }, { x + i, height() - frame_thickness() * 2 }, color);
|
||||
});
|
||||
|
||||
u64 normalized_start_time = min(m_select_start_time, m_select_end_time);
|
||||
u64 normalized_end_time = max(m_select_start_time, m_select_end_time);
|
||||
|
||||
int select_start_x = (int)((float)(normalized_start_time - m_profile.first_timestamp()) * column_width);
|
||||
int select_end_x = (int)((float)(normalized_end_time - m_profile.first_timestamp()) * column_width);
|
||||
painter.fill_rect({ select_start_x, frame_thickness(), select_end_x - select_start_x, height() - frame_thickness() * 2 }, Color(0, 0, 0, 60));
|
||||
}
|
||||
|
||||
void ProfileTimelineWidget::mousedown_event(GMouseEvent&)
|
||||
u64 ProfileTimelineWidget::timestamp_at_x(int x) const
|
||||
{
|
||||
float column_width = (float)frame_inner_rect().width() / (float)m_profile.length_in_ms();
|
||||
float ms_into_profile = (float)x / column_width;
|
||||
return m_profile.first_timestamp() + (u64)ms_into_profile;
|
||||
}
|
||||
|
||||
void ProfileTimelineWidget::mousemove_event(GMouseEvent&)
|
||||
void ProfileTimelineWidget::mousedown_event(GMouseEvent& event)
|
||||
{
|
||||
if (event.button() != GMouseButton::Left)
|
||||
return;
|
||||
|
||||
m_selecting = true;
|
||||
m_select_start_time = timestamp_at_x(event.x());
|
||||
m_select_end_time = m_select_start_time;
|
||||
m_profile.set_timestamp_filter_range(m_select_start_time, m_select_end_time);
|
||||
update();
|
||||
}
|
||||
|
||||
void ProfileTimelineWidget::mouseup_event(GMouseEvent&)
|
||||
void ProfileTimelineWidget::mousemove_event(GMouseEvent& event)
|
||||
{
|
||||
if (!m_selecting)
|
||||
return;
|
||||
|
||||
m_select_end_time = timestamp_at_x(event.x());
|
||||
m_profile.set_timestamp_filter_range(m_select_start_time, m_select_end_time);
|
||||
update();
|
||||
}
|
||||
|
||||
void ProfileTimelineWidget::mouseup_event(GMouseEvent& event)
|
||||
{
|
||||
if (event.button() != GMouseButton::Left)
|
||||
return;
|
||||
|
||||
m_selecting = false;
|
||||
if (m_select_start_time == m_select_end_time)
|
||||
m_profile.clear_timestamp_filter_range();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue