Skip to content

Commit

Permalink
Bugfix ofxSliderGroup division by zero (#6034)
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroMTB authored and arturoc committed Jul 30, 2018
1 parent 81245d2 commit 659cc30
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions addons/ofxGui/src/ofxSliderGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,12 @@ ofxColorSlider_<ColorType> * ofxColorSlider_<ColorType>::setup(ofParameter<ofCol
add(new ofxSlider<ColorType>(p, width, height));
p.addListener(this, & ofxColorSlider_::changeSlider);
collection[i]->setFillColor(value.get());
collection[i]->setTextColor(p / p.getMax() > 0.75 ? ofFloatColor(0.) : ofFloatColor(1.));
float range = p.getMax()-p.getMin();
if(range == 0){
collection[i]->setTextColor( ofFloatColor(0.));
}else{
collection[i]->setTextColor( p/range > 0.75 ? ofFloatColor(0.) : ofFloatColor(1.));
}
}
add(&picker);
picker.getParameter().template cast<ofColor_<ColorType>>().addListener(this, & ofxColorSlider_::changeValue);
Expand Down Expand Up @@ -174,7 +179,12 @@ void ofxColorSlider_<ColorType>::changeSlider(const void * parameter, ColorType
for (int i=0; i<4; i++){
collection[i]->setFillColor(data);
auto p = parameters[i].template cast<ColorType>();
collection[i]->setTextColor(p / p.getMax() > 0.75 ? ofFloatColor(0.) : ofFloatColor(1.));
float range = p.getMax()-p.getMin();
if(range == 0){
collection[i]->setTextColor( ofFloatColor(0.));
}else{
collection[i]->setTextColor( p/range > 0.75 ? ofFloatColor(0.) : ofFloatColor(1.));
}
}
sliderChanging = false;
}
Expand All @@ -188,7 +198,12 @@ void ofxColorSlider_<ColorType>::changeValue(ofColor_<ColorType> & value){
parameters[i].template cast<ColorType>() = value[i];
collection[i]->setFillColor(value);
auto p = parameters[i].template cast<ColorType>();
collection[i]->setTextColor(p / p.getMax() > 0.75 ? ofFloatColor(0.) : ofFloatColor(1.));
float range = p.getMax()-p.getMin();
if(range == 0){
collection[i]->setTextColor( ofFloatColor(0.));
}else{
collection[i]->setTextColor( p/range > 0.75 ? ofFloatColor(0.) : ofFloatColor(1.));
}
}
}

Expand Down

0 comments on commit 659cc30

Please sign in to comment.