From: Joel Holdsworth Date: Mon, 9 Dec 2013 15:49:31 +0000 (+0000) Subject: Moved RulerHeight out of View into Ruler X-Git-Tag: pulseview-0.2.0~189 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=a6c1726e1132f475754482a1194d9ee58cdfb816;p=pulseview.git Moved RulerHeight out of View into Ruler --- diff --git a/pv/view/ruler.cpp b/pv/view/ruler.cpp index bf1507a7..8d7569e3 100644 --- a/pv/view/ruler.cpp +++ b/pv/view/ruler.cpp @@ -43,6 +43,7 @@ using namespace std; namespace pv { namespace view { +const int Ruler::RulerHeight = 30; const int Ruler::MinorTickSubdivision = 4; const int Ruler::ScaleUnits[3] = {1, 2, 5}; @@ -84,6 +85,11 @@ QString Ruler::format_time(double t, unsigned int prefix, return s; } +QSize Ruler::sizeHint() const +{ + return QSize(0, RulerHeight); +} + void Ruler::paintEvent(QPaintEvent*) { using namespace Qt; diff --git a/pv/view/ruler.h b/pv/view/ruler.h index 6f77cb4d..dc4e7bb7 100644 --- a/pv/view/ruler.h +++ b/pv/view/ruler.h @@ -36,6 +36,7 @@ class Ruler : public MarginWidget Q_OBJECT private: + static const int RulerHeight; static const int MinorTickSubdivision; static const int ScaleUnits[3]; @@ -52,6 +53,9 @@ public: static QString format_time(double t, unsigned int prefix, unsigned precision = 0); +public: + QSize sizeHint() const; + private: void paintEvent(QPaintEvent *event); diff --git a/pv/view/view.cpp b/pv/view/view.cpp index c2d97f07..f5f626b3 100644 --- a/pv/view/view.cpp +++ b/pv/view/view.cpp @@ -52,8 +52,6 @@ namespace view { const double View::MaxScale = 1e9; const double View::MinScale = 1e-15; -const int View::RulerHeight = 30; - const int View::MaxScrollValue = INT_MAX / 2; const int View::SignalHeight = 30; @@ -383,7 +381,8 @@ void View::update_scroll() void View::update_layout() { - setViewportMargins(_header->sizeHint().width(), RulerHeight, 0, 0); + setViewportMargins(_header->sizeHint().width(), + _ruler->sizeHint().height(), 0, 0); _ruler->setGeometry(_viewport->x(), 0, _viewport->width(), _viewport->y()); _header->setGeometry(0, _viewport->y(), @@ -480,7 +479,7 @@ void View::signals_changed() offset += SignalHeight + 2 * SignalMargin; } - setViewportMargins(_header->sizeHint().width(), RulerHeight, 0, 0); + update_layout(); normalize_layout(); } diff --git a/pv/view/view.h b/pv/view/view.h index 886aa830..6f1e8728 100644 --- a/pv/view/view.h +++ b/pv/view/view.h @@ -51,8 +51,6 @@ private: static const double MaxScale; static const double MinScale; - static const int RulerHeight; - static const int MaxScrollValue; public: