void timerCallback()
    {
        if (sourceDetails.sourceComponent == nullptr)
        {
            delete this;
        }
        else if (! isMouseButtonDownAnywhere())
        {
            if (mouseDragSource != nullptr)
                mouseDragSource->removeMouseListener (this);

            delete this;
        }
    }
Beispiel #2
0
void MLMultiSlider::mouseWheelMove (const MouseEvent& e, const MouseWheelDetails& wheel)
{
	// filter out zero motions from trackpad
	if ((wheel.deltaX == 0.) && (wheel.deltaY == 0.)) return;
	
	if(mCurrDragSlider >= 0) return;
	
	bool doFineAdjust = e.mods.isShiftDown();
	float wheelSpeed = doFineAdjust ? 0.1f : 1.f;
	float wheelDirection = (wheel.isReversed) ? -1.f : 1.f;
	
    if (isEnabled())
	{
		int s = getSliderUnderPoint(Vec2(e.x, e.y));
		if ((s >= 0) && ! isMouseButtonDownAnywhere())
		{
			float currentVal = getFloatProperty(ml::textUtils::addFinalNumber(ml::Symbol("value"), s));
			float minPosDelta = 0.01f;
			float deltaDir = (wheel.deltaY > 0.f) ? 1.f : -1.f;
			float posDelta = (wheel.deltaY + deltaDir*minPosDelta)*wheelSpeed*wheelDirection; 			
			
			const float currentPos = valueToProportionOfLength (currentVal);
			const float newPos = ml::clamp (currentPos + posDelta, 0.f, 1.f);
			float newValue = proportionOfLengthToValue (newPos);

			if(newValue != currentVal)
			{
				if(!isMouseWheelMoving)
				{
					isMouseWheelMoving = true;
					beginGesture();
				}
				mpTimer->startTimer(kWheelTimeoutDuration);

				mCurrDragSlider = s;
				sendSliderAction(snapValue (newValue, false), s);
				mpTimer->startTimer(kWheelTimeoutDuration);
				mCurrDragSlider = -1;
			}
        }
    }
    else
    {
        Component::mouseWheelMove (e, wheel);
    }
}