From: David Gow Date: Wed, 9 Apr 2014 12:17:14 +0000 (+0800) Subject: Merge branch 'master' of git.ucc.asn.au:ipdf/code X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;ds=inline;h=e12f1118cca4997c895c5ece32900be74f59ecdd;hp=-c;p=ipdf%2Fcode.git Merge branch 'master' of git.ucc.asn.au:ipdf/code --- e12f1118cca4997c895c5ece32900be74f59ecdd diff --combined src/view.cpp index 4425ebe,80f4986..969bbb3 --- a/src/view.cpp +++ b/src/view.cpp @@@ -7,10 -7,34 +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; @@@ -33,7 -57,7 +57,7 @@@ glBegin(GL_QUADS); for (unsigned id = 0; id < m_document.ObjectCount(); ++id) { - if (m_document.m_objects.types[id] == RECT_FILLED) + if (m_document.m_objects.types[id] != RECT_FILLED) continue; Rect obj_bounds = m_document.m_objects.bounds[id]; glVertex2f(Float(obj_bounds.x), Float(obj_bounds.y)); @@@ -45,7 -69,7 +69,7 @@@ for (unsigned id = 0; id < m_document.ObjectCount(); ++id) { - if (m_document.m_objects.types[id] == RECT_OUTLINE) + if (m_document.m_objects.types[id] != RECT_OUTLINE) continue; Rect obj_bounds = m_document.m_objects.bounds[id]; glBegin(GL_LINE_LOOP);