Esempio n. 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);
    }

}
Esempio n. 2
0
//--------------------------------------------------------------
void ofxMuiColorPicker::draw() {
    
    //if(name == "MCP") {
    //    cout << "in here" << endl;
    //}
    
    ofPushStyle();
	ofPushMatrix(); // initial push
    
    ofTranslate(getHitBoxX(),getHitBoxY());
    

    
    ofSetColor(255);
    picker.draw(0,0);

    ofFill();
    ofSetColor(getValue());
    ofxRect(colorPickerPreview);

    ofFill();
    ofSetColor(30);
    ofLine(colorPickerPreview.x,colorPickerPreview.y,getHitBoxWidth(),colorPickerPreview.y);
    
    ofNoFill();
    
    
    if(showEyeDroperPreview) {
        
        eyeDropperPreview.loadScreenData(mousePosition.x-eyeDropperPreviewPixelWidth/2.0f,
                                         mousePosition.y-eyeDropperPreviewPixelHeight/2.0f
                                         ,eyeDropperPreviewPixelWidth,eyeDropperPreviewPixelHeight);

        
        ofPushMatrix();
        ofTranslate(screenToHitBox(mousePosition));

        
        ofSetColor(255);
       // ofxRect(0,0,
       // ofPushMatrix(

        ofPushMatrix();
        ofScale(defaults->colorPickerEyeDropperZoom,defaults->colorPickerEyeDropperZoom);
        ofTranslate(-eyeDropperPreviewPixelWidth/2.0, -eyeDropperPreviewPixelHeight/2.0f);
        eyeDropperPreview.draw(0,0);
        ofPopMatrix();
        
        ofCircle(0,0,4,4);

        
        ofPopMatrix();
     
    } else {
        //ofSetColor(getValue().getInverted().getBrightness());
        ofCircle(cursor.x-2, cursor.y-2, 4);
    }
    
    /*
    if(isDragging) {
        ofFill();
        ofSetColor(255);
        ofxRect(0,0,40,40);
    }
    */
        
        
    ofPopMatrix(); // HIT RECT PUSH
    ofPopStyle();
    
    
}
Esempio n. 3
0
//--------------------------------------------------------------
void ofxMuiColorPicker::onDragOver() {
    showEyeDroperPreview = false;
    cursor = screenToHitBox(mousePosition);
    //setValue(picker.getColor(cursor.x,cursor.y));
}
Esempio n. 4
0
//--------------------------------------------------------------
bool ofxMuiKnob::hitTest(float screenX, float screenY) {
    // this function could be overriden w/ via the virtual declaration
    // hitRect is always described in with respect to the content frame
    ofVec2f hitBoxMousePos = screenToHitBox(ofVec2f(screenX, screenY));
    return localHitTest(hitBoxMousePos.x, hitBoxMousePos.y);
}
Esempio n. 5
0
//--------------------------------------------------------------
void ofxMuiKnob::registerMousePosition(ofVec2f mousePoint) {
    lastKnobAngle = knobAngle;
    knobAngle = calculateKnobPosition(screenToHitBox(mousePoint));
    dKnobAngle = smallestAngleDelta(knobAngle, lastKnobAngle);
}