Skip to content

Commit

Permalink
Added actions (closes #124)
Browse files Browse the repository at this point in the history
- SWS/BR: Delete take under mouse cursor
- SWS/BR: Select TCP/MCP track under mouse cursor
- SWS/BR: Select envelope under mouse cursor
- SWS/BR: Select/Delete envelope point under mouse cursor (2 versions: selected envelope only and whatever envelope is under mouse cursor)
  • Loading branch information
Breeder committed Oct 28, 2014
1 parent b87438b commit 3dadfdc
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 1 deletion.
10 changes: 10 additions & 0 deletions Breeder/BR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@ static COMMAND_T g_commandTable[] =
{ { DEFACCEL, "SWS/BR: Decrease selected envelope points by 5 db (volume envelope only)" }, "BR_DEC_VOL_ENV_PT_5db", IncreaseDecreaseVolEnvPoints, NULL, -50},
{ { DEFACCEL, "SWS/BR: Decrease selected envelope points by 10 db (volume envelope only)" }, "BR_DEC_VOL_ENV_PT_10db", IncreaseDecreaseVolEnvPoints, NULL, -100},

{ { DEFACCEL, "SWS/BR: Select envelope under mouse cursor" }, "BR_SEL_ENV_MOUSE", SelectEnvelopeUnderMouse, NULL, 0},
{ { DEFACCEL, "SWS/BR: Select envelope point under mouse cursor (selected envelope only)" }, "BR_SEL_ENV_PT_MOUSE_ACT_ENV_ONLY", SelectDeleteEnvPointUnderMouse, NULL, 1},
{ { DEFACCEL, "SWS/BR: Select envelope point under mouse cursor" }, "BR_SEL_ENV_PT_MOUSE", SelectDeleteEnvPointUnderMouse, NULL, 2},
{ { DEFACCEL, "SWS/BR: Delete envelope point under mouse cursor (selected envelope only)" }, "BR_DEL_ENV_PT_MOUSE_ACT_ENV_ONLY", SelectDeleteEnvPointUnderMouse, NULL, -1},
{ { DEFACCEL, "SWS/BR: Delete envelope point under mouse cursor" }, "BR_DEL_ENV_PT_MOUSE", SelectDeleteEnvPointUnderMouse, NULL, -2},

{ { DEFACCEL, "SWS/BR: Unselect envelope" }, "BR_UNSEL_ENV", UnselectEnvelope, NULL, 0},

{ { DEFACCEL, "SWS/BR: Save envelope point selection, slot 1" }, "BR_SAVE_ENV_SEL_SLOT_1", SaveEnvSelSlot, NULL, 0},
Expand Down Expand Up @@ -418,6 +424,10 @@ static COMMAND_T g_commandTable[] =
{ { DEFACCEL, "SWS/BR: Toggle media item online/offline" }, "BR_TOGGLE_ITEM_ONLINE", ToggleItemOnline},
{ { DEFACCEL, "SWS/BR: Copy take media source file path of selected items to clipboard" }, "BR_TSOURCE_PATH_TO_CLIPBOARD", ItemSourcePathToClipBoard},

{ { DEFACCEL, "SWS/BR: Delete take under mouse cursor" }, "BR_DELETE_TAKE_MOUSE", DeleteTakeUnderMouse, NULL, 0},
{ { DEFACCEL, "SWS/BR: Select TCP track under mouse cursor" }, "BR_SEL_TCP_TRACK_MOUSE", SelectTrackUnderMouse, NULL, 0},
{ { DEFACCEL, "SWS/BR: Select MCP track under mouse cursor" }, "BR_SEL_MCP_TRACK_MOUSE", SelectTrackUnderMouse, NULL, 1},

{ { DEFACCEL, "SWS/BR: Play from mouse cursor position" }, "BR_PLAY_MOUSECURSOR", PlaybackAtMouseCursor, NULL, 0},
{ { DEFACCEL, "SWS/BR: Play/pause from mouse cursor position" }, "BR_PLAY_PAUSE_MOUSECURSOR", PlaybackAtMouseCursor, NULL, 1},
{ { DEFACCEL, "SWS/BR: Play/stop from mouse cursor position" }, "BR_PLAY_STOP_MOUSECURSOR", PlaybackAtMouseCursor, NULL, 2},
Expand Down
41 changes: 40 additions & 1 deletion Breeder/BR_Envelope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,46 @@ void IncreaseDecreaseVolEnvPoints (COMMAND_T* ct)
Undo_OnStateChangeEx2(NULL, SWS_CMD_SHORTNAME(ct), UNDO_STATE_ALL, -1);
}
}
void SelectEnvelopeUnderMouse (COMMAND_T* ct)
{
BR_MouseInfo mouseInfo(BR_MouseInfo::MODE_MCP_TCP | BR_MouseInfo::MODE_ARRANGE);

if ((!strcmp(mouseInfo.GetWindow(), "tcp") && !strcmp(mouseInfo.GetSegment(), "envelope")) ||
(!strcmp(mouseInfo.GetWindow(), "arrange") && !strcmp(mouseInfo.GetSegment(), "envelope")) ||
(!strcmp(mouseInfo.GetDetails(), "env_point") || !strcmp(mouseInfo.GetSegment(), "env_segment"))
)
{
if (mouseInfo.GetEnvelope() && mouseInfo.GetEnvelope() != GetSelectedEnvelope(NULL))
{
SetCursorContext(2, mouseInfo.GetEnvelope());
UpdateArrange();
}
}
}

