コード例 #1
0
ファイル: CanvasNavigator.cpp プロジェクト: falkTX/los
void CanvasNavigator::updateMarkers()
{
    MarkerList* markers = song->marker();
    for (iMarker m = markers->begin(); m != markers->end(); ++m)
    {
        QPointF point(calcSize(m->second.tick()), 0.0);
        QGraphicsRectItem* marker = m_markers.value(m->second.id());
        if(marker)
            marker->setPos(point);
    }
}
コード例 #2
0
ファイル: markerview.cpp プロジェクト: faesong/oom
void MarkerView::prevMarker()
{
	unsigned int curPos = song->cpos(); //prevent compiler warning: comparison of sigend/unsigned
	unsigned int nextPos = 0;
	MarkerList* marker = song->marker();
	for (iMarker i = marker->begin(); i != marker->end(); ++i)
	{
		if (i->second.tick() < curPos && i->second.tick() > nextPos)
			nextPos = i->second.tick();
	}
	/*      if (nextPos == 0)
			  return;*/
	Pos p(nextPos, true);
	song->setPos(0, p, true, true, false);
}
コード例 #3
0
ファイル: markerview.cpp プロジェクト: faesong/oom
void MarkerView::markerChanged(int val)
{
	//if (val != Song::MARKER_CUR)
	//      return;
	// p3.3.43
	switch (val)
	{
			// MARKER_CUR, MARKER_ADD, MARKER_REMOVE, MARKER_NAME,
			// MARKER_TICK, MARKER_LOCK
		case Song::MARKER_ADD:
		case Song::MARKER_REMOVE:
			updateList();
			break; // Try falling through and let it try to select something. No, let updateList() do it...

		case Song::MARKER_CUR:
		{

			MarkerList* marker = song->marker();
			for (iMarker i = marker->begin(); i != marker->end(); ++i)
			{
				if (i->second.current())
				{
					MarkerItem* item = (MarkerItem*) table->topLevelItem(0);
					while (item)
					{
						if (item->marker() == &i->second)
						{
							table->setCurrentItem(item);
							return;
						}
						item = (MarkerItem*) table->itemBelow(item);
					}
				}
			}
		}
			break;

		default:
			break;
	}
}
コード例 #4
0
ファイル: markerview.cpp プロジェクト: faesong/oom
void MarkerView::updateList()
{
	// Added p3.3.43 Manage selected item, due to clearing of table...
	MarkerList* marker = song->marker();
	MarkerItem* selitem = (MarkerItem*) table->currentItem();
	Marker* selm = selitem ? selitem->marker() : 0;
	// p3.3.44 Look for removed markers before added markers...
	if (selitem)
	{
		MarkerItem* mitem = (MarkerItem*) table->topLevelItem(0);
		while (mitem)
		{
			bool found = false;
			for (iMarker i = marker->begin(); i != marker->end(); ++i)
			{
				Marker* m = &i->second;
				if (m == mitem->marker())
				{
					found = true;
					break;
				}
			}
			// Anything removed from the marker list?
			if (!found)
			{
				// If it is the current selected item, it no longer exists. Make the next item be selected.
				if (mitem == selitem)
				{
					MarkerItem* mi = (MarkerItem*) table->itemBelow(selitem);
					if (mi)
					{
						selitem = mi;
						selm = selitem->marker();
					}
				}
			}
			mitem = (MarkerItem*) table->itemBelow(mitem);
		}
	}
	// Look for added markers...
	for (iMarker i = marker->begin(); i != marker->end(); ++i)
	{
		Marker* m = &i->second;
		bool found = false;
		MarkerItem* item = (MarkerItem*) table->topLevelItem(0);
		while (item)
		{
			if (item->marker() == m)
			{
				found = true;
				break;
			}
			item = (MarkerItem*) table->itemBelow(item);
		}
		// Anything new found in the marker list?
		if (!found)
			selm = m;
	}

	// Block signals added. Triggers itemSelectionChanged() causing crash. Tim.
	table->blockSignals(true);
	table->clear();
	table->blockSignals(false);

	//MarkerList* marker = song->marker();
	for (iMarker i = marker->begin(); i != marker->end(); ++i)
	{
		Marker* m = &i->second;

		// Changed p3.3.43
		//QString tick;
		//tick.setNum(i->first);
		//new MarkerItem(table, m);
		MarkerItem* item = new MarkerItem(table, m);
		if (m == selm)
		{
			m->setCurrent(true);
			table->setCurrentItem(item);
		}
		else
		{
			m->setCurrent(false);
		}
	}
}
コード例 #5
0
ファイル: mtscale.cpp プロジェクト: Adamiko/los
void MTScale::pdraw(QPainter& p, const QRect& r)
{
	QColor colTimeLine = QColor(172,181,176);
	int x = r.x();
	int w = r.width();

	//printf("MTScale::pdraw x:%d w:%d\n", x, w);

	x -= 20;
	w += 40; // wg. Text

	//---------------------------------------------------
	//    draw Marker
	//---------------------------------------------------

	int y = 12;
	p.setPen(colTimeLine);
	p.setFont(QFont("fixed-width", 9, QFont::Bold));
	p.drawLine(r.x(), y + 1, r.x() + r.width(), y + 1);
	QRect tr(r);
	tr.setHeight(12);
	MarkerList* marker = song->marker();
	for (iMarker m = marker->begin(); m != marker->end(); ++m)
	{

		int xp;
		if (waveMode)
			xp = mapx(m->second.frame());
		else
			xp = mapx(m->second.tick());
		if (xp > x + w)
			break;
		int xe = r.x() + r.width();
		iMarker mm = m;
		++mm;
		if (mm != marker->end())
		{

			if (waveMode)
				xe = mapx(tempomap.tick2frame(mm->first));
			else
				xe = mapx(mm->first);
		}

		QRect tr(xp, 0, xe - xp, 13);

		QRect wr = r.intersect(tr);
		if (!wr.isEmpty())
		{
			if (m->second.current())
			{
				p.fillRect(wr, QColor(89, 89, 102));
			}

			int x2;
			if (mm != marker->end())
			{
				if (waveMode)
					x2 = mapx(tempomap.tick2frame(mm->first));
				else
					x2 = mapx(mm->first);
			}
			else
				x2 = xp + 200;

			//printf("MTScale::pdraw marker %s xp:%d y:%d h:%d r.x:%d r.w:%d\n", m->second.name().toLatin1(), xp, height(), y, r.x(), r.width());

			// Must be reasonable about very low negative x values! With long songs > 15min
			//  and with high horizontal magnification, 'ghost' drawings appeared,
			//  apparently the result of truncation later (xp = -65006 caused ghosting
			//  at bar 245 with magnification at max.), even with correct clipping region
			//  applied to painter in View::paint(). Tim.  Apr 5 2009
			// Quote: "Warning: Note that QPainter does not attempt to work around
			//  coordinate limitations in the underlying window system. Some platforms may
			//  behave incorrectly with coordinates as small as +/-4000."
			if (xp >= -32)
				p.drawPixmap(xp, 0, *flagIconS);

			if (xp >= -1023)
			{
				QRect r = QRect(xp + 10, 0, x2 - xp, 12);
				p.setPen(colTimeLine);
				p.drawText(r, Qt::AlignLeft | Qt::AlignVCenter, m->second.name());
			}

			if (xp >= 0)
			{
				p.setPen(colTimeLine);
				p.drawLine(xp, y, xp, height());
			}
		}
	}
	unsigned ctick;
	int bar1, bar2, beat;
	unsigned tick;

	if (waveMode)
	{
		ctick = tempomap.frame2tick(mapxDev(x));
		AL::sigmap.tickValues(ctick, &bar1, &beat, &tick);
		AL::sigmap.tickValues(tempomap.frame2tick(mapxDev(x + w)),
				&bar2, &beat, &tick);
	}
	else
	{
		ctick = mapxDev(x);
		AL::sigmap.tickValues(ctick, &bar1, &beat, &tick);
		AL::sigmap.tickValues(mapxDev(x + w), &bar2, &beat, &tick);
	}

	//printf("bar %d  %d-%d=%d\n", bar, ntick, stick, ntick-stick);
	int h = height() - 12;

	int stick = AL::sigmap.bar2tick(bar1, 0, 0);
	int ntick;
	for (int bar = bar1; bar <= bar2; bar++, stick = ntick)
	{
		ntick = AL::sigmap.bar2tick(bar + 1, 0, 0);
		int tpix, a, b = 0;
		if (waveMode)
		{
			a = tempomap.tick2frame(ntick);
			b = tempomap.tick2frame(stick);
			tpix = rmapx(a - b);
		}
		else
		{
			tpix = rmapx(ntick - stick);
		}
		if (tpix < 64)
		{
			// don�t show beats if measure is this small
			int n = 1;
			if (tpix < 32)
				n = 2;
			if (tpix <= 16)
				n = 4;
			if (tpix < 8)
				n = 8;
			if (tpix <= 4)
				n = 16;
			if (tpix <= 2)
				n = 32;
			if (bar % n)
				continue;
			int x = mapx(waveMode ? b : stick);
			QString s;
			s.setNum(bar + 1);
			p.drawLine(x, y + 1, x, y + 1 + h);
			QRect r = QRect(x + 2, y, 1000, h);
			p.setFont(QFont("fixed-width", 9, QFont::Bold));
			p.drawText(r, Qt::AlignLeft | Qt::AlignVCenter | Qt::TextDontClip, s);
		}
		else
		{
			int z, n;
			AL::sigmap.timesig(stick, z, n);
			for (int beat = 0; beat < z; beat++)
			{
				int xx = AL::sigmap.bar2tick(bar, beat, 0);
				if (waveMode)
					xx = tempomap.tick2frame(xx);
				int xp = mapx(xx);
				QString s;
				QRect r(xp + 2, y, 1000, h);
				int y1;
				int num;
				if (beat == 0)
				{
					num = bar + 1;
					y1 = y + 1;
					p.setFont(QFont("fixed-width", 9, QFont::Bold));
				}
				else
				{
					num = beat + 1;
					y1 = y + 7;
					p.setFont(QFont("fixed-width", 7, QFont::Normal));
					r.setY(y + 3);
				}
				s.setNum(num);
				p.drawLine(xp, y1, xp, y + 1 + h);
				p.drawText(r, Qt::AlignLeft | Qt::AlignVCenter | Qt::TextDontClip, s);
			}
		}
	}

	//---------------------------------------------------
	//    draw location marker
	//---------------------------------------------------

	//Christopher here is your color
	p.setPen(QColor(156,75,219));

	if (pos[3] != MAXINT)
	{
		int xp = mapx(pos[3]);
		if (xp >= x && xp < x + w)
			p.drawLine(xp, 0, xp, height());
	}

	p.setPen(colTimeLine);
	if (barLocator)
	{
		p.setPen(QColor(0, 186, 255));
		int xp = mapx(pos[0]);
		if (xp >= x && xp < x + w)
			p.drawLine(xp, 0, xp, height());
		p.setPen(QColor(139, 225, 69));
		xp = mapx(pos[1]);
		if (xp >= x && xp < x + w)
			p.drawLine(xp, 0, xp, height());
		xp = mapx(pos[2]);
		if (xp >= x && xp < x + w)
			p.drawLine(xp, 0, xp, height());
	}
	else
	{
		for (int i = 0; i < 3; ++i)
		{
			int xp = mapx(pos[i]);
			if (xp >= x && xp < x + w)
			{
				QPixmap* pm = markIcon[i];
				p.drawPixmap(xp - pm->width() / 2, y - 1, *pm);
			}
		}
	}
}
コード例 #6
0
ファイル: structure.cpp プロジェクト: Windfisch/muse
void adjustGlobalLists(Undo& operations, int startPos, int diff)
{
  const TempoList* t = &MusEGlobal::tempomap;
  const AL::SigList* s   = &AL::sigmap;
  const KeyList* k   = &MusEGlobal::keymap;

  criTEvent it   = t->rbegin();
  AL::criSigEvent is = s->rbegin();
  criKeyEvent ik = k->rbegin();

  // key
  for (; ik != k->rend(); ik++) {
    const KeyEvent &ev = (KeyEvent)ik->second;
    int tick = ev.tick;
    int key = ev.key;
    if (tick < startPos )
      break;

    if (tick > startPos && tick +diff < startPos ) { // remove
      operations.push_back(UndoOp(UndoOp::DeleteKey, tick, key));
    }
    else {
      operations.push_back(UndoOp(UndoOp::DeleteKey,tick, key));
      operations.push_back(UndoOp(UndoOp::AddKey,tick+diff, key));
      }
  }

  // tempo
  for (; it != t->rend(); it++) {
    const TEvent* ev = (TEvent*)it->second;
    int tick = ev->tick;
    int tempo = ev->tempo;
    if (tick < startPos )
      break;

    if (tick > startPos && tick +diff < startPos ) { // remove
      operations.push_back(UndoOp(UndoOp::DeleteTempo,tick, tempo));
    }
    else {
      operations.push_back(UndoOp(UndoOp::DeleteTempo,tick, tempo));
      operations.push_back(UndoOp(UndoOp::AddTempo,tick+diff, tempo));
      }
  }

  // sig
  for (; is != s->rend(); is++) {
    const AL::SigEvent* ev = (AL::SigEvent*)is->second;
    int tick = ev->tick;
    if (tick < startPos )
      break;

    int z = ev->sig.z;
    int n = ev->sig.n;
    if (tick > startPos && tick +diff < startPos ) { // remove
      operations.push_back(UndoOp(UndoOp::DeleteSig,tick, z, n));
    }
    else {
      operations.push_back(UndoOp(UndoOp::DeleteSig,tick, z, n));
      operations.push_back(UndoOp(UndoOp::AddSig,tick+diff, z, n));
    }
  }

  MarkerList *markerlist = MusEGlobal::song->marker();
  for(iMarker i = markerlist->begin(); i != markerlist->end(); ++i)
  {
      Marker* m = &i->second;
      int tick = m->tick();
      if (tick > startPos)
      {
        if (tick + diff < startPos ) { // these ticks should be removed
          operations.push_back(UndoOp(UndoOp::ModifyMarker, 0, m));    
        } else {
          Marker *newMarker = new Marker();
          *newMarker = *m;
          newMarker->setTick(tick + diff);  
          operations.push_back(UndoOp(UndoOp::ModifyMarker, newMarker, m));
        }
      }
  }

}
コード例 #7
0
ファイル: CanvasNavigator.cpp プロジェクト: falkTX/los
void CanvasNavigator::updateParts()/*{{{*/
{
    m_editing = true;
    m_playhead = 0;
    m_start = 0;
    m_canvasBox =  0;
    m_punchIn = 0;
    m_punchOut = 0;
    m_parts.clear();
    m_markers.clear();
    m_scene->clear();
    /*foreach(PartItem* i, m_parts)
        m_scene->removeItem(i);
    while(m_parts.size())
        delete m_parts.takeFirst();*/
    m_heightList.clear();
    m_scene->setSceneRect(QRectF());
    int index = 1;
    //QList<QGraphicsItem*> group;
    MidiTrackList* tl = song->visibletracks();
    ciMidiTrack ci = tl->begin();
    for(; ci != tl->end(); ci++)
    {
        m_heightList.append((*ci)->height());
    }
    ci = tl->begin();
    if(ci != tl->end())
    {
        int mh = (*ci)->height();
        double partHeight = (mh * 8)/100;
        m_start = m_scene->addRect(0.0, 0.0, calcSize(song->len()), partHeight);
        m_start->setBrush(QColor(63, 63, 63));
        m_start->setPen(QPen(QColor(63, 63, 63)));
        m_start->setZValue(-50);
        ci++;//Special case for master
    }
    for(; ci != tl->end(); ci++)
    {
        MidiTrack* track = *ci;
        if(track)
        {
            QList<int> list = m_heightList.mid(0, index);
            int ypos = 0;
            foreach(int i, list)
                ypos += i;
            ypos = (ypos * 8)/100;
            int ih = m_heightList.at(index);
            double partHeight = (ih * 8)/100;

            //qDebug("CanvasNavigator::updateParts: partHeight: %2f, ypos: %d", partHeight, ypos);
            PartList* parts = track->parts();
            if(parts && !parts->empty())
            {
                for(iPart p = parts->begin(); p != parts->end(); p++)
                {
                    Part *part =  p->second;

                    int tick, len;
                    if(part)
                    {
                        tick = part->tick();
                        len = part->lenTick();
                    }
                    double w = calcSize(len);
                    double pos = calcSize(tick);

                    PartItem* item = new PartItem(pos, ypos, w, partHeight);
                    item->setPart(part);
                    m_parts.append(item);
                    //group.append((QGraphicsItem*)item);
                    int i = part->colorIndex();
                    QColor partWaveColor(config.partWaveColors[i]);
                    QColor partColor(config.partColors[i]);
                    //partWaveColor.setAlpha(150);
                    partColor.setAlpha(150);
                    item->setBrush(part->selected() ? partWaveColor : partColor);
                    item->setPen(part->selected() ? partColor : partWaveColor);
                    m_scene->addItem(item);
                }
            }
            ++index;
        }
    }
    QColor colTimeLine = QColor(0, 186, 255);
    int kpos = 0;
    foreach(int i, m_heightList)
        kpos += i;
    //kpos = ((kpos + 400) * 8)/100;
    kpos = ((kpos + 400) * 8)/100;

    m_playhead = new QGraphicsRectItem(0, 0, 1, kpos);
    m_playhead->setBrush(colTimeLine);
    m_playhead->setPen(Qt::NoPen);
    m_playhead->setZValue(124001.0f);
    m_playhead->setFlags(QGraphicsItem::ItemIgnoresTransformations);
    m_scene->addItem(m_playhead);
    QColor loopColor(139, 225, 69);
    QColor markerColor(243,191,124);
    MarkerList* markers = song->marker();
    for (iMarker m = markers->begin(); m != markers->end(); ++m)
    {
        //double xp = calcSize(m->second.tick());
        QGraphicsRectItem *marker = m_scene->addRect(0, 0, 1, kpos);
        marker->setData(Qt::UserRole, m->second.id());
        m_markers[m->second.id()] = marker;
        marker->setPen(Qt::NoPen);
        marker->setBrush(markerColor);
        marker->setZValue(124002.0f);
        marker->setFlags(QGraphicsItem::ItemIgnoresTransformations);
        m_updateMarkers = true;
    }

    m_punchIn = new QGraphicsRectItem(0, 0, 1, kpos);
    m_punchIn->setBrush(loopColor);
    m_punchIn->setPen(Qt::NoPen);
    m_punchIn->setZValue(124003.0f);
    m_punchIn->setFlags(QGraphicsItem::ItemIgnoresTransformations);
    m_scene->addItem(m_punchIn);
    m_punchIn->setVisible(song->loop() || song->punchin());

    m_punchOut = new QGraphicsRectItem(0, 0, 1, kpos);
    m_punchOut->setBrush(loopColor);
    m_punchOut->setPen(Qt::NoPen);
    m_punchOut->setZValue(124003.0f);
    m_punchOut->setFlags(QGraphicsItem::ItemIgnoresTransformations);
    m_scene->addItem(m_punchOut);
    m_punchOut->setVisible(song->loop() || song->punchout());

    createCanvasBox();

    //group.append((QGraphicsItem*)m_start);
    //group.append((QGraphicsItem*)m_playhead);
    //if(group.size())
    //{
    //	m_partGroup = m_scene->createItemGroup(group);
    //}
    //else
    m_partGroup = 0;
    updateSpacing();
    m_editing = false;
}/*}}}*/