void ofxGuiPanel::buildFromXml() { int numberOfTags = mGlobals->mXml.getNumTags("OBJECT"); if(numberOfTags > 0) { for(int i = 0; i < numberOfTags; i++) { mGlobals->mXml.pushTag("OBJECT", i); int id = mGlobals->mXml.getValue("ID", 0); string type = mGlobals->mXml.getValue("TYPE", ""); string name = mGlobals->mXml.getValue("NAME", ""); int width = mGlobals->mXml.getValue("WIDTH", 0); int height = mGlobals->mXml.getValue("HEIGHT", 0); int display = mGlobals->mXml.getValue("DISPLAY", 0); int steps = mGlobals->mXml.getValue("STEPS", 0); int mode = mGlobals->mXml.getValue("MODE", 0); string image = mGlobals->mXml.getValue("IMAGE", ""); if(type == "SLIDER") { float min = mGlobals->mXml.getValue("MIN", 0.0f); float max = mGlobals->mXml.getValue("MAX", 0.0f); float value = mGlobals->mXml.getValue("VALUE", 0.0f); ofxGuiSlider* slider = addSlider(id, name, width, height, min, max, value, display, steps); slider->buildFromXml(); } else if(type == "XYPAD") { float minx = mGlobals->mXml.getValue("MIN_X", 0.0f); float miny = mGlobals->mXml.getValue("MIN_Y", 0.0f); float maxx = mGlobals->mXml.getValue("MAX_X", 0.0f); float maxy = mGlobals->mXml.getValue("MAX_Y", 0.0f); float valuex = mGlobals->mXml.getValue("VALUE_X", 0.0f); float valuey = mGlobals->mXml.getValue("VALUE_Y", 0.0f); ofxPoint2f min = ofxPoint2f(minx, miny); ofxPoint2f max = ofxPoint2f(maxx, maxy); ofxPoint2f value = ofxPoint2f(valuex, valuey); ofxGuiXYPad* xypad = addXYPad(id, name, width, height, min, max, value, display, steps); xypad->buildFromXml(); } else if(type == "POINTS") { float minx = mGlobals->mXml.getValue("MIN_X", 0.0f); float miny = mGlobals->mXml.getValue("MIN_Y", 0.0f); float maxx = mGlobals->mXml.getValue("MAX_X", 0.0f); float maxy = mGlobals->mXml.getValue("MAX_Y", 0.0f); float valuex = mGlobals->mXml.getValue("VALUE_X", 0.0f); float valuey = mGlobals->mXml.getValue("VALUE_Y", 0.0f); ofxPoint2f min = ofxPoint2f(minx, miny); ofxPoint2f max = ofxPoint2f(maxx, maxy); ofxPoint2f value = ofxPoint2f(valuex, valuey); ofxGuiPoints* points = addPoints(id, name, width, height, min, max, value, display, steps); points->buildFromXml(); } else if(type == "BUTTON") { bool value = mGlobals->mXml.getValue("VALUE", 0); ofxGuiButton* button = addButton(id, name, width, height, value, mode, image); button->buildFromXml(); } else if(type == "FILES") { string subPath = mGlobals->mXml.getValue("SUBPATH", ""); string suffix = mGlobals->mXml.getValue("SUFFIX", ""); ofxGuiFiles* files = addFiles(id, name, width, height, mGlobals->mXmlfile, subPath, suffix); files->buildFromXml(); } else if(type == "COLOR") { ofRGBA value = ofRGBA(mGlobals->mXml.getValue("VALUE", "FFFFFFFF")); ofxGuiColor* color = addColor(id, name, width, height, value, mode); color->buildFromXml(); } else if(type == "MATRIX") { int xGrid = mGlobals->mXml.getValue("XGRID", 0); int yGrid = mGlobals->mXml.getValue("YGRID", 0); int value = mGlobals->mXml.getValue("VALUE", 0); int spacing = mGlobals->mXml.getValue("SPACING", 0); ofxGuiMatrix* matrix = addMatrix(id, name, width, height, xGrid, yGrid, value, mode, spacing); matrix->buildFromXml(); } else if(type == "SCOPE") { int length = mGlobals->mXml.getValue("LENGTH", 0); float valuex = mGlobals->mXml.getValue("VALUE_X", 0.0f); float valuey = mGlobals->mXml.getValue("VALUE_Y", 0.0f); ofxPoint2f value = ofxPoint2f(valuex, valuey); ofxGuiScope* scope = addScope(id, name, width, height, length, value, mode); scope->buildFromXml(); } else if(type == "KNOB") { float min = mGlobals->mXml.getValue("MIN", 0.0f); float max = mGlobals->mXml.getValue("MAX", 0.0f); float value = mGlobals->mXml.getValue("VALUE", 0.0f); ofxGuiKnob* knob = addKnob(id, name, width, height, min, max, value, display, steps); knob->buildFromXml(); } mGlobals->mXml.popTag(); } } }
ofxGuiGlobals::ofxGuiGlobals() { mXmlfile = ""; // TODO: make this work with sandbox mHeadFontName = "fonts/Questrial-Regular.ttf"; mHeadFontSize = 12; mHeadFontXOffset = -1; mHeadFontYOffset = 10; mHeadFontHeight = 12; // TODO: make this work with sandbox mParamFontName = "fonts/Questrial-Regular.ttf"; mParamFontSize = 9; mParamFontXOffset = 1; mParamFontYOffset = 10; mParamFontHeight = 15; mButtonXText = 5; mButtonYText = -1; mFilesXText = 3; mFilesYText = 3; mPointSize = 6; mKnobSize = 10; mCoverColor = ofRGBA(0x00000080);//(0x00000088); mTextColor = ofRGBA(0xFFFFFFFF); mBorderColor = ofRGBA(0xFFFFFF80);//(0xFFFFFFFF); mFrameColor = ofRGBA(0xFFFFFFFF); mSliderColor = ofRGBA(0x6699CCFF); mAxisColor = ofRGBA(0x00FF00FF); mHandleColor = ofRGBA(0xFFFFFFFF); mButtonColor = ofRGBA(0x6699CCFF); mCurveColor = ofRGBA(0x6699CCFF); mScopeColor = ofRGBA(0x6699CCFF); mMatrixColor = ofRGBA(0xFF0000FF); loadFonts(); }
void ofxGuiGlobals::buildFromXml() { int numberOfTags = mXml.getNumTags("STYLE"); if(numberOfTags != 1) return; mXml.pushTag("STYLE", 0); mHeadFontName = mXml.getValue("HEADFONT", "Questrial-Regular.ttf"); mHeadFontSize = mXml.getValue("HEADSIZE", 14); mHeadFontXOffset = mXml.getValue("HEADXOFF", -2); mHeadFontYOffset = mXml.getValue("HEADYOFF", 10); mHeadFontHeight = mXml.getValue("HEADHEIGHT", 12); mParamFontName = mXml.getValue("PARAMFONT", "Questrial-Regular.ttf"); mParamFontSize = mXml.getValue("PARAMSIZE", 10); mParamFontXOffset = mXml.getValue("PARAMXOFF", -2); mParamFontYOffset = mXml.getValue("PARAMYOFF", 10); mParamFontHeight = mXml.getValue("PARAMHEIGHT", 12); mButtonXText = mXml.getValue("BUTTONXTEXT", 4); mButtonYText = mXml.getValue("BUTTONYTEXT", 0); mFilesXText = mXml.getValue("FILESXTEXT", 3); mFilesYText = mXml.getValue("FILESYTEXT", 3); mPointSize = mXml.getValue("POINTSIZE", 6); mKnobSize = mXml.getValue("KNOBSIZE", 10); mCoverColor = ofRGBA(mXml.getValue("COVERCOLOR", "00000088")); mTextColor = ofRGBA(mXml.getValue("TEXTCOLOR", "FFFFFFFF")); mBorderColor = ofRGBA(mXml.getValue("BORDERCOLOR", "FFFFFFFF")); mFrameColor = ofRGBA(mXml.getValue("FRAMECOLOR", "FFFFFFFF")); mSliderColor = ofRGBA(mXml.getValue("SLIDERCOLOR", "0099FFFF")); mAxisColor = ofRGBA(mXml.getValue("AXISCOLOR", "00FF00FF")); mHandleColor = ofRGBA(mXml.getValue("HANDLECOLOR", "FFFFFFFF")); mButtonColor = ofRGBA(mXml.getValue("BUTTONCOLOR", "FFDD00FF")); mCurveColor = ofRGBA(mXml.getValue("CURVECOLOR", "FF9900FF")); mScopeColor = ofRGBA(mXml.getValue("SCOPECOLOR", "FF9900FF")); mMatrixColor = ofRGBA(mXml.getValue("ACTIVECOLOR", "FF0000FF")); mXml.popTag(); loadFonts(); }
ofxGuiGlobals::ofxGuiGlobals() { mXmlfile = ""; mHeadFontName = "fonts/verdana.ttf"; mHeadFontSize = 7; mHeadFontXOffset = -2; mHeadFontYOffset = 8; mHeadFontHeight = 12; mParamFontName = "fonts/verdana.ttf"; mParamFontSize = 7; mParamFontXOffset = -2; mParamFontYOffset = 6; mParamFontHeight = 12; mButtonXText = 4; mButtonYText = 0; mFilesXText = 3; mFilesYText = 3; mPointSize = 6; mKnobSize = 10; mCoverColor = ofRGBA(0xEAEAEAFF); mInCoverColor = ofRGBA(0xFFFFFFFF); mTextColor = ofRGBA(0x535353FF); mBorderColor = ofRGBA(0x535353FF); mFrameColor = ofRGBA(0x535353FF); mSliderColor = ofRGBA(0x0099FFFF); mAxisColor = ofRGBA(0x00FF00FF); mHandleColor = ofRGBA(0xFFFFFFFF); mButtonColor = ofRGBA(0xFFDD00FF); mCurveColor = ofRGBA(0xFF9900FF); mScopeColor = ofRGBA(0xFF9900FF); mMatrixColor = ofRGBA(0xFF0000FF); loadFonts(); }