当前位置: 首页>>代码示例>>C++>>正文


C++ SyncDocument::getTrackIndexFromPos方法代码示例

本文整理汇总了C++中SyncDocument::getTrackIndexFromPos方法的典型用法代码示例。如果您正苦于以下问题:C++ SyncDocument::getTrackIndexFromPos方法的具体用法?C++ SyncDocument::getTrackIndexFromPos怎么用?C++ SyncDocument::getTrackIndexFromPos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SyncDocument的用法示例。


在下文中一共展示了SyncDocument::getTrackIndexFromPos方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: editToggleInterpolationType

void TrackView::editToggleInterpolationType()
{
	SyncDocument *doc = getDocument();
	if (NULL == doc) return;
	
	if (editTrack < int(getTrackCount())) {
		size_t trackIndex = doc->getTrackIndexFromPos(editTrack);
		const sync_track *t = doc->tracks[trackIndex];

		int idx = key_idx_floor(t, editRow);
		if (idx < 0) {
			MessageBeep(~0U);
			return;
		}

		// copy and modify
		track_key newKey = t->keys[idx];
		newKey.type = (enum key_type)
		    ((newKey.type + 1) % KEY_TYPE_COUNT);

		// apply change to data-set
		SyncDocument::Command *cmd = doc->getSetKeyFrameCommand(int(trackIndex), newKey);
		doc->exec(cmd);

		// update user interface
		SendMessage(GetParent(getWin()), WM_CURRVALDIRTY, 0, 0);
		InvalidateRect(getWin(), NULL, FALSE);
	}
	else
		MessageBeep(~0U);
}
开发者ID:henrikno,项目名称:rocket,代码行数:31,代码来源:trackview.cpp

示例2: editEnterValue

void TrackView::editEnterValue()
{
	SyncDocument *doc = getDocument();
	if (NULL == doc) return;
	
	if (int(editString.size()) > 0 && editTrack < int(getTrackCount()))
	{
		size_t trackIndex = doc->getTrackIndexFromPos(editTrack);
		const sync_track *t = doc->tracks[trackIndex];

		track_key newKey;
		newKey.type = KEY_STEP;
		newKey.row = editRow;
		int idx = sync_find_key(t, editRow);
		if (idx >= 0)
			newKey = t->keys[idx]; // copy old key
		newKey.value = float(atof(editString.c_str())); // modify value
		editString.clear();

		SyncDocument::Command *cmd = doc->getSetKeyFrameCommand(int(trackIndex), newKey);
		doc->exec(cmd);

		SendMessage(GetParent(getWin()), WM_CURRVALDIRTY, 0, 0);
		InvalidateRect(getWin(), NULL, FALSE);
	}
	else
		MessageBeep(~0U);
}
开发者ID:henrikno,项目名称:rocket,代码行数:28,代码来源:trackview.cpp

示例3: editBiasValue

void TrackView::editBiasValue(float amount)
{
	SyncDocument *doc = getDocument();
	if (NULL == doc) return;
	
	int selectLeft  = min(selectStartTrack, selectStopTrack);
	int selectRight = max(selectStartTrack, selectStopTrack);
	int selectTop    = min(selectStartRow, selectStopRow);
	int selectBottom = max(selectStartRow, selectStopRow);
	
	if (0 == getTrackCount()) {
		MessageBeep(~0U);
		return;
	}
	
	SyncDocument::MultiCommand *multiCmd = new SyncDocument::MultiCommand();
	for (int track = selectLeft; track <= selectRight; ++track) {
		assert(track < int(getTrackCount()));
		size_t trackIndex = doc->getTrackIndexFromPos(track);
		const sync_track *t = doc->tracks[trackIndex];

		for (int row = selectTop; row <= selectBottom; ++row) {
			int idx = sync_find_key(t, row);
			if (idx >= 0) {
				struct track_key k = t->keys[idx]; // copy old key
				k.value += amount; // modify value

				// add sub-command
				SyncDocument::Command *cmd = doc->getSetKeyFrameCommand(int(trackIndex), k);
				multiCmd->addCommand(cmd);
			}
		}
	}
	
	if (0 == multiCmd->getSize()) {
		MessageBeep(~0U);
		delete multiCmd;
	}
	else
	{
		doc->exec(multiCmd);
		
		SendMessage(GetParent(getWin()), WM_CURRVALDIRTY, 0, 0);
		invalidateRange(selectLeft, selectRight, selectTop, selectBottom);
	}
}
开发者ID:henrikno,项目名称:rocket,代码行数:46,代码来源:trackview.cpp

