X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fview%2Fheader.cpp;h=ca5df96fca250dc23666bbdcf59f644a07083139;hp=dec5c20cbabfad042ec785886a2a2be9ca747e40;hb=d7c0ca4a965c5f9cb2ae9aea584bb2547f4baca1;hpb=f3f98f8fade1cffb28161da2710dfc9def5e6d74;ds=sidebyside diff --git a/pv/view/header.cpp b/pv/view/header.cpp index dec5c20c..ca5df96f 100644 --- a/pv/view/header.cpp +++ b/pv/view/header.cpp @@ -42,6 +42,8 @@ using namespace std; namespace pv { namespace view { +const int Header::Padding = 12; + Header::Header(View &parent) : MarginWidget(parent), _dragging(false) @@ -56,6 +58,19 @@ Header::Header(View &parent) : this, SLOT(on_signals_moved())); } +QSize Header::sizeHint() const +{ + int max_width = 0; + + const vector< shared_ptr > traces(_view.get_traces()); + BOOST_FOREACH(shared_ptr t, traces) { + assert(t); + max_width = max(max_width, (int)t->get_label_rect(0).width()); + } + + return QSize(max_width + Padding, 0); +} + shared_ptr Header::get_mouse_over_trace(const QPoint &pt) { const int w = width(); @@ -261,7 +276,7 @@ void Header::on_signals_changed() connect(t.get(), SIGNAL(visibility_changed()), this, SLOT(update())); connect(t.get(), SIGNAL(text_changed()), - this, SLOT(update())); + this, SLOT(on_trace_text_changed())); connect(t.get(), SIGNAL(colour_changed()), this, SLOT(update())); } @@ -272,6 +287,11 @@ void Header::on_signals_moved() update(); } +void Header::on_trace_text_changed() +{ + update(); + geometry_updated(); +} } // namespace view } // namespace pv