projects
/
pulseview.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
1dffa58
)
ViewItem: Added hit_box_rect
author
Joel Holdsworth
<joel@airwebreathe.org.uk>
Sat, 27 Dec 2014 19:05:45 +0000
(19:05 +0000)
committer
Joel Holdsworth
<joel@airwebreathe.org.uk>
Mon, 29 Dec 2014 12:24:23 +0000
(12:24 +0000)
pv/view/timemarker.cpp
patch
|
blob
|
history
pv/view/timemarker.hpp
patch
|
blob
|
history
pv/view/trace.cpp
patch
|
blob
|
history
pv/view/trace.hpp
patch
|
blob
|
history
pv/view/viewitem.cpp
patch
|
blob
|
history
pv/view/viewitem.hpp
patch
|
blob
|
history
diff --git
a/pv/view/timemarker.cpp
b/pv/view/timemarker.cpp
index 894f023bf11c4d547db8649398905a8e57c8abe8..1e5b8206e54165ebc3cc36e20181eef686c422ce 100644
(file)
--- a/
pv/view/timemarker.cpp
+++ b/
pv/view/timemarker.cpp
@@
-88,11
+88,18
@@
QRectF TimeMarker::label_rect(const QRectF &rect) const
const QSizeF label_size(text_size + LabelPadding * 2);
const float top = rect.height() - label_size.height() -
TimeMarker::ArrowSize - 0.5f;
const QSizeF label_size(text_size + LabelPadding * 2);
const float top = rect.height() - label_size.height() -
TimeMarker::ArrowSize - 0.5f;
- const float x =
(time_ - view_.offset()) / view_.scale
();
+ const float x =
get_x
();
return QRectF(QPointF(x - label_size.width() / 2, top), label_size);
}
return QRectF(QPointF(x - label_size.width() / 2, top), label_size);
}
+QRectF TimeMarker::hit_box_rect(const QRectF &rect) const
+{
+ const float x = get_x();
+ const float h = QFontMetrics(QApplication::font()).height();
+ return QRectF(x - h / 2.0f, rect.top(), h, rect.height());
+}
+
void TimeMarker::paint_label(QPainter &p, const QRect &rect, bool hover)
{
if (!enabled())
void TimeMarker::paint_label(QPainter &p, const QRect &rect, bool hover)
{
if (!enabled())
diff --git
a/pv/view/timemarker.hpp
b/pv/view/timemarker.hpp
index 4f7361bd13acb5a9e119e30183c8f82a5a0a92d0..113a6a10a6f04c097d2bc9d828e1f516f63fa2f0 100644
(file)
--- a/
pv/view/timemarker.hpp
+++ b/
pv/view/timemarker.hpp
@@
-79,6
+79,13
@@
public:
*/
QRectF label_rect(const QRectF &rect) const;
*/
QRectF label_rect(const QRectF &rect) const;
+ /**
+ * Computes the outline rectangle of the viewport hit-box.
+ * @param rect the rectangle of the viewport area.
+ * @return Returns the rectangle of the hit-box.
+ */
+ QRectF hit_box_rect(const QRectF &rect) const;
+
/**
* Gets the text to show in the marker.
*/
/**
* Gets the text to show in the marker.
*/
diff --git
a/pv/view/trace.cpp
b/pv/view/trace.cpp
index bf1c4ae511f4f507726e97ab2f726b7b95fb6dc0..a96b0327e0e6ffd6f5364876b928ebaa87077daf 100644
(file)
--- a/
pv/view/trace.cpp
+++ b/
pv/view/trace.cpp
@@
-163,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);
diff --git
a/pv/view/trace.hpp
b/pv/view/trace.hpp
index 294946155cc2f20f2737c2452428e293a44e5b17..e6e053dac26c114828843b508a13c4bdb4819067 100644
(file)
--- a/
pv/view/trace.hpp
+++ b/
pv/view/trace.hpp
@@
-73,6
+73,13
@@
public:
*/
void set_colour(QColor colour);
*/
void set_colour(QColor colour);
+ /**
+ * Computes the outline rectangle of the viewport hit-box.
+ * @param rect the rectangle of the viewport area.
+ * @return Returns the rectangle of the hit-box.
+ */
+ QRectF hit_box_rect(const QRectF &rect) const;
+
/**
* Paints the signal label.
* @param p the QPainter to paint into.
/**
* Paints the signal label.
* @param p the QPainter to paint into.
diff --git
a/pv/view/viewitem.cpp
b/pv/view/viewitem.cpp
index 02a9c6a2f39d8deb9dcb0e0c4d3f11e1b1f16a93..1492d14d8d1d45851769dadb6f9af9278c50ae98 100644
(file)
--- a/
pv/view/viewitem.cpp
+++ b/
pv/view/viewitem.cpp
@@
-64,6
+64,12
@@
void ViewItem::drag_release()
drag_point_ = QPoint(INT_MIN, INT_MIN);
}
drag_point_ = QPoint(INT_MIN, INT_MIN);
}
+QRectF ViewItem::hit_box_rect(const QRectF &rect) const
+{
+ (void)rect;
+ return QRectF();
+}
+
QMenu* ViewItem::create_context_menu(QWidget *parent)
{
context_parent_ = parent;
QMenu* ViewItem::create_context_menu(QWidget *parent)
{
context_parent_ = parent;
diff --git
a/pv/view/viewitem.hpp
b/pv/view/viewitem.hpp
index eb0823e47e8f1b55b897597a0c8bf14a0b960742..7579b555cdc460b36207c1f64fcab7f260eca2a9 100644
(file)
--- a/
pv/view/viewitem.hpp
+++ b/
pv/view/viewitem.hpp
@@
-100,6
+100,14
@@
public:
*/
virtual QRectF label_rect(const QRectF &rect) const = 0;
*/
virtual QRectF label_rect(const QRectF &rect) const = 0;
+ /**
+ * Computes the outline rectangle of the viewport hit-box.
+ * @param rect the rectangle of the viewport area.
+ * @return Returns the rectangle of the hit-box.
+ * @remarks The default implementation returns an empty hit-box.
+ */
+ virtual QRectF hit_box_rect(const QRectF &rect) const;
+
/**
* Paints the signal label.
* @param p the QPainter to paint into.
/**
* Paints the signal label.
* @param p the QPainter to paint into.