示例#1
0
void ofxUIRotarySlider::setParent(ofxUIWidget *_parent)
{
    parent = _parent;
    calculatePaddingRect();
    center = ofxUIVec2f(rect->getWidth()*.5, rect->getHeight()*.5);
    homePoint = ofxUIVec2f(rect->getWidth()*.5, rect->getHeight());
}
示例#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 ofxUISuperCanvas::keyReleased(int key)
{
    if(getIsBindedToKey(key) && bKeyHit)
    {
        bKeyHit = false;
        if((ofGetElapsedTimef() - lastHitTime) < deltaTime)
        {
            setMinified(false);
            lastPosition = ofxUIVec2f(ofGetMouseX(), ofGetMouseY());
            if(getTriggerType() & OFX_UI_TRIGGER_BEGIN)
            {
                triggerEvent(this);
            }
        }
        else
        {
            setMinified(true);
            rect->setX(lastPosition.x);
            rect->setY(lastPosition.y);
            if(getTriggerType() & OFX_UI_TRIGGER_END)
            {
                triggerEvent(this);
            }
        }
        lastHitTime = ofGetElapsedTimef();
    }
    ofxUICanvas::keyReleased(key);
}
示例#4
0
void ofxUIImageSampler::loadState(ofxXmlSettings *XML)
{
    setValue(ofxUIVec2f(XML->getValue("XValue", getValue().x, 0), XML->getValue("YValue", getValue().y, 0)));
    setColor(ofxUIColor(XML->getValue("RColor", getColor().r, 0),
                        XML->getValue("GColor", getColor().g, 0),
                        XML->getValue("BColor", getColor().b, 0),
                        XML->getValue("AColor", getColor().a, 0)));
}
示例#5
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();
}
示例#6
0
void ofxUICircleSlider::mousePressed(int x, int y, int button)
{
    if(rect->inside(x, y))
    {
        hit = true;
        hitPoint = ofxUIVec2f(x,y);
        state = OFX_UI_STATE_DOWN;
        triggerEvent(this);
    }
    else
    {
        state = OFX_UI_STATE_NORMAL;
    }
    stateChange();
}
示例#7
0
void ofxUISuperCanvas::superInit(string _label, int _size)
{
    size = _size;
    title = _label;
    kind = OFX_UI_WIDGET_SUPERCANVAS;
    canvasTitle = new ofxUILabel(rect->getWidth()-widgetSpacing*2, title, size);
    canvasTitle->setEmbedded(true);
    headerWidgets.push_back(canvasTitle);
    addWidgetPosition(canvasTitle, widgetPosition, widgetAlign);
    deltaTime = .35;
    lastHitTime = ofGetElapsedTimef();
    bIsMinified = false;
    lastHitTime = 0;
    bTitleLabelHit = false;
    hitPoint = ofxUIVec2f(0.0, 0.0);
}
示例#8
0
void ofxUISuperCanvas::keyPressed(int key)
{
    if(getIsBindedToKey(key) && !bKeyHit)
    {
        bKeyHit = true;
        lastPosition = ofxUIVec2f(rect->getX(), rect->getY());
        setMinified(false);
        rect->setX(ofGetMouseX());
        rect->setY(ofGetMouseY()); 
        if(getTriggerType() & OFX_UI_TRIGGER_BEGIN)
        {
            triggerEvent(this);
        }
    }

    ofxUICanvas::keyPressed(key);
}
示例#9
0
ofxUIVec2f ofxUISlider_<T>::getMaxAndMin()
{
	return ofxUIVec2f(max, min);
}
示例#10
0
ofxUIVec2f ofxUIRectangle::percentInsideParent(float px, float py)
{
    return ofxUIVec2f((px-(x+parent->getX()))/(width), (py-(y+parent->getY()))/(height));
}
示例#11
0
ofxUIVec2f ofxUIRectangle::percentInsideChild(float px, float py)
{
    return ofxUIVec2f((px-x)/(width), (py-y)/(height));
}