~ubuntu-branches/ubuntu/quantal/muse/quantal

« back to all changes in this revision

Viewing changes to muse/master/masteredit.cpp

  • Committer: Package Import Robot
  • Author(s): Alessio Treglia
  • Date: 2012-07-18 16:07:06 UTC
  • mfrom: (1.1.12) (10.1.11 sid)
  • Revision ID: package-import@ubuntu.com-20120718160706-qy1lydijykeiqqmg
Tags: 2.0-1
* New stable release.
* debian/rules: Exclude muse/widgets/arrangercolumns.{cpp,h}~ from being
  deleted by dh_clean.
* Drop 0002-gcc_hardening.patch, applied upstream.
* Drop 0003-ftbfs_gcc47.patch, applied upstream.
* Refresh 1001-buildsystem.patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
#include "xml.h"
36
36
#include "lcombo.h"
37
37
#include "doublelabel.h"
38
 
///#include "sigedit.h"
39
38
#include "globals.h"
40
39
#include "app.h"
 
40
#include "gconfig.h"
 
41
#include "audio.h"
41
42
 
42
 
#include <values.h>
 
43
#include <limits.h>
43
44
 
44
45
#include <QActionGroup>
45
46
#include <QCloseEvent>
76
77
        return;
77
78
        
78
79
      if (type & SC_TEMPO) {
79
 
            int tempo = MusEGlobal::tempomap.tempo(MusEGlobal::song->cpos());
 
80
            int tempo = MusEGlobal::tempomap.tempoAt(MusEGlobal::song->cpos());  // Bypass the useList flag and read from the list.
80
81
            curTempo->blockSignals(true);
81
82
            curTempo->setValue(double(60000000.0/tempo));
82
83
            
105
106
   : MidiEditor(TopWin::MASTER, _rasterInit, 0)
106
107
      {
107
108
      setWindowTitle(tr("MusE: Mastertrack"));
 
109
      setFocusPolicy(Qt::NoFocus);
108
110
      _raster = 0;      // measure
109
111
 
110
112
      //---------Pulldown Menu----------------------------
111
 
//      QPopupMenu* file = new QPopupMenu(this);
112
 
//      menuBar()->insertItem("&File", file);
113
 
 
114
113
      QMenu* settingsMenu = menuBar()->addMenu(tr("Window &Config"));
115
114
      settingsMenu->addAction(subwinAction);
116
115
      settingsMenu->addAction(shareAction);
117
116
      settingsMenu->addAction(fullscreenAction);
118
117
 
119
118
      // 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
119
      MusEGui::EditToolBar* tools2 = new MusEGui::EditToolBar(this, MusEGui::PointerTool | MusEGui::PencilTool | MusEGui::RubberTool);
134
120
      addToolBar(tools2);
135
121
 
136
122
      QToolBar* enableMaster = addToolBar(tr("Enable master"));
137
123
      enableMaster->setObjectName("Enable master");
138
124
      enableButton = new QToolButton();
 
125
      enableButton->setFocusPolicy(Qt::NoFocus);
139
126
      enableButton->setCheckable(true);
140
127
      enableButton->setText(tr("Enable"));
141
128
      enableButton->setToolTip(tr("Enable usage of master track"));
163
150
            QT_TRANSLATE_NOOP("MusEGui::MasterEdit", "Off"), QT_TRANSLATE_NOOP("MusEGui::MasterEdit", "Bar"), "1/2", "1/4", "1/8", "1/16"
164
151
            };
165
152
      rasterLabel = new MusEGui::LabelCombo(tr("Snap"), 0);
166
 
      rasterLabel->setFocusPolicy(Qt::NoFocus);
 
153
      rasterLabel->setFocusPolicy(Qt::TabFocus);
167
154
      for (int i = 0; i < 6; i++)
168
155
            rasterLabel->insertItem(i, tr(rastval[i]));
169
156
      rasterLabel->setCurrentIndex(1);
173
160
      //---------values for current position---------------
174
161
      info->addWidget(new QLabel(tr("CurPos ")));
175
162
      curTempo = new MusEGui::TempoEdit(0);
176
 
      curSig   = new SigEdit(0);
 
163
      curSig   = new SigEdit(0);  // SigEdit is already StrongFocus.
 
164
      curTempo->setFocusPolicy(Qt::StrongFocus);
177
165
      curSig->setValue(AL::TimeSignature(4, 4));
178
166
      curTempo->setToolTip(tr("tempo at current position"));
179
167
      curSig->setToolTip(tr("time signature at current position"));
180
168
      info->addWidget(curTempo);
181
169
      info->addWidget(curSig);
182
 
      ///connect(curSig, SIGNAL(valueChanged(int,int)), song, SLOT(setSig(int,int)));
183
 
      connect(curSig, SIGNAL(valueChanged(const AL::TimeSignature&)), MusEGlobal::song, SLOT(setSig(const AL::TimeSignature&)));
184
 
      
185
 
      ///connect(curTempo, SIGNAL(valueChanged(double)), song, SLOT(setTempo(double)));
186
 
      connect(curTempo, SIGNAL(tempoChanged(double)), MusEGlobal::song, SLOT(setTempo(double)));
 
170
 
 
171
      connect(curSig, SIGNAL(valueChanged(const AL::TimeSignature&)), SLOT(sigChange(const AL::TimeSignature&)));
 
172
      connect(curTempo, SIGNAL(tempoChanged(double)), SLOT(tempoChange(double)));
187
173
                                                                                    
188
174
      //---------------------------------------------------
189
175
      //    master
196
182
      vscroll->setRange(30000, 250000);
197
183
      time1     = new MusEGui::MTScale(&_raster, mainw, xscale);
198
184
      sign      = new MusEGui::SigScale(&_raster, mainw, xscale);
199
 
//      thits     = new MusEGui::HitScale(&_raster, mainw, xscale);
 
185
//      thits     = new MusEGui::HitScale(&_raster, mainw, xscale); DELETETHIS what IS this? delete zhits as well
200
186
 
201
187
      canvas    = new Master(this, mainw, xscale, yscale);
202
188
 
209
195
      //    Rest
210
196
      //---------------------------------------------------
211
197
 
212
 
//      QSizeGrip* corner   = new QSizeGrip(mainw);
213
 
 
214
198
      mainGrid->setRowStretch(5, 100);
215
199
      mainGrid->setColumnStretch(1, 100);
216
200
 
219
203
      mainGrid->addWidget(MusECore::hLine(mainw),  2, 1);
220
204
      mainGrid->addWidget(sign,          3, 1);
221
205
      mainGrid->addWidget(MusECore::hLine(mainw),  4, 1);
222
 
//    mainGrid->addWidget(thits,         5, 1);
 
206
//    mainGrid->addWidget(thits,         5, 1); DELETETHIS
223
207
//    mainGrid->addWidget(MusECore::hLine(mainw),  6, 1);
224
208
      mainGrid->addWidget(canvas,        5, 1);
225
209
      mainGrid->addWidget(tscale,        5, 0);
226
210
      mainGrid->addWidget(MusECore::hLine(mainw),  6, 1);
227
 
//    mainGrid->addWidget(zhits,         9, 1);
 
211
//    mainGrid->addWidget(zhits,         9, 1); DELETETHIS
228
212
//    mainGrid->addWidget(MusECore::hLine(mainw),  7, 1);
229
213
      mainGrid->addWidget(time2,         7, 1);
230
214
      mainGrid->addWidget(hscroll,       8, 1);
231
215
      mainGrid->addWidget(vscroll, 0, 2, 10, 1);
232
 
//      mainGrid->addWidget(corner,  9, 2, AlignBottom | AlignRight);
233
216
 
234
 
      canvas->setFocus(); // Tim.
 
217
      canvas->setFocus(); 
235
218
 
236
219
      connect(tools2, SIGNAL(toolChanged(int)), canvas, SLOT(setTool(int)));
237
220
      connect(vscroll, SIGNAL(scrollChanged(int)),   canvas, SLOT(setYPos(int)));
242
225
 
243
226
      connect(hscroll, SIGNAL(scrollChanged(int)), time1,  SLOT(setXPos(int)));
244
227
      connect(hscroll, SIGNAL(scrollChanged(int)), sign,   SLOT(setXPos(int)));
245
 
//      connect(hscroll, SIGNAL(scrollChanged(int)), thits,  SLOT(setXPos(int)));
 
228
//      connect(hscroll, SIGNAL(scrollChanged(int)), thits,  SLOT(setXPos(int))); DELETETHIS
246
229
      connect(hscroll, SIGNAL(scrollChanged(int)), canvas, SLOT(setXPos(int)));
247
 
//      connect(hscroll, SIGNAL(scrollChanged(int)), zhits,  SLOT(setXPos(int)));
 
230
//      connect(hscroll, SIGNAL(scrollChanged(int)), zhits,  SLOT(setXPos(int)));DELETETHIS
248
231
      connect(hscroll, SIGNAL(scrollChanged(int)), time2,  SLOT(setXPos(int)));
249
232
 
250
233
      connect(hscroll, SIGNAL(scaleChanged(int)), time1,  SLOT(setXMag(int)));
251
234
      connect(hscroll, SIGNAL(scaleChanged(int)), sign,   SLOT(setXMag(int)));
252
 
//      connect(hscroll, SIGNAL(scaleChanged(int)), thits,  SLOT(setXMag(int)));
 
235
//      connect(hscroll, SIGNAL(scaleChanged(int)), thits,  SLOT(setXMag(int)));DELETETHIS
253
236
      connect(hscroll, SIGNAL(scaleChanged(int)), canvas, SLOT(setXMag(int)));
254
 
//      connect(hscroll, SIGNAL(scaleChanged(int)), zhits,  SLOT(setXMag(int)));
 
237
//      connect(hscroll, SIGNAL(scaleChanged(int)), zhits,  SLOT(setXMag(int))); DELETETHIS
255
238
      connect(hscroll, SIGNAL(scaleChanged(int)), time2,  SLOT(setXMag(int)));
256
239
 
257
240
      connect(time1,  SIGNAL(timeChanged(unsigned)), SLOT(setTime(unsigned)));
258
 
//      connect(sign,   SIGNAL(timeChanged(unsigned)), pos, SLOT(setValue(unsigned)));
 
241
//      connect(sign,   SIGNAL(timeChanged(unsigned)), pos, SLOT(setValue(unsigned))); DELETETHIS
259
242
//      connect(thits,  SIGNAL(timeChanged(unsigned)), pos, SLOT(setValue(unsigned)));
260
243
//      connect(canvas, SIGNAL(timeChanged(unsigned)), pos, SLOT(setValue(unsigned)));
261
244
//      connect(zhits,  SIGNAL(timeChanged(unsigned)), pos, SLOT(setValue(unsigned)));
269
252
      connect(canvas, SIGNAL(followEvent(int)), hscroll, SLOT(setOffset(int)));
270
253
      connect(canvas, SIGNAL(timeChanged(unsigned)),   SLOT(setTime(unsigned)));
271
254
 
 
255
      connect(curSig,   SIGNAL(returnPressed()), SLOT(focusCanvas()));
 
256
      connect(curSig,   SIGNAL(escapePressed()), SLOT(focusCanvas()));
 
257
      connect(curTempo, SIGNAL(returnPressed()), SLOT(focusCanvas()));
 
258
      connect(curTempo, SIGNAL(escapePressed()), SLOT(focusCanvas()));
 
259
      
272
260
      initTopwinState();
273
 
      MusEGlobal::muse->topwinMenuInited(this);
 
261
      finalizeInit();
274
262
      }
