Yet another tilt fix. Change mouse cursor when at envelope segment. Envelope segment hit detection tweak.

This commit is contained in:
xenakios 2018-02-28 16:01:16 +02:00
parent 3816194fbf
commit b2944afbab
2 changed files with 7 additions and 3 deletions

View File

@ -210,7 +210,11 @@ void EnvelopeComponent::mouseMove(const MouseEvent & ev)
} }
else else
{ {
setMouseCursor(MouseCursor::NormalCursor); int temp = findHotEnvelopeSegment(ev.x, ev.y, true);
if (temp>=0)
setMouseCursor(MouseCursor::UpDownResizeCursor);
else
setMouseCursor(MouseCursor::NormalCursor);
m_bubble.setVisible(false); m_bubble.setVisible(false);
} }
} }
@ -412,7 +416,7 @@ int EnvelopeComponent::findHotEnvelopeSegment(double xcor, double ycor, bool det
double normx = jmap<double>(xcor, 0.0, getWidth(), m_view_start_time, m_view_end_time); double normx = jmap<double>(xcor, 0.0, getWidth(), m_view_start_time, m_view_end_time);
double yval = m_envelope->GetInterpolatedNodeValue(normx); double yval = m_envelope->GetInterpolatedNodeValue(normx);
float ycor0 = (float)(getHeight()-jmap<double>(yval, 0.0, 1.0, 0.0, getHeight())); float ycor0 = (float)(getHeight()-jmap<double>(yval, 0.0, 1.0, 0.0, getHeight()));
juce::Rectangle<float> segrect2((float)(xcor - 20), (float)(ycor - 20), 40, 40); juce::Rectangle<float> segrect2((float)(xcor - 20), (float)(ycor - 10), 40, 20);
if (segrect2.contains((float)xcor, ycor0)) if (segrect2.contains((float)xcor, ycor0))
return i; return i;
} }

View File

@ -577,7 +577,7 @@ public:
double scaled = 0.5 - m_transform_y_scale * diff; double scaled = 0.5 - m_transform_y_scale * diff;
double shifted = scaled + m_transform_y_shift + m_transform_y_sinus* double shifted = scaled + m_transform_y_shift + m_transform_y_sinus*
sin(2*3.141592653*(x-m_transform_x_shift)*m_transform_y_sinus_freq); sin(2*3.141592653*(x-m_transform_x_shift)*m_transform_y_sinus_freq);
double tiltline = m_transform_y_tilt*x; double tiltline = m_transform_y_tilt-(2.0*m_transform_y_tilt*x);
double tilted = shifted+tiltline; double tilted = shifted+tiltline;
return jlimit(0.0,1.0,tilted); return jlimit(0.0,1.0,tilted);
} }