~ubuntu-branches/ubuntu/saucy/muse/saucy

« back to all changes in this revision

Viewing changes to muse/arranger/tlist.cpp

  • Committer: Package Import Robot
  • Author(s): Alessio Treglia
  • Date: 2013-01-07 10:27:14 UTC
  • mfrom: (1.1.14)
  • Revision ID: package-import@ubuntu.com-20130107102714-fajkwjbz02aqupbh
Tags: 2.1-1
* New upstream release.
* Refresh 1001-buildsystem.patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
80
80
static const int MIN_TRACKHEIGHT = 20;
81
81
static const int WHEEL_DELTA = 120;
82
82
QColor collist[] = { Qt::red, Qt::yellow, Qt::blue , Qt::black, Qt::white, Qt::green };
83
 
 
 
83
QString colnames[] = { "Red", "Yellow", "Blue", "Black", "White", "Green"};
84
84
//---------------------------------------------------------
85
85
//   TList
86
86
//---------------------------------------------------------
1446
1446
    if (id == cl->id())  // got it, change state
1447
1447
        cl->setVisible(act->isChecked());
1448
1448
  }
1449
 
  MusEGlobal::song->update(SC_TRACK_MODIFIED);
 
1449
 
 
1450
  // if automation is OFF for the track we change it to READ as a convenience
 
1451
  // hopefully this confuses users far less than not understanding why the
 
1452
  // automation does not do anything.
 
1453
  if (((MusECore::AudioTrack*)editAutomation)->automationType() == AUTO_OFF)
 
1454
  {
 
1455
      MusEGlobal::audio->msgSetTrackAutomationType((MusECore::AudioTrack*)editAutomation, AUTO_READ);
 
1456
      if (MusEGlobal::debugMsg)
 
1457
          printf("Changing automation from OFF to READ\n");
 
1458
  }
 
1459
 
 
1460
  MusEGlobal::song->update(SC_TRACK_MODIFIED|SC_AUTOMATION);
1450
1461
}
1451
1462
 
1452
1463
//---------------------------------------------------------
1461
1472
  int colindex = act->data().toInt() & 0xff;
1462
1473
  int id = (act->data().toInt() & 0x00ffffff) >> 8;
1463
1474
 
 
1475
  // Is it the clear automation action item?
 
1476
  // (As commented below, we should rewrite this to make it easier to understand..)
 
1477
  if (colindex == 253)
 
1478
  {
 
1479
      if(QMessageBox::question(MusEGlobal::muse, QString("Muse"),
 
1480
          tr("Clear all controller events?"), tr("&Ok"), tr("&Cancel"),
 
1481
          QString::null, 0, 1 ) == 0)
 
1482
      {
 
1483
        MusECore::AudioTrack* track = static_cast<MusECore::AudioTrack*>(editAutomation);
 
1484
        MusEGlobal::audio->msgClearControllerEvents(track, id);
 
1485
 
 
1486
      }
 
1487
  }
 
1488
 
 
1489
 
1464
1490
  // Is it the clear midi control action item?
1465
1491
  if(colindex == 254)  
1466
1492
  {
1537
1563
  MusECore::CtrlListList* cll = ((MusECore::AudioTrack*)editAutomation)->controller();
1538
1564
  for(MusECore::CtrlListList::iterator icll =cll->begin();icll!=cll->end();++icll) {
1539
1565
    MusECore::CtrlList *cl = icll->second;
1540
 
    if (cl->id() == id) // got it, change color
 
1566
    if (cl->id() == id) { // got it, change color and enable
1541
1567
        cl->setColor(collist[colindex]);
 
1568
        cl->setVisible(true);
 
1569
    }
1542
1570
  }
1543
1571
  MusEGlobal::song->update(SC_TRACK_MODIFIED);
1544
1572
}
1551
1579
  PopupMenu * m = new PopupMenu(parent, true);  
1552
1580
 
1553
1581
  QActionGroup* col_actgrp = new QActionGroup(m);
 
1582
  m->addAction(new MusEGui::MenuTitleItem(tr("Change color"), m));
1554
1583
  col_actgrp->setExclusive(true);
1555
1584
  for (int i = 0; i< 6; i++) {
1556
1585
    QPixmap pix(10,10);
1559
1588
    p.setPen(Qt::black);
1560
1589
    p.drawRect(0,0,10,10);
1561
1590
    QIcon icon(pix);
1562
 
    QAction *act = col_actgrp->addAction(icon,"");
 
1591
    QAction *act = col_actgrp->addAction(icon,colnames[i]);
1563
1592
    act->setCheckable(true);
1564
1593
    if (c == collist[i])
1565
1594
        act->setChecked(true);
1604
1633
      m->addActions(midi_actgrp->actions());
1605
1634
    }
1606
1635
  }
 
1636
  m->addAction(new MenuTitleItem(tr("Other"), m));
 
1637
  QAction *act = m->addAction(tr("clear automation"));
 
1638
  act->setCheckable(false);
 
1639
  act->setData((id<<8) + 253); // Shift 8 bits. Make clear menu item 253 (should enum this)
1607
1640
  
1608
1641
  connect(m, SIGNAL(triggered(QAction*)), SLOT(changeAutomationColor(QAction*)));
1609
1642
  return m;
1784
1817
                      act = p->addAction(cl->name());
1785
1818
                      act->setCheckable(true);
1786
1819
                      act->setChecked(cl->isVisible());
 
1820
 
 
1821
                      QPixmap pix(8,8);
 
1822
                      QPainter qp(&pix);
 
1823
                      qp.fillRect(0,0,8,8,cl->color());
 
1824
                      qp.setPen(Qt::black);
 
1825
                      qp.drawRect(0,0,8,8);
 
1826
                      QIcon icon(pix);
 
1827
                      act->setIcon(icon);
 
1828
                      //act->setIconVisibleInMenu(true); //setToolTip(tr("click to show/unshow, submenu to select color"));
1787
1829
                      
1788
1830
                      int data = ctrl<<8; // shift 8 bits
1789
1831
                      data += 150; // illegal color > 100