Skip to content

Commit aaf8228

Browse files
authored
Bugfix - ofxToggle/ofxButton size changes properly update checkbox size (#8503)
* ofxToggle setSize override to correctly change checkbox size * ofxButton setSize override to correctly change checkbox size * mistyped ofxToggle -> ofxButton
1 parent aed1697 commit aaf8228

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

addons/ofxGui/src/ofxButton.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ ofxButton* ofxButton::setup(const std::string& toggleName, float width, float he
4646
return this;
4747
}
4848

49+
void ofxButton::setSize(float width, float height){
50+
b.width = width;
51+
b.height = height;
52+
checkboxRect.set(1, 1, b.height - 2, b.height - 2);
53+
sizeChangedCB();
54+
}
55+
4956
void ofxButton::generateDraw(){
5057
bg.clear();
5158
bg.setFillColor(thisBackgroundColor);

addons/ofxGui/src/ofxButton.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class ofxButton : public ofxToggle{
1212
~ofxButton();
1313
ofxButton* setup(ofParameter<void> _bVal, float width = defaultWidth, float height = defaultHeight);
1414
ofxButton* setup(const std::string& toggleName, float width = defaultWidth, float height = defaultHeight);
15+
virtual void setSize(float width, float height);
1516
void generateDraw();
1617

1718
virtual bool mouseReleased(ofMouseEventArgs & args);

addons/ofxGui/src/ofxToggle.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ ofxToggle * ofxToggle::setup(const std::string& toggleName, bool _bVal, float wi
3131
return setup(value,width,height);
3232
}
3333

34+
void ofxToggle::setSize(float width, float height){
35+
b.width = width;
36+
b.height = height;
37+
checkboxRect.set(1, 1, b.height - 2, b.height - 2);
38+
sizeChangedCB();
39+
}
3440

3541
bool ofxToggle::mouseMoved(ofMouseEventArgs & args){
3642
if(isGuiDrawing() && b.inside(args)){

addons/ofxGui/src/ofxToggle.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class ofxToggle : public ofxBaseGui{
1111
ofxToggle(ofParameter<bool> _bVal, float width = defaultWidth, float height = defaultHeight);
1212
ofxToggle * setup(ofParameter<bool> _bVal, float width = defaultWidth, float height = defaultHeight);
1313
ofxToggle * setup(const std::string& toggleName, bool _bVal, float width = defaultWidth, float height = defaultHeight);
14-
14+
virtual void setSize(float width, float height);
1515

1616
virtual bool mouseMoved(ofMouseEventArgs & args);
1717
virtual bool mousePressed(ofMouseEventArgs & args);

0 commit comments

Comments
 (0)