X-Git-Url: https://git.ucc.asn.au/?p=ipdf%2Fcode.git;a=blobdiff_plain;f=src%2Fview.cpp;h=80f49861b116db216258cf96e9349370704460eb;hp=f78ec40e4c5c8d6648d0d9400878420cd8cb2de8;hb=a269b3e29535918a390f448829a3459e4853425b;hpb=e6c66a8e58f1dda071e6fc4abed39afe49d348f8 diff --git a/src/view.cpp b/src/view.cpp index f78ec40..80f4986 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;