]> sigrok.org Git - pulseview.git/blobdiff - pv/view/header.cpp
Header: Invisible traces shouldn't influence the width.
[pulseview.git] / pv / view / header.cpp
index af67abddd899f401b01eeb3d8665e271f959547c..e7bfcbf01a1df5e5d6febc762a8219c78fc4b3b6 100644 (file)
@@ -59,6 +59,10 @@ Header::Header(View &parent) :
 
        connect(&_view, SIGNAL(signals_moved()),
                this, SLOT(on_signals_moved()));
+
+       // Trigger the initial event manually. The default device has signals
+       // which were created before this object came into being
+       on_signals_changed();
 }
 
 QSize Header::sizeHint() const
@@ -68,7 +72,10 @@ QSize Header::sizeHint() const
        const vector< shared_ptr<Trace> > traces(_view.get_traces());
        BOOST_FOREACH(shared_ptr<Trace> t, traces) {
                assert(t);
-               max_width = max(max_width, (int)t->get_label_rect(0).width());
+
+               if (t->enabled()) {
+                       max_width = max(max_width, (int)t->get_label_rect(0).width());
+               }
        }
 
        return QSize(max_width + Padding, 0);
@@ -277,9 +284,9 @@ void Header::on_signals_changed()
        BOOST_FOREACH(shared_ptr<Trace> t, traces) {
                assert(t);
                connect(t.get(), SIGNAL(visibility_changed()),
-                       this, SLOT(update()));
+                       this, SLOT(on_trace_changed()));
                connect(t.get(), SIGNAL(text_changed()),
-                       this, SLOT(on_trace_text_changed()));
+                       this, SLOT(on_trace_changed()));
                connect(t.get(), SIGNAL(colour_changed()),
                        this, SLOT(update()));
        }
@@ -290,7 +297,7 @@ void Header::on_signals_moved()
        update();
 }
 
-void Header::on_trace_text_changed()
+void Header::on_trace_changed()
 {
        update();
        geometry_updated();