Пример #1
0
//--------------------------------------------------------------
void ofxMuiKnob::onPress() {
    registerMousePosition(mousePosition);

    float nv = getNormalizedKnobPosition();

    if(getBounds().isBounded()) {

        if(isRangeEnabled() && isShiftPressed()) {
            if(isCtrlPressed()) {
                setRightOrLeftRangeLimit(nv);
            } else {
                setClosestRangeLimit(nv);
            }
        } else if(isRangeEnabled() && isCtrlPressed()) {
            normCtrlDragStartMin = getNormalizedRangeMin();
            normCtrlDragStartMax = getNormalizedRangeMax();
        } else {
            setNormalizedValue(nv);
        }
    } else {
        //setNormalizedValue(nv);
        ofVec2f v = screenToHitBox(mousePosition);
        float d = v.distance(getHitBoxCenter());
        float ds = ofNormalize(d,0,getHitBoxWidth()*2.0f) * 10.0f;

        add(ds*dKnobScaler*dKnobAngle);
    }

}
Пример #2
0
Axis::Axis( const std::string& name, float restValue )
	: Component(kAxis, name),
	  mNormalizedValue(0.f),
	  mRestValue(0.f)
{
	setRestValue( restValue );
	setNormalizedValue( restValue );
}
Пример #3
0
//--------------------------------------------------------------
void ofxMuiKnob::onDrag() {
    registerMousePosition(mousePosition);

    float nv = getNormalizedKnobPosition();

    cout << "nv=" << nv << endl;

    if(getBounds().isBounded()) {
        if(isRangeEnabled() && isShiftPressed()) {
            if(isCtrlPressed()) {
                setRightOrLeftRangeLimit(nv);
            } else {
                setClosestRangeLimit(nv);
            }
        } else if(isRangeEnabled() && isCtrlPressed()) {
            normCtrlDragStartMin = getNormalizedRangeMin();
            normCtrlDragStartMax = getNormalizedRangeMax();
        } else {
            setNormalizedValue(nv);
        }

        /*
        if(isRangeEnabled() && isShiftPressed()) {
            setClosestRangeLimit(nv);
        } else if(isRangeEnabled() && isCtrlPressed()) {
            // TODO -- fix this
            // TODO -- quick angle change problem

            float normDx =
            fabs(smallestAngleDelta(normCtrlDragStartMin, normCtrlDragStartMax) )/ (2 * PI - boundaryWedgeAngle);
            setNormalizedRangeMin(ofClamp(normCtrlDragStartMin + normDx,0,1));
            setNormalizedRangeMax(ofClamp(normCtrlDragStartMax + normDx,0,1));
        } else {
            //setNormalizedValue(nv);
            ofVec2f v = screenToHitBox(mousePosition);
            float d = v.distance(getHitBoxCenter());
            float ds = ofNormalize(d,0,getHitBoxWidth()*2.0f) * 10.0f;

            add(ds*dKnobScaler*getBounds().delta()*dKnobAngle);
        }
         */
    } else {
        //setNormalizedValue(nv);
        //ofVec2f v = screenToHitBox(mousePosition);
        //float d = v.distance(ofVec2f(getHitBoxWidth()*0.5f,getHitBoxHeight()*0.5f));
        float ds =  1;//ofNormalize(d,0,getHitBoxWidth()*2.0f) * 10.0f;

        add(ds*dKnobScaler*dKnobAngle);


        cout << getValue() << endl;
    }
}
Пример #4
0
//--------------------------------------------------------------
void  ofxMuiNumberData::setAllNormalizedValues(float val) {
    if(canUseSetAll()) {
        for(int i = 0; i < getNumValues(); i++) setNormalizedValue(val,i);
    }
}
Пример #5
0
void QRealProperty::setValue(qreal value)
{
    setNormalizedValue(normalize(value, _minimum, _maximum));
}