X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;ds=sidebyside;f=src%2Fview.cpp;h=969bbb366c5ffe18697d8fc04ae88eebd7299af5;hb=e12f1118cca4997c895c5ece32900be74f59ecdd;hp=ed62704fd66b5864c071d769973b7aeb72fe43d4;hpb=32cd67ec48271c176eba218e082fcf5824aa8e6c;p=ipdf%2Fcode.git diff --git a/src/view.cpp b/src/view.cpp index ed62704..969bbb3 100644 --- a/src/view.cpp +++ b/src/view.cpp @@ -5,6 +5,36 @@ using namespace IPDF; 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; @@ -27,7 +57,7 @@ void View::Render() 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)); @@ -39,7 +69,7 @@ void View::Render() 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);