示例4: editDelete

void TrackView::editDelete()
{
	SyncDocument *doc = getDocument();
	if (NULL == doc) return;
	
	int selectLeft  = min(selectStartTrack, selectStopTrack);
	int selectRight = max(selectStartTrack, selectStopTrack);
	int selectTop    = min(selectStartRow, selectStopRow);
	int selectBottom = max(selectStartRow, selectStopRow);
	
	if (0 == getTrackCount()) return;
	assert(selectRight < int(getTrackCount()));
	
	SyncDocument::MultiCommand *multiCmd = new SyncDocument::MultiCommand();
	for (int track = selectLeft; track <= selectRight; ++track) {
		size_t trackIndex = doc->getTrackIndexFromPos(track);
		const sync_track *t = doc->tracks[trackIndex];

		for (int row = selectTop; row <= selectBottom; ++row) {
			if (is_key_frame(t, row)) {
				SyncDocument::Command *cmd = new SyncDocument::DeleteCommand(int(trackIndex), row);
				multiCmd->addCommand(cmd);
			}
		}
	}
	
	if (0 == multiCmd->getSize()) {
		MessageBeep(~0U);
		delete multiCmd;
	}
	else
	{
		doc->exec(multiCmd);
		
		SendMessage(GetParent(getWin()), WM_CURRVALDIRTY, 0, 0);
		InvalidateRect(getWin(), NULL, FALSE);
	}
}
开发者ID:henrikno,项目名称:rocket,代码行数:38,代码来源:trackview.cpp

示例5: DefWindowProcW


//.........这里部分代码省略.........
			break;
		
		case ID_EDIT_SELECTROW:
			trackView->selectRow(trackView->getEditRow());
			break;
		
		case ID_FILE_REMOTEEXPORT:
			document.sendSaveCommand();
			break;
		
		case ID_RECENTFILES_FILE1:
		case ID_RECENTFILES_FILE2:
		case ID_RECENTFILES_FILE3:
		case ID_RECENTFILES_FILE4:
		case ID_RECENTFILES_FILE5:
			{
				int index = LOWORD(wParam) - ID_RECENTFILES_FILE1;
				std::wstring fileName;
				if (mruFileList.getEntry(index, fileName))
				{
					loadDocument(fileName);
				}
			}
			break;
		
		case ID_FILE_EXIT:
			attemptQuit();
			break;
		
		case ID_EDIT_UNDO:  SendMessage(trackViewWin, WM_UNDO,  0, 0); break;
		case ID_EDIT_REDO:  SendMessage(trackViewWin, WM_REDO,  0, 0); break;
		case ID_EDIT_COPY:  SendMessage(trackViewWin, WM_COPY,  0, 0); break;
		case ID_EDIT_CUT:   SendMessage(trackViewWin, WM_CUT,   0, 0); break;
		case ID_EDIT_PASTE: SendMessage(trackViewWin, WM_PASTE, 0, 0); break;
		
		case ID_EDIT_SETROWS:
			{
				int rows = int(trackView->getRows());
				INT_PTR result = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SETROWS), hwnd, (DLGPROC)setRowsDialogProc, (LPARAM)&rows);
				if (FAILED(result))
					error("unable to create dialog box");
			}
			break;
		
		case ID_EDIT_BIAS:
			{
				int initialBias = 0;
				INT_PTR result = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_BIASSELECTION), hwnd, (DLGPROC)biasSelectionDialogProc, (LPARAM)&initialBias);
				if (FAILED(result))
					error("unable to create dialog box");
			}
			break;
		}
		break;
	
	case WM_ROWCHANGED:
		{
			char temp[256];
			snprintf(temp, 256, "%d", lParam );
			SendMessage(statusBarWin, SB_SETTEXT, 1, (LPARAM)temp);
		}
		break;
	
	case WM_TRACKCHANGED:
		{
			char temp[256];
			snprintf(temp, 256, "%d", lParam);
			SendMessage(statusBarWin, SB_SETTEXT, 2, (LPARAM)temp);
		}
		break;
	
	case WM_CURRVALDIRTY:
		{
			char temp[256];
			if (document.num_tracks > 0) {
				const sync_track *t = document.tracks[document.getTrackIndexFromPos(trackView->getEditTrack())];
				int row = trackView->getEditRow();
				int idx = key_idx_floor(t, row);
				snprintf(temp, 256, "%f", sync_get_val(t, row));
				const char *str = "---";
				if (idx >= 0) {
					switch (t->keys[idx].type) {
					case KEY_STEP:   str = "step"; break;
					case KEY_LINEAR: str = "linear"; break;
					case KEY_SMOOTH: str = "smooth"; break;
					case KEY_RAMP:   str = "ramp"; break;
					}
				}
				SendMessage(statusBarWin, SB_SETTEXT, 4, (LPARAM)str);
			} else
				snprintf(temp, 256, "---");
			SendMessage(statusBarWin, SB_SETTEXT, 3, (LPARAM)temp);
		}
		break;
	
	default:
		return DefWindowProcW(hwnd, msg, wParam, lParam);
	}
	return 0;
}
开发者ID:visualizersdotnl,项目名称:hot-stuff-src,代码行数:101,代码来源:editor.cpp

