Skip to content

Commit

Permalink
Merge remote-tracking branch 'nofish/br-mouse-ctx-fix-env-detection-A…
Browse files Browse the repository at this point in the history
…I-underl-env-bypassed' into v2.14-triage
  • Loading branch information
cfillion committed Feb 5, 2024
2 parents 1c2c567 + 9916097 commit 1c6d9ea
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
1 change: 1 addition & 0 deletions Breeder/BR_EnvelopeUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ class BR_Envelope
EnvProperties& operator= (const EnvProperties& properties);
vector<WDL_FastString> automationItems;
//POOLEDENVINST id pos length offset rate timeBased baseline(.5=0) amplitude loop ? ?
// see https://forum.cockos.com/showpost.php?p=2198410
// For now we're just storing as strings in properties and not handling parsing of these
//struct AutomationItem
//{
Expand Down
44 changes: 43 additions & 1 deletion Breeder/BR_MouseUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,18 @@ void BR_MouseInfo::GetContext (const POINT& p)
{
BR_Envelope envelope(mouseInfo.envelope);
trackEnvHit = this->IsMouseOverEnvelopeLine(envelope, height-2*ENV_GAP, offset+ENV_GAP, mouseDisplayX, mouseY, mousePos, arrangeStart, arrangeZoom, &mouseInfo.envPointId);

// if env is hit, check if underlying envelope outside of automation items is bypassed, #1727
if (trackEnvHit)
{
int bypassUnderlEnvProjDefault = *ConfigVar<int>("pooledenvattach") & 4;
int AIoptions = envelope.GetAIoptions(); // -1 == use project default
if ((bypassUnderlEnvProjDefault && AIoptions == -1) || (AIoptions & 4))
{
if (!this->IsMouseOverAI(envelope, height - 2 * ENV_GAP, offset + ENV_GAP, mouseY, mousePos))
trackEnvHit = 0;
}
}
}

if (trackEnvHit == 1) mouseInfo.details = "env_point";
Expand Down Expand Up @@ -778,9 +790,21 @@ void BR_MouseInfo::GetContext (const POINT& p)
{
if (trackEnvHit == 1) mouseInfo.details = "env_point";
else if (trackEnvHit == 2) mouseInfo.details = "env_segment";

// if env is hit, check if underlying envelope outside of automation items is bypassed, #1488
int bypassUnderlEnvProjDefault = *ConfigVar<int>("pooledenvattach") & 4;
BR_Envelope envelope(mouseInfo.envelope);
int AIoptions = envelope.GetAIoptions(); // -1 == use project default
if ((bypassUnderlEnvProjDefault && AIoptions == -1) || (AIoptions & 4))
{
if (!this->IsMouseOverAI(envelope, height - 2 * ENV_GAP, offset + ENV_GAP, mouseY, mousePos))
{
mouseInfo.details = "empty";
}
}
}
// Item and things inside it
else if (mouseInfo.item)
if (!trackEnvHit && mouseInfo.item)
{
// Take envelope takes priority
if (takeEnvHit != 0)
Expand Down Expand Up @@ -1311,6 +1335,24 @@ int BR_MouseInfo::IsMouseOverEnvelopeLine (BR_Envelope& envelope, int drawableEn
return mouseHit;
}

bool BR_MouseInfo::IsMouseOverAI(BR_Envelope & envelope, int drawableEnvHeight, int yOffset, int mouseY, double mousePos)
{
// Check if mouse is in drawable part of envelope lane where line resides
if (mouseY >= yOffset && mouseY < yOffset + drawableEnvHeight)
{
TrackEnvelope* trEnv = envelope.GetPointer();
int AIcount = CountAutomationItems(trEnv);
for (int i = 0; i < AIcount; i++) {
double AIpos = GetSetAutomationItemInfo(trEnv, i, "D_POSITION", 0, false);
double AIlength = GetSetAutomationItemInfo(trEnv, i, "D_LENGTH", 0, false);

if (mousePos >= AIpos && mousePos < AIpos + AIlength)
return true;
}
}
return false;
}

int BR_MouseInfo::IsMouseOverEnvelopeLineTrackLane (MediaTrack* track, int trackHeight, int trackOffset, list<TrackEnvelope*>& laneEnvs, int mouseDisplayX, int mouseY, double mousePos, double arrangeStart, double arrangeZoom, TrackEnvelope** trackEnvelope, int* pointUnderMouse)
{
/* laneEnv list should hold all track envelopes that have their own lane so *
Expand Down
1 change: 1 addition & 0 deletions Breeder/BR_MouseUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ class BR_MouseInfo
int IsMouseOverEnvelopeLine (BR_Envelope& envelope, int drawableEnvHeight, int yOffset, int mouseDisplayX, int mouseY, double mousePos, double arrangeStart, double arrangeZoom, int* pointUnderMouse);
int IsMouseOverEnvelopeLineTrackLane (MediaTrack* track, int trackHeight, int trackOffset, list<TrackEnvelope*>& laneEnvs, int mouseDisplayX, int mouseY, double mousePos, double arrangeStart, double arrangeZoom, TrackEnvelope** trackEnvelope, int* pointUnderMouse);
int IsMouseOverEnvelopeLineTake (MediaItem_Take* take, int takeHeight, int takeOffset, int mouseDisplayX, int mouseY, double mousePos, double arrangeStart, double arrangeZoom, TrackEnvelope** trackEnvelope, int* pointUnderMouse);
bool IsMouseOverAI(BR_Envelope& envelope, int drawableEnvHeight, int yOffset, int mouseY, double mousePos);
int GetRulerLaneHeight (int rulerH, int lane);
int IsHwndMidiEditor (HWND hwnd, HWND* midiEditor, HWND* subView);
static bool SortEnvHeightsById (const pair<int,int>& left, const pair<int,int>& right);
Expand Down

0 comments on commit 1c6d9ea

Please # to comment.