void ofxUIRectangle::draw() { if(parent != NULL) { int px=x, py=y; ofxUIRectangle* parentRect = this; // 循环到canvas的上一层 while(parentRect->getParent()->getParent() != NULL) { px += parentRect->x; py += parentRect->y; parentRect = parentRect->getParent(); } // --!这里只是将rect绘制的相对位置 从直接绘制转移到了fbo当中 //ofxUIDrawRect(parent->getX()+x, parent->getY()+y, width, height); ofxUIDrawRect(px,py,width,height); } else { // --!这里画布的底框绘制位置理应与画布fbo之间的位移为0 ofxUIDrawRect(0,0,width,height); //ofxUIDrawRect(x,y,width,height); } }
void ofxUISlider_<T>::drawFill() { if(draw_fill && value > 0.0) { ofxUIFill(); ofxUISetColor(color_fill); if(orientation == OFX_UI_ORIENTATION_HORIZONTAL) { 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)); } } }
void ofxUIRangeSlider::drawFill() { if(draw_fill) { ofxUIFill(); ofxUISetColor(color_fill); if(kind == OFX_UI_WIDGET_RSLIDER_H) { ofxUIDrawRect(rect->getX()+rect->getWidth()*valuelow, rect->getY(), rect->getWidth()*(valuehigh-valuelow), rect->getHeight()); } else { ofxUIDrawRect(rect->getX(), rect->getY()+(1.0-valuehigh)*rect->getHeight(), rect->getWidth(), rect->getHeight()*(valuehigh-valuelow)); } } }
void ofxUIEnvelopeEditor::drawEnvelope(){ vector<ofVec3f> points = envelope->getPoints(); int size = points.size(); float rX = rect->getX(); float rY = rect->getY(); ofxUISetRectMode(OFX_UI_RECTMODE_CENTER); ofxUINoFill(); for (int i = 0; i < size; i++) { float x = rX + points[i].x*rect->getWidth(); float y = rY + points[i].y*rect->getHeight(); ofxUICircle(x, y, pointNodeRadius); if(i < size-1) { float nx = rX + points[i+1].x*rect->getWidth(); float hx = (x + nx)/2.0; ofxUIDrawRect(hx, rY + envelope->getY((hx-rX)/rect->getWidth())*rect->getHeight(), pointNodeRectWidth, pointNodeRectHeight); } } ofxUIFill(); ofxUISetRectMode(OFX_UI_RECTMODE_CORNER); polyline.draw(); }
void ofxUISlider::drawFill() { if(draw_fill && value > 0.0) { ofxUIFill(); ofxUISetColor(color_fill); 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)); } } }
void ofxUISlider_<T>::drawSkinRect( ofPtr<ofBaseDraws> &pDraw, ofRectangle &RFill ) { if(pDraw.use_count()>0) { pDraw->draw(RFill); } else { ofxUIDrawRect(RFill.x,RFill.y,RFill.width,RFill.height); } }
void ofxUISlider_<T>::drawFillHighlight() { if(draw_fill_highlight) { ofxUIFill(); ofxUISetColor(color_fill_highlight); if(orientation == OFX_UI_ORIENTATION_HORIZONTAL) { 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), valueString); } } }
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)); } } }
void ofxUIRangeSlider::drawFillHighlight() { if(draw_fill_highlight) { ofxUIFill(); ofxUISetColor(color_fill_highlight); if(kind == OFX_UI_WIDGET_RSLIDER_H) { ofxUIDrawRect(rect->getX()+rect->getWidth()*valuelow, rect->getY(), rect->getWidth()*(valuehigh-valuelow), rect->getHeight()); } else { ofxUIDrawRect(rect->getX(), rect->getY()+(1.0-valuehigh)*rect->getHeight(), rect->getWidth(), rect->getHeight()*(valuehigh-valuelow)); } if(kind == OFX_UI_WIDGET_RSLIDER_V) { label->drawString(rect->getX()+rect->getWidth()+padding, label->getRect()->getHeight()/2.0+rect->getY()+rect->getHeight()-rect->getHeight()*valuehigh, valuehighString); label->drawString(rect->getX()+rect->getWidth()+padding, label->getRect()->getHeight()/2.0+rect->getY()+rect->getHeight()-rect->getHeight()*valuelow, valuelowString); } } }
void ofxUIImageSampler::drawFillHighlight() { if(draw_fill_highlight) { ofxUISetColor(color_fill_highlight); ofxUIDrawLine(rect->getX()+value.x*rect->getWidth(), rect->getY(), rect->getX()+value.x*rect->getWidth(), rect->getY()+rect->getHeight()); ofxUIDrawLine(rect->getX(), rect->getY()+value.y*rect->getHeight(), rect->getX()+rect->getWidth(), rect->getY()+value.y*rect->getHeight()); ofxUIFill(); ofxUISetColor(sampledColor); ofxUISetRectMode(OFX_UI_RECTMODE_CENTER); ofxUIDrawRect(rect->getX()+value.x*rect->getWidth(), rect->getY()+value.y*rect->getHeight(), squareSize, squareSize); ofxUISetRectMode(OFX_UI_RECTMODE_CORNER); } }
void ofxUITextInput::drawFill() { if(draw_fill) { ofxUIFill(); ofxUISetColor(color_fill); rect->draw(); } if(clicked) { ofNoFill(); ofxUISetColor(color_outline_highlight); rect->draw(); float h = label->getRect()->getHeight(); float ph = rect->getHeight(); label->getRect()->setY(ph/2.0 - h/2.0); ofxUIFill(); ofxUISetColor(label->getColorFillHighlight(), 255.0*fabs(cos(theta))); theta +=0.05; int displayCursorPosition = cursorPosition - firstVisibleCharacterIndex; string displayStringBeforeCursor = displaystring.substr(0, displayCursorPosition); spaceOffset = label->getStringWidth(displayStringBeforeCursor); float x = label->getRect()->getX()+spaceOffset; float y = label->getRect()->getY()-padding; float t = label->getRect()->getHeight()+padding*2.0; ofxUIDrawRect(x, y, cursorWidth, t); } if(textstring.size() == 0 && !clicked) { ofxUIFill(); ofxUISetColor(color_fill); label->drawString(rect->getX()+defaultX, rect->getY()+defaultY, defaultstring); } }
void ofxUIImageSampler::drawFill() { if(draw_fill) { if(image != NULL) { ofxUIFill(); ofxUISetColor(255); image->draw(rect->getX(), rect->getY(), rect->width, rect->height); } ofxUISetColor(color_fill); ofxUIDrawLine(rect->getX()+value.x*rect->getWidth(), rect->getY(), rect->getX()+value.x*rect->getWidth(), rect->getY()+rect->getHeight()); ofxUIDrawLine(rect->getX(), rect->getY()+value.y*rect->getHeight(), rect->getX()+rect->getWidth(), rect->getY()+value.y*rect->getHeight()); ofxUIFill(); ofxUISetColor(sampledColor); ofxUISetRectMode(OFX_UI_RECTMODE_CENTER); ofxUIDrawRect(rect->getX()+value.x*rect->getWidth(), rect->getY()+value.y*rect->getHeight(), squareSize, squareSize); ofxUISetRectMode(OFX_UI_RECTMODE_CORNER); } }
void ofxUINumberDialer::drawFillHighlight() { if(draw_fill_highlight) { ofxUIFill(); ofxUISetColor(color_fill_highlight); float x = label->getRect()->getX(); float y = label->getRect()->getY()+label->getRect()->getHeight(); float w = label->getStringWidth("_"); ofxUIDrawRect(x+currentPrecisionZone*w,y+padding*.5,w, padding*.5); if(displayLabel) { label->drawString(x+rect->getWidth(), y, name); } for(unsigned int i = 0; i < displaystring.size(); i++) { float tw = label->getStringWidth(displaystring.substr(i,1)); float delta = w/2.0 - tw/2.0; label->drawString(x+i*w+delta, y, displaystring.substr(i,1)); } } }