示例6: editPaste

void TrackView::editPaste()
{
	SyncDocument *doc = getDocument();
	if (NULL == doc) return;
	
	if (0 == getTrackCount()) {
		MessageBeep(~0U);
		return;
	}
	
	if (FAILED(OpenClipboard(getWin())))
	{
		MessageBox(NULL, "Failed to open clipboard", NULL, MB_OK);
		return;
	}
	
	if (IsClipboardFormatAvailable(clipboardFormat))
	{
		HGLOBAL hmem = GetClipboardData(clipboardFormat);
		char *clipbuf = (char *)GlobalLock(hmem);
		
		// 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(size_t));
		
		SyncDocument::MultiCommand *multiCmd = new SyncDocument::MultiCommand();
		for (int i = 0; i < buffer_width; ++i) {
			size_t trackPos = editTrack + i;
			if (trackPos >= getTrackCount()) continue;

			size_t trackIndex = doc->getTrackIndexFromPos(trackPos);
			const sync_track *t = doc->tracks[trackIndex];
			for (int j = 0; j < buffer_height; ++j) {
				int row = editRow + j;
				if (is_key_frame(t, row))
					multiCmd->addCommand(new SyncDocument::DeleteCommand(int(trackIndex), row));
			}
		}
		
		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);
			
			assert(ce.track >= 0);
			assert(ce.track < buffer_width);
			assert(ce.keyFrame.row >= 0);
			assert(ce.keyFrame.row < buffer_height);

			size_t trackPos = editTrack + ce.track;
			if (trackPos < getTrackCount())
			{
				size_t trackIndex = doc->getTrackIndexFromPos(trackPos);
				track_key key = ce.keyFrame;
				key.row += editRow;

				// since we deleted all keyframes in the edit-box already, we can just insert this one. 
				SyncDocument::Command *cmd = new SyncDocument::InsertCommand(int(trackIndex), key);
				multiCmd->addCommand(cmd);
			}
		}
		doc->exec(multiCmd);
		
		GlobalUnlock(hmem);
		clipbuf = NULL;
	}
	else
		MessageBeep(~0U);
	
	CloseClipboard();
}
开发者ID:henrikno,项目名称:rocket,代码行数:75,代码来源:trackview.cpp


注:本文中的SyncDocument::getTrackIndexFromPos方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。