oulaoups / controlp5

Automatically exported from code.google.com/p/controlp5
0 stars 0 forks source link

Slider values are clamped at 100 (default max range?) during initialization #47

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run the test example below.
2. The only way to set the value is by hardcoding it in a setValue call.

--[ EXAMPLE SKETCH BEGIN]---

import controlP5.*;
ControlP5 cp5;

int sliderValueOne = 211;
int sliderValueTwo = 222;

void setup() {
  size(300, 150);
  cp5 = new ControlP5(this);
  print("I used to be " + sliderValueOne);
  cp5.addSlider("sliderValueOne").setPosition(75, 50).setRange(0, 255).setValue(sliderValueOne);
  cp5.addSlider("sliderValueTwo").setPosition(75, 90).setRange(0, 255).setValue(144).setValue(sliderValueTwo);
  println(", but I got capped at " + sliderValueOne);
  noStroke();
}

void draw() {
  background(sliderValueOne);
  fill(sliderValueTwo);
  rect(25, 25, width-50, height-50);
}

--[ EXAMPLE SKETCH END]---

What is the expected output? What do you see instead?

The expected output is that the Sliders are automatically set to their actual 
initial values, 211 and 222 respectively. However it seems they are clamped at 
the default max range 100. Even when manually using setValue after setRange, it 
is still not possible to set the Sliders to the variable's value. In fact the 
variable's original value is clamped as a result. See the first Slider. The 
only way to set a Slider above 100 is by using setValue() with a hardcoded 
value. See the second Slider.

What version of the product are you using? On what operating system?

Window XP + Processing 1.5.1 + ControlP5 0.7.2

Please provide any additional information below.

Other than that, controlP5 is still awesome ;-)

Original issue reported on code.google.com by amnonp5@gmail.com on 5 May 2012 at 5:07

GoogleCodeExporter commented 9 years ago
ok, reproduced and fixed with next release (0.7.3)

Original comment by andreas....@lasalle.edu.sg on 15 May 2012 at 11:41

GoogleCodeExporter commented 9 years ago

Original comment by soj...@gmail.com on 15 May 2012 at 12:15

GoogleCodeExporter commented 9 years ago

Original comment by soj...@gmail.com on 18 May 2012 at 5:07

GoogleCodeExporter commented 9 years ago
Andreas, thanks for fixing this. I tested the new release 0.7.3. and saw that 
it worked. However in my app it didn't work. I tracked down the problem. If you 
call setSize() BEFORE setRange() the value is still capped to 100. If you call 
setSize() AFTER setRange all is well. See the example code below. Of course 
re-ordering the calls is no problem, so I have adapted this in my app. However 
I thought I should let you know, because there is still some involuntary 
capping going on somewhere. :D

--[ EXAMPLE SKETCH BEGIN]---

import controlP5.*;
ControlP5 cp5;

int sliderValueOne = 211;
int sliderValueTwo = 222;

void setup() {
  size(300, 150);
  cp5 = new ControlP5(this);
  cp5.addSlider("sliderValueOne").setSize(75, 9).setPosition(75, 50).setRange(0, 255);
  cp5.addSlider("sliderValueTwo").setPosition(75, 90).setRange(0, 255).setSize(75, 9);
  noStroke();
}

void draw() {
  background(sliderValueOne);
  fill(sliderValueTwo);
  rect(25, 25, width-50, height-50);
}

--[ EXAMPLE SKETCH END]---

Original comment by amnonp5@gmail.com on 22 May 2012 at 11:06