void SelectDeleteEnvPointUnderMouse (COMMAND_T* ct)
{
BR_MouseInfo mouseInfo(BR_MouseInfo::MODE_ARRANGE | BR_MouseInfo::MODE_ENV_LANE_DO_SEGMENT);
if (!strcmp(mouseInfo.GetDetails(), "env_point"))
{
if (mouseInfo.GetEnvelope() && (abs((int)ct->user) == 2 || (abs((int)ct->user) == 1 && mouseInfo.GetEnvelope() == GetSelectedEnvelope(NULL))))
{
BR_Envelope envelope(mouseInfo.GetEnvelope(), false);

if ((int)ct->user > 0 && !envelope.GetSelection(mouseInfo.GetEnvelopePoint()))
envelope.SetSelection(mouseInfo.GetEnvelopePoint(), true);
else if ((int)ct->user < 0)
{
envelope.DeletePoint(mouseInfo.GetEnvelopePoint());
if (envelope.CountPoints() == 0) // in case there are no more points left, envelope will get removed - so insert default point back
envelope.CreatePoint(0, 0, envelope.CenterValue(), envelope.GetDefaultShape(), 0, false); // position = 0 is why we created BR_Envelope with !takeEnvelopesUseProjectTime
}

if (envelope.Commit())
Undo_OnStateChangeEx2(NULL, SWS_CMD_SHORTNAME(ct), UNDO_STATE_ALL, -1);
}
}
}

void UnselectEnvelope (COMMAND_T* ct)
{
Expand All @@ -1136,7 +1176,6 @@ void UnselectEnvelope (COMMAND_T* ct)
SetCursorContext(2, NULL);
GetSetFocus(true, &hwnd, &context);
UpdateArrange();
Undo_OnStateChangeEx2(NULL, SWS_CMD_SHORTNAME(ct), UNDO_STATE_ALL, -1);
}
}

