Пример #1
0
void ofxUIRangeSlider::updateLabel()
{
    valuelowString = ofxUIToString(getValueLow(),labelPrecision);
    valuehighString = ofxUIToString(getValueHigh(),labelPrecision);
    
    if(kind == OFX_UI_WIDGET_RSLIDER_H)
    {
        label->setLabel(name + ": " + valuelowString + " " + valuehighString);
    }
}
Пример #2
0
void ofxUISlider_<T>::init(string _name, T _min, T _max, T *_value, float w, float h, float x, float y)
{
	initRect(x,y,w,h);
	name = string(_name);
	setOrientation(w, h);
	setKind();
	
	draw_fill = true;
	
	value = *_value;                                               //the widget's value
	if(useReference)
	{
		valueRef = _value;
	}
	else
	{
		valueRef = new T();
		*valueRef = value;
	}
	
	max = _max;
	min = _min;
	labelPrecision = 2;
	
	if(value > max)
	{
		value = max;
	}
	if(value < min)
	{
		value = min;
	}
	
	value = ofxUIMap(value, min, max, 0.0, 1.0, true);    
	valueString = ofxUIToString(getScaledValue(),labelPrecision);
	
	if(orientation == OFX_UI_ORIENTATION_HORIZONTAL)
	{
		label = new ofxUILabel(0,h+padding,string(name+" LABEL"), string(name + ": " + ofxUIToString(max,labelPrecision)), OFX_UI_FONT_SMALL);
	}
	else
	{
		label = new ofxUILabel(0,h+padding,string(name+" LABEL"), string(name), OFX_UI_FONT_SMALL);
	}
	addEmbeddedWidget(label);
	label->setVisible(drawLabel);

	increment = ABS(max - min) / 100.0;
	bRoundedToNearestInt = false;
	bClampValue = true;
	bSticky = false;
	stickyValue = MAX(10.0*ceil(increment), 1.0);
}
Пример #3
0
void ofxUIImageSlider::updateLabel()
{
    if(kind == OFX_UI_WIDGET_IMAGESLIDER_H)
    {
        label->setLabel(name + ": " + ofxUIToString(getScaledValue(),labelPrecision));
    }
}
Пример #4
0
void ofxUISlider_<T>::updateLabel()
{
	valueString = ofxUIToString(getValue(),labelPrecision);
	if(orientation == OFX_UI_ORIENTATION_HORIZONTAL)
	{
		label->setLabel(name + ": " + valueString);
	}
}
void ofxUIToggleMatrix::init(float x, float y, float w, float h, int _rows, int _cols, string _name, int _size)
{
    initRect(x,y,w,h);
    name = string(_name);
    kind = OFX_UI_WIDGET_TOGGLEMATRIX;
    rows = _rows;
    cols = _cols;
    draw_back = false;
    
    toggleWidth = w;
    toggleHeight = h;
    
    for(int j = 0; j < rows; j++)
    {
        for(int i = 0; i < cols; i++)
        {
            ofxUIToggle *toggle = new ofxUIToggle((name+"("+ofxUIToString(i,0)+","+ofxUIToString(j,0)+")"), false, toggleWidth, toggleHeight, 0, 0, OFX_UI_FONT_SMALL);
            toggle->setLabelVisible(false);
            addEmbeddedWidget(toggle);
            toggles.push_back(toggle);
        }
    }
    allowMultiple = true;
}
Пример #6
0
void ofxUIRotarySlider::init(float x, float y, float w, float _min, float _max, float *_value, string _name, int _size)
{
    initRect(x,y,w,w);
    name = string(_name);
    kind = OFX_UI_WIDGET_ROTARYSLIDER;
    
    draw_fill = true;
    
    value = *_value;                                               //the widget's value
    if(useReference)
    {
        valueRef = _value;
    }
    else
    {
        valueRef = new float();
        *valueRef = value;
    }
    
    max = _max;
    min = _min;
    
    if(value > max)
    {
        value = max;
    }
    if(value < min)
    {
        value = min;
    }
    
    outerRadius = rect->getWidth()*.5;
    innerRadius = rect->getWidth()*.25;
    
    value = ofxUIMap(value, min, max, 0.0, 1.0, true);
    valueString = ofxUIToString(getValue(),2);
    label = new ofxUILabel(0,w+padding,(name+" LABEL"), (name + ": " + valueString), _size);
    addEmbeddedWidget(label);
    increment = fabs(max - min) / 10.0;
}
Пример #7
0
void ofxUICircleSlider::drawOutlineHighlight()
{
    if(draw_outline_highlight)
    {
        ofNoFill();
        ofxUISetColor(color_outline_highlight);
        ofxUICircle(rect->getX()+rect->getHalfWidth(), rect->getY()+rect->getHalfHeight(), rect->getHalfWidth());
        if(!draw_fill_highlight)
        {
            ofxUISetColor(label->getColorFill());
            label->drawString(rect->getX()+rect->getWidth()+padding, label->getRect()->getHeight()/2.0+rect->getY()+rect->getHeight()-rect->getHeight()*.5, ofxUIToString(getScaledValue(),labelPrecision));
        }
    }
}
Пример #8
0
void ofxUIImageSlider::init(float w, float h, float _min, float _max, float *_value, string _pathURL, string _name)
{
    name = string(_name);
    if(w > h)
    {
        kind = OFX_UI_WIDGET_IMAGESLIDER_H;
    }
    else
    {
        kind = OFX_UI_WIDGET_IMAGESLIDER_V;
    }
    
    paddedRect = new ofxUIRectangle(-padding, -padding, w+padding*2.0, h+padding);
    paddedRect->setParent(rect);
    
    draw_fill = true;
    
    value = *_value;                                               //the widget's value
    if(useReference)
    {
        valueRef = _value;
    }
    else
    {
        valueRef = new float();
        *valueRef = value;
    }
    
    max = _max;
    min = _min;
    labelPrecision = 2;
    
    if(value > max)
    {
        value = max;
    }
    if(value < min)
    {
        value = min;
    }
    
    value = ofxUIMap(value, min, max, 0.0, 1.0, true);
    
    if(kind == OFX_UI_WIDGET_IMAGESLIDER_H)
    {
        label = new ofxUILabel(0,h+padding,(name+" LABEL"), (name + ": " + ofxUIToString(max,labelPrecision)), OFX_UI_FONT_SMALL);
    }
    else
    {
        label = new ofxUILabel(0,h+padding,(name+" LABEL"), name, OFX_UI_FONT_SMALL);
    }
    
    label->setParent(label);
    label->setRectParent(rect);
    label->setEmbedded(true);
    increment = fabs(max - min) / 10.0;
    
    string coreURL = _pathURL;
    string extension = "";
    string period (".");
    size_t found;
    
    found=_pathURL.find(period);
    if (found!=string::npos)
    {
        coreURL = _pathURL.substr(0,found);
        extension = _pathURL.substr(found);
    }
    
    track = new ofImage();         //back
    track->loadImage(coreURL+"track"+extension);
    
    trackleft = new ofImage();         //back
    trackleft->loadImage(coreURL+"trackleft"+extension);
    tlaspect = (float)trackleft->getWidth()/(float)trackleft->getHeight();
    
    trackright = new ofImage();         //back
    trackright->loadImage(coreURL+"trackright"+extension);
    traspect = (float)trackright->getWidth()/(float)trackright->getHeight();
    
    progress = new ofImage();      //fill
    progress->loadImage(coreURL+"progress"+extension);
    
    progressright = new ofImage();      //fill
    progressright->loadImage(coreURL+"progressright"+extension);
    
    progressleft = new ofImage();      //fill
    progressleft->loadImage(coreURL+"progressleft"+extension);
    
    handle = new ofImage();        //handle
    handle->loadImage(coreURL+"handle"+extension);
    
    handleDown = new ofImage();    //handleOver State
    handleDown->loadImage(coreURL+"handledown"+extension);
    
    handleHalfWidth = handle->getWidth()*.5;
    handleHalfHeight = handle->getHeight()*.5;
    
    if(kind == OFX_UI_WIDGET_IMAGESLIDER_H)
    {
        ratio = rect->getHeight() / (float) track->getHeight();
        imageRect = new ofxUIRectangle(handleHalfWidth*ratio,0,rect->getWidth()-handle->getWidth()*ratio, rect->getHeight());
        
    }
    else
    {
        ratio = rect->getWidth() /  (float) track->getWidth();
        imageRect = new ofxUIRectangle(0,handleHalfHeight*ratio,rect->getWidth(), rect->getHeight()-handle->getHeight()*ratio);
    }
    imageRect->setParent(rect);
}
Пример #9
0
void ofxUIImageSlider::drawFillHighlight()
{
    if(draw_fill_highlight)
    {
        ofxUISetColor(255);
        if(kind == OFX_UI_WIDGET_IMAGESLIDER_H)
        {
            if(value > 0.00)
                progressleft->draw(rect->getX(), rect->getY(), tlaspect*rect->getHeight(), rect->getHeight());
            
            progress->draw(rect->getX()+rect->getHeight()*tlaspect-1,rect->getY(),(rect->getWidth() - 2.0*rect->getHeight()*tlaspect)*value + 1, rect->getHeight());
            
            if(value > .99)
                progressright->draw(rect->getX()+rect->getWidth() - tlaspect*rect->getHeight(), rect->getY(), tlaspect*rect->getHeight(), rect->getHeight());
            
            ofxUISetRectMode(OFX_UI_RECTMODE_CENTER);
            ofxUISetColor(255);
            handleDown->draw(imageRect->getX()+value*imageRect->getWidth(), rect->getY()+rect->getHalfHeight(), ratio*handle->getWidth(), ratio*handle->getHeight());
            ofxUISetRectMode(OFX_UI_RECTMODE_CORNER);
        }
        else
        {
            
            
        }
        if(kind == OFX_UI_WIDGET_IMAGESLIDER_V)
        {
            label->drawString(imageRect->getX()+imageRect->getWidth()+padding, label->getRect()->getHeight()/2.0+imageRect->getY()+imageRect->getHeight()-imageRect->getHeight()*value, ofxUIToString(getScaledValue(),labelPrecision));
        }
    }
}
Пример #10
0
//--------------------------------------------------------------
void wtmApp::updateFrequencyLabel() {
    ofxUISlider* slider = (ofxUISlider*) gui->getWidget(kGUISignalFrequencyName);
    int reverseValue = (round(slider->getValue()));
    slider->getLabelWidget()->setLabel(slider->getName() + ": ~" + ofxUIToString(16000000./(round(reverseValue)+1.)/2000., 0) + " kHz");
}
Пример #11
0
void ofxUIRotarySlider::updateLabel()
{
    valueString = ofxUIToString(getValue(),2);
    label->setLabel(name + ": " + valueString);
}
Пример #12
0
void ofxUIRangeSlider::init(string _name, float _min, float _max, float *_valuelow, float *_valuehigh, float w, float h,
          float x, float y, int _size)
{
    initRect(x,y,w,h);
    name = string(_name);
    if(w > h)
    {
        kind = OFX_UI_WIDGET_RSLIDER_H;
    }
    else
    {
        kind = OFX_UI_WIDGET_RSLIDER_V;
    }
    
    draw_fill = true;
    
    valuelow = *_valuelow;                                                  //the widget's value
    valuehigh = *_valuehigh;                                                //the widget's value
    
    if(useReference)
    {
        valuelowRef = _valuelow;
        valuehighRef = _valuehigh;
    }
    else
    {
        valuelowRef = new float();
        valuehighRef = new float();
        *valuelowRef = valuelow;
        *valuehighRef = valuehigh;
    }
    
    max = _max;
    min = _min;
    hitHigh = false;
    hitLow = false;
    hitCenter = false;
    
    if(valuelow > max)
    {
        valuelow = max;
    }
    if(valuelow < min)
    {
        valuelow = min;
    }
    
    if(valuehigh > max)
    {
        valuehigh = max;
    }
    if(valuehigh < min)
    {
        valuehigh = min;
    }
    
    valuelow = ofxUIMap(valuelow, min, max, 0.0, 1.0, true);
    valuehigh = ofxUIMap(valuehigh, min, max, 0.0, 1.0, true);
    labelPrecision = 2;
    
    valuelowString = ofxUIToString(getScaledValueLow(),labelPrecision);
    valuehighString = ofxUIToString(getScaledValueHigh(),labelPrecision);
    
    if(kind == OFX_UI_WIDGET_RSLIDER_H)
    {
        label = new ofxUILabel(0,h+padding,(name+" LABEL"), (name + ": " + valuelowString + " " + valuehighString), _size);
    }
    else
    {
        label = new ofxUILabel(0,h+padding,(name+" LABEL"), name, _size);
    }
    addEmbeddedWidget(label);
    
    increment = fabs(max - min) / 10.0;
}
Пример #13
0
void ofxUIRotarySlider::updateLabel()
{
    label->setLabel(name + ": " + ofxUIToString(getScaledValue(),2));
}
Пример #14
0
void ofxUINumberDialer::init(float _min, float _max, float *_value, int _precision, string _name, int _size)
{
    name = string(_name);
    kind = OFX_UI_WIDGET_NUMBERDIALER;
    
    if(useReference)
    {
        value = _value;
    }
    else
    {
        value = new float();
        *value = (*_value);
    }
    
    max = _max;
    min = _min;
    if(*value > max)
    {
        *value = max;
    }
    else if(*value < min)
    {
        *value = min;
    }
    precision = _precision;
    currentPrecisionZone = 1;
    
    
    string minString = ofxUIToString(min, precision);
    string maxString = ofxUIToString(max, precision);
    if(minString.length() > maxString.length())
    {
        textstring = minString;
    }
    else
    {
        textstring = "+"+maxString;
    }
    
    string temp = "";
    if(precision > 0)
    {
        temp+="..";
        hasPeriod = 1;
    }
    else
    {
        temp += "+";
        hasPeriod = 0;
    }
    
    numOfPrecisionZones = textstring.length()-1;             //1 for the "-/+" sign & 1 for the "."
    
    displaystring = textstring;
    
    paddedRect = new ofxUIRectangle(-padding, -padding, padding*2.0, padding*2.0);
    paddedRect->setParent(rect);
    
    for(int i = 0; i < numOfPrecisionZones; i++)
    {
        temp+="0";
    }
    
    displayLabel = false;
    label = new ofxUILabel(padding,0,(name+" LABEL"), temp, _size);
    label->setParent(label);
    label->setRectParent(rect);
    label->setEmbedded(true);
    label->setVisible(false);
    draw_fill = true;
}
Пример #15
0
void ofxUISlider::init(string _name, float _min, float _max, float *_value, float w, float h, float x, float y)
{
    rect = new ofxUIRectangle(x,y,w,h);
    name = string(_name);
    if(w > h)
    {
        kind = OFX_UI_WIDGET_SLIDER_H;
    }
    else
    {
        kind = OFX_UI_WIDGET_SLIDER_V;
    }
    
    paddedRect = new ofxUIRectangle(-padding, -padding, w+padding*2.0, h+padding);
    paddedRect->setParent(rect);
    
    draw_fill = true;
    
    value = *_value;                                               //the widget's value
    if(useReference)
    {
        valueRef = _value;
    }
    else
    {
        valueRef = new float();
        *valueRef = value;
    }
    
    max = _max;
    min = _min;
    labelPrecision = 2;
    
    if(value > max)
    {
        value = max;
    }
    if(value < min)
    {
        value = min;
    }
    
    value = ofxUIMap(value, min, max, 0.0, 1.0, true);
    
    if(kind == OFX_UI_WIDGET_SLIDER_H)
    {
        label = new ofxUILabel(0,h+padding,string(name+" LABEL"), string(name + ": " + ofxUIToString(max,labelPrecision)), OFX_UI_FONT_SMALL);
    }
    else
    {
        label = new ofxUILabel(0,h+padding,string(name+" LABEL"), string(name), OFX_UI_FONT_SMALL);
    }
    
    label->setParent(label);
    label->setRectParent(rect);
    label->setEmbedded(true);
    increment = fabs(max - min) / 100.0;
    bRoundedToNearestInt = false;
    bClampValue = true;
}
Пример #16
0
void ofxUISlider::drawFillHighlight()
{
    if(draw_fill_highlight)
    {
        ofxUIFill();
        ofxUISetColor(color_fill_highlight);
        if(kind == OFX_UI_WIDGET_SLIDER_H)
        {
            ofxUIDrawRect(rect->getX(), rect->getY(), rect->getWidth()*MIN(MAX(value, 0.0), 1.0), rect->getHeight());
        }
        else
        {
            ofxUIDrawRect(rect->getX(), rect->getY()+rect->getHeight(), rect->getWidth(), -rect->getHeight()*MIN(MAX(value, 0.0), 1.0));
        }
        if(kind == OFX_UI_WIDGET_SLIDER_V)
        {
            label->drawString(rect->getX()+rect->getWidth()+padding, label->getRect()->getHeight()/2.0+rect->getY()+rect->getHeight()-rect->getHeight()*MIN(MAX(value, 0.0), 1.0), ofxUIToString(getScaledValue(),labelPrecision));
        }
    }
}