From: Soeren Apel Date: Tue, 11 Nov 2014 20:27:13 +0000 (+0100) Subject: DecodeTrace: Turn row_height and text_height into class members X-Git-Tag: pulseview-0.3.0~502 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=ef40ad83ac7e2cb12b4ecfede4564ba3ef416905;p=pulseview.git DecodeTrace: Turn row_height and text_height into class members --- diff --git a/pv/view/decodetrace.cpp b/pv/view/decodetrace.cpp index c8a20dc3..61653658 100644 --- a/pv/view/decodetrace.cpp +++ b/pv/view/decodetrace.cpp @@ -116,6 +116,8 @@ DecodeTrace::DecodeTrace(pv::SigSession &session, decoder_stack->stack().front()->decoder()->name)), _session(session), _decoder_stack(decoder_stack), + _text_height(0), + _row_height(0), _delete_mapper(this), _show_hide_mapper(this) { @@ -178,9 +180,9 @@ void DecodeTrace::paint_mid(QPainter &p, int left, int right) samples_per_pixel, 0.0); QFontMetrics m(QApplication::font()); - const int text_height = m.boundingRect(QRect(), 0, "Tg").height(); - const int annotation_height = (text_height * 5) / 4; - const int row_height = (text_height * 6) / 4; + _text_height = m.boundingRect(QRect(), 0, "Tg").height(); + _row_height = (_text_height * 6) / 4; + const int annotation_height = (_text_height * 5) / 4; assert(_decoder_stack); const QString err = _decoder_stack->error_message(); @@ -218,7 +220,7 @@ void DecodeTrace::paint_mid(QPainter &p, int left, int right) annotation_height, left, right, samples_per_pixel, pixels_offset, y, base_colour); - y += row_height; + y += _row_height; _cur_row_headings.push_back(row.title()); } @@ -235,13 +237,11 @@ void DecodeTrace::paint_fore(QPainter &p, int left, int right) (void)right; - QFontMetrics m(QApplication::font()); - const int text_height = m.boundingRect(QRect(), 0, "Tg").height(); - const int row_height = (text_height * 6) / 4; + assert(_row_height); for (size_t i = 0; i < _cur_row_headings.size(); i++) { - const int y = i * row_height + get_y(); + const int y = i * _row_height + get_y(); p.setPen(QPen(Qt::NoPen)); p.setBrush(QApplication::palette().brush(QPalette::WindowText)); @@ -256,8 +256,8 @@ void DecodeTrace::paint_fore(QPainter &p, int left, int right) p.drawPolygon(points, countof(points)); } - const QRect r(left + ArrowSize * 2, y - row_height / 2, - right - left, row_height); + const QRect r(left + ArrowSize * 2, y - _row_height / 2, + right - left, _row_height); const QString h(_cur_row_headings[i]); const int f = Qt::AlignLeft | Qt::AlignVCenter | Qt::TextDontClip; diff --git a/pv/view/decodetrace.h b/pv/view/decodetrace.h index b93aa01f..420961ad 100644 --- a/pv/view/decodetrace.h +++ b/pv/view/decodetrace.h @@ -180,6 +180,7 @@ private: std::vector _decoder_forms; std::vector _cur_row_headings; + int _text_height, _row_height; QSignalMapper _delete_mapper, _show_hide_mapper; };