]> sigrok.org Git - pulseview.git/commitdiff
TraceGroup: Implemented label_rect
authorJoel Holdsworth <redacted>
Tue, 26 Aug 2014 08:17:21 +0000 (09:17 +0100)
committerJoel Holdsworth <redacted>
Wed, 19 Nov 2014 10:23:02 +0000 (10:23 +0000)
pv/view/header.cpp
pv/view/tracegroup.cpp
pv/view/tracegroup.h

index 50eefc43cd765b1d0a300fb7fb622549b94044c8..f3849fbe3f1db3ad3005a14273a1a00a9ea434ec 100644 (file)
@@ -64,13 +64,11 @@ Header::Header(View &parent) :
 
 QSize Header::sizeHint() const
 {
-       int max_width = 0;
-
+       QRectF max_rect(-Padding, 0, Padding, 0);
        for (auto &i : _view)
                if (i->enabled())
-                       max_width = max(max_width, (int)i->label_rect(0).width());
-
-       return QSize(max_width + Padding + BaselineOffset, 0);
+                       max_rect = max_rect.united(i->label_rect(0));
+       return QSize(max_rect.width() + Padding + BaselineOffset, 0);
 }
 
 shared_ptr<RowItem> Header::get_mouse_over_row_item(const QPoint &pt)
index f99b19666ba27892902a97fde42801a47a8ddca2..9d0465fc3c863421f69bec5eaf5740b7629e83f2 100644 (file)
@@ -29,6 +29,9 @@ using std::shared_ptr;
 namespace pv {
 namespace view {
 
+const int TraceGroup::Padding = 8;
+const int TraceGroup::Width = 12;
+
 TraceGroup::~TraceGroup()
 {
        _owner = nullptr;
@@ -74,8 +77,13 @@ void TraceGroup::paint_label(QPainter &p, int right, bool hover)
 
 QRectF TraceGroup::label_rect(int right) const
 {
-       (void)right;
-       return QRectF();
+       QRectF rect;
+       for (const shared_ptr<RowItem> r : child_items())
+               if (r)
+                       rect = rect.united(r->label_rect(right));
+
+       return QRectF(rect.x() - Width - Padding, rect.y(),
+               Width, rect.height());
 }
 
 bool TraceGroup::pt_in_label_rect(int left, int right, const QPoint &point)
index 0d246cee3c05471c88dbe4f99425eafcea395230..21298dcb01e4d10f09423289a2a98f4ba0cb8ad7 100644 (file)
@@ -31,6 +31,10 @@ class TraceGroup : public RowItem, public RowItemOwner
 {
        Q_OBJECT
 
+private:
+       static const int Padding;
+       static const int Width;
+
 public:
        /**
         * Virtual destructor