~s-cecilio/lomse/master

« back to all changes in this revision

Viewing changes to include/lomse_graphic_view.h

  • Committer: cecilios
  • Date: 2010-11-14 17:47:31 UTC
  • Revision ID: git-v1:1fa3764c8c4d338b95b1a537b1e78271170c0025
latest new code. demo_1 tested on linux and win32

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//---------------------------------------------------------------------------------------
 
2
//  This file is part of the Lomse library.
 
3
//  Copyright (c) 2010 Lomse project
 
4
//
 
5
//  Lomse is free software; you can redistribute it and/or modify it under the
 
6
//  terms of the GNU General Public License as published by the Free Software Foundation,
 
7
//  either version 3 of the License, or (at your option) any later version.
 
8
//
 
9
//  Lomse is distributed in the hope that it will be useful, but WITHOUT ANY
 
10
//  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 
11
//  PARTICULAR PURPOSE.  See the GNU General Public License for more details.
 
12
//
 
13
//  You should have received a copy of the GNU General Public License along
 
14
//  with Lomse; if not, see <http://www.gnu.org/licenses/>.
 
15
//
 
16
//  For any comment, suggestion or feature request, please contact the manager of
 
17
//  the project at cecilios@users.sourceforge.net
 
18
//
 
19
//---------------------------------------------------------------------------------------
 
20
 
 
21
#ifndef __LOMSE_GRAPHIC_VIEW_H__
 
22
#define __LOMSE_GRAPHIC_VIEW_H__
 
23
 
 
24
#include "lomse_injectors.h"
 
25
#include "lomse_view.h"
 
26
#include "lomse_drawer.h"
 
27
#include "platform/lomse_platform.h"
 
28
 
 
29
#include <vector>
 
30
using namespace std;
 
31
 
 
32
 
 
33
namespace lomse
 
