Ejemplo n.º 1
0
void TrackView::setEditTrack(int newEditTrack, bool selecting)
{
	if (0 == getTrackCount()) return;

	int oldEditTrack = editTrack;
	editTrack = newEditTrack;

	// clamp to document
	editTrack = qBound(0, editTrack, getTrackCount() - 1);

	if (oldEditTrack != editTrack) {
		updateSelection(QPoint(editTrack, editRow), selecting);
		onTrackHeaderChanged(oldEditTrack);
		onTrackHeaderChanged(editTrack);
		dirtyPosition();
		dirtyCurrentValue();
	}

	if (viewport()->width() > 0) {
		int viewportWidth = viewport()->width() - leftMarginWidth;
		int minX = getLogicalX(editTrack);
		int maxX = getLogicalX(editTrack + 1);

		if (minX < scrollPosX)
			setScrollPos(minX, scrollPosY);
		else if (maxX > scrollPosX + viewportWidth)
			setScrollPos(maxX - viewportWidth, scrollPosY);
	} else
		setupScrollBars();
}
Ejemplo n.º 2
0
void TrackView::mouseMoveEvent(QMouseEvent *event)
{
	int track = getTrackFromPhysicalX(event->pos().x());
	if (dragging) {
		const int trackCount = getTrackCount();

		if (track < 0 || track >= trackCount)
			return;

		if (track > anchorTrack) {
			for (int i = anchorTrack; i < track; ++i)
				page->swapTrackOrder(i, i + 1);
			anchorTrack = track;
			setEditTrack(track, false);
		} else if (track < anchorTrack) {
			for (int i = anchorTrack; i > track; --i)
				page->swapTrackOrder(i, i - 1);
			anchorTrack = track;
			setEditTrack(track, false);
		}
	} else {
		if (event->pos().y() < topMarginHeight &&
		    track >= 0 && track < getTrackCount()) {
			setCursor(handCursor);
		} else
			setCursor(QCursor(Qt::ArrowCursor));
	}
}
Ejemplo n.º 3
0
void TrackView::editBiasValue(float amount)
{
	SyncDocument *doc = getDocument();

	if (0 == getTrackCount()) {
		QApplication::beep();
		return;
	}

	QRect selection = getSelection();

	doc->beginMacro("bias");
	for (int track = selection.left(); track <= selection.right(); ++track) {
		Q_ASSERT(track < getTrackCount());
		SyncTrack *t = getTrack(track);

		for (int row = selection.top(); row <= selection.bottom(); ++row) {
			if (t->isKeyFrame(row)) {
				SyncTrack::TrackKey k = t->getKeyFrame(row); // copy old key
				k.value += amount; // modify value

				// add sub-command
				doc->setKeyFrame(t, k);
			}
		}
	}
	doc->endMacro();

	dirtyCurrentValue();
}
Ejemplo n.º 4
0
void TrackView::editEnterValue()
{
	SyncDocument *doc = getDocument();
	if (!lineEdit->isVisible())
		return;

	if (lineEdit->text().length() > 0 && editTrack < getTrackCount()) {
		SyncTrack *t = getTrack(editTrack);

		SyncTrack::TrackKey newKey;
		newKey.type = SyncTrack::TrackKey::STEP;
		newKey.row = editRow;
		if (t->isKeyFrame(editRow))
			newKey = t->getKeyFrame(editRow); // copy old key
		QString text = lineEdit->text();
		text.remove(lineEdit->validator()->locale().groupSeparator()); // workaround QTBUG-40456
		newKey.value = lineEdit->validator()->locale().toFloat(text); // modify value

		doc->setKeyFrame(t, newKey);

		dirtyCurrentValue();
	} else
		QApplication::beep();

	lineEdit->hide();
	setFocus();
}
Ejemplo n.º 5
0
static void deleteArea(int rowPos, int track, int bufferWidth, int bufferHeight)
{
	int i, j;
	const int track_count = getTrackCount();
	struct sync_track** tracks = getTracks();

	Commands_beginMulti("deleteArea");

	for (i = 0; i < bufferWidth; ++i) 
	{
		struct sync_track* t;
		int trackPos = track + i;
		int trackIndex = trackPos;

		if (trackPos >= track_count) 
			continue;

		t = tracks[trackIndex];

		for (j = 0; j < bufferHeight; ++j) 
		{
			int row = rowPos + j;

			Commands_deleteKey(trackIndex, row);
		}
	}

	Commands_endMulti();
	updateNeedsSaving();
}
Ejemplo n.º 6
0
void TrackView::editToggleInterpolationType()
{
	SyncDocument *doc = getDocument();

	if (editTrack < getTrackCount()) {
		SyncTrack *t = getTrack(editTrack);
		QMap<int, SyncTrack::TrackKey> keyMap = t->getKeyMap();

		QMap<int, SyncTrack::TrackKey>::const_iterator it = keyMap.lowerBound(editRow);
		if (it != keyMap.constBegin() && it.key() != editRow)
			--it;

		if (it.key() > editRow || it == keyMap.constEnd()) {
			QApplication::beep();
			return;
		}

		// copy and modify
		SyncTrack::TrackKey newKey = *it;
		newKey.type = (SyncTrack::TrackKey::KeyType)
		    ((newKey.type + 1) % SyncTrack::TrackKey::KEY_TYPE_COUNT);

		// apply change to data-set
		doc->setKeyFrame(t, newKey);

		// update user interface
		dirtyCurrentValue();
	} else
		QApplication::beep();
}
Ejemplo n.º 7
0
//------------------------------------------------------------------------------
bool UnixRedBookDevice::play(U32 track)
{
#if !defined(__FreeBSD__)
   if(!mAcquired)
   {
      setLastError("Device has not been acquired");
      return(false);
   }

   U32 numTracks;
   if(!getTrackCount(&numTracks))
      return(false);

   if(track >= numTracks)
   {
      setLastError("Track index is out of range");
      return(false);
   }

   if (!updateStatus())
      return false;

   AssertFatal(mCD, "mCD is NULL");
   if (SDL_CDPlayTracks(mCD, track, 0, 1, 0) == -1)
   {
      setLastError(SDL_GetError());
      return false;
   }

   mPlaying = true;

   setLastError("");
   return(true);
#endif	// !defined(__FreeBSD__)
}
Ejemplo n.º 8
0
void TrackView::editCut()
{
	if (0 == getTrackCount()) {
		QApplication::beep();
		return;
	}

	editCopy();
	editClear();
}
Ejemplo n.º 9
0
void TrackView::mousePressEvent(QMouseEvent *event)
{
	int track = getTrackFromPhysicalX(event->pos().x());
	if (event->button() == Qt::LeftButton &&
	    event->pos().y() < topMarginHeight &&
	    track >= 0 && track < getTrackCount()) {
		dragging = true;
		anchorTrack = track;
	}
}
Ejemplo n.º 10
0
void TrackView::paintTracks(QStylePainter &painter, const QRegion &region)
{
	const QRect &rect = region.boundingRect();
	int startTrack = qBound(0, getTrackFromPhysicalX(qMax(rect.left(), leftMarginWidth)), getTrackCount());
	int endTrack = qBound(0, getTrackFromPhysicalX(rect.right()) + 1, getTrackCount());

	painter.setClipRect(QRectF(QPointF(leftMarginWidth - 0.5f, topMarginHeight - 0.5f),
	                           QPointF(rect.right() + 1.0f, rect.bottom() + 1.0f)));
	painter.fillRect(rect, palette().dark());

	for (int track = startTrack; track < endTrack; ++track)
		paintTrack(painter, region, track);
}
Ejemplo n.º 11
0
void TrackView::editClear()
{
	SyncDocument *doc = getDocument();

	QRect selection = getSelection();

	if (0 == getTrackCount()) return;
	Q_ASSERT(selection.right() < getTrackCount());

	doc->beginMacro("clear");
	for (int track = selection.left(); track <= selection.right(); ++track) {
		SyncTrack *t = getTrack(track);

		for (int row = selection.top(); row <= selection.bottom(); ++row) {
			if (t->isKeyFrame(row))
				doc->deleteKeyFrame(t, row);
		}
	}

	doc->endMacro();
	dirtyCurrentValue();
}
Ejemplo n.º 12
0
void TrackView::setupScrollBars()
{
	verticalScrollBar()->setValue(editRow);
	verticalScrollBar()->setMinimum(0);
	verticalScrollBar()->setMaximum(getRows() - 1);
	verticalScrollBar()->setPageStep(windowRows);

	int contentWidth = getTrackCount() * trackWidth;
	int viewWidth = qMax(viewport()->width() - leftMarginWidth, 0);
	horizontalScrollBar()->setValue(editTrack * trackWidth);
	horizontalScrollBar()->setRange(0, contentWidth - viewWidth);
	horizontalScrollBar()->setSingleStep(20);
	horizontalScrollBar()->setPageStep(viewWidth);
}
Ejemplo n.º 13
0
static void updateTrackStatus()
{
	int i, track_count = getTrackCount();

	if (RemoteConnection_connected())
		return;

	if (reset_tracks)
	{
		for (i = 0; i < track_count; ++i)
			s_editorData.trackData.tracks[i].active = false;

		Editor_update();

		reset_tracks = false;
	}
}
Ejemplo n.º 14
0
    void NSFSoundStream::setCurrentTrack(int track) {
        sf::Lock lock(mutex);

        if(track >= 0 && track < getTrackCount()) {
            // sampleEmus[activeSampler]->start_track(track);
            // activeSampler++;
            // activeSampler %= samplerCount;
            if(samplerSlots.count(track) > 0) {
                auto sampler = samplerSlots.at(track);
                (sampler.first)->start_track(track);
            } else if(!availableSamplers.empty()) {
                auto sampler = availableSamplers.top();
                availableSamplers.pop();
                (sampler.first)->start_track(track);
                activeSamplers.push_back(sampler);
                samplerSlots[track] = sampler;
            }
        }
    }
