void CustomColorAll(COMMAND_T*) { // Get the first selected track for (int i = 1; i <= GetNumTracks(); i++) { MediaTrack* tr = CSurf_TrackFromID(i, false); if (*(int*)GetSetMediaTrackInfo(tr, "I_SELECTED", NULL)) { Undo_BeginBlock(); Main_OnCommand(40357, 0); // Set track(s) to one custom color // Assume the user clicked 'OK' in the color picker! COLORREF cr = *(COLORREF*)GetSetMediaTrackInfo(tr, "I_CUSTOMCOLOR", NULL); for (int i = 1; i <= GetNumTracks(); i++) { tr = CSurf_TrackFromID(i, false); for (int j = 0; j < GetTrackNumMediaItems(tr); j++) { MediaItem* mi = GetTrackMediaItem(tr, j); if (*(bool*)GetSetMediaItemInfo(mi, "B_UISEL", NULL)) GetSetMediaItemInfo(mi, "I_CUSTOMCOLOR", &cr); } } UpdateTimeline(); Undo_EndBlock(__LOCALIZE("Set selected track(s)/item(s) to custom color","sws_undo"), UNDO_STATE_ALL); return; } } // No tracks selected so just run the item action Main_OnCommand(40704, 0); // Set item(s) to one custom color }
void SmartRemove(COMMAND_T*) { if (GetCursorContext() == 1 && AreThereSelItemsInTimeSel()) Main_OnCommand(40312, 0); // Remove sel area of items else Main_OnCommand(40697, 0); // Std remove (w/ prompt) }
void SmartSplit(COMMAND_T*) { double t1, t2; GetSet_LoopTimeRange(false, false, &t1, &t2, false); if (AreThereSelItemsInTimeSel() || (t1 != t2 && !CountSelectedMediaItems(0))) Main_OnCommand(40061, 0); // Split at time sel else Main_OnCommand(40012, 0); // Std split at cursor }
void SmartCut(COMMAND_T* ct) { if (GetCursorContext() == 1 && AreThereSelItemsInTimeSel()) Main_OnCommand(40307, 0); // Cut sel area of items else if (GetCursorContext() == 0) CutWithIOs(ct); else Main_OnCommand(40059, 0); // Std cut }
void SmartCopy(COMMAND_T* ct) { if (GetCursorContext() == 1 && AreThereSelItemsInTimeSel()) Main_OnCommand(40060, 0); // Copy sel area of items else if (GetCursorContext() == 0) CopyWithIOs(ct); else Main_OnCommand(40057, 0); // Std copy }
void TripleSplit(COMMAND_T*) { if (AreThereSelItemsInTimeSel()) Main_OnCommand(40061, 0); // Split at time sel else if (AreThereItemsUnderCursor(false)) Main_OnCommand(40012, 0); // Std split at cursor else Main_OnCommand(40746, 0); // Split at mouse cursor }
void RecToggle(COMMAND_T* = NULL) { // 1016 == stop // 1013 == record if (!(GetPlayState() & 4)) Main_OnCommand(1013, 0); else Main_OnCommand(1016, 0); }
void OpenProjectsFromList(COMMAND_T*) { char cPath[256]; GetProjectPath(cPath, 256); char* filename = BrowseForFiles(__LOCALIZE("Select project list","sws_mbox"), cPath, NULL, false, "Reaper Project List (*.RPL)\0*.RPL\0All Files\0*.*\0"); if (filename) { FILE* f = fopenUTF8(filename, "r"); if (f) { // Save "prompt on new project" variable int iNewProjOpts; int sztmp; int* pNewProjOpts = (int*)get_config_var("newprojdo", &sztmp); iNewProjOpts = *pNewProjOpts; *pNewProjOpts = 0; int i = 0; int iProjects = -1; while (EnumProjects(++iProjects, NULL, 0)); // Count projects char cName[10]; EnumProjects(-1, cName, 10); if (iProjects != 1 || cName[0] != 0 || GetNumTracks() != 0) { if (MessageBox(g_hwndParent, __LOCALIZE("Close active tabs first?","sws_mbox"), __LOCALIZE("SWS Project List Open","sws_mbox"), MB_YESNO) == IDYES) Main_OnCommand(40886, 0); else i = 1; } while(fgets(cPath, 256, f)) { char* pC; while((pC = strchr(cPath, '\r'))) *pC = 0; // Strip newlines no matter the format while((pC = strchr(cPath, '\n'))) *pC = 0; if (cPath[0]) { if (i++) Main_OnCommand(41929, 0); // New project tab (ignore default template) Main_openProject(cPath); } } fclose(f); *pNewProjOpts = iNewProjOpts; } else MessageBox(g_hwndParent, __LOCALIZE("Unable to open file.","sws_mbox"), __LOCALIZE("SWS Project List Open","sws_mbox"), MB_OK); free(filename); } }
void SmartUnsel(COMMAND_T*) { switch(GetCursorContext()) { case 0: //Tracks Main_OnCommand(40297, 0); break; case 1: //Items Main_OnCommand(40289, 0); break; case 2: //Envelopes Main_OnCommand(40331, 0); break; } }
void SWS_TrackListWnd::OnCommand(WPARAM wParam, LPARAM lParam) { switch (wParam) { case IDC_CLEAR | (BN_CLICKED << 16): SetWindowText(GetDlgItem(m_hwnd, IDC_FILTER), ""); break; case IDC_FILTER | (EN_CHANGE << 16): { char curFilter[256]; GetWindowText(GetDlgItem(m_hwnd, IDC_FILTER), curFilter, 256); m_filter.Get()->SetFilter(curFilter); Update(); break; } case IDC_HIDE: m_bHideFiltered = IsDlgButtonChecked(m_hwnd, IDC_HIDE) == BST_CHECKED ? true : false; Update(); break; case IDC_LINK: m_bLink = IsDlgButtonChecked(m_hwnd, IDC_LINK) == BST_CHECKED ? true : false; Update(); break; case RENAME_MSG: if (m_trLastTouched) m_pLists.Get(0)->EditListItem((SWS_ListItem*)m_trLastTouched, 1); break; default: if (wParam >= LOADSNAP_MSG) GetSnapshot((int)(wParam - LOADSNAP_MSG), ALL_MASK, false); else Main_OnCommand((int)wParam, (int)lParam); } }
bool InsertSilence(const char* _undoTitle, double _pos, double _len) { if (_pos>=0.0 && _len>0.0 && _pos<SNM_GetProjectLength()) { if (_undoTitle) Undo_BeginBlock2(NULL); PreventUIRefresh(1); double timeSel1, timeSel2, d=_pos+_len; GetSet_LoopTimeRange2(NULL, false, false, &timeSel1, &timeSel2, false); GetSet_LoopTimeRange2(NULL, true, false, &_pos, &d, false); Main_OnCommand(40200, 0); // insert space at time sel // restore time sel, enlarge if needed (mimic native behavior) if (timeSel1>_pos) timeSel1+=_len; if (_pos<timeSel2) timeSel2+=_len; GetSet_LoopTimeRange2(NULL, true, false, &timeSel1, &timeSel2, false); PreventUIRefresh(-1); if (_undoTitle) Undo_EndBlock2(NULL, _undoTitle, UNDO_STATE_ALL); return true; } return false; }
void SafeTiemSel(COMMAND_T*) { double t1, t2; GetSet_LoopTimeRange(false, false, &t1, &t2, false); if (t1 == t2) Main_OnCommand(40290, 0); }
void FindWnd::OnCommand(WPARAM wParam, LPARAM lParam) { switch(LOWORD(wParam)) { case IDC_EDIT: if (HIWORD(wParam)==EN_CHANGE) { GetDlgItemText(m_hwnd, IDC_EDIT, g_searchStr, MAX_SEARCH_STR_LEN); UpdateNotFoundMsg(true); } break; case BTNID_ZOOM_SCROLL_EN: if (!HIWORD(wParam) || HIWORD(wParam)==600) m_zoomSrollItems = !m_zoomSrollItems; break; case BTNID_FIND: Find(0); break; case BTNID_PREV: Find(-1); break; case BTNID_NEXT: Find(1); break; case CMBID_TYPE: if (HIWORD(wParam)==CBN_SELCHANGE) { m_type = m_cbType.GetCurSel(); UpdateNotFoundMsg(true); // + redraw SetFocus(GetDlgItem(m_hwnd, IDC_EDIT)); } break; default: Main_OnCommand((int)wParam, (int)lParam); break; } }
void SelPrevItem(COMMAND_T* ctx) { // Find the last selected MediaItem* prevMi = NULL; for (int i = 1; i <= GetNumTracks(); i++) { MediaTrack* tr = CSurf_TrackFromID(i, false); if (GetTrackVis(tr) & 2) { for (int j = 0; j < GetTrackNumMediaItems(tr); j++) { MediaItem* mi = GetTrackMediaItem(tr, j); if (*(bool*)GetSetMediaItemInfo(mi, "B_UISEL", NULL)) { if (prevMi) { if (ctx->user == 0) Main_OnCommand(40289, 0); // Unselect all items GetSetMediaItemInfo(prevMi, "B_UISEL", &g_bTrue); UpdateTimeline(); return; } } prevMi = mi; } } } }
void SWS_TrackListView::OnItemBtnClk(SWS_ListItem* item, int iCol, int iKeyState) { MediaTrack* tr = (MediaTrack*)item; // Always non-null if (iCol == COL_TCP || iCol == COL_MCP) { bool bClickedStar = ((iCol == COL_TCP && GetTrackVis(tr) & 2) || (iCol == COL_MCP && GetTrackVis(tr) & 1)); m_bDisableUpdates = true; if (m_pTrackListWnd->Linked() && !(iKeyState & LVKF_SHIFT)) { if (iKeyState & LVKF_CONTROL && iKeyState & LVKF_ALT) ShowSelOnly(); else if (bClickedStar) HideTracks(); else ShowInMCPandTCP(); } else if (iCol == COL_TCP) { if (iKeyState & LVKF_CONTROL && iKeyState & LVKF_ALT) ShowInTCPEx(); else if (bClickedStar) HideFromTCP(); else ShowInTCP(); } else // iCol == COL_MCP { if (iKeyState & LVKF_CONTROL && iKeyState & LVKF_ALT) ShowInMCPEx(); else if (bClickedStar) HideFromMCP(); else ShowInMCP(); } m_bDisableUpdates = false; m_pTrackListWnd->Update(); } else if (iCol == COL_MUTE) Main_OnCommand(6, 0); else if (iCol == COL_SOLO) Main_OnCommand(7, 0); else if (iCol == COL_ARM) Main_OnCommand(9, 0); }
void GrooveDialog::OnCommand(WPARAM wParam, LPARAM lParam) { switch(LOWORD(wParam)) { case FNG_OPEN_FOLDER: OnGrooveFolderButton(HIWORD(wParam), lParam); break; case FNG_REFRESH: RefreshGrooveList(); break; case IDC_GROOVELIST: OnGrooveList(HIWORD(wParam), lParam); break; case IDC_STRENGTH: OnStrengthChange(HIWORD(wParam), lParam); break; case IDC_VELSTRENGTH: OnVelStrengthChange(HIWORD(wParam), lParam); break; case IDC_SENS_32ND: setSensitivity(m_hwnd, 32); setGrooveTolerance(32); break; case IDC_SENS_16TH: setSensitivity(m_hwnd, 16); setGrooveTolerance(16); break; case IDC_SENS_4TH: setSensitivity(m_hwnd, 4); setGrooveTolerance(4); break; case IDC_SENS_8TH: setSensitivity(m_hwnd, 8); setGrooveTolerance(8); break; case IDC_TARG_ITEMS: setTarget(m_hwnd, true); setGrooveTarget(TARGET_ITEMS); break; case IDC_TARG_NOTES: setTarget(m_hwnd, false); setGrooveTarget(TARGET_NOTES); break; case IDC_APPLYGROOVE: ApplySelectedGroove(); break; case IDC_STORE: if(IsDlgButtonChecked(m_hwnd, IDC_TARG_ITEMS) == BST_CHECKED) Main_OnCommandEx(NamedCommandLookup("_FNG_GET_GROOVE"), 0, 0); else Main_OnCommandEx(NamedCommandLookup("_FNG_GET_GROOVE_MIDI"), 0, 0); SendDlgItemMessage(m_hwnd, IDC_GROOVELIST, LB_SETCURSEL, 0, 0); break; default: Main_OnCommand((int)wParam, (int)lParam); // Required when you have reaper commands in the context menu } }
void OpenRelatedProject(COMMAND_T* pCmd) { if ((int)pCmd->user == g_relatedProjects.Get()->GetSize()) // Give the user the chance to add a related project if they selected the first open spot if (MessageBox(g_hwndParent, __LOCALIZE("No related project found. Add one now?","sws_mbox"), __LOCALIZE("SWS Open Related Project","sws_mbox"), MB_YESNO) == IDYES) AddRelatedProject(); if ((int)pCmd->user >= g_relatedProjects.Get()->GetSize()) return; WDL_String* pStr = g_relatedProjects.Get()->Get((int)pCmd->user); ReaProject* pProj; // See if it's already opened char cOpenedProj[256]; int i = 0; while ((pProj = EnumProjects(i++, cOpenedProj, 256))) { if (_stricmp(cOpenedProj, pStr->Get()) == 0) { SelectProjectInstance(pProj); return; } } // Nope, open in new tab // Save "prompt on new project" variable int iNewProjOpts; int sztmp; int* pNewProjOpts = (int*)get_config_var("newprojdo", &sztmp); iNewProjOpts = *pNewProjOpts; *pNewProjOpts = 0; pProj = EnumProjects(-1, NULL, 0); Main_OnCommand(41929, 0); // New project tab (ignore default template) Main_openProject(pStr->Get()); EnumProjects(-1, cOpenedProj, 256); if (_stricmp(pStr->Get(), cOpenedProj)) { Main_OnCommand(40860, 0); // 40860 = Close current project tab SelectProjectInstance(pProj); g_relatedProjects.Get()->Delete((int)pCmd->user, true); } *pNewProjOpts = iNewProjOpts; }
// global action timer armed via SNM_Init()/OnInitTimer() void GlobalStartupActionTimer() { if (int cmdId = NamedCommandLookup(g_globalAction.Get())) { Main_OnCommand(cmdId, 0); #ifdef _SNM_DEBUG OutputDebugString("GlobalStartupActionTimer() - Performed global startup action '"); OutputDebugString(g_globalAction.Get()); OutputDebugString("'\n"); #endif } }
void generate_items_sequence(std::shared_ptr<breakpoint_envelope> env, const char* fn) { SetCursorContext(1, NULL); Main_OnCommand(40182, 0); // select all items Main_OnCommand(40006, 0); // remove selected items MediaTrack* dest_track = GetTrack(nullptr, 0); double timepos = 0.0; double seqlen = 30.0; int sanity = 0; while (timepos < seqlen) { create_item_result r = create_item_with_take_and_source(dest_track, fn); SetMediaItemPosition(r.item, timepos, false); double srclen = GetMediaSourceLength(r.src, nullptr); double normtime = 1.0 / seqlen * timepos; double directionfactor = skip_near_zero(-1.0 + 2.0*env->interpolate(normtime), 0.02); if (directionfactor < 0.0) { //readbg() << "item " << sanity << " should be reversed\n"; SetMediaItemSelected(r.item, true); Main_OnCommand(41051, 0); // toggle reverse SetMediaItemSelected(r.item, false); } double absfactor = fabs(directionfactor); double itemlen = bound_value(0.02, srclen*absfactor, srclen); SetMediaItemLength(r.item, itemlen, false); SetMediaItemTakeInfo_Value(r.take, "D_PLAYRATE", 1.0 / absfactor); timepos += srclen*absfactor; ++sanity; if (sanity > 1000) { readbg() << "too many items created!\n"; break; } } UpdateArrange(); }
// per-project action timer armed via ProcessExtensionLine() void ProjectStartupActionTimer() { plugin_register("-timer",(void*)ProjectStartupActionTimer); if (int cmdId = NamedCommandLookup(g_prjActions.Get()->Get())) { Main_OnCommand(cmdId, 0); #ifdef _SNM_DEBUG OutputDebugString("ProjectStartupActionTimer() - Performed project startup action '"); OutputDebugString(g_prjActions.Get()->Get()); OutputDebugString("'\n"); #endif } }
void SetTrackHeight(MediaTrack* track, int height, bool useChunk) { if (!useChunk) { GetSetMediaTrackInfo(track, "I_HEIGHTOVERRIDE", &height); PreventUIRefresh(1); Main_OnCommand(41327, 0); Main_OnCommand(41328, 0); PreventUIRefresh(-1); } else { SNM_ChunkParserPatcher p(track); char pTrackLine[BUFFER_SIZE] = ""; if (p.Parse(SNM_GET_CHUNK_CHAR, 1, "TRACK", "TRACKHEIGHT", 0, 1, pTrackLine)) { _snprintfSafe(pTrackLine, BUFFER_SIZE, "%d", height); p.ParsePatch(SNM_SET_CHUNK_CHAR, 1, "TRACK", "TRACKHEIGHT", 0, 1, pTrackLine); } } }
// The main dialog procedure. INT_PTR WINAPI Main_DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch( uMsg ) { case WM_INITDIALOG: return Main_OnInitDialog(hWnd, reinterpret_cast<HWND>(wParam), lParam); case WM_COMMAND: Main_OnCommand(hWnd, LOWORD(wParam), reinterpret_cast<HWND>(lParam), HIWORD(wParam)); break; } return FALSE; }
void SetTrackVis(MediaTrack* tr, int vis) // &1 == mcp, &2 == tcp { int iTrack = CSurf_TrackToID(tr, false); if (iTrack == 0) { // TODO - obey master in mcp if ((vis & 2) != (*(int*)GetConfigVar("showmaintrack") ? 2 : 0)) Main_OnCommand(40075, 0); } else if (iTrack > 0) { if (vis != GetTrackVis(tr)) { GetSetMediaTrackInfo(tr, "B_SHOWINTCP", vis & 2 ? &g_bTrue : &g_bFalse); GetSetMediaTrackInfo(tr, "B_SHOWINMIXER", vis & 1 ? &g_bTrue : &g_bFalse); } } }
// Goto the end of the project, *including* perhaps marker ends void GotoEndInclMarkers(COMMAND_T*) { Main_OnCommand(40043, 0); int x = 0; double dRegStart, dRegEnd; bool bReg; double dMarkerEnd = -DBL_MAX; while ((x = EnumProjectMarkers(x, &bReg, &dRegStart, &dRegEnd, NULL, NULL))) { if (bReg && dRegEnd > dMarkerEnd) dMarkerEnd = dRegEnd; else if (!bReg && dRegStart > dMarkerEnd) dMarkerEnd = dRegStart; } if (dMarkerEnd > GetCursorPosition()) SetEditCurPos(dMarkerEnd, true, true); }
// 메인 윈도우의 메시지 처리 함수 LRESULT CALLBACK WndProc(HWND hWnd,UINT iMessage,WPARAM wParam,LPARAM lParam) { switch(iMessage) { case WM_CREATE: return Main_OnCreate(hWnd,wParam,lParam); case WM_DESTROY: return Main_OnDestroy(hWnd,wParam,lParam); case WM_SIZE: return Main_OnSize(hWnd,wParam,lParam); case WM_COMMAND: return Main_OnCommand(hWnd,wParam,lParam); case WM_INITMENU: return Main_OnInitMenu(hWnd,wParam,lParam); case WM_SETFOCUS: return Main_OnSetFocus(hWnd,wParam,lParam); } return(DefWindowProc(hWnd,iMessage,wParam,lParam)); }
static void ContinuousActionTimer () { if (g_actionInProgress && g_actionInProgress->cmd) { // Don't let other windows steal our keyboard accelerator SetFocus(GetArrangeWnd()); // Make sure tooltip is not displayed if mouse is over another window (tooltip only follows mouse movements in arrange/ruler) if (g_actionInProgress->SetTooltip) { POINT p; GetCursorPos(&p); HWND hwnd = WindowFromPoint(p); if (hwnd != GetArrangeWnd() && hwnd != GetRulerWnd()) SetTooltip(NULL, NULL); } Main_OnCommand(g_actionInProgress->cmd, ACTION_FLAG); } }
void LoadOrSelectProject(const char* _fn, bool _newTab) { if (!_fn) return; int i=0; bool found = false; ReaProject* prj = NULL; char fn[SNM_MAX_PATH] = ""; while (!found && (prj = EnumProjects(i++, fn, sizeof(fn)))) if (!_stricmp(_fn, fn)) found = true; if (found) SelectProjectInstance(prj); else { if (_newTab) Main_OnCommand(40859,0); Main_openProject((char*)_fn); // includes an undo point } }
void MacroDebug() { DialogBox(g_hInst,MAKEINTRESOURCE(IDD_MACRODEBUG),g_hwndParent,doDebug); if (g_selectedMacro) { char cCommandText[256]; for (int i = 0; i < g_selectedMacro->m_iNumActions; i++) { sprintf(cCommandText, "Run %s?", kbd_getTextFromCmd(g_selectedMacro->m_pActions[i], NULL)); int iRet = MessageBox(g_hwndParent, cCommandText, g_selectedMacro->m_cName, MB_YESNOCANCEL); if (iRet == IDYES) Main_OnCommand(g_selectedMacro->m_pActions[i], 0); else if (iRet == IDCANCEL) break; } g_selectedMacro = NULL; } g_macros.Empty(true); }
void OnTriggerActionTimer() { // unregister timer (called once) plugin_register("-timer",(void*)OnTriggerActionTimer); if (int cmdId = NamedCommandLookup(g_prjActions.Get()->Get())) { // specific case for "load theme" actions (~1s delay) if (strstr(g_prjActions.Get()->Get(), "S&M_LOAD_THEME")) ScheduledJob::Schedule(new StartupProjectActionJob(cmdId)); // standard case, faster else Main_OnCommand(cmdId, 0); #ifdef _SNM_DEBUG OutputDebugString("OnTriggerActionTimer() - Performed startup action '"); OutputDebugString(g_prjActions.Get()->Get()); OutputDebugString("'\n"); #endif } }
// 메인 윈도우의 메시지 처리 함수 LRESULT CALLBACK WndProc(HWND hWnd,UINT iMessage,WPARAM wParam,LPARAM lParam) { switch(iMessage) { case WM_CREATE: return Main_OnCreate(hWnd,wParam,lParam); case WM_DESTROY: return Main_OnDestroy(hWnd,wParam,lParam); case WM_SIZE: return Main_OnSize(hWnd,wParam,lParam); case WM_COMMAND: return Main_OnCommand(hWnd,wParam,lParam); case WM_INITMENU: return Main_OnInitMenu(hWnd,wParam,lParam); case WM_SETFOCUS: return Main_OnSetFocus(hWnd,wParam,lParam); case WM_FONTCHANGE: ReEnum(); InvalidateRect(hCanvas,NULL,FALSE); return 0; } return(DefWindowProc(hWnd,iMessage,wParam,lParam)); }