* @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),
* Translate the view
* @param x, y - Amount to translate
*/
-void View::Translate(Real x, Real y)
+void View::Translate(VReal x, VReal y)
{
if (!m_use_gpu_transform)
m_buffer_dirty = true;
#ifdef TRANSFORM_BEZIERS_TO_PATH
type = PATH;
#endif
- m_document.TranslateObjects(-x, -y, type);
+ m_document.TranslateObjects(-x.ToDouble(), -y.ToDouble(), type);
#endif
x *= m_bounds.w;
y *= m_bounds.h;
* @param x, y - Coordinates to scale at (eg: Mouse cursor position)
* @param scale_amount - Amount to scale by
*/
-void View::ScaleAroundPoint(Real x, Real y, Real scale_amount)
+void View::ScaleAroundPoint(VReal x, VReal y, VReal scale_amount)
{
// (x0, y0, w, h) -> (x*w - (x*w - x0)*s, y*h - (y*h - y0)*s, w*s, h*s)
x += m_bounds.x;
y += m_bounds.y;
- Real top = y - m_bounds.y;
- Real left = x - m_bounds.x;
+ VReal top = y - m_bounds.y;
+ VReal left = x - m_bounds.x;
top *= scale_amount;
left *= scale_amount;
#ifndef QUADTREE_DISABLED
if (m_bounds_dirty || !m_lazy_rendering)
{
- if ( (m_bounds.x > 1.0 || m_bounds.x < 0.0 || m_bounds.y > 1.0 || m_bounds.y < 0.0 || m_bounds.w > 1.0 || m_bounds.h > 1.0))
+ if ( m_bounds.w > 1.0 || m_bounds.h > 1.0)
{
//TODO: Generate a new parent node.
if (m_document.GetQuadTree().nodes[m_current_quadtree_node].parent != QUADTREE_EMPTY)
m_current_quadtree_node = m_document.GetQuadTree().nodes[m_current_quadtree_node].parent;
}
}
+
+ // TODO: Support generating new parent nodes.
+ if (false && m_document.GetQuadTree().nodes[m_current_quadtree_node].parent != QUADTREE_EMPTY)
+ {
+ if (m_bounds.x < -0.5)
+ {
+ m_bounds = Rect(m_bounds.x + 1, m_bounds.y, m_bounds.w, m_bounds.h);
+ m_current_quadtree_node = m_document.GetQuadTree().GetNeighbour(m_current_quadtree_node, -1, 0, &m_document);
+ }
+ if (m_bounds.y < -0.5)
+ {
+ m_bounds = Rect(m_bounds.x, m_bounds.y + 1, m_bounds.w, m_bounds.h);
+ m_current_quadtree_node = m_document.GetQuadTree().GetNeighbour(m_current_quadtree_node, 0, -1, &m_document);
+ }
+ if (m_bounds.w + m_bounds.x > 0.5)
+ {
+ m_bounds = Rect(m_bounds.x - 1, m_bounds.y, m_bounds.w, m_bounds.h);
+ m_current_quadtree_node = m_document.GetQuadTree().GetNeighbour(m_current_quadtree_node, 1, 0, &m_document);
+ }
+ if (m_bounds.h + m_bounds.y > 0.5)
+ {
+ m_bounds = Rect(m_bounds.x, m_bounds.y - 1, m_bounds.w, m_bounds.h);
+ m_current_quadtree_node = m_document.GetQuadTree().GetNeighbour(m_current_quadtree_node, 0, 1, &m_document);
+ }
+ }
+
if (ContainedInQuadChild(m_bounds, QTC_TOP_LEFT))
{
if (m_document.GetQuadTree().nodes[m_current_quadtree_node].top_left == QUADTREE_EMPTY)
{
m_bounds = Rect(m_bounds.x - 1, m_bounds.y - 1, m_bounds.w, m_bounds.h);
m_bounds_dirty = true;
- RenderQuadtreeNode(width, height, m_document.GetQuadTree().GetNeighbour(node, -1, -1), remaining_depth - 1);
+ RenderQuadtreeNode(width, height, m_document.GetQuadTree().GetNeighbour(node, -1, -1, &m_document), remaining_depth - 1);
}
+ m_bounds = old_bounds;
if (m_bounds.Intersects(Rect(-1,0,1,1)))
{
m_bounds = Rect(m_bounds.x - 1, m_bounds.y, m_bounds.w, m_bounds.h);
m_bounds_dirty = true;
- RenderQuadtreeNode(width, height, m_document.GetQuadTree().GetNeighbour(node, -1, 0), remaining_depth - 1);
+ RenderQuadtreeNode(width, height, m_document.GetQuadTree().GetNeighbour(node, -1, 0, &m_document), remaining_depth - 1);
}
+ m_bounds = old_bounds;
if (m_bounds.Intersects(Rect(-1,1,1,1)))
{
m_bounds = Rect(m_bounds.x - 1, m_bounds.y + 1, m_bounds.w, m_bounds.h);
m_bounds_dirty = true;
- RenderQuadtreeNode(width, height, m_document.GetQuadTree().GetNeighbour(node, -1, 1), remaining_depth - 1);
+ RenderQuadtreeNode(width, height, m_document.GetQuadTree().GetNeighbour(node, -1, 1, &m_document), remaining_depth - 1);
}
+ m_bounds = old_bounds;
if (m_bounds.Intersects(Rect(0,-1,1,1)))
{
m_bounds = Rect(m_bounds.x, m_bounds.y - 1, m_bounds.w, m_bounds.h);
m_bounds_dirty = true;
- RenderQuadtreeNode(width, height, m_document.GetQuadTree().GetNeighbour(node, 0, -1), remaining_depth - 1);
+ RenderQuadtreeNode(width, height, m_document.GetQuadTree().GetNeighbour(node, 0, -1, &m_document), remaining_depth - 1);
}
+ m_bounds = old_bounds;
if (m_bounds.Intersects(Rect(0,1,1,1)))
{
m_bounds = Rect(m_bounds.x, m_bounds.y + 1, m_bounds.w, m_bounds.h);
m_bounds_dirty = true;
- RenderQuadtreeNode(width, height, m_document.GetQuadTree().GetNeighbour(node, 0, 1), remaining_depth - 1);
+ RenderQuadtreeNode(width, height, m_document.GetQuadTree().GetNeighbour(node, 0, 1, &m_document), remaining_depth - 1);
}
+ m_bounds = old_bounds;
if (m_bounds.Intersects(Rect(1,-1,1,1)))
{
m_bounds = Rect(m_bounds.x + 1, m_bounds.y - 1, m_bounds.w, m_bounds.h);
m_bounds_dirty = true;
- RenderQuadtreeNode(width, height, m_document.GetQuadTree().GetNeighbour(node, 1, -1), remaining_depth - 1);
+ RenderQuadtreeNode(width, height, m_document.GetQuadTree().GetNeighbour(node, 1, -1, &m_document), remaining_depth - 1);
}
+ m_bounds = old_bounds;
if (m_bounds.Intersects(Rect(1,0,1,1)))
{
m_bounds = Rect(m_bounds.x + 1, m_bounds.y, m_bounds.w, m_bounds.h);
m_bounds_dirty = true;
- RenderQuadtreeNode(width, height, m_document.GetQuadTree().GetNeighbour(node, 1, 0), remaining_depth - 1);
+ RenderQuadtreeNode(width, height, m_document.GetQuadTree().GetNeighbour(node, 1, 0, &m_document), remaining_depth - 1);
}
+ m_bounds = old_bounds;
if (m_bounds.Intersects(Rect(1,1,1,1)))
{
m_bounds = Rect(m_bounds.x + 1, m_bounds.y + 1, m_bounds.w, m_bounds.h);
m_bounds_dirty = true;
- RenderQuadtreeNode(width, height, m_document.GetQuadTree().GetNeighbour(node, 1, 1), remaining_depth - 1);
+ RenderQuadtreeNode(width, height, m_document.GetQuadTree().GetNeighbour(node, 1, 1, &m_document), remaining_depth - 1);
}
m_bounds = old_bounds;
m_bounds_dirty = true;