void ofxSimpleGuiToggle::draw(float x, float y) { // enabled = true; setPos(x, y); glPushMatrix(); glTranslatef(x, y, 0); ofEnableAlphaBlending(); ofFill(); setTextColor(*value); ofRect(0, 0, height, height); if((*value)) { setFullColor(true); ofRect(2, 2, height-4, height-4); //ofLine(0, 0, height, height); //ofLine(height, 0, 0, height); } setTextBGColor(); ofRect(height, 0, width - height, height); setTextColor(); ofDrawBitmapString(name, height + 15, 15); ofDisableAlphaBlending(); glPopMatrix(); }
void ofxSimpleGuiContent::draw(float x, float y) { if(content->getWidth() == 0 && content->getHeight() ==0) return; setPos(x, y); setup(); glPushMatrix(); glTranslatef(x, y, 0); ofEnableAlphaBlending(); ofFill(); glColor4f(0, 0, 0, 0.8f); ofRect(0, 0, width, fixheight); ofSetColor(0xffffff); content->draw(0, 0, width, fixheight); ofFill(); setTextBGColor(); ofRect(0, fixheight, width, config->sliderTextHeight); setTextColor(); ofDrawBitmapString(name, 3, fixheight + 15); ofDisableAlphaBlending(); glPopMatrix(); }
void ofxSimpleGuiSlider2d::draw(float x, float y) { setPos(x, y); ofPoint pointv; pointv.x = ofMap((*value).x, min.x, max.x, x, x+width); pointv.y = ofMap((*value).y, min.y, max.y, y, y+height-config->slider2DTextHeight); ofEnableAlphaBlending(); glPushMatrix(); glTranslatef(x, y, 0); ofFill(); setFullColor(); ofRect(0, 0, width, height - config->slider2DTextHeight); ofFill(); setTextBGColor(); ofRect(0, height-config->slider2DTextHeight, width, config->slider2DTextHeight); setTextColor(); ofDrawBitmapString(name+"\nx:"+ofToString(value->x, 2)+"\ny:"+ofToString(value->y, 2), 3, height+15-config->slider2DTextHeight); setTextColor(); ofCircle(pointv.x-x, pointv.y-y, 2); setTextColor(); ofLine(pointv.x-x, 0, pointv.x-x, height-config->slider2DTextHeight); ofLine(0, pointv.y-y,width, pointv.y-y); glPopMatrix(); ofDisableAlphaBlending(); }
void ofxSimpleGuiButton::draw(float x, float y) { setPos(x, y); ofPushStyle(); glPushMatrix(); glTranslatef(x, y, 0); ofEnableAlphaBlending(); ofFill(); setTextBGColor(); ofRect(0, 0, width, height); // if a toggle if((*value) && beToggle) { setTextColor(); //ofLine(0, 0, box.width, box.height); //ofLine(box.width, 0, 0, box.height); } setTextColor(); ofDrawBitmapString(name, 3, 15); //ofDisableAlphaBlending(); glPopMatrix(); ofPopStyle(); }
//--------------------------------------------------------------------- draw void ofxSimpleGuiColorPicker::draw(float x, float y) { // enabled = true; //update postion of gui object setPos(x, y); glPushMatrix(); glTranslatef(x, y, 0); int startY = 0; for(int i=0; i<4; i++) { //VALUE CLAMP barwidth[i] = ofMap(values[i], 0, max, 0.0, (float)width); if(barwidth[i] > width) barwidth[i] = width; else if(barwidth[i] < 0) barwidth[i] = 0; ofEnableAlphaBlending(); ofFill(); setEmptyColor(); ofRect(0, startY, width, config->sliderHeight*1.8); switch(i) { case 0:glColor3f(values[i], 0, 0); break; case 1:glColor3f(0, values[i], 0); break; case 2:glColor3f(0, 0, values[i]); break; case 3:glColor3f(values[i], values[i], values[i]); break; } ofRect(0, startY, barwidth[i], config->sliderHeight * 1.8); int iover = (getMouseY() - y) / config->sliderHeight/2; bool isOver = iover == i; if(isOver) { glColor3f(1, 1, 1); } else { glColor3f(0.5, 0.5, 0.5); } ofDrawBitmapString(ofToString(values[i], 4), 3, startY + 14); startY += config->sliderHeight * 2; } ofFill(); setTextBGColor(); ofRect(0, startY, width, config->sliderTextHeight); glColor3f(values[0], values[1], values[2]); // ofRect(0, startY+config->sliderTextHeight, width, config->sliderTextHeight * 1.5); ofRect(150, startY + 3, width - 150 -3, config->sliderTextHeight - 8); setTextColor(); string s = name; ofDrawBitmapString(s, 3, startY + 14); ofDisableAlphaBlending(); glPopMatrix(); }
void ofxSimpleGuiColorSlider::draw(float x, float y) { // enabled = true; //update postion of gui object setPos(x, y); //VALUE CLAMP barwidth = ofMap((*value), min, max, 0.0, (float)width); if(barwidth > width) barwidth = width; else if(barwidth < 0) barwidth = 0; ofEnableAlphaBlending(); glPushMatrix(); glTranslatef(x, y, 0); ofFill(); setEmptyColor(); ofRect(0, 0, width, config->sliderHeight); //setFullColor(); ofSetColor(color.r, color.g, color.b,color.a); ofRect(0, 0, barwidth, config->sliderHeight); setTextBGColor(); ofRect(0, config->sliderHeight, width, config->sliderTextHeight); //string s = name + ": " + ofToString((*value)); //ofDrawBitmapString(s, 3, config->sliderHeight + 14); if (keyboardEdit) { ofSetColor(255, 0, 0); //< set text to red while editing with keyboard. TODO: Make this more generic using something like setTextEditColor() string s = name + ": " + keyboardInputString; ofDrawBitmapString(s, 3, config->sliderHeight + 14); } else { setTextColor(); string s = name + ": ";// if (displayInteger) { if (max == 255) { s += ofToString(getValue(),0); } else { s += ofToString(getValue() * 255, 0); } } else { if (max == 255) { s += ofToString(getValue(),0); } else { s += ofToString(getValue(), 4); } } ofDrawBitmapString(s, 3, config->sliderHeight + 14); } ofDisableAlphaBlending(); glPopMatrix(); }
void ofxSimpleGuiSliderRange::draw(float x, float y) { setPos(x, y); range.set(ofMap((*value).min, min, max, 0, (float)width), ofMap((*value).max, min, max, 0, (float)width)); ofPushStyle(); ofEnableAlphaBlending(); glPushMatrix(); glTranslatef(x, y, 0); ofFill(); setEmptyColor(); ofRect(0, 0, width, config->sliderHeight); setFullColor(); ofRect(range.min, 0, range.max-range.min, config->sliderHeight); setTextBGColor(); ofRect(0, config->sliderHeight, width, config->sliderTextHeight); setTextColor(); ofDrawBitmapString(name+"\n["+ofToString(value->min, 2)+", "+ofToString(value->max, 2)+"]", 3, height+15-config->sliderTextHeight); glPopMatrix(); /* glPushMatrix(); glTranslatef(x, y, 0); ofFill(); setFullColor(); ofRect(0, 0, width, height - config->sliderHeight); ofFill(); setTextBGColor(); ofRect(0, height-config->slider2DTextHeight, width, config->sliderHeight); setTextColor(); // ofCircle(pointv.x-x, pointv.y-y, 2); setTextColor(); // ofLine(pointv.x-x, 0, pointv.x-x, height-config->slider2DTextHeight); // ofLine(0, pointv.y-y,width, pointv.y-y); glPopMatrix(); */ // ofDisableAlphaBlending(); ofPopStyle(); }
void ofxSimpleGuiSlider2d::draw(float x, float y) { bool positionChanged = false; if (x != this->x || y != this->y) { positionChanged = true; } setPos(x, y); if(positionChanged){ point.x = ofMap((*value).x, min.x, max.x, x, x+width); point.y = ofMap((*value).y, min.y, max.y, y, y+height-config->slider2DTextHeight); } ofPoint pointv; pointv.x = ofMap((*value).x, min.x, max.x, x, x+width); pointv.y = ofMap((*value).y, min.y, max.y, y, y+height-config->slider2DTextHeight); ofEnableAlphaBlending(); glPushMatrix(); glTranslatef(x, y, 0); ofFill(); setTextBGColor(); ofSetColor(128, 128, 128, 128); ofRect(0, 0, width, height - config->slider2DTextHeight); ofFill(); setTextBGColor(); ofRect(0, height-config->slider2DTextHeight, width, config->slider2DTextHeight); setTextColor(); ofDrawBitmapString(name+"\nx:"+ofToString(value->x, 2)+" y:"+ofToString(value->y, 2), 3, height+15-config->slider2DTextHeight); setTextColor(); ofCircle(pointv.x-x, pointv.y-y, 2); setTextColor(); ofLine(pointv.x-x, 0, pointv.x-x, height-config->slider2DTextHeight); ofLine(0, pointv.y-y,width, pointv.y-y); glPopMatrix(); ofDisableAlphaBlending(); }
void ofxSimpleGuiComboBox::draw(float x, float y) { //we assume a max of 256 characters. char choiceBuf[512]; setPos(x, y); glPushMatrix(); glTranslatef(x, y, 0); ofEnableAlphaBlending(); ofFill(); setTextBGColor(); ofRect(0, 0, width, height); setTextColor(); // sprintf(choiceBuf, "%s: %s", m_title, m_choices.size() ? m_choices[m_selectedChoice] : "(No Choices Available)"); ofDrawBitmapString(m_title + " : " + (m_choices.size() ? m_choices[m_selectedChoice] : "N/A"), kSGCBTextPaddingX, kSGCBTextPaddingY); //draw a combobox down triangle icon so the users know to click ofTriangle(width - (kSGCBTriangleWidth + KSGCBTrianglePadding), kSGCBTextPaddingY/2, width - (KSGCBTrianglePadding), kSGCBTextPaddingY/2, width - (kSGCBTriangleWidth/2 + KSGCBTrianglePadding), kSGCBTextPaddingY); if ( ignoresXML() ){ ofSetHexColor(config->noXmlColor); ofRect(width-config->noXmlBarWidth, 0, config->noXmlBarWidth, height); } if(m_hasFocus) { setCBTextBGColor(); ofRect(0, height, width, config->comboBoxTextHeight * m_choices.size()); setTextColor(); ofLine(0, config->comboBoxHeight-1, width, config->comboBoxHeight-1); for(int i=0; i < m_choices.size(); i++) { setCBTextColor(); //invert for selected choice float curY = height + i*config->comboBoxTextHeight; if(i==m_mouseChoice){ //draw a text colored rect so we can see the inverse ofRect(0, curY, width, config->comboBoxTextHeight); setCBTextBGColor(); } ofDrawBitmapString(m_choices[i], kSGCBTextPaddingX, curY + kSGCBTextPaddingY); } } ofDisableAlphaBlending(); glPopMatrix(); }
void ofxSimpleGuiFPSCounter::draw(float x, float y) { setPos(x, y); glPushMatrix(); glTranslatef(x, y, 0); ofEnableAlphaBlending(); ofFill(); setTextBGColor(false); ofRect(0, 0, width, height); setTextColor(false); ofDrawBitmapString("FPS: " + ofToString(ofGetFrameRate()), 3, 15); glPopMatrix(); }
void ofxSimpleGuiButton::draw(float x, float y) { setPos(x, y); glPushMatrix(); glTranslatef(x, y, 0); // if a toggle if(currentValue && beToggle && !isHovered) { setTextColor(); ofSetColor(255, 255, 255, 255); selectedImage->draw(0, 0); } else if ( hasHover && isHovered && !isDown ) { ofSetColor(255, 255, 255, 255); hoverImage->draw(0, 0); } else if ( isDown ) { if(hasDown) { ofSetColor(255, 255, 255, 255); downImage->draw( 0, 0 ); } } else { if(hasUp) { ofSetColor(255, 255, 255, 255); upImage->draw(0, 0); } else { ofEnableAlphaBlending(); ofFill(); setTextBGColor(); ofRect(0, 0, width, height); } } setTextColor(); ofDrawBitmapString(name, 3, 15); ofDisableAlphaBlending(); glPopMatrix(); }
void ofxSimpleGuiButton::draw(float x, float y) { setPos(x, y); glPushMatrix(); glTranslatef(x, y, 0); ofEnableAlphaBlending(); ofFill(); setTextBGColor(!isFixed()); ofRect(0, 0, width, height); setTextColor(!isFixed()); ofCircle(height/3, height/2, height /5); ofDrawBitmapString(name + " (" + ofToString(counter)+")", height - 15, 26); ofDisableAlphaBlending(); fixButtonDraw(); glPopMatrix(); }
//--------------------------------------------------------------------- draw void ofxSimpleGuiColorPicker::draw(float x, float y) { // enabled = true; //update postion of gui object setPos(x, y); glPushMatrix(); glTranslatef(x, y, 0); int startY = 0; for(int i=0; i<4; i++) { barwidth[i] = ofMap(getValue(i), 0, max, 0.0, (float)width); if(barwidth[i] > width) barwidth[i] = width; else if(barwidth[i] < 0) barwidth[i] = 0; ofEnableAlphaBlending(); ofFill(); setEmptyColor(); ofRect(0, startY, width, config->sliderTextHeight); if(max == 1){ switch(i) { case 0:glColor3f(getValue(i), 0, 0); break; case 1:glColor3f(0, getValue(i), 0); break; case 2:glColor3f(0, 0, getValue(i)); break; case 3:glColor3f(getValue(i), getValue(i), getValue(i)); break; } } else { switch(i) { case 0:ofSetColor(getValue(i), 0, 0); break; case 1:ofSetColor(0, getValue(i), 0); break; case 2:ofSetColor(0, 0, getValue(i)); break; case 3:ofSetColor(getValue(i), getValue(i), getValue(i)); break; } } ofRect(0, startY, barwidth[i], config->sliderTextHeight); int iover = (getMouseY() - y) / (config->sliderTextHeight); bool isOver = iover == i; if(isOver) { glColor3f(1, 1, 1); } else { glColor3f(0.5, 0.5, 0.5); } if (max == 1 && displayInteger) { ofDrawBitmapString(ofToString(getValue(i)*255, 0), 3, startY + 14); } else { if(max == 255){ ofDrawBitmapString(ofToString(getValue(i), 0), 3, startY + 14); } else { ofDrawBitmapString(ofToString(getValue(i), 4), 3, startY + 14); } } startY += config->sliderTextHeight; } ofFill(); setTextBGColor(); ofRect(0, startY, width, config->sliderTextHeight); if(max == 1){ glColor3f(getValue(0), getValue(1), getValue(2)); } else { ofSetColor(getValue(0), getValue(1), getValue(2)); } // ofRect(0, startY+config->sliderTextHeight, width, config->sliderTextHeight * 1.5); ofRect(150, startY + 3, width - 150 -3, config->sliderTextHeight - 8); setTextColor(); string s = name; ofDrawBitmapString(s, 3, startY + 14); ofDisableAlphaBlending(); glPopMatrix(); }
void ofxSimpleGuiContentSlider2d::draw(float x, float y) { setPos(x, y); ofEnableAlphaBlending(); glPushMatrix(); glTranslatef(x, y, 0); ofFill(); glColor4f(0, 0, 0, 1.0f); ofRect(0, sliderTextHeight, width, sliderHeight); ofSetColor(255, 255, 255, 255); content->draw(0, sliderTextHeight, fixwidth, fixheight); setTextBGColor(!isFixed()); ofRect(0, 0, width, sliderTextHeight); setTextColor(!isFixed()); char vs[64]; std::sprintf(vs, "\nx:%.2f\ny:%.2f", value->x,value->y); ofDrawBitmapString(name + vs , 6, 15); setTextColor2(!isFixed()); char vs2[64]; std::sprintf(vs2, "\n\nx:%.2f\ny:%.2f", value2->x,value2->y); ofDrawBitmapString(vs2 , secBtnPos.x, 0); ofSetHexColor(0xffffff); ////////// // ofSetColor(0, 0, 0,0); // setContent2DSliderBGColor(!isFixed()); // if (!isFixed()) ofRect(0, sliderTextHeight, fixwidth, fixheight); ofTranslate((int)0.0f, (int)sliderTextHeight); if (!isFixed()) { ofSetHexColor(0xFFFFFF); ofCircle(point.x, point.y, 2); ofLine(point.x, 0, point.x, fixheight); ofLine(0, point.y,width, point.y); if (bSecondPoint) { ofSetHexColor(0xFFFF00); ofCircle(point2.x, point2.y, 2); ofLine(point2.x, 0, point2.x, fixheight); ofLine(0, point2.y,width, point2.y); } ofSetHexColor(0xFFFFFF); ofRectangle maxxB = base64GetStringBoundingBox("X:" + ofToString(max.x)); char valueString[64]; std::sprintf(valueString,"( %.2f , %.2f )",(*value).x, (*value).y); ofRectangle valueStringBox = base64GetStringBoundingBox(valueString); base64DrawBitmapString("(" + ofToString(min.x) + "," + ofToString(min.y) + ")", 1, 2); base64DrawBitmapString("X:" + ofToString(max.x), width - maxxB.width - 1, 2); base64DrawBitmapString("Y:" + ofToString(max.y), 1, fixheight - maxxB.height -1); if (width/2 > point.x && fixheight/2 > (point.y - y)){ //左上にあるとき base64DrawBitmapString(valueString, point.x + 3, point.y + 3); } else if (width/2 < point.x && fixheight/2 > (point.y)) {//右上 base64DrawBitmapString(valueString, point.x - valueStringBox.width - 3, point.y + 3); } else if (width/2 > point.x && fixheight/2 < point.y) {//左下 base64DrawBitmapString(valueString, point.x + 3, point.y - valueStringBox.height - 3); } else {//右下 base64DrawBitmapString(valueString, point.x - valueStringBox.width - 3, point.y - valueStringBox.height - 3); } if (bSecondPoint) { ofSetHexColor(0xFFFF00); char valueString2[64]; std::sprintf(valueString2,"( %.2f , %.2f )",(*value2).x, (*value2).y); ofRectangle valueStringBox2 = base64GetStringBoundingBox(valueString2); if (width/2 > point2.x && fixheight/2 > (point2.y - y)){ base64DrawBitmapString(valueString2, point2.x + 3, point2.y + 3); } else if (width/2 < point2.x && fixheight/2 > (point2.y)) {//右上 base64DrawBitmapString(valueString2, point2.x - valueStringBox2.width - 3, point2.y + 3); } else if (width/2 > point2.x && fixheight/2 < point2.y) {//左下 base64DrawBitmapString(valueString2, point2.x + 3, point2.y - valueStringBox2.height - 3); } else {//右下 base64DrawBitmapString(valueString2, point2.x - valueStringBox2.width - 3, point2.y - valueStringBox2.height - 3); } } } ofTranslate(0, 0 - (int)sliderTextHeight); fixButtonDrawOfContentSlider2d(); if (!fixed) { ofFill(); ofSetHexColor(config->emptyColor); ofRect(secBtnPos.x, 1.0f, secondPointBoxWidth, secondPointBoxWidth); ofSetHexColor(0xFFFF00); } else { ofSetHexColor(config->borderColor); ofNoFill(); } ofSetLineWidth(0.5); if (bSecondPoint) { ofFill(); } else ofNoFill(); ofCircle(secBtnPos.x + secondPointBoxWidth / 2.0f, secondPointBoxWidth / 2 + 1.0f, secondPointBoxWidth / 2); ofNoFill(); ofSetHexColor(config->borderColor); ofRect(secBtnPos.x - 0.5, 0.5f, secondPointBoxWidth + 1.0f, secondPointBoxWidth + 1.0f); glPopMatrix(); ofDisableAlphaBlending(); }