X-Git-Url: https://git.ucc.asn.au/?p=ipdf%2Fcode.git;a=blobdiff_plain;f=src%2Fview.cpp;h=969bbb366c5ffe18697d8fc04ae88eebd7299af5;hp=4425ebec40267b937fb79a89a38467ed3b058975;hb=e12f1118cca4997c895c5ece32900be74f59ecdd;hpb=37f826f1fd7b64ee1eb68e4036b43e306560828a;ds=sidebyside diff --git a/src/view.cpp b/src/view.cpp index 4425ebe..969bbb3 100644 --- a/src/view.cpp +++ b/src/view.cpp @@ -7,10 +7,34 @@ using namespace std; void View::Translate(Real x, Real y) { + x *= m_bounds.w; + y *= m_bounds.h; m_bounds.x += x; m_bounds.y += y; } +void View::ScaleAroundPoint(Real x, Real y, Real scaleAmt) +{ + // Convert to local coords. + x *= m_bounds.w; + y *= m_bounds.h; + x += m_bounds.x; + y += m_bounds.y; + + Debug("Mouse wheel event %f %f %f\n", Float(x), Float(y), Float(scaleAmt)); + + Real top = y - m_bounds.y; + Real left = x - m_bounds.x; + + top *= scaleAmt; + left *= scaleAmt; + + m_bounds.x = x - left; + m_bounds.y = y - top; + m_bounds.w *= scaleAmt; + m_bounds.h *= scaleAmt; +} + void View::Render() { static bool debug_output_done = false;