Turtles all the way down
[ipdf/code.git] / src / view.cpp
index 1bd5730..53511d2 100644 (file)
@@ -24,7 +24,7 @@ using namespace std;
  * @param bounds - Initial bounds of the View
  * @param colour - Colour to use for rendering this view. TODO: Make sure this actually works, or just remove it
  */
-View::View(Document & document, Screen & screen, const Rect & bounds, const Colour & colour)
+View::View(Document & document, Screen & screen, const VRect & bounds, const Colour & colour)
        : m_use_gpu_transform(USE_GPU_TRANSFORM), m_use_gpu_rendering(USE_GPU_RENDERING), m_bounds_dirty(true), m_buffer_dirty(true), 
                m_render_dirty(true), m_document(document), m_screen(screen), m_cached_display(), m_bounds(bounds), m_colour(colour), m_bounds_ubo(), 
                m_objbounds_vbo(), m_object_renderers(NUMBER_OF_OBJECT_TYPES), m_cpu_rendering_pixels(NULL),
@@ -96,10 +96,8 @@ void View::Translate(Real x, Real y)
                #endif
        m_document.TranslateObjects(-x, -y, type);
        #endif
-       x *= m_bounds.w;
-       y *= m_bounds.h;
-       m_bounds.x += x;
-       m_bounds.y += y;
+       m_bounds.x += m_bounds.w*VReal(x);
+       m_bounds.y += m_bounds.h*VReal(y);
        //Debug("View Bounds => %s", m_bounds.Str().c_str());
 
        
@@ -143,19 +141,19 @@ void View::ScaleAroundPoint(Real x, Real y, Real scale_amount)
        #endif
        m_document.ScaleObjectsAboutPoint(x, y, scale_amount, type);
        #endif
-       x *= m_bounds.w;
-       y *= m_bounds.h;
-       x += m_bounds.x;
-       y += m_bounds.y;
+       VReal vx = m_bounds.w * VReal(x);
+       VReal vy = m_bounds.h * VReal(y);
+       vx += m_bounds.x;
+       vy += m_bounds.y;
        
-       Real top = y - m_bounds.y;
-       Real left = x - m_bounds.x;
+       VReal top = vy - m_bounds.y;
+       VReal left = vx - m_bounds.x;
        
        top *= scale_amount;
        left *= scale_amount;
        
-       m_bounds.x = x - left;
-       m_bounds.y = y - top;
+       m_bounds.x = vx - left;
+       m_bounds.y = vy - top;
        m_bounds.w *= scale_amount;
        m_bounds.h *= scale_amount;
        //Debug("Scale at {%s, %s} by %s View Bounds => %s", x.Str().c_str(), y.Str().c_str(), scale_amount.Str().c_str(), m_bounds.Str().c_str());
@@ -174,7 +172,7 @@ Rect View::TransformToViewCoords(const Rect& inp) const
        #ifdef TRANSFORM_OBJECTS_NOT_VIEW
                return inp;
        #endif
-       return TransformRectCoordinates(m_bounds, inp);
+       return TransformRectCoordinates(m_bounds.Convert<Real>(), inp);
 }
 
 /**

UCC git Repository :: git.ucc.asn.au