예제 #1
0
//--------------------------------------------------------------
void ofxMuiKnob::doContentBoxLayout() {

    // TODO: handle the case where the label is EMPTY


    // vertical ofxMuiLabelCaps
    if(label->getHeight() > getHitBoxHeight()) {
        setContentBoxHeight(label->getHeight());
        setHitBoxY((label->getHeight() - getHitBoxHeight())/2.0);
        label->setY(0);
    } else {
        setContentBoxHeight(getHitBoxHeight());
        label->setY((getHitBoxHeight() - label->getHeight())/2.0);
        setHitBoxY(0);
    }


    // label to the right
    label->setX(getHitBoxWidth()); // label to the right
    setHitBoxX(0);

    // value label placement
    valueLabel->setX(getHitBoxX());

    valueLabel->setY(getHitBoxY() + (getHitBoxHeight() - valueLabel->getHeight())/2.0);

    // TODO: this doesn't account for auto widths ...
    setContentBoxWidth(getHitBoxWidth() + label->getWidth());

}
예제 #2
0
//--------------------------------------------------------------
bool ofxMuiKnob::localHitTest(float localX, float localY) {
    // Normalize the coordinates compared to the ellipse
    // having a center at 0,0 and a radius of 0.5.
    // via Java Ellipse2D
    float ellw = getHitBoxWidth();
    if (ellw <= 0.0) return false;
    float normx = (localX - getHitBoxX()) / ellw - 0.5f;
    float ellh = getHitBoxHeight();
    if (ellh <= 0.0) return false;
    float normy = (localY - getHitBoxY()) / ellh - 0.5f;
    return (normx * normx + normy * normy) < 0.25f;
}
예제 #3
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();
    
    
}
예제 #4
0
//--------------------------------------------------------------
ofVec2f ofxMuiBox::getHitBoxPosition() const {
    return ofVec2f(getHitBoxX(), getHitBoxY());
}
예제 #5
0
//--------------------------------------------------------------
ofVec2f ofxMuiBox::getHitBoxOffset() const {
    return getContentBoxOffset() + ofVec2f(getHitBoxX(), getHitBoxY());
}