]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * This file is part of the PulseView project. | |
3 | * | |
4 | * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk> | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation; either version 2 of the License, or | |
9 | * (at your option) any later version. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with this program; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
19 | */ | |
20 | ||
21 | #include "cursor.h" | |
22 | ||
23 | #include "view.h" | |
24 | ||
25 | #include <QBrush> | |
26 | #include <QPainter> | |
27 | #include <QRect> | |
28 | #include <QRectF> | |
29 | ||
30 | namespace pv { | |
31 | namespace view { | |
32 | ||
33 | const QColor Cursor::LineColour(32, 74, 135); | |
34 | const QColor Cursor::FillColour(52, 101, 164); | |
35 | const QColor Cursor::HighlightColour(83, 130, 186); | |
36 | const QColor Cursor::TextColour(Qt::white); | |
37 | ||
38 | const int Cursor::Size = 12; | |
39 | const int Cursor::Offset = 1; | |
40 | ||
41 | Cursor::Cursor(const View &view, double time) : | |
42 | TimeMarker(view, LineColour, time) | |
43 | { | |
44 | } | |
45 | ||
46 | void Cursor::paint_label(QPainter &p, const QRect &rect) | |
47 | { | |
48 | const float x = (_time - _view.offset()) / _view.scale(); | |
49 | const QRectF r(x - Size/2, rect.height() - Size - Offset, | |
50 | Size, Size); | |
51 | ||
52 | p.setPen(LineColour); | |
53 | p.setBrush(QBrush(FillColour)); | |
54 | p.drawEllipse(r); | |
55 | ||
56 | p.setPen(HighlightColour); | |
57 | p.setBrush(QBrush()); | |
58 | p.drawEllipse(r.adjusted(1, 1, -1, -1)); | |
59 | } | |
60 | ||
61 | } // namespace view | |
62 | } // namespace pv |