275
263
 
276
264
//---------------------------------------------------------
279
267
 
280
268
MasterEdit::~MasterEdit()
281
269
      {
282
 
      //undoRedo->removeFrom(tools);  // p4.0.6 Removed
283
270
      }
284
271
 
285
272
//---------------------------------------------------------
310
297
                        break;
311
298
                  case MusECore::Xml::TagEnd:
312
299
                        if (tag == "master") {
313
 
                              // raster setzen
 
300
                              // set raster
314
301
                              int item = 0;
315
302
                              switch(_raster) {
316
303
                                    case 1:   item = 0; break;
386
373
      }
387
374
 
388
375
//---------------------------------------------------------
 
376
//   focusCanvas
 
377
//---------------------------------------------------------
 
378
 
 
379
void MasterEdit::focusCanvas()
 
380
{
 
381
  if(MusEGlobal::config.smartFocus)
 
382
  {
 
383
    canvas->setFocus();
 
384
    canvas->activateWindow();
 
385
  } 
 
386
}
 
387
 
 
388
//---------------------------------------------------------
389
389
//   _setRaster
390
390
//---------------------------------------------------------
391
391
 
396
396
            };
397
397
      _raster = rasterTable[index];
398
398
      _rasterInit = _raster;
 
399
      focusCanvas();
