projects
/
pulseview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Ruler scale calculation optimization
[pulseview.git]
/
pv
/
view
/
trace.cpp
diff --git
a/pv/view/trace.cpp
b/pv/view/trace.cpp
index 1464b5eea135d19aa7ad70ad41820c703fd7871f..729b0b4c1588ff6ae93cc5c152dbdcd2e46994cc 100644
(file)
--- a/
pv/view/trace.cpp
+++ b/
pv/view/trace.cpp
@@
-21,7
+21,7
@@
#include <extdef.h>
#include <assert.h>
#include <extdef.h>
#include <assert.h>
-#include <
math.
h>
+#include <
cmat
h>
#include <QApplication>
#include <QFormLayout>
#include <QApplication>
#include <QFormLayout>
@@
-43,8
+43,8
@@
const int Trace::LabelHitPadding = 2;
Trace::Trace(QString name) :
name_(name),
Trace::Trace(QString name) :
name_(name),
- popup_(
NULL
),
- popup_form_(
NULL
)
+ popup_(
nullptr
),
+ popup_form_(
nullptr
)
{
}
{
}
@@
-134,6
+134,8
@@
pv::widgets::Popup* Trace::create_popup(QWidget *parent)
using pv::widgets::Popup;
popup_ = new Popup(parent);
using pv::widgets::Popup;
popup_ = new Popup(parent);
+ popup_->set_position(parent->mapToGlobal(
+ point(parent->rect())), Popup::Right);
create_popup_form();
create_popup_form();
@@
-149,11
+151,10
@@
QRectF Trace::label_rect(const QRectF &rect) const
QFontMetrics m(QApplication::font());
const QSize text_size(
QFontMetrics m(QApplication::font());
const QSize text_size(
- m.boundingRect(QRect(), 0, name_).width(),
- m.boundingRect(QRect(), 0, "Tg").height());
+ m.boundingRect(QRect(), 0, name_).width(), m.height());
const QSizeF label_size(
const QSizeF label_size(
- text_size.width() +
View::
LabelPadding.width() * 2,
- ceilf((text_size.height() +
View::
LabelPadding.height() * 2) / 2) * 2);
+ text_size.width() + LabelPadding.width() * 2,
+ ceilf((text_size.height() + LabelPadding.height() * 2) / 2) * 2);
const float half_height = label_size.height() / 2;
return QRectF(
rect.right() - half_height - label_size.width() - 0.5,
const float half_height = label_size.height() / 2;
return QRectF(
rect.right() - half_height - label_size.width() - 0.5,
@@
-162,6
+163,13
@@
QRectF Trace::label_rect(const QRectF &rect) const
label_size.height());
}
label_size.height());
}
+QRectF Trace::hit_box_rect(const QRectF &rect) const
+{
+ const float h = QFontMetrics(QApplication::font()).height();
+ return QRectF(rect.left(), get_visual_y() - h / 2.0f,
+ rect.width(), h);
+}
+
void Trace::paint_axis(QPainter &p, const ViewItemPaintParams &pp, int y)
{
p.setPen(AxisPen);
void Trace::paint_axis(QPainter &p, const ViewItemPaintParams &pp, int y)
{
p.setPen(AxisPen);
@@
-211,8
+219,8
@@
void Trace::populate_popup_form(QWidget *parent, QFormLayout *form)
void Trace::on_popup_closed()
{
void Trace::on_popup_closed()
{
- popup_ =
NULL
;
- popup_form_ =
NULL
;
+ popup_ =
nullptr
;
+ popup_form_ =
nullptr
;
}
void Trace::on_text_changed(const QString &text)
}
void Trace::on_text_changed(const QString &text)
@@
-228,7
+236,7
@@
void Trace::on_colour_changed(const QColor &colour)
set_colour(colour);
if (owner_)
set_colour(colour);
if (owner_)
- owner_->appearance_changed(true, false);
+ owner_->
row_item_
appearance_changed(true, false);
}
} // namespace view
}
} // namespace view