~ubuntu-branches/ubuntu/wily/muse/wily-proposed

« back to all changes in this revision

Viewing changes to muse/master/masteredit.cpp

  • Committer: Package Import Robot
  • Author(s): Alessio Treglia
  • Date: 2011-12-03 17:12:54 UTC
  • mfrom: (1.1.8)
  • Revision ID: package-import@ubuntu.com-20111203171254-28b1j4lpb46r5jtl
Tags: 2.0~rc1-1
* New upstream RC release.
* Refresh patches, remove those patches not needed anymore.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
//  Linux Music Editor
4
4
//    $Id: masteredit.cpp,v 1.4.2.5 2009/07/01 22:14:56 spamatica Exp $
5
5
//  (C) Copyright 1999 Werner Schweer (ws@seh.de)
 
6
//
 
7
//  This program is free software; you can redistribute it and/or
 
8
//  modify it under the terms of the GNU General Public License
 
9
//  as published by the Free Software Foundation; version 2 of
 
10
//  the License, or (at your option) any later version.
 
11
//
 
12
//  This program is distributed in the hope that it will be useful,
 
13
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
//  GNU General Public License for more details.
 
16
//
 
17
//  You should have received a copy of the GNU General Public License
 
18
//  along with this program; if not, write to the Free Software
 
19
//  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
20
//
6
21
//=========================================================
7
22
 
8
23
#include "awl/sigedit.h"
22
37
#include "doublelabel.h"
23
38
///#include "sigedit.h"
24
39
#include "globals.h"
 
40
#include "app.h"
25
41
 
26
42
#include <values.h>
27
43
 
31
47
#include <QLabel>
32
48
#include <QToolBar>
33
49
#include <QToolButton>
 
50
#include <QMenuBar>
 
51
#include <QMenu>
 
52
 
 
53
namespace MusEGui {
34
54
 
35
55
int MasterEdit::_rasterInit = 0;
36
56
 
40
60
 
41
61
void MasterEdit::closeEvent(QCloseEvent* e)
42
62
      {
43
 
      emit deleted((unsigned long)this);
 
63
      _isDeleting = true;  // Set flag so certain signals like songChanged, which may cause crash during delete, can be ignored.
 
64
 
 
65
      emit isDeleting(static_cast<TopWin*>(this));
44
66
      e->accept();
45
67
      }
46
68
 
50
72
 
51
73
void MasterEdit::songChanged(int type)
52
74
      {
 
75
      if(_isDeleting)  // Ignore while while deleting to prevent crash.
 
76
        return;
 
77
        
53
78
      if (type & SC_TEMPO) {
54
 
            int tempo = tempomap.tempo(song->cpos());
 
79
            int tempo = MusEGlobal::tempomap.tempo(MusEGlobal::song->cpos());
55
80
            curTempo->blockSignals(true);
56
81
            curTempo->setValue(double(60000000.0/tempo));
57
82
            
59
84
            }
60
85
      if (type & SC_SIG) {
61
86
            int z, n;
62
 
            AL::sigmap.timesig(song->cpos(), z, n);
 
87
            AL::sigmap.timesig(MusEGlobal::song->cpos(), z, n);
63
88
            curSig->blockSignals(true);
64
89
            curSig->setValue(AL::TimeSignature(z, n));
65
90
            curSig->blockSignals(false);
67
92
            }
68
93
      if (type & SC_MASTER) {
69
94
            enableButton->blockSignals(true);
70
 
            enableButton->setChecked(song->masterFlag());
 
95
            enableButton->setChecked(MusEGlobal::song->masterFlag());
71
96
            enableButton->blockSignals(false);
72
97
            }
73
98
      }
77
102
//---------------------------------------------------------
78
103
 
79
104
MasterEdit::MasterEdit()
80
 
