X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Fview%2Fview.cpp;h=18ce679df877f030b2f35a11e208f9ef72e63bcd;hb=269528f55e7fd77f762c2008d257921cd30e1519;hp=f727cc33b540b4fddc18b77f154a08051d3a78d4;hpb=d1e7d82c6327c15f38d66602e65c4d3abe114df7;p=pulseview.git diff --git a/pv/view/view.cpp b/pv/view/view.cpp index f727cc3..18ce679 100644 --- a/pv/view/view.cpp +++ b/pv/view/view.cpp @@ -18,7 +18,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#ifdef ENABLE_DECODE #include +#endif #include #include @@ -52,9 +54,6 @@ namespace view { const double View::MaxScale = 1e9; const double View::MinScale = 1e-15; -const int View::LabelMarginWidth = 70; -const int View::RulerHeight = 30; - const int View::MaxScrollValue = INT_MAX / 2; const int View::SignalHeight = 30; @@ -95,6 +94,8 @@ View::View(SigSession &session, QWidget *parent) : connect(_cursors.second().get(), SIGNAL(time_changed()), this, SLOT(marker_time_changed())); + connect(_header, SIGNAL(geometry_updated()), + this, SLOT(on_geometry_updated())); connect(_header, SIGNAL(signals_moved()), this, SLOT(on_signals_moved())); @@ -108,7 +109,6 @@ View::View(SigSession &session, QWidget *parent) : connect(_ruler, SIGNAL(selection_changed()), this, SIGNAL(selection_changed())); - setViewportMargins(LabelMarginWidth, RulerHeight, 0, 0); setViewport(_viewport); _viewport->installEventFilter(this); @@ -143,7 +143,7 @@ int View::v_offset() const void View::zoom(double steps) { - zoom(steps, (width() - LabelMarginWidth) / 2); + zoom(steps, _viewport->width() / 2); } void View::zoom(double steps, int offset) @@ -238,14 +238,20 @@ vector< shared_ptr > View::get_traces() const { const vector< shared_ptr > sigs( session().get_signals()); +#ifdef ENABLE_DECODE const vector< shared_ptr > decode_sigs( session().get_decode_signals()); vector< shared_ptr > traces( sigs.size() + decode_sigs.size()); +#else + vector< shared_ptr > traces(sigs.size()); +#endif vector< shared_ptr >::iterator i = traces.begin(); i = copy(sigs.begin(), sigs.end(), i); +#ifdef ENABLE_DECODE i = copy(decode_sigs.begin(), decode_sigs.end(), i); +#endif stable_sort(traces.begin(), traces.end(), compare_trace_v_offsets); return traces; @@ -381,6 +387,17 @@ void View::update_scroll() areaSize.height()); } +void View::update_layout() +{ + setViewportMargins(_header->sizeHint().width(), + _ruler->sizeHint().height(), 0, 0); + _ruler->setGeometry(_viewport->x(), 0, + _viewport->width(), _viewport->y()); + _header->setGeometry(0, _viewport->y(), + _viewport->x(), _viewport->height()); + update_scroll(); +} + bool View::compare_trace_v_offsets(const shared_ptr &a, const shared_ptr &b) { @@ -432,11 +449,7 @@ bool View::viewportEvent(QEvent *e) void View::resizeEvent(QResizeEvent*) { - _ruler->setGeometry(_viewport->x(), 0, - _viewport->width(), _viewport->y()); - _header->setGeometry(0, _viewport->y(), - _viewport->x(), _viewport->height()); - update_scroll(); + update_layout(); } void View::h_scroll_value_changed(int value) @@ -474,6 +487,7 @@ void View::signals_changed() offset += SignalHeight + 2 * SignalMargin; } + update_layout(); normalize_layout(); } @@ -510,5 +524,10 @@ void View::on_signals_moved() signals_moved(); } +void View::on_geometry_updated() +{ + update_layout(); +} + } // namespace view } // namespace pv