Ejemplo n.º 15
0
static void onTrackSide(enum ArrowDirection dir, bool startOrEnd, enum Selection selection)
{
	TrackViewInfo* viewInfo = getTrackViewInfo(); 
	TrackData* trackData = getTrackData();
	const int trackCount = getTrackCount();
	const int oldTrack = getActiveTrack();
	int track = 0;

	if (dir == ARROW_LEFT)
		track = startOrEnd ? 0 : getPrevTrack();
	else
		track = startOrEnd ? trackCount - 1 : getNextTrack();

	track = eclampi(track, 0, trackCount); 

	setActiveTrack(track);

	if (selection == DO_SELECTION)
	{
		Track* t = &trackData->tracks[track];

		// if this track has a folded group we can't select it so set back the selection to the old one

		if (t->group->folded)
			setActiveTrack(oldTrack);
		else
		{
			viewInfo->selectStopTrack = track;
		}
	}
	else
	{
		viewInfo->selectStartTrack = viewInfo->selectStopTrack = track;
		viewInfo->selectStartRow = viewInfo->selectStopRow = getRowPos();
	}

	if (!TrackView_isSelectedTrackVisible(viewInfo, trackData, track))
	{
		s_editorData.trackViewInfo.startPixel += TrackView_getTracksOffset(viewInfo, trackData, oldTrack, track);
		Editor_updateTrackScroll();
	}
}
Ejemplo n.º 16
0
void TrackView::paintTopMargin(QStylePainter &painter, const QRegion &region)
{
	const QRect &rect = region.boundingRect();
	painter.setClipRect(QRectF(QPointF(0.0f, 0.0f),
	                    QPointF(rect.right() + 1.0f, topMarginHeight - 0.5f)));

	QRect topMargin(QPoint(-2, 0),
	                QPoint(rect.right() + 3, topMarginHeight - 1));
	painter.fillRect(topMargin.adjusted(1, 1, -1, -1), palette().button());
	qDrawWinButton(&painter, topMargin, palette());

	int startTrack = qBound(0, getTrackFromPhysicalX(qMax(rect.left(), leftMarginWidth)), getTrackCount());
	int endTrack = qBound(0, getTrackFromPhysicalX(rect.right()) + 1, getTrackCount());

	for (int track = startTrack; track < endTrack; ++track) {
		const SyncTrack *t = getTrack(track);

		QRect topMargin(getPhysicalX(track), 0, trackWidth, topMarginHeight);
		if (!region.intersects(topMargin))
			continue;

		QRect fillRect = topMargin;

		QBrush bgBrush = palette().button();
		if (track == editTrack)
			bgBrush = editBrush;

		painter.fillRect(fillRect.adjusted(1, 1, -1, -1), bgBrush);
		qDrawWinButton(&painter, fillRect, bgBrush.color());

		if (!t->isActive())
			painter.setPen(QColor(128, 128, 128));
		else
			painter.setPen(QColor(0, 0, 0));

		painter.drawText(fillRect, t->getDisplayName());
	}

	// make sure that the top margin isn't overdrawn by the track-data
	painter.setClipRegion(QRect(0, topMarginHeight, rect.right() + 1, rect.bottom() + 1));
}
Ejemplo n.º 17
0
void TrackView::editCopy()
{
	if (0 == getTrackCount()) {
		QApplication::beep();
		return;
	}

	QRect selection = getSelection();

	QVector<struct CopyEntry> copyEntries;
	for (int track = selection.left(); track <= selection.right(); ++track) {
		const SyncTrack *t = getTrack(track);

		for (int row = selection.top(); row <= selection.bottom(); ++row) {
			if (t->isKeyFrame(row)) {
				CopyEntry ce;
				ce.track = track - selection.left();
				ce.keyFrame = t->getKeyFrame(row);
				ce.keyFrame.row -= selection.top();
				copyEntries.push_back(ce);
			}
		}
	}

	int buffer_width  = selection.width();
	int buffer_height = selection.height();
	size_t buffer_size = copyEntries.size();

	QByteArray data;
	data.append((char *)&buffer_width, sizeof(int));
	data.append((char *)&buffer_height, sizeof(int));
	data.append((char *)&buffer_size, sizeof(size_t));
	data.append((char *)copyEntries.data(), sizeof(CopyEntry) * copyEntries.size());

	QMimeData *mimeData = new QMimeData;
	mimeData->setData("application/x-gnu-rocket", data);
	QApplication::clipboard()->setMimeData(mimeData);
}
Ejemplo n.º 18
0
static void onPaste()
{
	const int buffer_width = s_copyData.bufferWidth;
	const int buffer_height = s_copyData.bufferHeight;
	const int buffer_size = s_copyData.count;
	const int track_count = getTrackCount();
	const int row_pos = getRowPos();
	const int active_track = getActiveTrack();
	int i, trackPos;

	if (!s_copyData.entries)
		return;

	// First clear the paste area

	deleteArea(row_pos, active_track, buffer_width, buffer_height);

	Commands_beginMulti("pasteArea");

	for (i = 0; i < buffer_size; ++i)
	{
		const CopyEntry* ce = &s_copyData.entries[i];
		
		trackPos = active_track + ce->track;
		if (trackPos < track_count)
		{
			size_t trackIndex = trackPos;
			struct track_key key = ce->keyFrame;
			key.row += row_pos;

			Commands_addOrUpdateKey(trackIndex, &key);
		}
	}

	Commands_endMulti();
	updateNeedsSaving();
}
Ejemplo n.º 19
0
void Track::writeData( QByteArray& data) const {
    QBuffer buffer( data);
    buffer.open(IO_WriteOnly);
    QDataStream stream( &buffer);
    stream.setByteOrder( QDataStream::LittleEndian);

    /** Write the track header **/
    stream << (Q_UINT32) 0x7469686D;        // 0x00 mhit
    stream << (Q_UINT32) 0xf4;              // 0x04 headerlen
    stream << (Q_UINT32) 0x0;               // 0x08 length - set later
    stream << (Q_UINT32) 0x0;               // 0x0C number of mhods
    stream << (Q_UINT32) getID();           // 0x10
    stream << (Q_UINT32) 1;                 // 0x14
    //stream << (Q_UINT32) 0;                 // 0x18
    stream << (Q_UINT32) 0x4d503320;        // ipod shiffle wants a "MP3 " here
    stream << vbr;                          // 0x1C
    stream << type;                         // 0x1D
    stream << compilation;                  // 0x1E
    stream << rating;                       // 0x1F
    stream << (Q_UINT32) getLastModified()+ MAC_EPOCH_DELTA; // 0x20
    stream << (Q_UINT32) getFileSize();     // 0x24
    stream << (Q_UINT32) getTrackLength();  // 0x28
    stream << (Q_UINT32) getTrackNumber();  // 0x2C
    stream << (Q_UINT32) getTrackCount();   // 0x30
    stream << (Q_UINT32) getYear();         // 0x34
    stream << (Q_UINT32) getBitrate();      // 0x38
    stream << (Q_UINT32) getSamplerate();   // 0x3C
    stream << (Q_UINT32) getVolumeAdjust(); // 0x40
    stream << (Q_UINT32) 0;                 // 0x44 empty space
    //stream << (Q_UINT32) getTrackLength();  // 0x48 empty space
    stream << (Q_UINT32) 0;  // 0x48 empty space
    stream << (Q_UINT32) 0;                 // 0x4C empty space
    stream << (Q_UINT32) getPlayCount();    // 0x50
    stream << (Q_UINT32) getPlayCount();    // 0x54
    stream << (Q_UINT32) getLastPlayed();   // 0x58
    stream << (Q_UINT32) getCdNumber();     // 0x5C
    stream << (Q_UINT32) getCdCount();      // 0x60
    stream << (Q_UINT32) 0;                 // 0x64 empty space //userid from apple store
    stream << (Q_UINT32) date_added;        // 0x68
    stream << (Q_UINT32) 0;                 // boockmarktime
    stream << (Q_UINT64) dbid;              // unique bit (64 bit)
    stream << (Q_UINT8) 0;                 // checked in iTZnes
    stream << (Q_UINT8) 0;                 // application rating
    stream << (Q_UINT16) 0;                 // BPM
    stream << (Q_UINT16) 0;                 // artworkcount
    stream << (Q_UINT16) 0xffff;            // unkown
    stream << (Q_UINT32) 0;                 // artwork size
    stream << (Q_UINT32) 0;                 // unkown
    stream << (float) -getSamplerate();      // samplerate as floating point "-"?!?
    stream << (Q_UINT32) 0;                 // date/time added
    stream << (Q_UINT32) file_format_code;  // unkown, but 0x0000000c for MP3 ?
    stream << (Q_UINT32) 0;                 // unkown
    stream << (Q_UINT32) 0;                 // unkown
    stream << (Q_UINT32) 0;                 // unkown
    stream << (Q_UINT32) 0;                 // unkown
    stream << (Q_UINT32) 0x02;              // unknown
    stream << (Q_UINT64) dbid; // same unique id as above
    for( int i= 0; i< 17; i++)
        stream << (Q_UINT32) 0;
    
    /** Write Track contents **/
    Q_UINT32 num_mhods = 0;
    for( PropertyMap::const_iterator element= properties.begin(); element!= properties.end(); ++element) {
        if( (*element).isEmpty())
            continue;

        const char *data= (const char *)(*element).ucs2();
        if( data == NULL)
            continue;

        int datalen= 2* (*element).length();

        stream << (Q_UINT32) 0x646F686D;    // mhod
        stream << (Q_UINT32) 0x18;    // headerlen
        stream << (Q_UINT32) 40+ datalen;
        stream << (Q_UINT32) element.key();
        stream << (Q_UINT32) 0;
        stream << (Q_UINT32) 0;
        stream << (Q_UINT32) 1;    // dummy - would refer to the trackID if used in playlist
        stream << (Q_UINT32) datalen;
        stream << (Q_UINT32) 0;
        stream << (Q_UINT32) 0;
        stream.writeRawBytes( data, datalen);
        num_mhods++;
    }
    buffer.at( 8);
    stream << (Q_UINT32)data.size();	// set content length
    stream << (Q_UINT32)num_mhods;	// set real mhod count
    buffer.close();
}
Ejemplo n.º 20
0
void TrackView::keyPressEvent(QKeyEvent *event)
{
	SyncDocument *doc = getDocument();

	if (!readOnly && lineEdit->isVisible()) {
		switch (event->key()) {
		case Qt::Key_Up:
		case Qt::Key_Down:
		case Qt::Key_Left:
		case Qt::Key_Right:
		case Qt::Key_PageUp:
		case Qt::Key_PageDown:
		case Qt::Key_Home:
		case Qt::Key_End:
		case Qt::Key_Space:
			editEnterValue();
			return;
		}
	}

	bool shiftDown = (event->modifiers() & Qt::ShiftModifier) != 0;
	bool ctrlDown = (event->modifiers() & Qt::ControlModifier) != 0;
	bool selecting = shiftDown;

	if (lineEdit->isHidden()) {
		switch (event->key()) {
		case Qt::Key_Backtab:
			if (ctrlDown) {
				// the main window will handle this
				event->ignore();
				return;
			}
			selecting = false;
			// FALLTHROUGH
		case Qt::Key_Left:
			if (ctrlDown) {
				if (0 < editTrack)
					page->swapTrackOrder(editTrack, editTrack - 1);
				else
					QApplication::beep();
			}
			if (0 != getTrackCount())
				setEditTrack(editTrack - 1, selecting);
			else
				QApplication::beep();
			return;

		case Qt::Key_Tab:
			if (ctrlDown) {
				// the main window will handle this
				event->ignore();
				return;
			}
			selecting = false;
			// FALLTHROUGH
		case Qt::Key_Right:
			if (ctrlDown) {
				if (getTrackCount() > editTrack + 1)
					page->swapTrackOrder(editTrack, editTrack + 1);
				else
					QApplication::beep();
			}
			if (0 != getTrackCount())
				setEditTrack(editTrack + 1, selecting);
			else
				QApplication::beep();
			return;
		}
	}

	if (lineEdit->isHidden()) {
		if (!readOnly && ctrlDown) {
			switch (event->key()) {
			case Qt::Key_Up:
				if (getTrackCount() > editTrack)
					editBiasValue(shiftDown ? 0.1f : 1.0f);
				else
					QApplication::beep();
				return;

			case Qt::Key_Down:
				if (getTrackCount() > editTrack)
					editBiasValue(shiftDown ? -0.1f : -1.0f);
				else
					QApplication::beep();
				return;

			case Qt::Key_PageUp:
				editBiasValue(shiftDown ? 100.0f : 10.0f);
				return;

			case Qt::Key_PageDown:
				editBiasValue(shiftDown ? -100.0f : -10.0f);
				return;
			}
		}

		switch (event->key()) {
		case Qt::Key_Up:
			setEditRow(editRow - 1, selecting);
			return;

		case Qt::Key_Down:
			setEditRow(editRow + 1, selecting);
			return;

		case Qt::Key_PageUp:
			setEditRow(editRow - 0x10, selecting);
			return;

		case Qt::Key_PageDown:
			setEditRow(editRow + 0x10, selecting);
			return;

		case Qt::Key_Home:
			if (ctrlDown)
				setEditTrack(0, false);
			else
				setEditRow(0, selecting);
			return;

		case Qt::Key_End:
			if (ctrlDown)
				setEditTrack(getTrackCount() - 1, false);
			else
				setEditRow(getRows() - 1, selecting);
			return;
		}
	}

	switch (event->key()) {
	case Qt::Key_Delete:
		editClear();
		return;

	case Qt::Key_Cancel:
	case Qt::Key_Escape:
		if (!readOnly && lineEdit->isVisible()) {
			// return to old value (i.e don't clear)
			lineEdit->hide();
			setFocus();
			QApplication::beep();
		}
		return;

	case Qt::Key_I:
		editToggleInterpolationType();
		return;

	case Qt::Key_K:
		doc->toggleRowBookmark(getEditRow());
		return;
	}

	if (!readOnly && !ctrlDown && lineEdit->isHidden() && event->text().length() && doc->getTrackCount()) {
		// no line-edit, check if input matches a double
		QString str = event->text();
		int pos = 0;
		if (lineEdit->validator()->validate(str, pos) != QValidator::Invalid) {
			lineEdit->move(getPhysicalX(getEditTrack()), getPhysicalY(getEditRow()));
			lineEdit->resize(trackWidth, rowHeight);
			lineEdit->setText("");
			lineEdit->show();
			lineEdit->event(event);
			lineEdit->setFocus();
			return;
		}
	}

	event->ignore();
}
Ejemplo n.º 21
0
int 
MidiFile::setTrackCount() {
	_fileHeader._tracks = getTrackCount();
	fprintf(stderr, "tracks: %i\n", _fileHeader._tracks);
	return 0;
}
Ejemplo n.º 22
0
bool Win32RedBookDevice::play(U32 track)
{
   if(!mAcquired)
   {
      setLastError("Device has not been acquired");
      return(false);
   }

   U32 numTracks;
   if(!getTrackCount(&numTracks))
      return(false);

   if(track >= numTracks)
   {
      setLastError("Track index is out of range");
      return(false);
   }

   MCI_STATUS_PARMS statusParms;

   // get track start time
   statusParms.dwItem = MCI_STATUS_POSITION;
   statusParms.dwTrack = track + 1;

   U32 error;
   error = mciSendCommand(mDeviceId, MCI_STATUS, MCI_STATUS_ITEM|MCI_TRACK|MCI_WAIT,
      (DWORD_PTR)(LPMCI_STATUS_PARMS)&statusParms);

   if(error)
   {
      setLastError(error);
      return(false);
   }

   MCI_PLAY_PARMS playParms;
   playParms.dwFrom = statusParms.dwReturn;

   // get track end time
   statusParms.dwItem = MCI_STATUS_LENGTH;
   error = mciSendCommand(mDeviceId, MCI_STATUS, MCI_STATUS_ITEM|MCI_TRACK|MCI_WAIT,
      (DWORD_PTR)(LPMCI_STATUS_PARMS)&statusParms);

   if(error)
   {
      setLastError(error);
      return(false);
   }

   playParms.dwTo = playParms.dwFrom + statusParms.dwReturn;

   // play the track
   playParms.dwCallback = MAKELONG(getWin32WindowHandle(), 0);
   error = mciSendCommand(mDeviceId, MCI_PLAY, MCI_FROM|MCI_TO|MCI_NOTIFY,
      (DWORD_PTR)(LPMCI_PLAY_PARMS)&playParms);

   if(error)
   {
      setLastError(error);
      return(false);
   }

   setLastError("");
   return(true);
}
Ejemplo n.º 23
0
bool SyncDocument::save(const QString &fileName)
{
	QDomDocument doc;
	QDomElement rootNode = doc.createElement("sync");
	rootNode.setAttribute("rows", int(getRows()));
	doc.appendChild(rootNode);

	rootNode.appendChild(doc.createTextNode("\n\t"));
	QDomElement tracksNode =
	    doc.createElement("tracks");
	for (size_t i = 0; i < getTrackCount(); ++i) {
		const SyncTrack *t = getTrack(trackOrder[i]);

		QDomElement trackElem =
		    doc.createElement("track");
		trackElem.setAttribute("name", t->name);

		QMap<int, SyncTrack::TrackKey> keyMap = t->getKeyMap();
		QMap<int, SyncTrack::TrackKey>::const_iterator it;
		for (it = keyMap.constBegin(); it != keyMap.constEnd(); ++it) {
			int row = it.key();
			float value = it->value;
			char interpolationType = char(it->type);

			QDomElement keyElem =
			    doc.createElement("key");
				
			keyElem.setAttribute("row", row);
			keyElem.setAttribute("value", value);
			keyElem.setAttribute("interpolation",
			    (int)interpolationType);

			trackElem.appendChild(
			    doc.createTextNode("\n\t\t\t"));
			trackElem.appendChild(keyElem);
		}
		if (keyMap.size())
			trackElem.appendChild(
			    doc.createTextNode("\n\t\t"));

		tracksNode.appendChild(doc.createTextNode("\n\t\t"));
		tracksNode.appendChild(trackElem);
	}
	if (getTrackCount())
		tracksNode.appendChild(doc.createTextNode("\n\t"));
	rootNode.appendChild(tracksNode);
	rootNode.appendChild(doc.createTextNode("\n\t"));

	QDomElement bookmarksNode =
	    doc.createElement("bookmarks");
	QList<int>::const_iterator it;
	for (it = rowBookmarks.begin(); it != rowBookmarks.end(); ++it) {
		QDomElement bookmarkElem =
		    doc.createElement("bookmark");
		bookmarkElem.setAttribute("row", *it);

		bookmarksNode.appendChild(
		    doc.createTextNode("\n\t\t"));
		bookmarksNode.appendChild(bookmarkElem);
	}
	if (0 != rowBookmarks.size())
		bookmarksNode.appendChild(
		    doc.createTextNode("\n\t"));
	rootNode.appendChild(bookmarksNode);
	rootNode.appendChild(doc.createTextNode("\n"));

	QFile file(fileName);
	if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
		QMessageBox::critical(NULL, "Error", file.errorString());
		return false;
	}
	QTextStream streamFileOut(&file);
	streamFileOut.setCodec("UTF-8");
	streamFileOut << doc.toString();
	streamFileOut.flush();
	file.close();

	undoStack.setClean();
	return true;
}
Ejemplo n.º 24
0
void TrackView::selectRow()
{
	setSelection(QRect(0, editRow, getTrackCount() - 1, editRow));
}
Ejemplo n.º 25
0
void TrackView::selectAll()
{
	setSelection(QRect(0, 0, getTrackCount() - 1, getRows() - 1));
}
Ejemplo n.º 26
0
void TrackView::editPaste()
{
	SyncDocument *doc = getDocument();

	if (0 == getTrackCount()) {
		QApplication::beep();
		return;
	}

	const QMimeData *mimeData = QApplication::clipboard()->mimeData();
	if (mimeData->hasFormat("application/x-gnu-rocket")) {
		const QByteArray mimeDataBuffer = mimeData->data("application/x-gnu-rocket");
		const char *clipbuf = mimeDataBuffer.data();

		// copy data
		int buffer_width, buffer_height, buffer_size;
		memcpy(&buffer_width,  clipbuf + 0,               sizeof(int));
		memcpy(&buffer_height, clipbuf + sizeof(int),     sizeof(int));
		memcpy(&buffer_size,   clipbuf + 2 * sizeof(int), sizeof(int));

		doc->beginMacro("paste");
		for (int i = 0; i < buffer_width; ++i) {
			int trackPos = editTrack + i;
			if (trackPos >= getTrackCount()) continue;

			SyncTrack *t = getTrack(trackPos);
			for (int j = 0; j < buffer_height; ++j) {
				int row = editRow + j;
				if (t->isKeyFrame(row))
					doc->deleteKeyFrame(t, row);
			}
		}

		const char *src = clipbuf + 2 * sizeof(int) + sizeof(size_t);
		for (int i = 0; i < buffer_size; ++i)
		{
			struct CopyEntry ce;
			memcpy(&ce, src, sizeof(CopyEntry));
			src += sizeof(CopyEntry);

			Q_ASSERT(ce.track >= 0);
			Q_ASSERT(ce.track < buffer_width);
			Q_ASSERT(ce.keyFrame.row >= 0);
			Q_ASSERT(ce.keyFrame.row < buffer_height);

			int trackPos = editTrack + ce.track;
			if (trackPos < getTrackCount()) {
				SyncTrack::TrackKey key = ce.keyFrame;
				key.row += editRow;

				// since we deleted all keyframes in the edit-box already, we can just insert this one.
				doc->setKeyFrame(getTrack(trackPos), key);
			}
		}
		doc->endMacro();

		dirtyCurrentValue();

		clipbuf = NULL;
	} else
		QApplication::beep();
}
Ejemplo n.º 27
0
bool SyncDocument::save(const QString &fileName)
{
	QDomDocument doc;
	QDomElement rootNode = doc.createElement("sync");
	rootNode.setAttribute("rows", getRows());
	doc.appendChild(rootNode);

	rootNode.appendChild(doc.createTextNode("\n\t"));
	QDomElement tracksNode =
	    doc.createElement("tracks");
	for (int i = 0; i < getSyncPageCount(); i++) {
		SyncPage *page = getSyncPage(i);
		for (int j = 0; j < page->getTrackCount(); ++j) {
			const SyncTrack *t = page->getTrack(j);
			QDomElement trackElem = serializeTrack(doc, t);

			tracksNode.appendChild(doc.createTextNode("\n\t\t"));
			tracksNode.appendChild(trackElem);
		}
	}
	if (getTrackCount())
		tracksNode.appendChild(doc.createTextNode("\n\t"));
	rootNode.appendChild(tracksNode);
	rootNode.appendChild(doc.createTextNode("\n\t"));

	QDomElement bookmarksNode =
	    doc.createElement("bookmarks");
	QList<int>::const_iterator it;
	for (it = rowBookmarks.begin(); it != rowBookmarks.end(); ++it) {
		QDomElement bookmarkElem =
		    doc.createElement("bookmark");
		bookmarkElem.setAttribute("row", *it);

		bookmarksNode.appendChild(
		    doc.createTextNode("\n\t\t"));
		bookmarksNode.appendChild(bookmarkElem);
	}
	if (0 != rowBookmarks.size())
		bookmarksNode.appendChild(
		    doc.createTextNode("\n\t"));
	rootNode.appendChild(bookmarksNode);
	rootNode.appendChild(doc.createTextNode("\n"));

#ifdef USE_QSAVEFILE
	QSaveFile file(fileName);
#else
	QFile file(fileName);
#endif

	if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
		QMessageBox::critical(NULL, "Error", file.errorString());
		return false;
	}
	QTextStream streamFileOut(&file);
	streamFileOut.setCodec("UTF-8");
	streamFileOut << doc.toString();
	streamFileOut.flush();

#ifdef USE_QSAVEFILE
	file.commit();
#else
	file.close();
#endif

	undoStack.setClean();
	return true;
}