From: Joel Holdsworth Date: Sun, 9 Sep 2012 11:21:28 +0000 (+0100) Subject: Made pv::view::View::zoom public X-Git-Tag: pulseview-0.1.0~303 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=17c0f398438df75dc5547d630e7d334e5de3c66a;p=pulseview.git Made pv::view::View::zoom public --- diff --git a/pv/view/view.cpp b/pv/view/view.cpp index 4e0fed06..95b94cf1 100644 --- a/pv/view/view.cpp +++ b/pv/view/view.cpp @@ -96,6 +96,19 @@ void View::zoom(double steps) zoom(steps, (width() - LabelMarginWidth) / 2); } +void View::zoom(double steps, int offset) +{ + const double cursor_offset = _offset + _scale * offset; + _scale *= pow(3.0/2.0, -steps); + _scale = max(min(_scale, MaxScale), MinScale); + _offset = cursor_offset - _scale * offset; + + _ruler->update(); + _viewport->update(); + update_scroll(); +} + + void View::set_scale_offset(double scale, double offset) { _scale = scale; @@ -132,18 +145,6 @@ void View::update_scroll() _viewport->get_total_height() - areaSize.height()); } -void View::zoom(double steps, int offset) -{ - const double cursor_offset = _offset + _scale * offset; - _scale *= pow(3.0/2.0, -steps); - _scale = max(min(_scale, MaxScale), MinScale); - _offset = cursor_offset - _scale * offset; - - _ruler->update(); - _viewport->update(); - update_scroll(); -} - bool View::viewportEvent(QEvent *e) { switch(e->type()) { diff --git a/pv/view/view.h b/pv/view/view.h index d7fc6356..0413b3d7 100644 --- a/pv/view/view.h +++ b/pv/view/view.h @@ -57,14 +57,13 @@ public: int v_offset() const; void zoom(double steps); + void zoom(double steps, int offset); void set_scale_offset(double scale, double offset); private: void update_scroll(); - void zoom(double steps, int offset); - private: bool viewportEvent(QEvent *e);