diff --git a/addons/ofxGui/src/ofxButton.cpp b/addons/ofxGui/src/ofxButton.cpp index 3e3ee871f5a..de2dceeb329 100644 --- a/addons/ofxGui/src/ofxButton.cpp +++ b/addons/ofxGui/src/ofxButton.cpp @@ -46,6 +46,13 @@ ofxButton* ofxButton::setup(const std::string& toggleName, float width, float he return this; } +void ofxButton::setSize(float width, float height){ + b.width = width; + b.height = height; + checkboxRect.set(1, 1, b.height - 2, b.height - 2); + sizeChangedCB(); +} + void ofxButton::generateDraw(){ bg.clear(); bg.setFillColor(thisBackgroundColor); diff --git a/addons/ofxGui/src/ofxButton.h b/addons/ofxGui/src/ofxButton.h index cc742abea11..5aaa93edf0b 100644 --- a/addons/ofxGui/src/ofxButton.h +++ b/addons/ofxGui/src/ofxButton.h @@ -12,6 +12,7 @@ class ofxButton : public ofxToggle{ ~ofxButton(); ofxButton* setup(ofParameter _bVal, float width = defaultWidth, float height = defaultHeight); ofxButton* setup(const std::string& toggleName, float width = defaultWidth, float height = defaultHeight); + virtual void setSize(float width, float height); void generateDraw(); virtual bool mouseReleased(ofMouseEventArgs & args); diff --git a/addons/ofxGui/src/ofxToggle.cpp b/addons/ofxGui/src/ofxToggle.cpp index 8a351988c1f..1d1f0bf2859 100644 --- a/addons/ofxGui/src/ofxToggle.cpp +++ b/addons/ofxGui/src/ofxToggle.cpp @@ -31,6 +31,12 @@ ofxToggle * ofxToggle::setup(const std::string& toggleName, bool _bVal, float wi return setup(value,width,height); } +void ofxToggle::setSize(float width, float height){ + b.width = width; + b.height = height; + checkboxRect.set(1, 1, b.height - 2, b.height - 2); + sizeChangedCB(); +} bool ofxToggle::mouseMoved(ofMouseEventArgs & args){ if(isGuiDrawing() && b.inside(args)){ diff --git a/addons/ofxGui/src/ofxToggle.h b/addons/ofxGui/src/ofxToggle.h index abacee0f077..6332f8ebfd6 100644 --- a/addons/ofxGui/src/ofxToggle.h +++ b/addons/ofxGui/src/ofxToggle.h @@ -11,7 +11,7 @@ class ofxToggle : public ofxBaseGui{ ofxToggle(ofParameter _bVal, float width = defaultWidth, float height = defaultHeight); ofxToggle * setup(ofParameter _bVal, float width = defaultWidth, float height = defaultHeight); ofxToggle * setup(const std::string& toggleName, bool _bVal, float width = defaultWidth, float height = defaultHeight); - + virtual void setSize(float width, float height); virtual bool mouseMoved(ofMouseEventArgs & args); virtual bool mousePressed(ofMouseEventArgs & args);