projects
/
pulseview.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
5c5ce75
)
RowItem: Pass rect into label_rect
author
Joel Holdsworth
<joel@airwebreathe.org.uk>
Sun, 7 Dec 2014 10:34:40 +0000
(10:34 +0000)
committer
Uwe Hermann
<uwe@hermann-uwe.de>
Wed, 10 Dec 2014 17:06:16 +0000
(18:06 +0100)
pv/view/header.cpp
patch
|
blob
|
history
pv/view/rowitem.hpp
patch
|
blob
|
history
pv/view/trace.cpp
patch
|
blob
|
history
pv/view/trace.hpp
patch
|
blob
|
history
pv/view/tracegroup.cpp
patch
|
blob
|
history
pv/view/tracegroup.hpp
patch
|
blob
|
history
pv/view/view.cpp
patch
|
blob
|
history
pv/view/view.hpp
patch
|
blob
|
history
diff --git
a/pv/view/header.cpp
b/pv/view/header.cpp
index 2269849c24da9886fd3ff132dfffb7e27bf017a4..4da188af70d916564d43b59264e490f81a67bbcb 100644
(file)
--- a/
pv/view/header.cpp
+++ b/
pv/view/header.cpp
@@
-75,15
+75,15
@@
QSize Header::sizeHint() const
QRectF max_rect(-Padding, 0, Padding, 0);
for (auto &i : view_)
if (i->enabled())
QRectF max_rect(-Padding, 0, Padding, 0);
for (auto &i : view_)
if (i->enabled())
- max_rect = max_rect.united(i->label_rect(
0
));
+ max_rect = max_rect.united(i->label_rect(
QRect()
));
return QSize(max_rect.width() + Padding + BaselineOffset, 0);
}
shared_ptr<RowItem> Header::get_mouse_over_row_item(const QPoint &pt)
{
return QSize(max_rect.width() + Padding + BaselineOffset, 0);
}
shared_ptr<RowItem> Header::get_mouse_over_row_item(const QPoint &pt)
{
- const
int w = width() - BaselineOffset
;
+ const
QRect r(BaselineOffset, 0, width() - BaselineOffset, height())
;
for (auto &i : view_)
for (auto &i : view_)
- if (i->enabled() && i->label_rect(
w
).contains(pt))
+ if (i->enabled() && i->label_rect(
r
).contains(pt))
return i;
return shared_ptr<RowItem>();
}
return i;
return shared_ptr<RowItem>();
}
@@
-113,7
+113,7
@@
void Header::paintEvent(QPaintEvent*)
// The trace labels are not drawn with the arrows exactly on the
// left edge of the widget, because then the selection shadow
// would be clipped away.
// The trace labels are not drawn with the arrows exactly on the
// left edge of the widget, because then the selection shadow
// would be clipped away.
- const
int w = width() - BaselineOffset
;
+ const
QRect rect(BaselineOffset, 0, width() - BaselineOffset, height())
;
vector< shared_ptr<RowItem> > row_items(
view_.begin(), view_.end());
vector< shared_ptr<RowItem> > row_items(
view_.begin(), view_.end());
@@
-130,8
+130,8
@@
void Header::paintEvent(QPaintEvent*)
assert(r);
const bool highlight = !dragging_ &&
assert(r);
const bool highlight = !dragging_ &&
- r->label_rect(
w
).contains(mouse_point_);
- r->paint_label(painter,
w
, highlight);
+ r->label_rect(
rect
).contains(mouse_point_);
+ r->paint_label(painter,
rect
, highlight);
}
painter.end();
}
painter.end();
diff --git
a/pv/view/rowitem.hpp
b/pv/view/rowitem.hpp
index 4f973e3fc218647d355fcede1492d45fe0a3725c..aca4fa83ecbb24bc4f372f25311e643b9a14c13c 100644
(file)
--- a/
pv/view/rowitem.hpp
+++ b/
pv/view/rowitem.hpp
@@
-129,19
+129,17
@@
public:
/**
* Paints the signal label.
* @param p the QPainter to paint into.
/**
* Paints the signal label.
* @param p the QPainter to paint into.
- * @param right the x-coordinate of the right edge of the header
- * area.
+ * @param rect the rectangle of the header area.
* @param hover true if the label is being hovered over by the mouse.
*/
* @param hover true if the label is being hovered over by the mouse.
*/
- virtual void paint_label(QPainter &p,
int righ
t, bool hover) = 0;
+ virtual void paint_label(QPainter &p,
const QRect &rec
t, bool hover) = 0;
/**
* Computes the outline rectangle of a label.
/**
* Computes the outline rectangle of a label.
- * @param right the x-coordinate of the right edge of the header
- * area.
+ * @param rect the rectangle of the header area.
* @return Returns the rectangle of the signal label.
*/
* @return Returns the rectangle of the signal label.
*/
- virtual QRectF label_rect(
int righ
t) const = 0;
+ virtual QRectF label_rect(
const QRectF &rec
t) const = 0;
public:
virtual void hover_point_changed();
public:
virtual void hover_point_changed();
diff --git
a/pv/view/trace.cpp
b/pv/view/trace.cpp
index e9235e56f2713bfd348f29ab6c3c14112968f81d..df6bd63d041ec74a4228919ea4383afb2c982ae4 100644
(file)
--- a/
pv/view/trace.cpp
+++ b/
pv/view/trace.cpp
@@
-68,7
+68,7
@@
void Trace::set_colour(QColor colour)
colour_ = colour;
}
colour_ = colour;
}
-void Trace::paint_label(QPainter &p,
int righ
t, bool hover)
+void Trace::paint_label(QPainter &p,
const QRect &rec
t, bool hover)
{
const int y = get_visual_y();
{
const int y = get_visual_y();
@@
-77,7
+77,7
@@
void Trace::paint_label(QPainter &p, int right, bool hover)
if (!enabled())
return;
if (!enabled())
return;
- const QRectF r = label_rect(r
igh
t);
+ const QRectF r = label_rect(r
ec
t);
// Paint the label
const float label_arrow_length = r.height() / 2;
// Paint the label
const float label_arrow_length = r.height() / 2;
@@
-143,7
+143,7
@@
pv::widgets::Popup* Trace::create_popup(QWidget *parent)
return popup_;
}
return popup_;
}
-QRectF Trace::label_rect(
int righ
t) const
+QRectF Trace::label_rect(
const QRectF &rec
t) const
{
using pv::view::View;
{
using pv::view::View;
@@
-156,7
+156,7
@@
QRectF Trace::label_rect(int right) const
ceilf((text_size.height() + View::LabelPadding.height() * 2) / 2) * 2);
const float half_height = label_size.height() / 2;
return QRectF(
ceilf((text_size.height() + View::LabelPadding.height() * 2) / 2) * 2);
const float half_height = label_size.height() / 2;
return QRectF(
- r
ight
- half_height - label_size.width() - 0.5,
+ r
ect.right()
- half_height - label_size.width() - 0.5,
get_visual_y() + 0.5f - half_height,
label_size.width() + half_height,
label_size.height());
get_visual_y() + 0.5f - half_height,
label_size.width() + half_height,
label_size.height());
diff --git
a/pv/view/trace.hpp
b/pv/view/trace.hpp
index a82520ccfdc68fedf589ea8afb326c4b99016fbb..7d5158c3a0d36d237e3e2c9596ea87d399083483 100644
(file)
--- a/
pv/view/trace.hpp
+++ b/
pv/view/trace.hpp
@@
-76,11
+76,10
@@
public:
/**
* Paints the signal label.
* @param p the QPainter to paint into.
/**
* Paints the signal label.
* @param p the QPainter to paint into.
- * @param right the x-coordinate of the right edge of the header
- * area.
+ * @param rect the rectangle of the header area.
* @param hover true if the label is being hovered over by the mouse.
*/
* @param hover true if the label is being hovered over by the mouse.
*/
- virtual void paint_label(QPainter &p,
int righ
t, bool hover);
+ virtual void paint_label(QPainter &p,
const QRect &rec
t, bool hover);
virtual QMenu* create_context_menu(QWidget *parent);
virtual QMenu* create_context_menu(QWidget *parent);
@@
-88,11
+87,10
@@
public:
/**
* Computes the outline rectangle of a label.
/**
* Computes the outline rectangle of a label.
- * @param right the x-coordinate of the right edge of the header
- * area.
+ * @param rect the rectangle of the header area.
* @return Returns the rectangle of the signal label.
*/
* @return Returns the rectangle of the signal label.
*/
- QRectF label_rect(
int righ
t) const;
+ QRectF label_rect(
const QRectF &rec
t) const;
protected:
/**
protected:
/**
diff --git
a/pv/view/tracegroup.cpp
b/pv/view/tracegroup.cpp
index 272fc1a1e3b341823e82133c099d4f35f392c617..13ba025f9c1235ed01576fe736812e963c73ad79 100644
(file)
--- a/
pv/view/tracegroup.cpp
+++ b/
pv/view/tracegroup.cpp
@@
-81,9
+81,9
@@
pair<int, int> TraceGroup::v_extents() const
return RowItemOwner::v_extents();
}
return RowItemOwner::v_extents();
}
-void TraceGroup::paint_label(QPainter &p,
int righ
t, bool hover)
+void TraceGroup::paint_label(QPainter &p,
const QRect &rec
t, bool hover)
{
{
- const QRectF r = label_rect(r
igh
t).adjusted(
+ const QRectF r = label_rect(r
ec
t).adjusted(
LineThickness / 2, LineThickness / 2,
-LineThickness / 2, -LineThickness / 2);
LineThickness / 2, LineThickness / 2,
-LineThickness / 2, -LineThickness / 2);
@@
-112,15
+112,15
@@
void TraceGroup::paint_label(QPainter &p, int right, bool hover)
p.drawPolyline(points, countof(points));
}
p.drawPolyline(points, countof(points));
}
-QRectF TraceGroup::label_rect(
int righ
t) const
+QRectF TraceGroup::label_rect(
const QRectF &rec
t) const
{
{
- QRectF rect;
+ QRectF
child_
rect;
for (const shared_ptr<RowItem> r : child_items())
if (r && r->enabled())
for (const shared_ptr<RowItem> r : child_items())
if (r && r->enabled())
-
rect = rect.united(r->label_rect(righ
t));
+
child_rect = child_rect.united(r->label_rect(rec
t));
- return QRectF(
rect.x() - Width - Padding,
rect.y(),
- Width, rect.height());
+ return QRectF(
child_rect.x() - Width - Padding, child_
rect.y(),
+ Width,
child_
rect.height());
}
bool TraceGroup::pt_in_label_rect(int left, int right, const QPoint &point)
}
bool TraceGroup::pt_in_label_rect(int left, int right, const QPoint &point)
diff --git
a/pv/view/tracegroup.hpp
b/pv/view/tracegroup.hpp
index f89ea437f33c8026ad1ab9898055bf145b9867d8..4f631d0da23927bca35b836f244155f4b01c8774 100644
(file)
--- a/
pv/view/tracegroup.hpp
+++ b/
pv/view/tracegroup.hpp
@@
-81,15
+81,14
@@
public:
* area.
* @param hover true if the label is being hovered over by the mouse.
*/
* area.
* @param hover true if the label is being hovered over by the mouse.
*/
- void paint_label(QPainter &p,
int righ
t, bool hover);
+ void paint_label(QPainter &p,
const QRect &rec
t, bool hover);
/**
* Computes the outline rectangle of a label.
/**
* Computes the outline rectangle of a label.
- * @param right the x-coordinate of the right edge of the header
- * area.
+ * @param rect the rectangle of the header area.
* @return Returns the rectangle of the signal label.
*/
* @return Returns the rectangle of the signal label.
*/
- QRectF label_rect(
int righ
t) const;
+ QRectF label_rect(
const QRectF &rec
t) const;
/**
* Determines if a point is in the header label rect.
/**
* Determines if a point is in the header label rect.
diff --git
a/pv/view/view.cpp
b/pv/view/view.cpp
index 4575d05e2b7dd0fc58009a4bc927892dbe52a9a3..3df87e540b986b0e08b1242c9139950f65f12a5b 100644
(file)
--- a/
pv/view/view.cpp
+++ b/
pv/view/view.cpp
@@
-505,16
+505,16
@@
void View::update_layout()
update_scroll();
}
update_scroll();
}
-void View::paint_label(QPainter &p,
int righ
t, bool hover)
+void View::paint_label(QPainter &p,
const QRect &rec
t, bool hover)
{
(void)p;
{
(void)p;
- (void)r
igh
t;
+ (void)r
ec
t;
(void)hover;
}
(void)hover;
}
-QRectF View::label_rect(
int righ
t)
+QRectF View::label_rect(
const QRectF &rec
t)
{
{
- (void)r
igh
t;
+ (void)r
ec
t;
return QRectF();
}
return QRectF();
}
diff --git
a/pv/view/view.hpp
b/pv/view/view.hpp
index 026c7683ffaef224c501ed94ad6cdbe586452742..5fc6e4e0a619c94442dea0e34e87dab8438af02c 100644
(file)
--- a/
pv/view/view.hpp
+++ b/
pv/view/view.hpp
@@
-200,19
+200,17
@@
private:
/**
* Satisifies RowItem functionality.
* @param p the QPainter to paint into.
/**
* Satisifies RowItem functionality.
* @param p the QPainter to paint into.
- * @param right the x-coordinate of the right edge of the header
- * area.
+ * @param rect the rectangle of the header area.
* @param hover true if the label is being hovered over by the mouse.
*/
* @param hover true if the label is being hovered over by the mouse.
*/
- void paint_label(QPainter &p,
int righ
t, bool hover);
+ void paint_label(QPainter &p,
const QRect &rec
t, bool hover);
/**
* Computes the outline rectangle of a label.
/**
* Computes the outline rectangle of a label.
- * @param right the x-coordinate of the right edge of the header
- * area.
+ * @param rect the rectangle of the header area.
* @return Returns the rectangle of the signal label.
*/
* @return Returns the rectangle of the signal label.
*/
- QRectF label_rect(
int righ
t);
+ QRectF label_rect(
const QRectF &rec
t);
static bool add_channels_to_owner(
const std::vector< std::shared_ptr<sigrok::Channel> > &channels,
static bool add_channels_to_owner(
const std::vector< std::shared_ptr<sigrok::Channel> > &channels,