void ofxUITextArea::init(string _name, string _textstring, float w, float h, float x, float y, int _size) { initRect(x,y,w,h); setName(_name); setKind(OFX_UI_WIDGET_TEXTAREA); textstring = _textstring; setDrawFill(true); setDrawBack(false); drawShadow = false; drawLabel = false; label = new ofxUILabel(padding*2.0,0,(name+" LABEL"), _size); addEmbeddedWidget(label); label->setVisible(drawLabel); if(h == 0) { autoSize = true; } else { autoSize = false; } }
void ofxUIEnvelopeEditor::init(string _name, ofxUIEnvelope *_envelope, float w, float h, float x, float y) { initRect(x, y, w, h); name = string(_name); kind = OFX_UI_WIDGET_ENVELOPEEDITOR; draw_fill = true; draw_outline = true; if(useReference) { envelope = _envelope; } else { envelope = new ofxUIEnvelope(); } labelPrecision = 2; label = new ofxUILabel(0,h+padding*2.0,(name+" LABEL"), (name + ":"), OFX_UI_FONT_SMALL); addEmbeddedWidget(label); hitThreshold = 0.05; pointNodeRadius = OFX_UI_GLOBAL_PADDING*1.5; pointNodeRectWidth = OFX_UI_GLOBAL_PADDING*2.5; pointNodeRectHeight = OFX_UI_GLOBAL_PADDING*2.5; bHitPoint = false; bHitCurve = false; hitPoint = NULL; hitCurve = NULL; hitCurveNext = NULL; }
void ofxUIImageButton::init(float x, float y, float w, float h, bool *_value, string _pathURL, string _name, int _size) { initRect(0,0,w,h); name = string(_name); kind = OFX_UI_WIDGET_IMAGEBUTTON; label = new ofxUILabel(w+padding,0, (name+" LABEL"), name, _size); addEmbeddedWidget(label); setLabelVisible(false); if(useReference) { value = _value; } else { value = new bool(); *value = *_value; } setValue(*_value); img = new ofImage(_pathURL); bChangedImage = false; }
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); warp = 1.0; setInternalValueFromValue(); }
void ofxUIBaseDraws::init(float x, float y, float w, float h, ofBaseDraws* _image, string _name) { initRect(x, y, w, h); name = _name; kind = OFX_UI_WIDGET_BASE_DRAWS; draw_back = false; draw_fill = true; image = _image; label = new ofxUILabel(0,h+padding*2.0,(name+" LABEL"),name, OFX_UI_FONT_SMALL); addEmbeddedWidget(label); }
void ofxUIDropDownList::addToggle(string toggleName) { float yt = rect->getHeight(); for(unsigned int i = 0; i < toggles.size(); i++) { ofxUILabelToggle *t = toggles[i]; yt +=t->getRect()->getHeight(); } ofxUILabelToggle *ltoggle; if(autoSize) { ltoggle = new ofxUILabelToggle(toggleName, false, 0, 0, 0, 0, size); } else { ltoggle = new ofxUILabelToggle(toggleName, false, rect->getWidth(), rect->getHeight(), 0, 0, size); } ltoggle->getRect()->setY(yt); ltoggle->getRect()->setX(0); ltoggle->setVisible(*value); addEmbeddedWidget(ltoggle); toggles.push_back(ltoggle); if(parent != NULL) { parent->addWidget(ltoggle); ofxUICanvas* c = (ofxUICanvas*)getCanvasParent(); if(c!=NULL){ c->setHeight(yt); } } ltoggle->setParent(this); ltoggle->setRectParent(rect); ltoggle->setModal(modal); if(isOpen()) { open(); } else { close(); } }
void ofxUISortableList::initDragableElements(vector<string> &items, int _size)// build draggable widgets for the sortable items { float ty = padding; int width = rect->getWidth() - padding*2; for(int i = 0; i < items.size(); i++) { stringstream index; index << i; string tname = items[i]; ofxUIDraggableLabelButton* listItem; listItem = new ofxUIDraggableLabelButton(tname, "", width, itemHeight, padding, ty, _size); listItem->setVisible(true); listItem->setLabelVisible(true); addEmbeddedWidget(listItem); listItem->setSortID(tname + index.str()); listItems.push_back(listItem); ty+=(itemHeight+padding); } }
void ofxUIDropDownList::init(string _name, vector<string> items, float w, float x, float y, int _size) { initRect(x,y,w,0); autoSize = (w == 0) ? true : false; name = string(_name); kind = OFX_UI_WIDGET_DROPDOWNLIST; size = _size; label = new ofxUILabel(0,0,(name+" LABEL"), name, _size); addEmbeddedWidget(label); value = new bool(); *value = false; draw_fill = *value; bShowCurrentSelected = false; allowMultiple = false; addToggles(items); autoClose = false; singleSelected = NULL; }
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; }
void ofxUITextInput::init(string _name, string _textstring, float w, float h, float x, float y, int _size) { initRect(x,y,w,h); name = string(_name); kind = OFX_UI_WIDGET_TEXTINPUT; textstring = string(_textstring); defaultstring = string(_textstring); displaystring = string(_textstring); clicked = false; //the widget's value autoclear = true; triggerOnClick = true; label = new ofxUILabel((name+" LABEL"), _size); addEmbeddedWidget(label); inputTriggerType = OFX_UI_TEXTINPUT_ON_FOCUS; cursorWidth = 0; spaceOffset = 0; theta = 0; autoUnfocus = true; cursorPosition = 0; firstVisibleCharacterIndex = 0; }
void ofxUIButton::init(string _name, bool *_value, float w, float h, float x, float y, int _size) { initRect(x,y,w,h); name = string(_name); kind = OFX_UI_WIDGET_BUTTON; label = new ofxUILabel((name+" LABEL"),name,_size); addEmbeddedWidget(label); labelPosition = OFX_UI_WIDGET_POSITION_RIGHT; if(useReference) { value = _value; } else { value = new bool(); *value = *_value; } setValue(*_value); }
void ofxUILabelToggle::init(string _name, bool *_value, float w, float h, float x, float y, int _size, bool _justifyLeft) { initRect(x,y,w,h); autoSize = (w == 0) ? true : false; justifyLeft = _justifyLeft; name = string(_name); kind = OFX_UI_WIDGET_LABELTOGGLE; label = new ofxUILabel((name+" LABEL"), name, _size); addEmbeddedWidget(label); if(useReference) { value = _value; } else { value = new bool(); *value = *_value; } setValue(*_value); }
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; }
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; }