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

« back to all changes in this revision

Viewing changes to midiedit/dlist.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: dlist.cpp,v 1.1 2002/01/30 13:25:31 muse Exp $
 
4
//    $Id: dlist.cpp,v 1.4 2003/11/19 21:28:40 lunar_shuttle Exp $
5
5
//  (C) Copyright 1999 Werner Schweer (ws@seh.de)
6
6
//=========================================================
7
7
 
153
153
//   devicesPopupMenu
154
154
//---------------------------------------------------------
155
155
 
156
 
void DList::devicesPopupMenu(DrumMap* t, int x, int y)
 
156
void DList::devicesPopupMenu(DrumMap* t, int x, int y, bool changeAll)
157
157
      {
158
158
      QPopupMenu* p = midiPortsPopup(this);
159
159
      int n = p->exec(mapToGlobal(QPoint(x, y)), 0);
160
 
      if (n != -1)
161
 
            t->port = n;
 
160
      if (n != -1) {
 
161
            if (!changeAll)
 
162
                  t->port = n;
 
163
            else
 
164
            for (int i=0; i<DRUM_MAPSIZE; i++)
 
165
                  drumMap[i].port = n;
 
166
            }
162
167
      delete p;
163
168
      }
164
169
 
170
175
      {
171
176
      int x = ev->x();
172
177
      int y = ev->y();
 
178
      int instr = y/TH;
173
179
      int button = ev->button();
174
180
      bool shift = ev->state() & ShiftButton;
175
181
      unsigned pitch = y / TH;
176
182
      DrumMap* dm = &drumMap[pitch];
 
183
      if (currentlySelected != 0) {
 
184
            if (dm != currentlySelected) {
 
185
                  currentlySelected->selected = false;
 
186
                  dm->selected = true;
 
187
                  currentlySelected = dm;
 
188
                  emit selectionChanged(currentlySelected);
 
189
                  emit keyFilterChanged(instr);
 
190
                  song->update(SC_DRUMMAP);
 
191
                  repaint();
 
192
            }
 
193
      }
 
194
      else {
 
195
            currentlySelected = dm;
 
196
            dm->selected = true;
 
197
            emit selectionChanged(currentlySelected);
 
198
            emit keyFilterChanged(instr);
 
199
            song->update(SC_DRUMMAP);
 
200
            repaint();
 
201
      }
177
202
 
178
203
      startY = y;
179
204
      sPitch = pitch;
188
213
      else if (button == QMouseEvent::MidButton)
189
214
            incVal = -1;
190
215
 
 
216
      // Check if we're already editing anything and have pressed the mouse elsewhere
 
217
      // In that case, treat it as if a return was pressed
 
218
      if (button == QMouseEvent::LeftButton) {
 
219
                  if ((editEntry && editEntry != dm  || col != selectedColumn) && editEntry != 0) {
 
220
                        returnPressed();
 
221
                        }
 
222
                  }
 
223
 
191
224
      switch (col) {
192
225
            case COL_NONE:
193
226
                  break;
196
229
                        dm->mute = !dm->mute;
197
230
                  break;
198
231
            case COL_PORT:
199
 
                  if (button == QMouseEvent::RightButton)
200
 
                        devicesPopupMenu(dm, mapx(x), mapy(pitch * TH));
 
232
                  if (button == QMouseEvent::RightButton) {
 
233
                        bool changeAll = ev->state() & ControlButton;
 
234
                        devicesPopupMenu(dm, mapx(x), mapy(pitch * TH), changeAll);
 
235
                        }
201
236
                  break;
202
237
            case COL_QNT:
203
238
                  dm->quant += incVal;
209
244
                        val = 0;
210
245
                  else if (val > 127)
211
246
                        val = 127;
 
247
                  // Check if there is any other drumMap with the same inmap value
 
248
                  // If so, switch the inmap between the instruments
 
249
                  for (int i=0; i<DRUM_MAPSIZE; i++) {
 
250
                        if (drumMap[i].enote == val && &drumMap[i] != dm) {
 
251
                              drumInmap[dm->enote] = i;
 
252
                              drumMap[i].enote = dm->enote;
 
253
                              break;
 
254
                        }
 
255
                  }
212
256
                  dm->enote = val;
213
 
                  drumInmap[val] = pitch;
 
257
                  drumInmap[val] = pitch; // The inmap for the particular note now points to the instrument we're currently at
214
258
                  break;
215
259
            case COL_LEN:
216
260
                  val = dm->len + incVal;
225
269
                  else if (val > 127)
226
270
                        val = 127;
227
271
                  dm->anote = val;
 
272
                  emit keyPressed(dm->enote, shift); //Send input-key
228
273
                  break;
229
274
            case COL_CHANNEL:
230
275
                  val = dm->channel + incVal;
232
277
                        val = 0;
233
278
                  else if (val > 127)
234
279
                        val = 127;
235
 
                  dm->channel = val;
 
280
                  if (ev->state() & ControlButton) {
 
281
                        for (int i=0; i<DRUM_MAPSIZE; i++)
 
282
                              drumMap[i].channel = val;
 
283
                  }
 
284
                  else
 
285
                        dm->channel = val;
236
286
                  break;
237
287
            case COL_LV1:
238
288
                  val = dm->lv1 + incVal;
267
317
                  dm->lv4 = val;
268
318
                  break;
269
319
            case COL_NAME:
270
 
                  if (button == QMouseEvent::LeftButton) {
271
 
                        if (editEntry && editEntry != dm)
272
 
                              returnPressed();
273
 
                        }
274
 
                  emit keyPressed(dm->anote, shift);
 
320
                  emit keyPressed(dm->enote, shift); //Send input key
275
321
                  break;
276
322
#if 0
277
323
            case COL_CHANNEL:
305
351
      {
306
352
      int x = ev->x();
307
353
      int y = ev->y();
308
 
//      int button = ev->button();
309
354
      unsigned pitch = y / TH;
310
355
      DrumMap* dm = &drumMap[pitch];
311
356
 
312
357
      int section = header->sectionAt(x);
313
358
 
314
 
      if (section == COL_NAME) {
 
359
      if (section == COL_NAME || section == COL_LEN || section == COL_LV1 ||
 
360
            section == COL_LV2 || section == COL_LV3 || section == COL_LV4) {
315
361
            editEntry = dm;
316
362
            if (editor == 0) {
317
363
                  editor = new QLineEdit(this);
323
369
            int colw = rmapx(header->sectionSize(section));
324
370
            int coly = mapy(pitch * TH);
325
371
            int colh = rmapy(TH);
326
 
            editor->setText(dm->name);
 
372
            selectedColumn = section; //Store selected column to have an idea of which one was selected when return is pressed
 
373
            switch (section) {
 
374
                  case COL_NAME:
 
375
                  editor->setText(dm->name);
 
376
                  break;
 
377
 
 
378
                  case COL_LEN: {
 
379
                  editor->setText(QString::number(dm->len));
 
380
                  break;
 
381
                  }
 
382
 
 
383
                  case COL_LV1:
 
384
                  editor->setText(QString::number(dm->lv1));
 
385
                  break;
 
386
 
 
387
                  case COL_LV2:
 
388
                  editor->setText(QString::number(dm->lv2));
 
389
                  break;
 
390
 
 
391
                  case COL_LV3:
 
392
                  editor->setText(QString::number(dm->lv3));
 
393
                  break;
 
394
 
 
395
                  case COL_LV4:
 
396
                  editor->setText(QString::number(dm->lv4));
 
397
                  break;
 
398
            }
 
399
 
327
400
            editor->end(false);
328
401
            editor->setGeometry(colx, coly, colw, colh);
 
402
            //In all cases but the column name, select all text:
 
403
            if (section != COL_NAME)
 
404
                  editor->selectAll();
329
405
            editor->show();
330
406
            }
331
407
      else
373
449
 
374
450
void DList::returnPressed()
375
451
      {
 
452
      int val = -1;
 
453
      if (selectedColumn != COL_NAME) {
 
454
            val = atoi(editor->text().ascii());
 
455
            if (selectedColumn != COL_LEN) {
 
456
                  if (val > 127) //Check bounds for lv1-lv4 values
 
457
                  val = 127;
 
458
                  if (val < 0)
 
459
                  val = 0;
 
460
                  }
 
461
            }
 
462
 
 
463
      switch(selectedColumn) {
 
464
            case COL_NAME:
 
465
                  editEntry->name = editor->text();
 
466
                  break;
 
467
 
 
468
            case COL_LEN:
 
469
                  editEntry->len = atoi(editor->text().ascii());
 
470
                  break;
 
471
 
 
472
            case COL_LV1:
 
473
                  editEntry->lv1 = val;
 
474
                  break;
 
475
 
 
476
            case COL_LV2:
 
477
                  editEntry->lv2 = val;
 
478
                  break;
 
479
 
 
480
            case COL_LV3:
 
481
                  editEntry->lv3 = val;
 
482
                  break;
 
483
 
 
484
            case COL_LV4:
 
485
                  editEntry->lv4 = val;
 
486
                  break;
 
487
 
 
488
            default:
 
489
                  printf("Return pressed in unknown column\n");
 
490
                  break;
 
491
            }
 
492
      selectedColumn = -1;
376
493
      editor->hide();
377
 
      editEntry->name = editor->text();
378
494
      editEntry = 0;
379
495
      setFocus();
 
496
      redraw();
380
497
      }
381
498
 
382
499
//---------------------------------------------------------
397
514
      }
398
515
 
399
516
//---------------------------------------------------------
 
517
//   songChanged
 
518
//---------------------------------------------------------
 
519
 
 
520
void DList::songChanged(int flags)
 
521
      {
 
522
      if (flags & SC_DRUMMAP)
 
523
            redraw();
 
524
      }
 
525
 
 
526
 
 
527
//---------------------------------------------------------
400
528
//   DList
401
529
//---------------------------------------------------------
402
530
 
414
542
      drag = NORMAL;
415
543
      editor = 0;
416
544
      editEntry = 0;
 
545
      currentlySelected = 0;
 
546
      selectedColumn = -1;
417
547
      }
 
548
//---------------------------------------------------------
 
549
//   ~DList
 
550
//---------------------------------------------------------
 
551
DList::~DList()
 
552
{
 
553
      if (currentlySelected != 0)
 
554
            currentlySelected->selected = false; //Reset the global
 
555
}
418
556
 
419
557
//---------------------------------------------------------
420
558
//   viewMouseMoveEvent
455
593
            drumMap[sPitch] = drumMap[dPitch];
456
594
            drumMap[dPitch] = dm;
457
595
            setCursor(QCursor(arrowCursor));
 
596
 
458
597
            drumInmap[drumMap[sPitch].enote]  = sPitch;
459
598
            drumOutmap[drumMap[sPitch].anote] = sPitch;
460
599
            drumInmap[drumMap[dPitch].enote]  = dPitch;
461
600
            drumOutmap[drumMap[dPitch].anote] = dPitch;
462
 
            emit mapChanged();
 
601
            currentlySelected = &drumMap[dPitch];
 
602
            emit mapChanged(sPitch, dPitch); //Pitch change throughout the whole track done in canvas
463
603
            }
464
604
      drag = NORMAL;
465
605
      redraw();
475
615
 
476
616
      switch (col) {
477
617
            case COL_NAME:
478
 
                  emit keyReleased(dm->anote, shift);
 
618
                  emit keyReleased(dm->enote, shift);
 
619
                  break;
 
620
            case COL_ANOTE:
 
621
                  emit keyReleased(dm->enote, shift);
479
622
                  break;
480
623
            default:
481
624
                  break;
482
625
            }
483
626
      }
484
627
 
 
628
int DList::getSelectedInstrument()
 
629
      {
 
630
            if (currentlySelected == 0)
 
631
                  return -1;
 
632
 
 
633
            return drumInmap[currentlySelected->enote];
 
634
      }