#include "view.h"
#include "viewport.h"
+#include "signal.h"
#include "../sigsession.h"
-#include "../signal.h"
#include <QMouseEvent>
setMouseTracking(true);
setAutoFillBackground(true);
setBackgroundRole(QPalette::Base);
+
+ connect(&_view, SIGNAL(signals_moved()),
+ this, SLOT(on_signals_moved()));
}
int Viewport::get_total_height() const
{
- int height = 0;
+ int h = 0;
BOOST_FOREACH(const shared_ptr<Signal> s,
_view.session().get_signals()) {
assert(s);
- height += View::SignalHeight;
+ h = max(s->get_v_offset() + View::SignalHeight, h);
}
- return height;
+ return h;
}
void Viewport::paintEvent(QPaintEvent *event)
draw_cursors_background(p);
// Plot the signal
- int offset = -_view.v_offset();
+ const int v_offset = _view.v_offset();
BOOST_FOREACH(const shared_ptr<Signal> s, sigs)
{
assert(s);
- const QRect signal_rect(0, offset,
+ const QRect signal_rect(0, s->get_v_offset() - v_offset,
width(), View::SignalHeight);
s->paint(p, signal_rect, _view.scale(), _view.offset());
-
- offset += View::SignalHeight;
}
draw_cursors_foreground(p);
cursors.second.paint(p, r);
}
+void Viewport::on_signals_moved()
+{
+ update();
+}
+
} // namespace view
} // namespace pv