~ubuntu-branches/ubuntu/karmic/rosegarden/karmic

« back to all changes in this revision

Viewing changes to src/gui/editors/notation/TrackHeader.h

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Ebner
  • Date: 2008-05-02 00:33:44 UTC
  • mfrom: (1.1.7 upstream) (6.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080502003344-67vbfhgqx2yl0ksi
Tags: 1:1.7.0-1ubuntu1
* Merge from Debian unstable. (LP: #225849) Remaining Ubuntu changes:
  - Add usr/share/doc/kde/HTML to rosegarden-data, to provide online
    help documentation.
  - Change fftw3-dev to libfftw3-dev.
  - Update maintainer field as per spec.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
 
3
 
 
4
/*
 
5
    Rosegarden
 
6
    A MIDI and audio sequencer and musical notation editor.
 
7
 
 
8
    This program is Copyright 2000-2008
 
9
        Guillaume Laurent   <glaurent@telegraph-road.org>,
 
10
        Chris Cannam        <cannam@all-day-breakfast.com>,
 
11
        Richard Bown        <richard.bown@ferventsoftware.com>
 
12
 
 
13
    This file is Copyright 2007-2008
 
14
        Yves Guillemot      <yc.guillemot@wanadoo.fr> 
 
15
 
 
16
    The moral rights of Guillaume Laurent, Chris Cannam, and Richard
 
17
    Bown to claim authorship of this work have been asserted.
 
18
 
 
19
    Other copyrights also apply to some parts of this work.  Please
 
20
    see the AUTHORS file and individual file headers for details.
 
21
 
 
22
    This program is free software; you can redistribute it and/or
 
23
    modify it under the terms of the GNU General Public License as
 
24
    published by the Free Software Foundation; either version 2 of the
 
25
    License, or (at your option) any later version.  See the file
 
26
    COPYING included with this distribution for more information.
 
27
*/
 
28
 
 
29
 
 
30
#ifndef _RG_TRACKHEADER_H_
 
31
#define _RG_TRACKHEADER_H_
 
32
 
 
33
#include "base/NotationTypes.h"
 
34
#include "base/Track.h"
 
35
 
 
36
#include <qsize.h>
 
37
#include <qwidget.h>
 
38
#include <qlabel.h>
 
39
 
 
40
#include <set>
 
41
 
 
42
class QLabel;
 
43
 
 
44
 
 
45
namespace Rosegarden
 
46
{
 
47
 
 
48
class NotePixmapFactory;
 
49
class NotationView;
 
50
class ColourMap;
 
51
class Segment;
 
52
 
 
53
class TrackHeader : public QLabel
 
54
{
 
55
    Q_OBJECT
 
56
public:
 
57
    /**
 
58
     * Create a new track header for track of id trackId.
 
59
     * *parent is the parent widget, height the height of staff and
 
60
     * ypos is the staff y position on canvas.
 
61
     */
 
62
    TrackHeader(QWidget *parent, TrackId trackId, int height, int ypos);
 
63
 
 
64
    /**
 
65
     * Draw a blue line around header when current is true
 
66
     * (intended to highlight the "current" track).
 
67
     */
 
68
    void setCurrent(bool current);
 
69
 
 
70
    /**
 
71
     * Examine staff at x position and gather data needed to draw
 
72
     * the track header.
 
73
     * Return the minimum width required to display the track header.
 
74
     * maxWidth is the maximum width allowed to show text. Return width
 
75
     * may be greater than maxWidth if needed to show clef and key signature.
 
76
     * (Header have always to show complete clef and key signature).
 
77
     */
 
78
    int lookAtStaff(double x, int maxWidth);
 
79
 
 
80
    /**
 
81
     * (Re)draw the header on the notation view using the data gathered
 
82
     * by lookAtStaff() last call and the specified width.
 
83
     */
 
84
    void updateHeader(int width);
 
85
 
 
86
    /**
 
87
     * Return the Id of the associated track.
 
88
     */
 
89
    TrackId getId()
 
90
    { return m_track;
 
91
    }
 
92
 
 
93
    /**
 
94
     * Return how many text lines may be written in the header (above
 
95
     * the clef and under the clef).
 
96
     * This data is coming from the last call of lookAtStaff().
 
97
     */
 
98
    int getNumberOfTextLines() { return m_numberOfTextLines; }
 
99
 
 
100
    /**
 
101
     * Return the Clef to draw in the header
 
102
     */
 
103
    Clef & getClef() { return m_clef; }
 
104
 
 
105
    /**
 
106
     * Get which key signature should be drawn in the header
 
107
     * from the last call of lookAtStaff().
 
108
     */
 
109
    Rosegarden::Key & getKey() { return m_key; }
 
110
 
 
111
    /**
 
112
     * Return true if a Clef (and a key signature) have to be drawn in the header
 
113
     */
 
114
    bool isAClefToDraw()
 
115
    {
 
116
        return (m_status & SEGMENT_HERE) || (m_status & BEFORE_FIRST_SEGMENT);
 
117
    }
 
118
 
 
119
    /**
 
120
     * Return the text to write in the header top
 
121
     */
 
122
    QString getUpperText() { return m_upperText; }
 
123
 
 
124
    /**
 
125
     * Return the transposition text
 
126
     * (to be written at the end of the upper text)
 
127
     */
 
128
    QString getTransposeText() { return m_transposeText; }
 
129
 
 
130
    /**
 
131
     * Return the text to write in the header bottom
 
132
     */
 
133
    QString getLowerText() { return m_label; }
 
134
 
 
135
    /**
 
136
     * Return true if two segments or more are superimposed and are
 
137
     * not using the same clef
 
138
     */
 
139
    bool isClefInconsistent() { return m_status & INCONSISTENT_CLEFS; }
 
140
 
 
141
    /**
 
142
     * Return true if two segments or more are superimposed and are
 
143
     * not using the same key signature
 
144
     */
 
145
    bool isKeyInconsistent() { return m_status & INCONSISTENT_KEYS; }
 
146
 
 
147
    /**
 
148
     * Return true if two segments or more are superimposed and are
 
149
     * not using the same label
 
150
     */
 
151
    bool isLabelInconsistent() { return m_status & INCONSISTENT_LABELS; }
 
152
 
 
153
    /**
 
154
     * Return true if two segments or more are superimposed and are
 
155
     * not using the same transposition
 
156
     */
 
157
    bool isTransposeInconsistent() 
 
158
    {
 
159
        return m_status & INCONSISTENT_TRANSPOSITIONS;
 
160
    }
 
161
 
 
162
 
 
163
private :
 
164
    /**
 
165
     * Convert the transpose value to the instrument tune and
 
166
     * return it in a printable string.
 
167
     */
 
168
    void transposeValueToName(int transpose, QString &transposeName);
 
169
 
 
170
 
 
171
    // Status bits
 
172
    static const int SEGMENT_HERE;
 
173
    static const int SUPERIMPOSED_SEGMENTS;
 
174
    static const int INCONSISTENT_CLEFS;
 
175
    static const int INCONSISTENT_KEYS;
 
176
    static const int INCONSISTENT_LABELS;
 
177
    static const int INCONSISTENT_TRANSPOSITIONS;
 
178
    static const int BEFORE_FIRST_SEGMENT;
 
179
 
 
180
    TrackId m_track;
 
181
    int m_height;
 
182
    int m_ypos;
 
183
    NotationView * m_notationView;
 
184
 
 
185
    Clef m_lastClef;
 
186
    Rosegarden::Key m_lastKey;
 
187
    QString m_lastLabel;
 
188
    int m_lastTranspose;
 
189
    QString m_lastUpperText;
 
190
    bool m_neverUpdated;
 
191
    bool m_isCurrent;
 
192
    int m_lastStatusPart;
 
193
    int m_lastWidth;
 
194
 
 
195
    Clef m_clef;
 
196
    Rosegarden::Key m_key;
 
197
    QString m_label;
 
198
    int m_transpose;
 
199
    int m_status;
 
200
    bool m_current;
 
201
 
 
202
    QString m_upperText;
 
203
    QString m_transposeText;
 
204
    int m_numberOfTextLines;
 
205
 
 
206
    // Used to sort the segments listed in the header toolTipText
 
207
    struct SegmentCmp {
 
208
        bool operator()(const Segment *s1, const Segment *s2) const;
 
209
    };
 
210
    typedef std::multiset<Segment *, SegmentCmp> SortedSegments;
 
211
 
 
212
    // First segment on the track.
 
213
    Segment * m_firstSeg;
 
214
    timeT m_firstSegStartTime;
 
215
};
 
216
 
 
217
}
 
218
 
 
219
#endif