blob: 97b0943c2381193881854ca5c8f047ce903392fd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
/*
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibGUI/Widget.h>
namespace Profiler {
class Profile;
class TimelineTrack;
class TimelineView final : public GUI::Widget {
C_OBJECT(TimelineView);
public:
virtual ~TimelineView() override;
Function<void()> on_selection_change;
Function<void()> on_scale_change;
float scale() const { return m_scale; }
bool is_selecting() const { return m_selecting; }
u64 select_start_time() const { return m_select_start_time; }
u64 select_end_time() const { return m_select_end_time; }
u64 hover_time() const { return m_hover_time; }
void set_selecting(bool value)
{
if (m_selecting == value)
return;
m_selecting = value;
}
void set_select_start_time(u64 value)
{
if (m_select_start_time == value)
return;
m_select_start_time = value;
update();
if (on_selection_change)
on_selection_change();
}
void set_select_end_time(u64 value)
{
if (m_select_end_time == value)
return;
m_select_end_time = value;
update();
if (on_selection_change)
on_selection_change();
}
void set_hover_time(u64 value)
{
if (m_hover_time == value)
return;
m_hover_time = value;
update();
if (on_selection_change)
on_selection_change();
}
private:
virtual void mousedown_event(GUI::MouseEvent&) override;
virtual void mousemove_event(GUI::MouseEvent&) override;
virtual void mouseup_event(GUI::MouseEvent&) override;
virtual void mousewheel_event(GUI::MouseEvent&) override;
explicit TimelineView(Profile&);
u64 timestamp_at_x(int x) const;
Profile& m_profile;
bool m_selecting { false };
u64 m_select_start_time { 0 };
u64 m_select_end_time { 0 };
u64 m_hover_time { 0 };
float m_scale { 10 };
};
}
|