Пример #1
0
void ofxUISlider_<T>::setValue(T _value)
{
    value = ofxUIMap(_value, min, max, 0.0, 1.0, bClampValue);

    updateValueRef();
    updateLabel();
}
Пример #2
0
void ofxUICircleSlider::mouseDragged(int x, int y, int button)
{
    if(hit)
    {
        switch(inputDirection)
        {
            case OFX_UI_DIRECTION_NORTHSOUTH:
                value -= increment*(hitPoint.y-y);
                valueClamp();
                break;
            case OFX_UI_DIRECTION_SOUTHNORTH:
                value += increment*(hitPoint.y-y);
                valueClamp();
                break;
            case OFX_UI_DIRECTION_EASTWEST:
                value += increment*(hitPoint.x-x);
                valueClamp();
                break;
            case OFX_UI_DIRECTION_WESTEAST:
                value -= increment*(hitPoint.x-x);
                valueClamp();
                break;
        }
        
        hitPoint = ofxUIVec2f(x,y);
        updateValueRef();
        triggerEvent(this);
        state = OFX_UI_STATE_DOWN;
    }
    else
    {
        state = OFX_UI_STATE_NORMAL;
    }
    stateChange();
}
Пример #3
0
void ofxUISlider_<T>::setParent(ofxUIWidget *_parent)
{
	parent = _parent;
	label->getRect()->setY(rect->getHeight()+padding);
	calculatePaddingRect();
	updateValueRef();
	updateLabel();
}
Пример #4
0
void ofxUIRotarySlider::setMaxAndMin(float _max, float _min)
{
    max = _max;
    min = _min;
    
    value = ofxUIMap(value, 0, 1.0, min, max, true);
    value = ofxUIMap(value, min, max, 0.0, 1.0, true);
    updateValueRef();
    updateLabel();
}
Пример #5
0
void ofxUISlider_<T>::setMaxAndMin(T _max, T _min, bool bKeepValueTheSame)
{
	max = _max;
	min = _min;
	
	if(!bKeepValueTheSame)
	{
		value = ofxUIMap(value, 0, 1.0, min, max, bClampValue);
		value = ofxUIMap(value, min, max, 0.0, 1.0, bClampValue);
		updateValueRef();
		updateLabel();
	}
}
Пример #6
0
void ofxUIRotarySlider::input(float x, float y)
{
    hitPoint = ofxUIVec2f(x,y);
    ofVec2f mappedHitPoint = hitPoint;
    mappedHitPoint -= ofVec2f(rect->getX()+center.x, rect->getY()+center.y);
    
    ofVec2f cVector = center-homePoint;
    value = ofxUIMap(cVector.angle(mappedHitPoint), -180, 180, 0, 1.0, true);
    
    value = MIN(1.0, MAX(0.0, value));
    updateValueRef();
    updateLabel();
}
Пример #7
0
void ofxUIRangeSlider::setMaxAndMin(float _max, float _min)
{
    max = _max;
    min = _min;
    
    valuelow= ofxUIMap(valuelow, 0, 1.0, min, max, true);
    valuelow = ofxUIMap(valuelow, min, max, 0.0, 1.0, true);
    
    valuehigh = ofxUIMap(valuehigh, 0, 1.0, min, max, true);
    valuehigh = ofxUIMap(valuehigh, min, max, 0.0, 1.0, true);
    updateValueRef();
    updateLabel();
}
Пример #8
0
void ofxUISlider::setParent(ofxUIWidget *_parent)
{
    parent = _parent;
    label->getRect()->setY(rect->getHeight()+padding);
    paddedRect->height = rect->getHeight() + label->getPaddingRect()->height + padding;
    paddedRect->x = -padding;
    paddedRect->y = -padding;
    if(label->getPaddingRect()->width > paddedRect->width)
    {
        paddedRect->width = label->getPaddingRect()->width;
    }
    updateValueRef();
    updateLabel();
}
Пример #9
0
void ofxUISlider_<T>::input(float x, float y)
{
	if(orientation == OFX_UI_ORIENTATION_HORIZONTAL)
	{
		value = rect->percentInside(x, y).x;
	}
	else
	{
		value = 1.0-rect->percentInside(x, y).y;
	}
	
	value = MIN(1.0, MAX(0.0, value));
	updateValueRef();
	updateLabel();
}
Пример #10
0
void ofxUISlider_<T>::input(float x, float y)
{
    if(orientation == OFX_UI_ORIENTATION_HORIZONTAL)
    {
        //value = rect->percentInside(x, y).x;
        internalValue = rect->percentInside(x, y).x;
    }
    else
    {
        //value = 1.0-rect->percentInside(x, y).y;
        internalValue = 1.0-rect->percentInside(x, y).y;
    }
 
    internalValue = MIN(1.0, MAX(0.0, rect->percentInside(x, y).x));
    value = pow((float) internalValue, warp); //ofLerp(min, max, pow((float) internalValue, warp));

    updateValueRef();
    updateLabel();
}
Пример #11
0
void ofxUISlider::input(float x, float y)
{
    if(kind == OFX_UI_WIDGET_SLIDER_H)
    {
        value = rect->percentInside(x, y).x;
    }
    else
    {
        value = 1.0-rect->percentInside(x, y).y;
    }
    
    if(value > 1.0)
    {
        value = 1.0;
    }
    else if(value < 0.0)
    {
        value = 0.0;
    }
    
    updateValueRef();
    updateLabel();
}
Пример #12
0
void ofxUISlider_<T>::setLabelPrecision(int _precision)
{
	labelPrecision = _precision;
	updateValueRef();
	updateLabel();
}
Пример #13
0
void ofxUIRotarySlider::setValue(float _value)
{
    value = ofxUIMap(_value, min, max, 0.0, 1.0, true);
    updateValueRef();
    updateLabel();
}
Пример #14
0
void ofxUIRangeSlider::setValueHigh(float _value)
{
    valuehigh = ofxUIMap(_value, min, max, 0.0, 1.0, true);
    updateValueRef();
    updateLabel();
}
Пример #15
0
void ofxUIRangeSlider::input(float x, float y)
{
    float v = 0;
    
    if(kind == OFX_UI_WIDGET_RSLIDER_H)
    {
        v = rect->percentInside(x, y).x;
    }
    else
    {
        v = 1.0-rect->percentInside(x, y).y;
    }
    
    if(hitHigh)
    {
        valuehigh = v;
    }
    else if(hitLow)
    {
        valuelow = v;
    }
    else if(hitCenter)
    {
        valuehigh +=(v-hitPoint);
        valuelow +=(v-hitPoint);
        hitPoint = v;
    }
    else
    {
        float dvh = fabs(valuehigh - v);
        float dvl = fabs(valuelow - v);
        if(dvh < .05 || v > valuehigh)
        {
            valuehigh = v;
            hitHigh = true;
        }
        else if(dvl < .05 || v < valuelow)
        {
            valuelow = v;
            hitLow = true;
        }
        else
        {
            hitCenter = true;
            hitPoint = v;
        }
    }
    
    if(valuehigh < valuelow && hitHigh)
    {
        valuehigh = hitValueLow;
        hitHigh = false;
        hitLow = true;
    }
    else if(valuelow > valuehigh && hitLow)
    {
        valuelow = hitValueHigh;
        hitHigh = true;
        hitLow = false;
    }
    
    valuehigh = MIN(1.0, MAX(0.0, valuehigh));
    valuelow = MIN(1.0, MAX(0.0, valuelow));
    updateValueRef();
    updateLabel();
}