]> sigrok.org Git - pulseview.git/blame - pv/views/trace/viewitem.cpp
Disable antialiasing on high-DPI displays
[pulseview.git] / pv / views / trace / viewitem.cpp
CommitLineData
f1283456
JH
1/*
2 * This file is part of the PulseView project.
3 *
4 * Copyright (C) 2013 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
efdec55a 17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
f1283456
JH
18 */
19
26e3af6b 20#include "viewitem.hpp"
f1283456 21
0dda6fe5
JH
22#include <climits>
23
d09674d4 24#include <QApplication>
9b6378f1 25#include <QMenu>
d09674d4
JH
26#include <QPalette>
27
f1283456 28namespace pv {
f4e57597 29namespace views {
1573bf16 30namespace trace {
f1283456 31
ec39632d 32const QSizeF ViewItem::LabelPadding(4, 0);
aef68e5e 33const int ViewItem::HighlightRadius = 3;
d09674d4 34
26e3af6b 35ViewItem::ViewItem() :
4c60462b 36 context_parent_(nullptr),
23e75650
JH
37 drag_point_(INT_MIN, INT_MIN),
38 selected_(false)
f1283456
JH
39{
40}
41
cbd9ec7f
SA
42bool ViewItem::is_selectable(QPoint pos) const
43{
44 (void)pos;
45 return true;
46}
47
26e3af6b 48bool ViewItem::selected() const
f1283456 49{
8dbbc7f0 50 return selected_;
f1283456
JH
51}
52
26e3af6b 53void ViewItem::select(bool select)
f1283456 54{
8dbbc7f0 55 selected_ = select;
f1283456
JH
56}
57
119c5c23 58bool ViewItem::is_draggable(QPoint pos) const
a009d219 59{
119c5c23 60 (void)pos;
a009d219
TS
61 return true;
62}
63
26e3af6b 64bool ViewItem::dragging() const
0dda6fe5 65{
8dbbc7f0 66 return drag_point_.x() != INT_MIN && drag_point_.y() != INT_MIN;
0dda6fe5
JH
67}
68
26e3af6b 69void ViewItem::drag()
0dda6fe5 70{
119c5c23 71 drag_point_ = drag_point(QRect());
0dda6fe5
JH
72}
73
26e3af6b 74void ViewItem::drag_release()
0dda6fe5 75{
8dbbc7f0 76 drag_point_ = QPoint(INT_MIN, INT_MIN);
0dda6fe5
JH
77}
78
3cd51b50
JH
79QRectF ViewItem::label_rect(const QRectF &rect) const
80{
81 (void)rect;
82 return QRectF();
83}
84
cbf0f87e 85QRectF ViewItem::hit_box_rect(const ViewItemPaintParams &pp) const
7708eb92 86{
cbf0f87e 87 (void)pp;
7708eb92
JH
88 return QRectF();
89}
90
9e773fec 91QMenu* ViewItem::create_header_context_menu(QWidget *parent)
9b6378f1 92{
8dbbc7f0 93 context_parent_ = parent;
9b6378f1
JH
94 return new QMenu(parent);
95}
96
be843692 97QMenu* ViewItem::create_view_context_menu(QWidget *parent, QPoint &click_pos)
d9b55cc8
SA
98{
99 (void)parent;
be843692 100 (void)click_pos;
d9b55cc8
SA
101 return nullptr;
102}
103
0f2f14a4
JH
104widgets::Popup* ViewItem::create_popup(QWidget *parent)
105{
106 (void)parent;
107 return nullptr;
108}
109
26e3af6b 110void ViewItem::delete_pressed()
5ed1adf5
JH
111{
112}
113
26e3af6b 114QPen ViewItem::highlight_pen()
d09674d4
JH
115{
116 return QPen(QApplication::palette().brush(
aef68e5e 117 QPalette::Highlight), HighlightRadius * 2,
d09674d4
JH
118 Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
119}
120
fa792224
JH
121void ViewItem::paint_label(QPainter &p, const QRect &rect, bool hover)
122{
123 (void)p;
124 (void)rect;
125 (void)hover;
126}
127
60938e04 128void ViewItem::paint_back(QPainter &p, ViewItemPaintParams &pp)
d4e39570
JH
129{
130 (void)p;
131 (void)pp;
132}
133
60938e04 134void ViewItem::paint_mid(QPainter &p, ViewItemPaintParams &pp)
d4e39570
JH
135{
136 (void)p;
137 (void)pp;
138}
139
60938e04 140void ViewItem::paint_fore(QPainter &p, ViewItemPaintParams &pp)
d4e39570
JH
141{
142 (void)p;
143 (void)pp;
144}
145
641574bc 146QColor ViewItem::select_text_color(QColor background)
d8d724cc 147{
20dd116e 148 return (background.lightness() > 110) ? Qt::black : Qt::white;
d8d724cc
JH
149}
150
1573bf16 151} // namespace trace
f4e57597 152} // namespace views
f1283456 153} // namespace pv