//--------------------------------------------------------------------- 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 ofxSimpleGuiColorTitle::draw(float x, float y) { setPos(x, y); if(hasTitle == false) return; glPushMatrix(); glTranslatef(x, y, 0); ofEnableAlphaBlending(); ofFill(); // setTextBGColor(value != NULL); // ofSetColor(0, 0, 0); setEmptyColor(); ofRect(0, 5, width, height-5); if(isInteger){ ofSetColor(value[0], value[1], value[2], value[3]); } else { glColor4f(value[0], value[1], value[2], value[3]); } ofRect(0, 0, width, 5); // if a toggle //if(value && (*value) && beToggle) { // setTextColor(); //ofLine(0, 0, box.width, box.height); //ofLine(box.width, 0, 0, box.height); //} setTextColor(value != NULL); if(isOpen){ ofDrawBitmapString(name, 3, 18); } else { ofDrawBitmapString(name+" ...", 3, 18); } ofDisableAlphaBlending(); glPopMatrix(); glColor4f(1,1,1,1); }
//--------------------------------------------------------------------- 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(); }