Expand Down
2 changes: 2 additions & 0 deletions Breeder/BR_Envelope.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ void Insert2EnvPointsTimeSelection (COMMAND_T*);
void FitEnvPointsToTimeSel (COMMAND_T*);
void CreateEnvPointMouse (COMMAND_T*);
void IncreaseDecreaseVolEnvPoints (COMMAND_T*);
void SelectEnvelopeUnderMouse (COMMAND_T*);
void SelectDeleteEnvPointUnderMouse (COMMAND_T*);
void UnselectEnvelope (COMMAND_T*);
void SaveEnvSelSlot (COMMAND_T*);
void RestoreEnvSelSlot (COMMAND_T*);
Expand Down
31 changes: 31 additions & 0 deletions Breeder/BR_Misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "BR_ProjState.h"
#include "BR_Util.h"
#include "../SnM/SnM.h"
#include "../SnM/SnM_Chunk.h"
#include "../SnM/SnM_Util.h"
#include "../Xenakios/XenakiosExts.h"
#include "../reaper/localize.h"
Expand Down Expand Up @@ -456,6 +457,36 @@ void ItemSourcePathToClipBoard (COMMAND_T* ct)
}
}

void DeleteTakeUnderMouse (COMMAND_T* ct)
{
BR_MouseInfo mouseInfo(BR_MouseInfo::MODE_ARRANGE);

// Don't differentiate between things within the item, but ignore any envelopes
if (!strcmp(mouseInfo.GetWindow(), "arrange") && !strcmp(mouseInfo.GetSegment(), "track") && mouseInfo.GetItem() && !mouseInfo.GetEnvelope())
{
if (CountTakes(mouseInfo.GetItem()) > 1 && !IsItemLocked(mouseInfo.GetItem()) && !IsLocked(ITEM_FULL))
{
SNM_TakeParserPatcher takePatcher(mouseInfo.GetItem());
takePatcher.RemoveTake(mouseInfo.GetTakeId());
if (takePatcher.Commit())
Undo_OnStateChangeEx2(NULL, SWS_CMD_SHORTNAME(ct), UNDO_STATE_ITEMS, -1);
}
}
}

void SelectTrackUnderMouse (COMMAND_T* ct)
{
BR_MouseInfo mouseInfo(BR_MouseInfo::MODE_MCP_TCP);
if (!strcmp(mouseInfo.GetWindow(), ((int)ct->user == 0) ? "tcp" : "mcp") && !strcmp(mouseInfo.GetSegment(), "track"))
{
if ((int)GetMediaTrackInfo_Value(mouseInfo.GetTrack(), "I_SELECTED") == 0)
{
SetMediaTrackInfo_Value(mouseInfo.GetTrack(), "I_SELECTED", 1);
Undo_OnStateChangeEx2(NULL, SWS_CMD_SHORTNAME(ct), UNDO_STATE_ALL, -1);
}
}
}

void PlaybackAtMouseCursor (COMMAND_T* ct)
{
if (IsRecording())
Expand Down
2 changes: 2 additions & 0 deletions Breeder/BR_Misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ void CycleRecordModes (COMMAND_T*);
void FocusArrangeTracks (COMMAND_T*);
void ToggleItemOnline (COMMAND_T*);
void ItemSourcePathToClipBoard (COMMAND_T*);
void DeleteTakeUnderMouse (COMMAND_T*);
void SelectTrackUnderMouse (COMMAND_T*);
void PlaybackAtMouseCursor (COMMAND_T*);
void SelectItemsByType (COMMAND_T*);
void SaveCursorPosSlot (COMMAND_T*);
Expand Down
4 changes: 4 additions & 0 deletions whatsnew.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ Added actions
- SWS/BR: Focus tracks
- SWS/BR: Unselect envelope
- SWS/BR: Increase/Decrease selected envelope points by x db (volume envelope only) (multiple versions: 0.1, 0.5, 1, 5 and 10 db)
- SWS/BR: Delete take under mouse cursor (Issue 124)
- SWS/BR: Select TCP/MCP track under mouse cursor (Issue 124)
- SWS/BR: Select envelope under mouse cursor (Issue 124)
- SWS/BR: Select/Delete envelope point under mouse cursor (2 versions: selected envelope only and whatever envelope is under mouse cursor) (Issue 124)
- SWS/wol: Select all tracks except folder parents
- SWS: Toggle horizontal zoom to selected items/time selection
+MIDI editor:
Expand Down

0 comments on commit 3dadfdc

Please sign in to comment.