Skip to content

Skip lookup of track spacers on hidden tracks and disable SWS zoom undo/redo #1961

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Breeder/BR_Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2297,7 +2297,7 @@ static int LimitTrackSpacerSize (MediaTrack* track, const int maxgap, const bool
bool HasTrackSpacerBefore (MediaTrack* track, const bool isMCP)
{
// faster than CSurf_TrackToID
int i { static_cast<int>(GetMediaTrackInfo_Value(track, "IP_TRACKNUMBER")) - 1 };
int i = static_cast<int>(GetMediaTrackInfo_Value(track, "IP_TRACKNUMBER")) - 1;

do
{
Expand All @@ -2316,7 +2316,7 @@ int GetTrackSpacerSize (MediaTrack* track, const bool isMCP, const int* heightOv
{
if (!track)
return *trackgapmax;
else if (HasTrackSpacerBefore(track, isMCP))
else if (IsTrackVisible(track, isMCP) && HasTrackSpacerBefore(track, isMCP))
return LimitTrackSpacerSize(track, *trackgapmax, isMCP, heightOverride);
}

Expand Down
22 changes: 21 additions & 1 deletion Zoom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -875,10 +875,14 @@ static SWSProjConfig<int> g_zoomLevel;
// Undo zoom prefs
static bool g_bUndoSWSOnly = false;
static bool g_bLastUndoProj = false;
static bool g_bSaveZoomSlices = false;

// Save the current zoom state, called from the slice
void SaveZoomSlice(bool bSWS)
{
if (!g_bSaveZoomSlices)
return;

// Do the initialization of g_zoomLevel, as project changes can result in new PtrLists
if (g_zoomStack.Get()->GetSize() == 0)
*g_zoomLevel.Get() = 0;
Expand Down Expand Up @@ -919,8 +923,19 @@ void SaveZoomSlice(bool bSWS)
g_zoomStack.Get()->Get(*g_zoomLevel.Get())->SavePos();
}

static bool CheckZoomSlicesEnabled()
{
if (g_bSaveZoomSlices)
return true;

MessageBox(g_hwndParent, __LOCALIZE("This feature is currently disabled. Enable SWS undo/redo zoom actions (adds overhead) in Extensions > SWS/S&M > Zoom preferences or consider using the native REAPER actions \"restore next/previous zoom level\".","sws_DLG_151"), __LOCALIZE("SWS - Error","sws_mbox"), MB_OK);
return false;
}

void UndoZoom(COMMAND_T* = NULL)
{
if (!CheckZoomSlicesEnabled())
return;
if (*g_zoomLevel.Get() + 1 < g_zoomStack.Get()->GetSize())
{
*g_zoomLevel.Get() += 1;
Expand All @@ -939,6 +954,8 @@ void UndoZoom(COMMAND_T* = NULL)

void RedoZoom(COMMAND_T*)
{
if (!CheckZoomSlicesEnabled())
return;
if (*g_zoomLevel.Get() > 0)
{
*g_zoomLevel.Get() -= 1;
Expand Down Expand Up @@ -1457,6 +1474,7 @@ static INT_PTR WINAPI ZoomPrefsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPAR
CheckDlgButton(hwndDlg, IDC_DRAGUP_ZOOM, BST_CHECKED);
CheckDlgButton(hwndDlg, IDC_UNDOSWSONLY, g_bUndoSWSOnly);
CheckDlgButton(hwndDlg, IDC_LASTUNDOPROJ, g_bLastUndoProj);
CheckDlgButton(hwndDlg, IDC_ZOOM_UNDO, g_bSaveZoomSlices);
for (int i = 0; i < NUM_MODIFIERS; i++)
SendMessage(GetDlgItem(hwndDlg, IDC_MMMODIFIER), CB_ADDSTRING, 0, (LPARAM)g_modifiers[i].cDesc);
for (int i = 0; i < NUM_MODIFIERS; i++)
Expand Down Expand Up @@ -1507,6 +1525,7 @@ static INT_PTR WINAPI ZoomPrefsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPAR
g_bDragUpUndo = IsDlgButtonChecked(hwndDlg, IDC_DRAGUP_UNDO) == BST_CHECKED;
g_bUndoSWSOnly = IsDlgButtonChecked(hwndDlg, IDC_UNDOSWSONLY) == BST_CHECKED;
g_bLastUndoProj = IsDlgButtonChecked(hwndDlg, IDC_LASTUNDOPROJ) == BST_CHECKED;
g_bSaveZoomSlices = IsDlgButtonChecked(hwndDlg, IDC_ZOOM_UNDO) == BST_CHECKED;
g_iMidMouseModifier = g_modifiers[SendMessage(GetDlgItem(hwndDlg, IDC_MMMODIFIER), CB_GETCURSEL, 0, 0)].iModifier;
g_bSetCursor = IsDlgButtonChecked(hwndDlg, IDC_MOVECUR) == BST_CHECKED;
g_bSeekPlay = IsDlgButtonChecked(hwndDlg, IDC_SEEKPLAY) == BST_CHECKED;
Expand Down Expand Up @@ -1710,6 +1729,7 @@ int ZoomInit(bool hookREAPERWndProcs)
g_bSeekPlay = !!(iPrefs & 8192);
g_bDragZoomUpper = !!(iPrefs & 16384);
g_bDragZoomLower = !!(iPrefs & 32768);
g_bSaveZoomSlices = !!(iPrefs & 65536);
char str[32];
GetPrivateProfileString(SWS_INI, DRAGZOOMSCALE_KEY, "0.1", str, 32, get_ini_file());
g_dDragZoomScale = atof(str);
Expand All @@ -1727,7 +1747,7 @@ void ZoomExit()
(g_bUnzoomMode ? 8 : 0) + (g_bUndoSWSOnly ? 16 : 0) + (g_bLastUndoProj ? 32 : 0) +
(g_bDragUpUndo ? 64 : 0) + (g_iMidMouseModifier << 8) + (g_bSetCursor ? 2048 : 0) +
(g_bSetTimesel ? 4096 : 0) + (g_bSeekPlay ? 8192 : 0) + (g_bDragZoomUpper ? 16384 : 0) +
(g_bDragZoomLower ? 32768 : 0));
(g_bDragZoomLower ? 32768 : 0) + (g_bSaveZoomSlices ? 65536 : 0));
WritePrivateProfileString(SWS_INI, ZOOMPREFS_KEY, str, get_ini_file());
sprintf(str, "%.2f", g_dDragZoomScale);
WritePrivateProfileString(SWS_INI, DRAGZOOMSCALE_KEY, str, get_ini_file());
Expand Down
8 changes: 5 additions & 3 deletions sws_extension.rc
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ BEGIN
CONTROL "",IDC_PROGRESS,"msctls_progress32",0x0,4,9,254,11
END

IDD_ZOOMPREFS DIALOGEX 0, 0, 243, 260
IDD_ZOOMPREFS DIALOGEX 0, 0, 243, 273
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "SWS Zoom Preferences"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
Expand Down Expand Up @@ -913,8 +913,10 @@ BEGIN
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,209,206,10
CONTROL "Last undo always zooms out to project",IDC_LASTUNDOPROJ,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,222,206,10
DEFPUSHBUTTON "OK",IDOK,130,239,50,14
PUSHBUTTON "Cancel",IDCANCEL,186,239,50,14
CONTROL "Enable SWS undo/redo zoom actions (adds overhead)",IDC_ZOOM_UNDO,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,235,206,10
DEFPUSHBUTTON "OK",IDOK,130,252,50,14
PUSHBUTTON "Cancel",IDCANCEL,186,252,50,14
END

IDD_AW_ITEM_SMOOTHING DIALOGEX 0, 0, 263, 119
Expand Down