projects
/
pulseview.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
1dc835a
)
RowItem: Split appart visual and layout v offsets
author
Joel Holdsworth
<joel@airwebreathe.org.uk>
Sat, 15 Nov 2014 10:04:52 +0000
(10:04 +0000)
committer
Joel Holdsworth
<joel@airwebreathe.org.uk>
Wed, 19 Nov 2014 10:23:30 +0000
(10:23 +0000)
pv/view/analogsignal.cpp
patch
|
blob
|
history
pv/view/decodetrace.cpp
patch
|
blob
|
history
pv/view/header.cpp
patch
|
blob
|
history
pv/view/logicsignal.cpp
patch
|
blob
|
history
pv/view/rowitem.cpp
patch
|
blob
|
history
pv/view/rowitem.h
patch
|
blob
|
history
pv/view/rowitemowner.cpp
patch
|
blob
|
history
pv/view/trace.cpp
patch
|
blob
|
history
pv/view/tracegroup.cpp
patch
|
blob
|
history
pv/view/view.cpp
patch
|
blob
|
history
pv/view/viewport.cpp
patch
|
blob
|
history
diff --git
a/pv/view/analogsignal.cpp
b/pv/view/analogsignal.cpp
index 250fb94e9bc6623c6720a581721662798cdb571c..a8d7b3e8113d6c514e9955fc9c897a65175977a3 100644
(file)
--- a/
pv/view/analogsignal.cpp
+++ b/
pv/view/analogsignal.cpp
@@
-90,7
+90,7
@@
std::pair<int, int> AnalogSignal::v_extents() const
void AnalogSignal::paint_back(QPainter &p, int left, int right)
{
if (_channel->enabled())
void AnalogSignal::paint_back(QPainter &p, int left, int right)
{
if (_channel->enabled())
- paint_axis(p, get_y(), left, right);
+ paint_axis(p, get_
visual_
y(), left, right);
}
void AnalogSignal::paint_mid(QPainter &p, int left, int right)
}
void AnalogSignal::paint_mid(QPainter &p, int left, int right)
@@
-99,7
+99,7
@@
void AnalogSignal::paint_mid(QPainter &p, int left, int right)
assert(right >= left);
assert(_owner);
assert(right >= left);
assert(_owner);
- const int y = get_y();
+ const int y = get_
visual_
y();
const View *const view = _owner->view();
assert(view);
const View *const view = _owner->view();
assert(view);
diff --git
a/pv/view/decodetrace.cpp
b/pv/view/decodetrace.cpp
index d97d01ef623931c2769c25dc5fe34b798cd6365c..5ca665e0dff947f17ebbcbd0a5a77aa8802d1b98 100644
(file)
--- a/
pv/view/decodetrace.cpp
+++ b/
pv/view/decodetrace.cpp
@@
-169,7
+169,7
@@
pair<int, int> DecodeTrace::v_extents() const
void DecodeTrace::paint_back(QPainter &p, int left, int right)
{
Trace::paint_back(p, left, right);
void DecodeTrace::paint_back(QPainter &p, int left, int right)
{
Trace::paint_back(p, left, right);
- paint_axis(p, get_y(), left, right);
+ paint_axis(p, get_
visual_
y(), left, right);
}
void DecodeTrace::paint_mid(QPainter &p, int left, int right)
}
void DecodeTrace::paint_mid(QPainter &p, int left, int right)
@@
-191,7
+191,7
@@
void DecodeTrace::paint_mid(QPainter &p, int left, int right)
}
// Iterate through the rows
}
// Iterate through the rows
- int y = get_y();
+ int y = get_
visual_
y();
pair<uint64_t, uint64_t> sample_range = get_sample_range(left, right);
assert(_decoder_stack);
pair<uint64_t, uint64_t> sample_range = get_sample_range(left, right);
assert(_decoder_stack);
@@
-236,7
+236,7
@@
void DecodeTrace::paint_fore(QPainter &p, int left, int right)
for (size_t i = 0; i < _visible_rows.size(); i++)
{
for (size_t i = 0; i < _visible_rows.size(); i++)
{
- const int y = i * _row_height + get_y();
+ const int y = i * _row_height + get_
visual_
y();
p.setPen(QPen(Qt::NoPen));
p.setBrush(QApplication::palette().brush(QPalette::WindowText));
p.setPen(QPen(Qt::NoPen));
p.setBrush(QApplication::palette().brush(QPalette::WindowText));
@@
-443,7
+443,7
@@
void DecodeTrace::draw_range(const pv::data::decode::Annotation &a, QPainter &p,
void DecodeTrace::draw_error(QPainter &p, const QString &message,
int left, int right)
{
void DecodeTrace::draw_error(QPainter &p, const QString &message,
int left, int right)
{
- const int y = get_y();
+ const int y = get_
visual_
y();
p.setPen(ErrorBgColour.darker());
p.setBrush(ErrorBgColour);
p.setPen(ErrorBgColour.darker());
p.setBrush(ErrorBgColour);
@@
-499,7
+499,7
@@
void DecodeTrace::draw_unresolved_period(QPainter &p, int h, int left,
if (sample_count == samples_decoded)
return;
if (sample_count == samples_decoded)
return;
- const int y = get_y();
+ const int y = get_
visual_
y();
tie(pixels_offset, samples_per_pixel) =
get_pixels_offset_samples_per_pixel();
tie(pixels_offset, samples_per_pixel) =
get_pixels_offset_samples_per_pixel();
@@
-562,7
+562,8
@@
int DecodeTrace::get_row_at_point(const QPoint &point)
if (!_row_height)
return -1;
if (!_row_height)
return -1;
- const int row = (point.y() - get_y() + _row_height / 2) / _row_height;
+ const int row = (point.y() - get_visual_y() + _row_height / 2) /
+ _row_height;
if (row < 0 || row >= (int)_visible_rows.size())
return -1;
if (row < 0 || row >= (int)_visible_rows.size())
return -1;
@@
-630,8
+631,9
@@
void DecodeTrace::hover_point_changed()
// decode trace, not below.
hp.setX(hp.x() - (text_size.width() / 2) - padding);
// decode trace, not below.
hp.setX(hp.x() - (text_size.width() / 2) - padding);
- hp.setY(get_y() - (_row_height / 2) + (hover_row * _row_height)
- - _row_height - text_size.height());
+ hp.setY(get_visual_y() - (_row_height / 2) +
+ (hover_row * _row_height) -
+ _row_height - text_size.height());
QToolTip::showText(view->viewport()->mapToGlobal(hp), ann);
}
QToolTip::showText(view->viewport()->mapToGlobal(hp), ann);
}
diff --git
a/pv/view/header.cpp
b/pv/view/header.cpp
index 514a3e49694e348dc08123749da90ff0290d1f67..2264bc2c945f96b41ea88d387af4c5221d3a8cb9 100644
(file)
--- a/
pv/view/header.cpp
+++ b/
pv/view/header.cpp
@@
-101,7
+101,7
@@
void Header::show_popup(const shared_ptr<RowItem> &item)
if (!p)
return;
if (!p)
return;
- const QPoint pt(width() - BaselineOffset, item->get_y());
+ const QPoint pt(width() - BaselineOffset, item->get_
visual_
y());
p->set_position(mapToGlobal(pt), Popup::Right);
p->show();
}
p->set_position(mapToGlobal(pt), Popup::Right);
p->show();
}
@@
-118,7
+118,7
@@
void Header::paintEvent(QPaintEvent*)
stable_sort(row_items.begin(), row_items.end(),
[](const shared_ptr<RowItem> &a, const shared_ptr<RowItem> &b) {
stable_sort(row_items.begin(), row_items.end(),
[](const shared_ptr<RowItem> &a, const shared_ptr<RowItem> &b) {
- return a->v
_offset() < b->
v_offset(); });
+ return a->v
isual_v_offset() < b->visual_
v_offset(); });
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
@@
-246,7
+246,7
@@
void Header::mouseMoveEvent(QMouseEvent *event)
for (std::shared_ptr<RowItem> r : _view)
if (r->dragging()) {
for (std::shared_ptr<RowItem> r : _view)
if (r->dragging()) {
- r->
set
_v_offset(r->drag_point().y() + delta);
+ r->
force_to
_v_offset(r->drag_point().y() + delta);
// Ensure the trace is selected
r->select();
// Ensure the trace is selected
r->select();
diff --git
a/pv/view/logicsignal.cpp
b/pv/view/logicsignal.cpp
index 37445d96072133e64fe3d90d1798e4840a7d2f9d..75a125a7eae58f334427edd86b73f5531058b825 100644
(file)
--- a/
pv/view/logicsignal.cpp
+++ b/
pv/view/logicsignal.cpp
@@
-132,7
+132,7
@@
std::pair<int, int> LogicSignal::v_extents() const
void LogicSignal::paint_back(QPainter &p, int left, int right)
{
if (_channel->enabled())
void LogicSignal::paint_back(QPainter &p, int left, int right)
{
if (_channel->enabled())
- paint_axis(p, get_y(), left, right);
+ paint_axis(p, get_
visual_
y(), left, right);
}
void LogicSignal::paint_mid(QPainter &p, int left, int right)
}
void LogicSignal::paint_mid(QPainter &p, int left, int right)
@@
-148,11
+148,11
@@
void LogicSignal::paint_mid(QPainter &p, int left, int right)
assert(right >= left);
assert(_owner);
assert(right >= left);
assert(_owner);
- const int y = get_y();
+ const int y = get_
visual_
y();
const View *const view = _owner->view();
assert(view);
const View *const view = _owner->view();
assert(view);
-
+
const double scale = view->scale();
assert(scale > 0);
const double scale = view->scale();
assert(scale > 0);
diff --git
a/pv/view/rowitem.cpp
b/pv/view/rowitem.cpp
index d850e321fe4fdcf0572065e268d6393fa3af8982..120a00a39d1cd0a1fb478c5facf446d86e8722ad 100644
(file)
--- a/
pv/view/rowitem.cpp
+++ b/
pv/view/rowitem.cpp
@@
-29,18
+29,37
@@
namespace view {
RowItem::RowItem() :
_owner(NULL),
RowItem::RowItem() :
_owner(NULL),
- _v_offset(0)
+ _layout_v_offset(0),
+ _visual_v_offset(0)
{
}
{
}
-int RowItem::v_offset() const
+int RowItem::
layout_
v_offset() const
{
{
- return _v_offset;
+ return _
layout_
v_offset;
}
}
-void RowItem::set_v_offset(int v_offset)
+void RowItem::set_
layout_
v_offset(int v_offset)
{
{
- _v_offset = v_offset;
+ if (_layout_v_offset == v_offset)
+ return;
+
+ _layout_v_offset = v_offset;
+}
+
+int RowItem::visual_v_offset() const
+{
+ return _visual_v_offset;
+}
+
+void RowItem::set_visual_v_offset(int v_offset)
+{
+ _visual_v_offset = v_offset;
+}
+
+void RowItem::force_to_v_offset(int v_offset)
+{
+ _layout_v_offset = _visual_v_offset = v_offset;
}
RowItemOwner* RowItem::owner() const
}
RowItemOwner* RowItem::owner() const
@@
-50,19
+69,24
@@
RowItemOwner* RowItem::owner() const
void RowItem::set_owner(RowItemOwner *owner)
{
void RowItem::set_owner(RowItemOwner *owner)
{
- assert((_owner && !owner) || (!_owner && owner));
+ assert(_owner || owner);
+
+ if (_owner)
+ _visual_v_offset += _owner->owner_v_offset();
_owner = owner;
_owner = owner;
+ if (_owner)
+ _visual_v_offset -= _owner->owner_v_offset();
}
}
-int RowItem::get_y() const
+int RowItem::get_
visual_
y() const
{
assert(_owner);
{
assert(_owner);
- return _v_offset + _owner->owner_v_offset();
+ return _v
isual_v
_offset + _owner->owner_v_offset();
}
QPoint RowItem::point() const
{
}
QPoint RowItem::point() const
{
- return QPoint(0, v_offset());
+ return QPoint(0, v
isual_v
_offset());
}
void RowItem::paint_back(QPainter &p, int left, int right)
}
void RowItem::paint_back(QPainter &p, int left, int right)
diff --git
a/pv/view/rowitem.h
b/pv/view/rowitem.h
index 1aafca4be3fbfee81b663532e9e6a887601d6f12..aba7260b0a814797c9ec689bedd16e663216056f 100644
(file)
--- a/
pv/view/rowitem.h
+++ b/
pv/view/rowitem.h
@@
-49,12
+49,27
@@
public:
/**
* Gets the vertical layout offset of this signal.
*/
/**
* Gets the vertical layout offset of this signal.
*/
- int v_offset() const;
+ int
layout_
v_offset() const;
/**
* Sets the vertical layout offset of this signal.
*/
/**
* Sets the vertical layout offset of this signal.
*/
- void set_v_offset(int v_offset);
+ void set_layout_v_offset(int v_offset);
+
+ /**
+ * Gets the vertical visual offset of this signal.
+ */
+ int visual_v_offset() const;
+
+ /**
+ * Sets the vertical visual offset of this signal.
+ */
+ void set_visual_v_offset(int v_offset);
+
+ /**
+ * Sets the visual and layout offset of this signal.
+ */
+ void force_to_v_offset(int v_offset);
/**
* Gets the owner this trace in the view trace hierachy.
/**
* Gets the owner this trace in the view trace hierachy.
@@
-68,9
+83,9
@@
public:
void set_owner(pv::view::RowItemOwner *owner);
/**
void set_owner(pv::view::RowItemOwner *owner);
/**
- * Gets the y-offset of the axis.
+ * Gets the
visual
y-offset of the axis.
*/
*/
- int get_y() const;
+ int get_
visual_
y() const;
/**
* Gets the drag point of the row item.
/**
* Gets the drag point of the row item.
@@
-133,7
+148,8
@@
Q_SIGNALS:
protected:
pv::view::RowItemOwner *_owner;
protected:
pv::view::RowItemOwner *_owner;
- int _v_offset;
+ int _layout_v_offset;
+ int _visual_v_offset;
};
} // namespace view
};
} // namespace view
diff --git
a/pv/view/rowitemowner.cpp
b/pv/view/rowitemowner.cpp
index 0fa230ab4e3fb47a609c105cb1de0dc91ad4d277..03f0e68d3ae52e5a0451f80c66683052b470e460 100644
(file)
--- a/
pv/view/rowitemowner.cpp
+++ b/
pv/view/rowitemowner.cpp
@@
-96,7
+96,7
@@
pair<int, int> RowItemOwner::v_extents() const
if (!r->enabled())
continue;
if (!r->enabled())
continue;
- const int child_offset = r->v_offset();
+ const int child_offset = r->
layout_
v_offset();
const pair<int, int> child_extents = r->v_extents();
extents.first = min(child_extents.first + child_offset,
extents.first);
const pair<int, int> child_extents = r->v_extents();
extents.first = min(child_extents.first + child_offset,
extents.first);
diff --git
a/pv/view/trace.cpp
b/pv/view/trace.cpp
index 3b92abe484c14efd5964789eed731077fed21344..166fc1abc6831beb966adf001f7bdc92024a1356 100644
(file)
--- a/
pv/view/trace.cpp
+++ b/
pv/view/trace.cpp
@@
-70,7
+70,7
@@
void Trace::set_colour(QColor colour)
void Trace::paint_label(QPainter &p, int right, bool hover)
{
void Trace::paint_label(QPainter &p, int right, bool hover)
{
- const int y = get_y();
+ const int y = get_
visual_
y();
p.setBrush(_colour);
p.setBrush(_colour);
@@
-157,7
+157,7
@@
QRectF Trace::label_rect(int right) const
const float half_height = label_size.height() / 2;
return QRectF(
right - half_height - label_size.width() - 0.5,
const float half_height = label_size.height() / 2;
return QRectF(
right - half_height - label_size.width() - 0.5,
- get_y() + 0.5f - half_height,
+ get_
visual_
y() + 0.5f - half_height,
label_size.width() + half_height,
label_size.height());
}
label_size.width() + half_height,
label_size.height());
}
diff --git
a/pv/view/tracegroup.cpp
b/pv/view/tracegroup.cpp
index f5263e3facc92ddc5805eaa92ac7f757e145f633..4404b1cd866fe9e160e05a676b9fd3423c3fddd4 100644
(file)
--- a/
pv/view/tracegroup.cpp
+++ b/
pv/view/tracegroup.cpp
@@
-152,7
+152,7
@@
pv::widgets::Popup* TraceGroup::create_popup(QWidget *parent)
int TraceGroup::owner_v_offset() const
{
int TraceGroup::owner_v_offset() const
{
- return
v_offset() + _owner->owner_v_offset()
;
+ return
_owner ? layout_v_offset() + _owner->owner_v_offset() : 0
;
}
void TraceGroup::update_viewport()
}
void TraceGroup::update_viewport()
@@
-167,10
+167,8
@@
void TraceGroup::on_ungroup()
child_items().begin(), child_items().end());
clear_child_items();
child_items().begin(), child_items().end());
clear_child_items();
- for (shared_ptr<RowItem> r : items)
{
+ for (shared_ptr<RowItem> r : items)
_owner->add_child_item(r);
_owner->add_child_item(r);
- r->set_v_offset(r->v_offset() + v_offset());
- }
_owner->remove_child_item(shared_from_this());
appearance_changed();
_owner->remove_child_item(shared_from_this());
appearance_changed();
diff --git
a/pv/view/view.cpp
b/pv/view/view.cpp
index 80ade0d23f5bccd573bb5385d064a1d40d9aec04..d48bbabebd4088e0b49128e00f5152577350b6b6 100644
(file)
--- a/
pv/view/view.cpp
+++ b/
pv/view/view.cpp
@@
-503,7
+503,7
@@
void View::signals_changed()
const pair<int, int> extents = r->v_extents();
if (r->enabled())
offset += -extents.first;
const pair<int, int> extents = r->v_extents();
if (r->enabled())
offset += -extents.first;
- r->
set
_v_offset(offset);
+ r->
force_to
_v_offset(offset);
if (r->enabled())
offset += extents.second;
}
if (r->enabled())
offset += extents.second;
}
diff --git
a/pv/view/viewport.cpp
b/pv/view/viewport.cpp
index 82d13c92b985985efa7c9033760d80307c181bb6..c85f915a591eba05e36791f870509da3b943eebe 100644
(file)
--- a/
pv/view/viewport.cpp
+++ b/
pv/view/viewport.cpp
@@
-70,7
+70,7
@@
void Viewport::paintEvent(QPaintEvent*)
vector< shared_ptr<RowItem> > row_items(_view.begin(), _view.end());
stable_sort(row_items.begin(), row_items.end(),
[](const shared_ptr<RowItem> &a, const shared_ptr<RowItem> &b) {
vector< shared_ptr<RowItem> > row_items(_view.begin(), _view.end());
stable_sort(row_items.begin(), row_items.end(),
[](const shared_ptr<RowItem> &a, const shared_ptr<RowItem> &b) {
- return a->v
_offset() < b->
v_offset(); });
+ return a->v
isual_v_offset() < b->visual_
v_offset(); });
QPainter p(this);
p.setRenderHint(QPainter::Antialiasing);
QPainter p(this);
p.setRenderHint(QPainter::Antialiasing);