X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fview%2Fheader.cpp;h=a7902521216a90655ba708669ab5b36b2886f52b;hp=dec5c20cbabfad042ec785886a2a2be9ca747e40;hb=8bd26d8b9c831b509ee3241ea4dac6f50c023622;hpb=5ed1adf555e0f0fb36d5b4b36f2be17745b5c8ae diff --git a/pv/view/header.cpp b/pv/view/header.cpp index dec5c20c..a7902521 100644 --- a/pv/view/header.cpp +++ b/pv/view/header.cpp @@ -36,12 +36,17 @@ #include -using namespace boost; -using namespace std; +using boost::shared_ptr; +using std::max; +using std::make_pair; +using std::pair; +using std::vector; namespace pv { namespace view { +const int Header::Padding = 12; + Header::Header(View &parent) : MarginWidget(parent), _dragging(false) @@ -54,6 +59,23 @@ 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 +{ + 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) @@ -261,7 +283,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 +294,11 @@ void Header::on_signals_moved() update(); } +void Header::on_trace_text_changed() +{ + update(); + geometry_updated(); +} } // namespace view } // namespace pv