Merge branch 'master' of git.ucc.asn.au:/ipdf/code
[ipdf/code.git] / src / view.h
1 #ifndef _VIEW_H
2 #define _VIEW_H
3
4 #include "ipdf.h"
5 #include "document.h"
6 #include "graphicsbuffer.h"
7 #include "framebuffer.h"
8 #include "shaderprogram.h"
9
10 namespace IPDF
11 {
12         class View
13         {
14                 public:
15                         View(Document & document, const Rect & bounds = Rect(0,0,1,1), const Colour & colour = Colour(0.f,0.f,0.f,1.f)) 
16                                 : m_colour(colour), m_use_gpu_transform(false), m_bounds_dirty(true), m_buffer_dirty(true), m_document(document), m_bounds(bounds) 
17                         {
18                                 Debug("View Created - Bounds => {%s}", m_bounds.Str().c_str());
19                         }
20                         virtual ~View() {}
21
22                         void Render(int width = 0, int height = 0);
23                         
24                         void Translate(Real x, Real y);
25                         void ScaleAroundPoint(Real x, Real y, Real scaleAmt);
26                         
27                         Rect TransformToViewCoords(const Rect& inp) const;
28                         
29                         const Rect& GetBounds() const { return m_bounds; }
30                         
31                         const bool UsingGPUTransform() const { return m_use_gpu_transform; }
32                         void ToggleGPUTransform() { m_use_gpu_transform = (!m_use_gpu_transform); m_bounds_dirty = true; m_buffer_dirty = true; }
33                 
34                 private:
35                         void ReRender();
36                         void DrawGrid();
37                         bool m_use_gpu_transform;
38                         bool m_bounds_dirty;
39                         bool m_buffer_dirty;
40                         ShaderProgram m_rect_shader;
41                         GraphicsBuffer m_bounds_ubo;
42                         GraphicsBuffer m_vertex_buffer;
43                         GraphicsBuffer m_index_buffer;
44                         FrameBuffer m_cached_display;
45                         Document & m_document;
46                         Rect m_bounds;
47                         Colour m_colour;
48                         uint32_t m_rendered_filled;
49                         uint32_t m_rendered_outline;
50         };
51 }
52
53 #endif //_VIEW_H

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