~ubuntu-branches/ubuntu/breezy/muse/breezy

« back to all changes in this revision

Viewing changes to midiedit/pianoroll.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Kobras
  • Date: 2004-02-07 15:18:22 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040207151822-es27xxkzbcxkebjm
Tags: 0.6.3-1
* New upstream version.
* Added patches:
  + [10_alsa_init_fix] New, from upstream CVS.
    Initialize direction variable when setting Alsa parameters.
  + [10_canvas_translation_fix] New, from upstream CVS.
    Do not translate tooltips twice in canvas popup.
  + [10_checkbox_fix] New, from upstream CVS.
    Use proper set/test methods on metronome checkboxes.
  + [10_html_doc_cleanup] New.
    Fix links and HTML errors in documentation.
  + [20_allow_system_timer] New.
    The new upstream version fails by default if the real-time clock
    could not be accessed (usually the case when not running suid-root).
    This patch reverts the old behaviour of falling back to the more
    inaccurate system timer.
* Updated patches:
  + [11_PIC_fixes_fixup] Rediffed.
* Removed patches:
  + [20_no_atomic_asm] Merged upstream.
* debian/compat: Splice out debhelper compatibility level from rules file.
* debian/control: Build-depend on latest jack release by default.
  Closes: #228788
* debian/control: Bump standards version.
* debian/control: Use auto-generated debconf dependency via misc:Depends.
* debian/control: Minor tweaks to the long description.
* debian/control: Tighten fluidsynth build dependency to sane version.
* debian/muse.doc-base: New. Register HTML documentation with doc-base.
* debian/templates: Tiny rewording, and typo fix.
* debian/templates, debian/po/*: Switch to po-debconf for translations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//=========================================================
2
2
//  MusE
3
3
//  Linux Music Editor
4
 
//    $Id: pianoroll.cpp,v 1.1 2002/01/30 14:10:08 muse Exp $
 
4
//    $Id: pianoroll.cpp,v 1.2 2003/11/07 23:38:51 lunar_shuttle Exp $
5
5
//  (C) Copyright 1999 Werner Schweer (ws@seh.de)
6
6
//=========================================================
7
7
 
42
42
 
43
43
int PianoRoll::_quantInit = 96;
44
44
int PianoRoll::_rasterInit = 96;
 
45
int PianoRoll::_widthInit = 600;
 
46
int PianoRoll::_heightInit = 400;
45
47
int PianoRoll::_quantStrengthInit = 80;      // 1 - 100%
46
48
int PianoRoll::_quantLimitInit = 50;         // tick value
47
49
bool PianoRoll::_quantLenInit = false;
51
53
static const int xscale = -10;
52
54
static const int yscale = 1;
53
55
static const int pianoWidth = 40;
 
56
static int pianorollTools = PointerTool | PencilTool | RubberTool | DrawTool;
54
57
 
55
58
//---------------------------------------------------------
56
59
//   PianoRoll
57
60
//---------------------------------------------------------
58
61
 
59
 
PianoRoll::PianoRoll(PartList* pl, QWidget* parent = 0, const char* name = 0)
 
62
PianoRoll::PianoRoll(PartList* pl, QWidget* parent, const char* name)
60
63
   : MidiEditor(_quantInit, _rasterInit, pl, parent, name)
61
64
      {
 
65
      resize(_widthInit, _heightInit);
62
66
      selEvent       = 0;
63
67
      selPart        = 0;
64
68
      quantConfig    = 0;
72
76
      //---------Men�----------------------------------
73
77
      menuEdit = new QPopupMenu(this);
74
78
      menuBar()->insertItem(tr("&Edit"), menuEdit);
 
79
      undoRedo->addTo(menuEdit);
 
80
      QAccel* ud = new QAccel(this);
 
81
      ud->connectItem(ud->insertItem(CTRL+Key_Z), song, SLOT(undo()));
 
82
      QAccel* rd = new QAccel(this);
 
83
      rd->connectItem(rd->insertItem(CTRL+Key_Y), song, SLOT(redo()));
 
84
 
 
85
      menuEdit->insertSeparator();
75
86
      menuEdit->insertItem(tr("Cut"),   PianoCanvas::CMD_CUT);
76
87
      menuEdit->setAccel(CTRL+Key_X,    PianoCanvas::CMD_CUT);
77
88
      menuEdit->insertItem(tr("Copy"),  PianoCanvas::CMD_COPY);
80
91
      menuEdit->setAccel(CTRL+Key_V,    PianoCanvas::CMD_PASTE);
81
92
      menuEdit->insertSeparator();
82
93
      menuEdit->insertItem(tr("Delete Events"), PianoCanvas::CMD_DEL);
 
94
      menuEdit->setAccel(Key_Delete, PianoCanvas::CMD_DEL);
83
95
      menuEdit->insertSeparator();
84
96
 
85
97
      QPopupMenu* menuSelect = new QPopupMenu(this);
86
98
      menuSelect->insertItem(tr("Select All"),   PianoCanvas::CMD_SELECT_ALL);
 
99
      menuSelect->setAccel(CTRL+Key_A, PianoCanvas::CMD_SELECT_ALL);
87
100
      menuSelect->insertItem(tr("Select None"),  PianoCanvas::CMD_SELECT_NONE);
 
101
      menuSelect->setAccel(CTRL+SHIFT+Key_A, PianoCanvas::CMD_SELECT_NONE);
88
102
      menuSelect->insertItem(tr("Invert"),       PianoCanvas::CMD_SELECT_INVERT);
 
103
      menuSelect->setAccel(CTRL+Key_I, PianoCanvas::CMD_SELECT_INVERT);
89
104
      menuSelect->insertSeparator();
90
105
      menuSelect->insertItem(tr("Inside Loop"),  PianoCanvas::CMD_SELECT_ILOOP);
91
106
      menuSelect->insertItem(tr("Outside Loop"), PianoCanvas::CMD_SELECT_OLOOP);
161
176
      speaker->setPixmap(*speakerIcon);
162
177
      speaker->setToggleButton(true);
163
178
 
164
 
      tools2 = new EditToolBar(this, PointerTool | PencilTool | RubberTool | DrawTool);
 
179
      tools2 = new EditToolBar(this, pianorollTools);
165
180
 
166
181
      //-------------------------------------------------------------
167
182
      //    Transport Bar
168
 
      new TransportToolbar(this);
 
183
      QToolBar* transport = new QToolBar(this);
 
184
      transportAction->addTo(transport);
169
185
 
170
186
      toolbar = new Toolbar1(this, _rasterInit, _quantInit);
171
187
      info    = new NoteInfo(this);
175
191
      //---------------------------------------------------
176
192
 
177
193
      splitter = new Splitter(Vertical, mainw, "splitter");
178
 
      QPushButton* ctrl = new QPushButton("ctrl", mainw, "Ctrl");
 
194
      QPushButton* ctrl = new QPushButton(tr("ctrl"), mainw, "Ctrl");
179
195
      QToolTip::add(ctrl, tr("Add Controller View"));
180
196
      hscroll = new ScrollScale(-25, -2, xscale, 20000, Horizontal, mainw);
181
197
      ctrl->setFixedSize(pianoWidth, hscroll->sizeHint().height());
199
215
 
200
216
      int offset = -(division/4);
201
217
      canvas->setOrigin(offset, 0);
 
218
      canvas->setCanvasTools(pianorollTools);
 
219
      canvas->setFocus();
 
220
      connect(canvas, SIGNAL(toolChanged(int)), tools2, SLOT(set(int)));
202
221
      time->setOrigin(offset, 0);
203
222
 
204
223
      gridS1->setRowStretch(2, 100);
243
262
      vscroll->setPos(KH * 30);
244
263
      setSelection(0, 0, 0);
245
264
 
246
 
      connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int)));
247
 
      connect(song, SIGNAL(soloChanged(SoundSource*)), SLOT(soloChanged(SoundSource*)));
 
265
      connect(song, SIGNAL(songChanged(int)), SLOT(songChanged1(int)));
248
266
 
249
267
      setCaption(canvas->getCaption());
250
268
      int s, e;
272
290
      }
273
291
 
274
292
//---------------------------------------------------------
 
293
//   songChanged1
 
294
//---------------------------------------------------------
 
295
 
 
296
void PianoRoll::songChanged1(int bits)
 
297
      {
 
298
      if (bits & SC_SOLO)
 
299
            toolbar->setSolo(canvas->track()->solo());
 
300
      songChanged(bits);
 
301
      }
 
302
 
 
303
//---------------------------------------------------------
275
304
//   follow
276
305
//---------------------------------------------------------
277
306
 
331
360
               selEvent->lenTick(),
332
361
               selEvent->pitch(),
333
362
               selEvent->velo(),
334
 
               selEvent->veloOff(),
335
 
               selEvent->channel()+1);
 
363
               selEvent->veloOff());
336
364
            }
337
365
      else {
338
366
            info->setEnabled(false);
353
381
      MidiEvent* event = new MidiEvent(*selEvent);
354
382
      switch(type) {
355
383
            case NoteInfo::VAL_TIME:
 
384
                  event->setPosTick(val - selPart->posTick());
356
385
                  break;
357
386
            case NoteInfo::VAL_LEN:
358
387
                  event->setLenTick(val);
363
392
            case NoteInfo::VAL_VELOFF:
364
393
                  event->setVeloOff(val);
365
394
                  break;
366
 
            case NoteInfo::VAL_CHANNEL:
367
 
//                  event->setChannel(val-1);
368
 
                  break;
369
395
            case NoteInfo::VAL_PITCH:
370
396
                  event->setPitch(val);
371
397
                  break;
448
474
                              _toInit = xml.parseInt();
449
475
                        else if (tag == "colormode")
450
476
                              colorModeInit = xml.parseInt();
 
477
                        else if (tag == "width")
 
478
                              _widthInit = xml.parseInt();
 
479
                        else if (tag == "height")
 
480
                              _heightInit = xml.parseInt();
451
481
                        else
452
482
                              xml.unknown("PianoRoll");
453
483
                        break;
473
503
      xml.intTag(level, "quantLimit", _quantLimitInit);
474
504
      xml.intTag(level, "quantLen", _quantLenInit);
475
505
      xml.intTag(level, "to", _toInit);
 
506
      xml.intTag(level, "width", _widthInit);
 
507
      xml.intTag(level, "height", _heightInit);
476
508
      xml.intTag(level, "colormode", colorModeInit);
477
509
      xml.etag(level, "pianoroll");
478
510
      }
479
511
 
480
 
void PianoRoll::soloChanged(SoundSource* s)
481
 
      {
482
 
      toolbar->setSolo(s == canvas->track());
483
 
      }
 
512
//---------------------------------------------------------
 
513
//   soloChanged
 
514
//    signal from solo button
 
515
//---------------------------------------------------------
484
516
 
485
517
void PianoRoll::soloChanged(bool flag)
486
518
      {
487
 
      song->setSolo(flag ? canvas->track() : 0);
 
519
      canvas->track()->node()->setSolo(flag);
488
520
      }
489
521
 
490
522
void PianoRoll::setRaster(int val)
493
525
      MidiEditor::setRaster(val);
494
526
      canvas->setFocus();     // give back focus after kb input
495
527
      }
 
528
 
496
529
void PianoRoll::setQuant(int val)
497
530
      {
498
531
      _quantInit = val;
622
655
            return;
623
656
            }
624
657
      bool shift = event->state() & ShiftButton;
625
 
//      bool ctrl  = event->state() & ControlButton;
626
658
 
627
659
      int index = 0;
628
660
      int n = sizeof(rasterTable);
636
668
 
637
669
      PianoCanvas* pc = (PianoCanvas*)canvas;
638
670
      switch(event->key()) {
 
671
            case Key_Escape:
 
672
                  close();
 
673
                  return;
639
674
            case Key_Right:
640
675
                  pc->pianoCmd(shift ? CMD_INSERT : CMD_RIGHT);
641
676
                  return;
672
707
            case Key_T:
673
708
                  val = rasterTable[index + ((off == 0) ? 9 : 0)];
674
709
                  break;
 
710
            case Key_E:
 
711
                  if (colorMode == 0)
 
712
                        colorMode = 1;
 
713
                  else if (colorMode == 1)
 
714
                        colorMode = 2;
 
715
                  else
 
716
                        colorMode = 0;
 
717
                  setEventColorMode(colorMode);
 
718
                  return;
 
719
            case Key_H: {
 
720
                  //This is a quite dirty hack. Since it's impossible to set scale value directly without using the [1,1024] domain,
 
721
                  //just increase/decrease until we reach next scale value. Would be better to put a function in
 
722
                  //scrollscale which receives a value from [scaleMin,scaleMax] directly. Not efficient for all in the world! /M.L.
 
723
                  int xmag = hscroll->mag();
 
724
                  int xscale = hscroll->getScaleValue();
 
725
                  if (xscale < hscroll->getScaleMax()) {
 
726
                        int xscale_next = xscale + 1;
 
727
                        while (hscroll->getScaleValue() != xscale_next) {
 
728
                              xmag+=10;
 
729
                              hscroll->setXmag(xmag);
 
730
                        }
 
731
                  }
 
732
                  return;
 
733
            }
 
734
            case Key_G: {
 
735
                  int xmag = hscroll->mag();
 
736
                  int xscale = hscroll->getScaleValue();
 
737
                  //I guess the rounding of the numbers makes it impossible to reach min /M.L.
 
738
                  if (xscale > hscroll->getScaleMin() + 1  && xmag > 20) {
 
739
                        int xscale_next = xscale - 1;
 
740
                        while (hscroll->getScaleValue() != xscale_next) {
 
741
                              xmag-=10;
 
742
                              hscroll->setXmag(xmag);
 
743
                        }
 
744
                  }
 
745
                  return;
 
746
            }
675
747
            case Key_Period:
676
748
                  val = rasterTable[index + ((off == 18) ? 9 : 18)];
677
749
                  break;
742
814
 
743
815
void PianoRoll::clipboardChanged()
744
816
      {
745
 
      QMimeSource* ms = QApplication::clipboard()->data();
746
 
      if (ms && ms->format(0)) {
747
 
            bool flag = strcmp(ms->format(0), "text/eventlist;charset=UTF-8") == 0;
748
 
            menuEdit->setItemEnabled(PianoCanvas::CMD_PASTE, flag);
 
817
      QMimeSource* ms = QApplication::clipboard()->data(QClipboard::Clipboard);
 
818
      bool flag = false;
 
819
      if (ms) {
 
820
            for (int i = 0;; ++i) {
 
821
                  if (ms->format(i) == 0)
 
822
                        break;
 
823
//                  printf("clipboard changed %s\n", ms->format(i));
 
824
                  flag = strcmp(ms->format(i), "text/eventlist;charset=UTF-8") == 0;
 
825
                  if (flag)
 
826
                        break;
 
827
                  }
749
828
            }
 
829
      menuEdit->setItemEnabled(PianoCanvas::CMD_PASTE, flag);
750
830
      }
751
831
 
752
832
//---------------------------------------------------------
771
851
      canvas->playEvents(_playEvents);
772
852
      }
773
853
 
 
854
//---------------------------------------------------------
 
855
//   resizeEvent
 
856
//---------------------------------------------------------
 
857
 
 
858
void PianoRoll::resizeEvent(QResizeEvent* ev)
 
859
      {
 
860
      QWidget::resizeEvent(ev);
 
861
      _widthInit = ev->size().width();
 
862
      _heightInit = ev->size().height();
 
863
      }
 
864