   : MidiEditor(0, _rasterInit, 0)
 
105
   : MidiEditor(TopWin::MASTER, _rasterInit, 0)
81
106
      {
82
107
      setWindowTitle(tr("MusE: Mastertrack"));
83
108
      _raster = 0;      // measure
84
 
      setMinimumSize(400, 300);
85
 
      resize(500, 350);
86
109
 
87
110
      //---------Pulldown Menu----------------------------
88
111
//      QPopupMenu* file = new QPopupMenu(this);
89
112
//      menuBar()->insertItem("&File", file);
90
113
 
91
 
      //---------ToolBar----------------------------------
92
 
      
93
 
      tools = addToolBar(tr("Master tools"));
94
 
      tools->addActions(undoRedo->actions());
95
 
 
96
 
      EditToolBar* tools2 = new EditToolBar(this, PointerTool | PencilTool | RubberTool);
 
114
      QMenu* settingsMenu = menuBar()->addMenu(tr("Window &Config"));
 
115
      settingsMenu->addAction(subwinAction);
 
116
      settingsMenu->addAction(shareAction);
 
117
      settingsMenu->addAction(fullscreenAction);
 
118
 
 
119
      // Toolbars ---------------------------------------------------------
 
120
      QToolBar* undo_tools=addToolBar(tr("Undo/Redo tools"));
 
121
      undo_tools->setObjectName("Undo/Redo tools");
 
122
      undo_tools->addActions(MusEGlobal::undoRedo->actions());
 
123
 
 
124
 
 
125
      QToolBar* panic_toolbar = addToolBar(tr("panic"));         
 
126
      panic_toolbar->setObjectName("panic");
 
127
      panic_toolbar->addAction(MusEGlobal::panicAction);
 
128
 
 
129
      QToolBar* transport_toolbar = addToolBar(tr("transport"));
 
130
      transport_toolbar->setObjectName("transport");
 
131
      transport_toolbar->addActions(MusEGlobal::transportAction->actions());
 
132
 
 
133
      MusEGui::EditToolBar* tools2 = new MusEGui::EditToolBar(this, MusEGui::PointerTool | MusEGui::PencilTool | MusEGui::RubberTool);
97
134
      addToolBar(tools2);
98
135
 
99
136
      QToolBar* enableMaster = addToolBar(tr("Enable master"));
 
137
      enableMaster->setObjectName("Enable master");
100
138
      enableButton = new QToolButton();
101
139
      enableButton->setCheckable(true);
102
140
      enableButton->setText(tr("Enable"));
103
141
      enableButton->setToolTip(tr("Enable usage of master track"));
104
 
      enableButton->setChecked(song->masterFlag());
 
142
      enableButton->setChecked(MusEGlobal::song->masterFlag());
105
143
      enableMaster->addWidget(enableButton);
106
 
      connect(enableButton, SIGNAL(toggled(bool)), song, SLOT(setMasterFlag(bool)));
 
144
      connect(enableButton, SIGNAL(toggled(bool)), MusEGlobal::song, SLOT(setMasterFlag(bool)));
107
145
 
108
146
      QToolBar* info = addToolBar(tr("Info"));
 
147
      info->setObjectName("Info");
109
148
      QLabel* label  = new QLabel(tr("Cursor"));
110
149
      label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
111
150
      label->setIndent(3);
112
151
      info->addWidget(label);
113
152
 
114
 
      cursorPos = new PosLabel(0);
 
153
      cursorPos = new MusEGui::PosLabel(0);
115
154
      cursorPos->setFixedHeight(22);
116
155
      cursorPos->setToolTip(tr("time at cursor position"));
117
156
      info->addWidget(cursorPos);
118
 
      tempo = new TempoLabel(0);
 
157
      tempo = new MusEGui::TempoLabel(0);
119
158
      tempo->setFixedHeight(22);
120
159
      tempo->setToolTip(tr("tempo at cursor position"));
121
160
      info->addWidget(tempo);
122
161
 
123
162
      const char* rastval[] = {
124
 
            QT_TRANSLATE_NOOP("@default", "Off"), "Bar", "1/2", "1/4", "1/8", "1/16"
 
163
            QT_TRANSLATE_NOOP("MusEGui::MasterEdit", "Off"), QT_TRANSLATE_NOOP("MusEGui::MasterEdit", "Bar"), "1/2", "1/4", "1/8", "1/16"
125
164
            };
126
 
      rasterLabel = new LabelCombo(tr("Snap"), 0);
 
165
      rasterLabel = new MusEGui::LabelCombo(tr("Snap"), 0);
127
166
      rasterLabel->setFocusPolicy(Qt::NoFocus);
128
167
      for (int i = 0; i < 6; i++)
129
168
            rasterLabel->insertItem(i, tr(rastval[i]));
133
172
 
134
173
      //---------values for current position---------------
135
174
      info->addWidget(new QLabel(tr("CurPos ")));
136
 
      curTempo = new TempoEdit(0);
 
175
      curTempo = new MusEGui::TempoEdit(0);
137
176
      curSig   = new SigEdit(0);
138
177
      curSig->setValue(AL::TimeSignature(4, 4));
139
178
      curTempo->setToolTip(tr("tempo at current position"));
141
180
      info->addWidget(curTempo);
142
181
      info->addWidget(curSig);
143
182
      ///connect(curSig, SIGNAL(valueChanged(int,int)), song, SLOT(setSig(int,int)));
144
 
      connect(curSig, SIGNAL(valueChanged(const AL::TimeSignature&)), song, SLOT(setSig(const AL::TimeSignature&)));
 
183
      connect(curSig, SIGNAL(valueChanged(const AL::TimeSignature&)), MusEGlobal::song, SLOT(setSig(const AL::TimeSignature&)));
145
184
      
146
185
      ///connect(curTempo, SIGNAL(valueChanged(double)), song, SLOT(setTempo(double)));
147
 
      connect(curTempo, SIGNAL(tempoChanged(double)), song, SLOT(setTempo(double)));
 
186
      connect(curTempo, SIGNAL(tempoChanged(double)), MusEGlobal::song, SLOT(setTempo(double)));
148
187
                                                                                    
149
188
      //---------------------------------------------------
150
189
      //    master
152
191
 
153
192
      int xscale = -20;
154
193
      int yscale = -500;
155
 
      hscroll   = new ScrollScale(-100, -2, xscale, song->len(), Qt::Horizontal, mainw);
156
 
      vscroll   = new ScrollScale(-1000, -100, yscale, 120000, Qt::Vertical, mainw);
 
194
      hscroll   = new MusEGui::ScrollScale(-100, -2, xscale, MusEGlobal::song->len(), Qt::Horizontal, mainw);
 
195
      vscroll   = new MusEGui::ScrollScale(-1000, -100, yscale, 120000, Qt::Vertical, mainw);
157
196
      vscroll->setRange(30000, 250000);
158
 
      time1     = new MTScale(&_raster, mainw, xscale);
159
 
      sign      = new SigScale(&_raster, mainw, xscale);
160
 
//      thits     = new HitScale(&_raster, mainw, xscale);
 
197
      time1     = new MusEGui::MTScale(&_raster, mainw, xscale);
 
198
      sign      = new MusEGui::SigScale(&_raster, mainw, xscale);
 
199
//      thits     = new MusEGui::HitScale(&_raster, mainw, xscale);
161
200
 
162
201
      canvas    = new Master(this, mainw, xscale, yscale);
163
202
 
164
 
//      zhits     = new HitScale(&_raster, mainw, xscale);
165
 
      time2     = new MTScale(&_raster, mainw, xscale);
 
203
//      zhits     = new MusEGui::HitScale(&_raster, mainw, xscale);
 
204
      time2     = new MusEGui::MTScale(&_raster, mainw, xscale);
166
205
      tscale    = new TScale(mainw, yscale);
167
206
      time2->setBarLocator(true);
168
207
 
175
214
      mainGrid->setRowStretch(5, 100);
176
215
      mainGrid->setColumnStretch(1, 100);
177
216
 
178
 
      mainGrid->addWidget(hLine(mainw),  0, 1);
 
217
      mainGrid->addWidget(MusECore::hLine(mainw),  0, 1);
179
218
      mainGrid->addWidget(time1,         1, 1);
180
 
      mainGrid->addWidget(hLine(mainw),  2, 1);
 
219
      mainGrid->addWidget(MusECore::hLine(mainw),  2, 1);
181
220
      mainGrid->addWidget(sign,          3, 1);
182
 
      mainGrid->addWidget(hLine(mainw),  4, 1);
 
221
      mainGrid->addWidget(MusECore::hLine(mainw),  4, 1);
183
222
//    mainGrid->addWidget(thits,         5, 1);
184
 
//    mainGrid->addWidget(hLine(mainw),  6, 1);
 
223
//    mainGrid->addWidget(MusECore::hLine(mainw),  6, 1);
185
224
      mainGrid->addWidget(canvas,        5, 1);
186
225
      mainGrid->addWidget(tscale,        5, 0);
187
 
      mainGrid->addWidget(hLine(mainw),  6, 1);
 
226
      mainGrid->addWidget(MusECore::hLine(mainw),  6, 1);
188
227
//    mainGrid->addWidget(zhits,         9, 1);
189
 
//    mainGrid->addWidget(hLine(mainw),  7, 1);
 
228
//    mainGrid->addWidget(MusECore::hLine(mainw),  7, 1);
190
229
      mainGrid->addWidget(time2,         7, 1);
191
230
      mainGrid->addWidget(hscroll,       8, 1);
192
231
      mainGrid->addWidget(vscroll, 0, 2, 10, 1);
224
263
 
225
264
      connect(tscale, SIGNAL(tempoChanged(int)), SLOT(setTempo(int)));
226
265
      connect(canvas, SIGNAL(tempoChanged(int)), SLOT(setTempo(int)));
227
 
      connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int)));
