Пример #1
0
//--------------------------------------------------------------
void ofxMuiKnob::update() {
//    tooltip = toString();
//    valueLabel->setText(tooltip);
//    valueLabel->setTooltip(tooltip);
//
    if(needsRedraw) { // dial shape needs update due to data change

        cout << "here" << endl;

        if(getBounds().isBounded()) {

            innerRadiusW = getHitBoxHalfWidth() * innerRadiusPct;
            outerRadiusW = getHitBoxHalfWidth() * outerRadiusPct;
            innerRadiusH = getHitBoxHalfHeight() * innerRadiusPct;
            outerRadiusH = getHitBoxHalfHeight() * outerRadiusPct;

            angleBounds0 = ofRadToDeg(normalizedValueToAngle(0.0f));
            angleBounds1 = ofRadToDeg(normalizedValueToAngle(1.0f));

            angleValue0 = angleBounds0;
            angleValue1 = ofRadToDeg(normalizedValueToAngle(getNormalizedValue()));

            dialShape.clear();
            dialShape.arc(0,0,outerRadiusW,outerRadiusH,angleBounds0,angleBounds1);
            dialShape.arcNegative(0,0,innerRadiusW,innerRadiusH,angleBounds1,angleBounds0);
            dialShape.close();


            if(getRange().isBounded()) {

                angleRange0 = ofRadToDeg(normalizedValueToAngle(getNormalizedRangeMin()));
                angleRange1 = ofRadToDeg(normalizedValueToAngle(getNormalizedRangeMax()));

                angleValue0 = angleRange0; // reset it if this is active

                dialRangeShape.clear();
                dialRangeShape.arc(0,0,outerRadiusW,outerRadiusH,angleRange0,angleRange1);
                dialRangeShape.arcNegative(0,0,innerRadiusW,innerRadiusH,angleRange1,angleRange0);
                dialRangeShape.close();
            }

            //
            dialValueShape.clear();
            dialValueShape.arc(0,0,outerRadiusW,outerRadiusH,angleValue0,angleValue1);
            dialValueShape.arcNegative(0,0,innerRadiusW,innerRadiusH,angleValue1,angleValue0);
            dialValueShape.close();


        } else {
            // nothing to draw
        }
        needsRedraw = false;
    }



}
Пример #2
0
//--------------------------------------------------------------
float ofxMuiBox::getHitBoxCenterY() const {
    return getHitBoxHalfHeight();
}
Пример #3
0
//--------------------------------------------------------------
void ofxMuiKnob::init() {

    setObjectType("KNOB");

    setHitBoxWidth(defaults->knobWidth);
    setHitBoxHeight(defaults->knobHeight);

    // set default key binding
    keyBind_increaseValue('=');
    keyBind_decreaseValue('-');

    setBoxProperties(defaults->knobBoxProperties);

    // set values
    setValue(0);
    //setBoundsMin(0.0f);
    //setBoundsMax(1.0f);

    //valueLabel->d();
    label->enable();

    lastKnobAngle = 0.0f;
    knobAngle = 0.0f;
    dKnobAngle = 0.0f;

    zeroAngle = HALF_PI; // up

    boundaryWedgeAngle = PI/4.0f;

    innerRadiusPct = 0.60f;
    outerRadiusPct = 1.00f;

    innerRadiusW = getHitBoxHalfWidth() * innerRadiusPct;
    outerRadiusW = getHitBoxHalfWidth() * outerRadiusPct;
    innerRadiusH = getHitBoxHalfHeight() * innerRadiusPct;
    outerRadiusH = getHitBoxHalfHeight() * outerRadiusPct;

    float b = innerRadiusW;
    float v = b / 6.0f;
    dialArrow.moveTo(0,-v);
    dialArrow.lineTo(b,0);
    dialArrow.lineTo(0,+v);
    dialArrow.close();
    dialArrow.setFilled(false);

    dialShape.setArcResolution(360);
    dialRangeShape.setArcResolution(360);
    dialValueShape.setArcResolution(360);

    needsRedraw = true;


    normCtrlDragStartMin = 0.0f;
    normCtrlDragStartMax = 0.0f;
    totalDragDelta = ofPoint(0.0f,0.0f);

    dKnobScaler = 0.01f;

    smartRotate = false;
    smoothedCenter = getHitBoxCenter();
    smoothedCenterAlpha = 0.95;

    requestBoxLayout();
}