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 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 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 ofxSimpleGuiSliderBase<Type>::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(); 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 + ": " + ofToString((*value)); ofDrawBitmapString(s, 3, config->sliderHeight + 14); } ofDisableAlphaBlending(); glPopMatrix(); }
//--------------------------------------------------------------------- void ofxSimpleGuiMovieSlider::drawWidget(float x, float y) { enabled = true; //update postion of gui object setPos(x, y); glPushMatrix(); glTranslatef(x, y, 0); ofEnableAlphaBlending(); ofFill(); // if(isMouseOver()) ofSetColor(config->overColor.r, config->overColor.g, config->overColor.b); // if(focused && !isMouseOver()) ofSetColor(config->focusColor.r, config->focusColor.g, config->focusColor.b); setFullColor(); ofRect(0, 0, barwidth, height); ofSetColor(config->textColor); float inputpos = ofMap(input->getPosition(), 0.0, 1.0, 0.0, videoLength); ostringstream info; info << name << ":" << ofToString(inputpos, 3) << "/" << ofToString(videoLength, 3) << endl; // TODO: //ofDrawBitmapString(info.str(), config->fontOffset.x, height+config->fontOffset.y); config->font.drawString(info.str(), config->fontOffset.x, height+config->fontOffset.y); // cues // if(cuePoint1 > 0.0) { // ofSetColor(config->overColor.r, config->overColor.g, config->overColor.b, 200); // ofRect(ofMap(cuePoint1, 0.0, 1.0, 0.0, width), 0, 1, height); // } // if(cuePoint2 < 1.0) { // ofSetColor(config->overColor.r, config->overColor.g, config->overColor.b, 200); // ofRect(ofMap(cuePoint2, 0.0, 1.0, 0.0, width), 0, 1, height); // } ofDisableAlphaBlending(); glPopMatrix(); // a bit of a hack but for simple no images to load :) pauseBtn->draw(x, y+35); cue1Btn->draw(x+23, y+35); cue2Btn->draw(x+46, y+35); resetBtn->draw(x+69, y+35); ofSetColor(0xffffff); config->font.drawString("1", x+30, y+49); config->font.drawString("2", x+53, y+49); config->font.drawString("R", x+76, y+49); /* ofDrawBitmapString("1", x+30, y+49); ofDrawBitmapString("2", x+53, y+49); ofDrawBitmapString("R", x+76, y+49); */ ofSetColor(0xffffff); ofFill(); if(!doPause) { ofRect(x+6, y+38, 2, 14); ofRect(x+13, y+38, 2, 14); } else if(doPause){ glPushMatrix(); glTranslatef(x+6, y+37, 0); ofTriangle(0, 0, 0, 16, 8, 8); glPopMatrix(); } }