228
 
      connect(song, SIGNAL(posChanged(int,unsigned,bool)), SLOT(posChanged(int,unsigned,bool)));
 
266
      connect(MusEGlobal::song, SIGNAL(songChanged(int)), SLOT(songChanged(int)));
 
267
      connect(MusEGlobal::song, SIGNAL(posChanged(int,unsigned,bool)), SLOT(posChanged(int,unsigned,bool)));
229
268
 
230
269
      connect(canvas, SIGNAL(followEvent(int)), hscroll, SLOT(setOffset(int)));
231
270
      connect(canvas, SIGNAL(timeChanged(unsigned)),   SLOT(setTime(unsigned)));
 
271
 
 
272
      initTopwinState();
 
273
      MusEGlobal::muse->topwinMenuInited(this);
232
274
      }
233
275
 
234
276
//---------------------------------------------------------
244
286
//   readStatus
245
287
//---------------------------------------------------------
246
288
 
247
 
void MasterEdit::readStatus(Xml& xml)
 
289
void MasterEdit::readStatus(MusECore::Xml& xml)
248
290
      {
249
291
      for (;;) {
250
 
            Xml::Token token = xml.parse();
 
292
            MusECore::Xml::Token token = xml.parse();
251
293
            const QString& tag = xml.s1();
252
294
            switch (token) {
253
 
                  case Xml::Error:
254
 
                  case Xml::End:
 
295
                  case MusECore::Xml::Error:
 
296
                  case MusECore::Xml::End:
255
297
                        return;
256
 
                  case Xml::TagStart:
 
298
                  case MusECore::Xml::TagStart:
257
299
                        if (tag == "midieditor")
258
300
                              MidiEditor::readStatus(xml);
259
301
                        else if (tag == "ypos")
266
308
                        else
267
309
                              xml.unknown("MasterEdit");
268
310
                        break;
269
 
                  case Xml::TagEnd:
 
311
                  case MusECore::Xml::TagEnd:
270
312
                        if (tag == "master") {
271
313
                              // raster setzen
272
314
                              int item = 0;
292
334
//   writeStatus
293
335
//---------------------------------------------------------
294
336
 
295
 
void MasterEdit::writeStatus(int level, Xml& xml) const
 
337
void MasterEdit::writeStatus(int level, MusECore::Xml& xml) const
296
338
      {
297
339
      xml.tag(level++, "master");
298
340
      xml.intTag(level, "ypos", vscroll->pos());
305
347
//   readConfiguration
306
348
//---------------------------------------------------------
307
349
 
308
 
void MasterEdit::readConfiguration(Xml& xml)
 
350
void MasterEdit::readConfiguration(MusECore::Xml& xml)
309
351
      {
310
352
      for (;;) {
311
 
            Xml::Token token = xml.parse();
 
353
            MusECore::Xml::Token token = xml.parse();
312
354
            const QString& tag = xml.s1();
313
355
            switch (token) {
314
 
                  case Xml::Error:
315
 
                  case Xml::End:
 
356
                  case MusECore::Xml::Error:
 
357
                  case MusECore::Xml::End:
316
358
                        return;
317
 
                  case Xml::TagStart:
 
359
                  case MusECore::Xml::TagStart:
318
360
                        if (tag == "raster")
319
361
                              _rasterInit = xml.parseInt();
 
362
                        else if (tag == "topwin")
 
363
                              TopWin::readConfiguration(MASTER, xml);
320
364
                        else
321
365
                              xml.unknown("MasterEdit");
322
366
                        break;
323
 
                  case Xml::TagEnd:
 
367
                  case MusECore::Xml::TagEnd:
324
368
                        if (tag == "masteredit")
325
369
                              return;
326
370
                  default:
333
377
//   writeConfiguration
334
378
//---------------------------------------------------------
335
379
 
336
 
void MasterEdit::writeConfiguration(int level, Xml& xml)
 
380
void MasterEdit::writeConfiguration(int level, MusECore::Xml& xml)
337
381
      {
338
382
      xml.tag(level++, "masteredit");
339
383
      xml.intTag(level, "raster", _rasterInit);
 
384
      TopWin::writeConfiguration(MASTER, level, xml);
340
385
      xml.tag(level, "/masteredit");
341
386
      }
342
387
 
361
406
      {
362
407
      if (idx == 0) {
363
408
            int z, n;
364
 
            int tempo = tempomap.tempo(val);
 
409
            int tempo = MusEGlobal::tempomap.tempo(val);
365
410
            AL::sigmap.timesig(val, z, n);
366
411
            curTempo->blockSignals(true);
367
412
            curSig->blockSignals(true);
404
449
            }
405
450
      }
406
451
 
 
452
} // namespace MusEGui