summaryrefslogtreecommitdiffstats
path: root/src/gui/dialogs/EventParameterDialog.cpp
blob: 6443f48bfaae71e62d07182347e1af1cf7473713 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */

/*
    Rosegarden
    A MIDI and audio sequencer and musical notation editor.
 
    This program is Copyright 2000-2008
        Guillaume Laurent   <glaurent@telegraph-road.org>,
        Chris Cannam        <cannam@all-day-breakfast.com>,
        Richard Bown        <richard.bown@ferventsoftware.com>
 
    The moral rights of Guillaume Laurent, Chris Cannam, and Richard
    Bown to claim authorship of this work have been asserted.
 
    Other copyrights also apply to some parts of this work.  Please
    see the AUTHORS file and individual file headers for details.
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License as
    published by the Free Software Foundation; either version 2 of the
    License, or (at your option) any later version.  See the file
    COPYING included with this distribution for more information.
*/


#include "EventParameterDialog.h"

#include <klocale.h>
#include "misc/Debug.h"
#include "misc/Strings.h"
#include "base/PropertyName.h"
#include <kcombobox.h>
#include <kdialogbase.h>
#include <tqhbox.h>
#include <tqlabel.h>
#include <tqstring.h>
#include <tqvbox.h>
#include <tqwidget.h>


namespace Rosegarden
{

EventParameterDialog::EventParameterDialog(
    TQWidget *tqparent,
    const TQString &name,
    const PropertyName &property,
    int startValue):
        KDialogBase(tqparent, 0, true, name, Ok | Cancel),
        m_property(property)
{
    TQVBox *vBox = makeVBoxMainWidget();

    TQHBox *topBox = new TQHBox(vBox);
    TQLabel *explainLabel = new TQLabel(topBox);
    TQString text = i18n("Set the %1 property of the event selection:").
                   arg(strtoqstr(property));
    explainLabel->setText(text);

    TQHBox *patternBox = new TQHBox(vBox);
    new TQLabel(i18n("Pattern"), patternBox);
    m_patternCombo = new KComboBox(patternBox);

    // create options
    // 0 flat
    text = i18n("Flat - set %1 to value").tqarg(strtoqstr(property));
    m_patternCombo->insertItem(text);

    // 1 alternating
    text = i18n("Alternating - set %1 to max and min on alternate events").tqarg(strtoqstr(property));
    m_patternCombo->insertItem(text);

    // 2 crescendo
    text = i18n("Crescendo - set %1 rising from min to max").tqarg(strtoqstr(property));
    m_patternCombo->insertItem(text);

    // 3 diminuendo
    text = i18n("Diminuendo - set %1 falling from max to min").tqarg(strtoqstr(property));
    m_patternCombo->insertItem(text);

    // 4 ringing
    text = i18n("Ringing - set %1 alternating from max to min with both dying to zero").tqarg(strtoqstr(property));
    m_patternCombo->insertItem(text);

    connect(m_patternCombo, TQT_SIGNAL(activated(int)),
            this, TQT_SLOT(slotPatternSelected(int)));

    TQHBox *value1Box = new TQHBox(vBox);
    m_value1Label = new TQLabel(i18n("Value"), value1Box);
    m_value1Combo = new KComboBox(value1Box);

    TQHBox *value2Box = new TQHBox(vBox);
    m_value2Label = new TQLabel(i18n("Value"), value2Box);
    m_value2Combo = new KComboBox(value2Box);

    for (unsigned int i = 0; i < 128; i++) {
        m_value1Combo->insertItem(TQString("%1").tqarg(i));
        m_value2Combo->insertItem(TQString("%1").tqarg(i));
    }
    m_value1Combo->setCurrentItem(127);

    slotPatternSelected(0);

    // start value
    m_value1Combo->setCurrentItem(startValue);
    m_value2Combo->setCurrentItem(startValue);

}

void
EventParameterDialog::slotPatternSelected(int value)
{
    switch (value) {
    case 0:  // flat
        m_value1Label->setText(i18n("Value"));
        m_value1Label->show();
        m_value1Combo->show();
        m_value2Label->hide();
        m_value2Combo->hide();
        break;

    case 1:  // alternating
        m_value1Label->setText(i18n("First Value"));
        m_value2Label->setText(i18n("Second Value"));
        m_value1Label->show();
        m_value1Combo->show();
        m_value2Label->show();
        m_value2Combo->show();
        break;

    case 2:  // crescendo
        m_value1Label->setText(i18n("Low Value"));
        m_value2Label->setText(i18n("High Value"));
        m_value1Label->show();
        m_value1Combo->show();
        m_value2Label->show();
        m_value2Combo->show();
        break;

    case 3:  // decrescendo
        m_value1Label->setText(i18n("High Value"));
        m_value2Label->setText(i18n("Low Value"));
        m_value1Label->show();
        m_value1Combo->show();
        m_value2Label->show();
        m_value2Combo->show();
        break;

    case 4:  // ringing
        m_value1Label->setText(i18n("First Value"));
        m_value2Label->setText(i18n("Second Value"));
        m_value1Label->show();
        m_value1Combo->show();
        m_value2Label->show();
        m_value2Combo->show();
        break;

    default:
        RG_DEBUG << "EventParameterDialog::slotPatternSelected - "
        << "unrecognised pattern number" << endl;
        break;
    }

}

PropertyPattern
EventParameterDialog::getPattern()
{
    return PropertyPattern(m_patternCombo->currentItem());
}

int
EventParameterDialog::getValue1()
{
    return m_value1Combo->currentItem();
}

int
EventParameterDialog::getValue2()
{
    return m_value2Combo->currentItem();
}

}
#include "EventParameterDialog.moc"