void aTextCntnr::parseContents() { //look thru rawcontentstring for the | and break into a vector contents=ofSplitString(rawcontentstring, "|"); int x = locXY.x+INDENT; //v.Yi int x = winX+locXY.x+W+10; for (int i=0; i<contents.size(); i++) { int y = locXY.y+LINESP+(i*LINESP); //v.Yi int y = winY+locXY.y+(i*LINESP); int W = ofBitmapStringGetBoundingBox(contents[i],x,y).width; int H = ofBitmapStringGetBoundingBox(contents[i],x,y).height; ofVec4f dimensions; dimensions[0] = x; dimensions[1] = y; dimensions[2] = W; dimensions[3] = H; int itemNum=(nodeNum*10)+i; //max 9 items //last digit is "idnum" of this item //ofVec4f _dims, bool _centered, int _id, int _nodenum, int _scenenum itemHotspots.push_back(new aHotspot(dimensions, false, i, nodeNum, scenenum)); textItems.push_back(new aText(dimensions, contents[i], clrLightOff_base, clrLightOff_hover, clrLightOn_base, clrLightOn_hover, itemNum )); textItems[i]->registerHotspot(itemHotspots[i]); //092614 } //each item is represented by a aText asset, and entire collection is listed in a vector for easy scanning printf("TextCntnr %s gets a contents list of size %lu\n",displayedName.c_str(), contents.size()); }
aTextCntnr::aTextCntnr(sTextContainerData _data, int _scenenum, int _nodenum){ nodeNum = _nodenum; scenenum = _scenenum; displayedName=_data.DISPNAME; locXY.set(ofPoint(_data.X,_data.Y)); W = ofBitmapStringGetBoundingBox(displayedName,locXY.x,locXY.y).width; H = ofBitmapStringGetBoundingBox(displayedName,locXY.x,locXY.y).height; dimensions[0] = _data.X; dimensions[1] = _data.Y; dimensions[2] = W; dimensions[3] = H; centered = (_data.ALIGN=="C"); visible = _data.VISIBLE; rawcontentstring =_data.CONTENTS; //a "|"-delimited list of what's inside // must happen last parseContents(); clrLightOff_base = ofColor(_data.R2,_data.G2,_data.B2); clrLightOff_hover = ofColor(_data.R2,_data.G2,_data.B2,190); clrLightOn_base = ofColor(_data.R,_data.G,_data.B); clrLightOn_hover = ofColor(_data.R,_data.G,_data.B,200); opened=false; lightOn=true; mouseIsOver=false; parseContents(); //1002 and an earlier version printf("TextCntnr instance complete for %s at %0.f %0.f\n",displayedName.c_str(), locXY.x, locXY.y); }
void menu_button::update_rect() { m_pos = m_anchor; switch(m_anchor_mode) { case LEFT: break; case CENTER: if(m_font) m_pos.x -= m_font->getStringBoundingBox(m_text, 0, 0).width / 2.0; else m_pos.x -= ofBitmapStringGetBoundingBox(m_text, 0, 0).width / 2.0; break; case RIGHT: if(m_font) m_pos.x -= m_font->getStringBoundingBox(m_text, 0, 0).width; else m_pos.x -= ofBitmapStringGetBoundingBox(m_text, 0, 0).width; break; } if(m_font) m_rect = m_font->getStringBoundingBox(m_text, m_pos.x, m_pos.y); else m_rect = ofBitmapStringGetBoundingBox(m_text, m_pos.x, m_pos.y); // Padding m_rect.x -= 12; m_rect.y -= 12; m_rect.width += 24; m_rect.height += 24; }
ofRectangle ofxBaseGui::getTextBoundingBox(const string & text,float x, float y){ if(useTTF){ return font.getStringBoundingBox(text,x,y); }else{ return ofBitmapStringGetBoundingBox(text,x,y); } }
void GuiRangeSliderBase::draw() { if (toUpdateValueString) { valueString = valueStringNext; valueStringWidth = ofBitmapStringGetBoundingBox(valueString, 0, 0).width; stringHeight = ofBitmapStringGetBoundingBox(name, 0, 0).height; toUpdateValueString = false; } ofPushStyle(); ofFill(); ofSetColor(colorBackground); ofSetLineWidth(1); ofRect(rectangle); ofSetColor(colorForeground); ofRect(rectangle.x + rectangle.width * sliderLow, rectangle.y, rectangle.width * (sliderHigh - sliderLow), rectangle.height); ofNoFill(); ofSetColor(colorOutline); ofRect(rectangle); if (mouseOver) { ofNoFill(); ofSetLineWidth(2); ofSetColor(colorActive); ofRect(rectangle); ofSetLineWidth(1); } ofSetColor(colorText); ofDrawBitmapString(display, rectangle.x + 3, rectangle.y + 1 + 0.5 * (rectangle.height + 0.5 * stringHeight)); ofDrawBitmapString(valueString, rectangle.x + rectangle.width - valueStringWidth - 1, rectangle.y + 1 + 0.5 * (rectangle.height + 0.5 * stringHeight)); ofPopStyle(); }