399
400
      }
400
401
 
401
402
//---------------------------------------------------------
406
407
      {
407
408
      if (idx == 0) {
408
409
            int z, n;
409
 
            int tempo = MusEGlobal::tempomap.tempo(val);
 
410
            int tempo = MusEGlobal::tempomap.tempoAt(val); // Bypass the useList flag and read from the list.
410
411
            AL::sigmap.timesig(val, z, n);
411
412
            curTempo->blockSignals(true);
412
413
            curSig->blockSignals(true);
425
426
 
426
427
void MasterEdit::setTime(unsigned tick)
427
428
      {
428
 
      if (tick == MAXINT)
 
429
      if (tick == INT_MAX)
429
430
            cursorPos->setEnabled(false);
430
431
      else {
431
432
            cursorPos->setEnabled(true);
448
449
            tempo->setValue(val);
449
450
            }
450
451
      }
 
452
      
 
453
void MasterEdit::sigChange(const AL::TimeSignature& sig)
 
454
{
 
455
  // TODO: FIXME: Tempo/sig undo + redo broken here. Either fix tempo and sig, or finish something here...
 
456
  MusEGlobal::audio->msgAddSig(MusEGlobal::song->cPos().tick(), sig.z, sig.n);  // Add will replace if found. 
 
457
}
 
458
 
 
459
void MasterEdit::tempoChange(double t)
 
460
{
 
461
  if(int(t) == 0)
 
462
    return;
 
463
  
 
464
  // TODO: FIXME: Tempo/sig undo + redo broken here. Either fix tempo and sig, or finish something here... Also in transport.
 
465
  //MusEGlobal::song->startUndo();
 
466
  //iTEvent e = find(tick);
 
467
  //MusEGlobal::audio->msgDeleteTempo(it->first, it->second, false);
 
468
  MusEGlobal::audio->msgAddTempo(MusEGlobal::song->cPos().tick(), int(60000000.0/t), true);  // Add will replace if found. 
 
469
  //MusEGlobal::song->endUndo(SC_TEMPO);
 
470
}
451
471
 
452
472
} // namespace MusEGui