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

« back to all changes in this revision

Viewing changes to src/gui/editors/notation/HeadersGroup.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_HEADERSGROUP_H_
 
31
#define _RG_HEADERSGROUP_H_
 
32
 
 
33
#include "base/Track.h"
 
34
 
 
35
#include <vector>
 
36
#include <qsize.h>
 
37
#include <qwidget.h>
 
38
#include <qvbox.h>
 
39
 
 
40
 
 
41
class QLabel;
 
42
class QResizeEvent;
 
43
 
 
44
 
 
45
namespace Rosegarden
 
46
{
 
47
 
 
48
 
 
49
class NotationView;
 
50
class Composition;
 
51
class TrackHeader;
 
52
 
 
53
 
 
54
class HeadersGroup : public QVBox
 
55
{
 
56
    Q_OBJECT
 
57
public:
 
58
    /**
 
59
     * Create an empty headers group
 
60
     */
 
61
    HeadersGroup(QWidget *parent, NotationView * nv, Composition * comp);
 
62
 
 
63
    void removeAllHeaders();
 
64
 
 
65
    void addHeader(int trackId, int height, int ypos, double xcur);
 
66
 
 
67
    /**
 
68
     * Resize a filler at bottom of group to set the headersGroup height
 
69
     * to the value specified in parameter.
 
70
     * (Used to give to the headers group exactly the same height as the
 
71
     * canvas. Necessary to get synchronous vertical scroll.) 
 
72
     */
 
73
    void completeToHeight(int height);
 
74
 
 
75
    NotationView * getNotationView()
 
76
    { return m_notationView;
 
77
    }
 
78
 
 
79
    Composition * getComposition()
 
80
    { return m_composition;
 
81
    }
 
82
 
 
83
    /**
 
84
     * Return the total height of all the headers (without the filler).
 
85
     */
 
86
    int getUsedHeight()
 
87
    { return m_usedHeight;
 
88
    }
 
89
 
 
90
    /**
 
91
     * Highlight as "current" the header of the specified track.
 
92
     */
 
93
    void setCurrent(TrackId trackId);
 
94
 
 
95
    /**
 
96
     * Highlight as "current" the header of the specified track.
 
97
     */
 
98
    int getWidth()
 
99
    {
 
100
        return m_lastWidth;
 
101
    }
 
102
 
 
103
    typedef enum { ShowNever, ShowWhenNeeded, ShowAlways } ShowHeadersModeType;
 
104
 
 
105
    // Used to ensure to have one default value and only one.
 
106
    static const ShowHeadersModeType DefaultShowMode = ShowAlways;
 
107
 
 
108
    // Useful in configuration dialog.
 
109
    static bool isValidShowMode(int mode)
 
110
    {
 
111
        return ((mode >= ShowNever) && (mode <= ShowAlways));
 
112
    }
 
113
 
 
114
public slots :
 
115
    /**
 
116
     * Called when notation canvas moves.
 
117
     * Setting force to true forces the headers to be redrawn even 
 
118
     * if x has not changed since the last call.
 
119
     */
 
120
    void slotUpdateAllHeaders(int x, int y, bool force = false);
 
121
 
 
122
signals :
 
123
    void headersResized(int newWidth);
 
124
 
 
125
private:
 
126
    void resizeEvent(QResizeEvent * ev);
 
127
 
 
128
    NotationView * m_notationView;
 
129
    Composition * m_composition;
 
130
 
 
131
    typedef std::vector<TrackHeader *> TrackHeaderVector;
 
132
    TrackHeaderVector m_headers;
 
133
 
 
134
    int m_usedHeight;
 
135
    QLabel * m_filler;
 
136
    int m_lastX;
 
137
    int m_lastWidth;
 
138
 
 
139
};
 
140
 
 
141
 
 
142
}
 
143
 
 
144
#endif