34
{
 
35
 
 
36
//forward declarations
 
37
class Document;
 
38
class GraphicModel;
 
39
class ScreenDrawer;
 
40
class Drawer;
 
41
//class MvcElement;
 
42
//class Controller;
 
43
 
 
44
 
 
45
//---------------------------------------------------------------------------------------
 
46
// A view to edit the score in full page
 
47
class GraphicView : public View
 
48
{
 
49
protected:
 
50
    LibraryScope& m_libraryScope;
 
51
    GraphicModel* m_pGraficModel;
 
52
    ScreenDrawer* m_pDrawer;
 
53
    std::vector<RenderingBuffer*> m_pPages;
 
54
    PlatformSupport* m_pPlatform;
 
55
    RenderOptions m_options;
 
56
    //DocCursor       m_cursor;
 
57
 
 
58
public:
 
59
    //GraphicView(Document* pDoc);   //, Controller* pController);
 
60
    GraphicView(LibraryScope& libraryScope, Document* pDoc, PlatformSupport* pPlatform,
 
61
                ScreenDrawer* pDrawer);
 
62
    virtual ~GraphicView();
 
63
 
 
64
    //--------------------------------------------------------------------
 
65
    // Methods to serve platform dependent event handlers. 
 
66
    //virtual void on_init();
 
67
    virtual void on_resize(Pixels vx, Pixels vy);
 
68
    //virtual void on_idle();
 
69
    virtual void on_mouse_move(int x, int y, unsigned flags);
 
70
    virtual void on_mouse_button_down(int x, int y, unsigned flags);
 
71
    virtual void on_mouse_button_up(int x, int y, unsigned flags);
 
72
    //virtual void on_key(int x, int y, unsigned key, unsigned flags);
 
73
    //virtual void on_ctrl_change();
 
74
 
 
75
    //--------------------------------------------------------------------
 
76
    // The View is requested to re-paint itself onto the window
 
77
    virtual void on_paint();
 
78
    //virtual void on_post_draw(void* raw_handler);
 
79
 
 
80
    //window related commands
 
81
    void update_window();
 
82
 
 
83
    //inline DocCursor& get_cursor() { return m_cursor; }
 
84
    //void on_document_reloaded();
 
85
 
 
86
    ////caret movement
 
87
    //void caret_right();
 
88
    //void caret_left();
 
89
    //void caret_to_object(long nId);
 
90
 
 
91
    //observed object notifications
 
92
        void handle_event(Observable* ref);
 
93
 
 
94
    //graphic model
 
95
    GraphicModel* get_graphic_model();
 
96
 
 
97
    //scale
 
98
    inline void zoom_in() { m_scale *= 1.05; }
 
99
    inline void zoom_out() { m_scale /= 1.05; }
 
100
    inline void set_scale(double scale) { m_scale = scale; }
 
101
    inline double get_scale() { return m_scale; }
 
102
 
 
103
    //rendering options
 
104
    inline void set_option_draw_box_doc_page_content(bool value) { 
 
105
        m_options.draw_box_doc_page_content_flag = value;
 
106
    }
 
107
    inline void set_option_draw_box_score_page(bool value) { 
 
108
        m_options.draw_box_score_page_flag = value; 
 
109
    }
 
110
    inline void set_option_draw_box_system(bool value) { 
 
111
        m_options.draw_box_system_flag = value; 
 
112
    }
 
113
    inline void set_option_draw_box_slice(bool value) {
 
114
        m_options.draw_box_slice_flag = value; 
 
115
    }
 
116
    inline void set_option_draw_box_slice_instr(bool value) { 
 
117
        m_options.draw_box_slice_instr_flag = value; 
 
118
    }
 
119
 
 
120
protected:
 
121
    GraphicModel* create_graphic_model();
 
122
    void draw_graphic_model();
 
123
    void add_controls();
 
124
    virtual void generate_paths() = 0;
 
125
 
 
126
    //renderization parameters
 
127
    double m_expand;
 
128
    double m_gamma;
 
129
    double m_scale;
 
130
    double m_rotation;
 
131
 
 
132
    ////agg renderization related 
 
133
    //agg::slider_ctrl<agg::rgba8> m_expand;
 
134
    //agg::slider_ctrl<agg::rgba8> m_gamma;
 
135
    //agg::slider_ctrl<agg::rgba8> m_scale;
 
136
    //agg::slider_ctrl<agg::rgba8> m_rotate;
 
137
 
 
138
    //current viewport origin (pixels)
 
139
    Pixels m_vxOrg;      
 
140
    Pixels m_vyOrg;
 
141
 
 
142
    //temporary for dragging (pixels)
 
143
    Pixels m_dx;        
 
144
    Pixels m_dy;
 
145
    bool   m_drag_flag;
 
146
};
 
147
 
 
148
 
 
149
//---------------------------------------------------------------------------------------
 
150
// A graphic view with one page, no margins (i.e. LenMus ScoreAuxCtrol)
 
151
class SimpleView : public GraphicView
 
152
{
 
153
protected:
 
154
 
 
155
public:
 
156
    SimpleView(LibraryScope& libraryScope, Document* pDoc, PlatformSupport* pPlatform,
 
157
               ScreenDrawer* pDrawer);
 
158
    virtual ~SimpleView() {}
 
159
 
 
160
protected:
 
161
    void generate_paths();
 
162
 
 
163
};
 
164
 
 
165
 
 
166
//---------------------------------------------------------------------------------------
 
167
// A graphic view with pages in vertical (i.e. Adobe PDF Reader, MS Word)
 
168
class VerticalBookView : public GraphicView
 
169
{
 
170
protected:
 
171
 
 
172
public:
 
173
    VerticalBookView(LibraryScope& libraryScope, Document* pDoc, 
 
174
                     PlatformSupport* pPlatform, ScreenDrawer* pDrawer);
 
175
    virtual ~VerticalBookView() {}
 
176
 
 
177
protected:
 
178
    void generate_paths();
 
179
 
 
180
};
 
181
 
 
182
 
 
183
//---------------------------------------------------------------------------------------
 
184
// A graphic view with pages in horizontall (i.e. Finale, Sibelius)
 
185
class HorizontalBookView : public GraphicView
 
186
{
 
187
protected:
 
188
 
 
189
public:
 
190
    HorizontalBookView(LibraryScope& libraryScope, Document* pDoc,
 
191
                       PlatformSupport* pPlatform, ScreenDrawer* pDrawer);
 
192
    virtual ~HorizontalBookView() {}
 
193
 
 
194
protected:
 
195
    void generate_paths();
 
196
 
 
197
};
 
198
 
 
199
 
 
200
 
 
201
}   //namespace lomse
 
202
 
 
203
#endif      //__LOMSE_GRAPHIC_VIEW_H__