Coolslider button positioning is inconsistent
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
RCP Toolbox |
Fix Committed
|
Medium
|
Unassigned |
Bug Description
I am implementing the CoolSlider in one of my projects as a custom slider control and noticed that sometimes the button is inconsistent on where it is positioned depending on the last position it was at. This could have something to do with the size of my images but after a lot of experimentation I was unable to come up with anything to prevent the issue. After digging in the code I found that if I added a line of code to doMoveThumbHori
Information on my CoolSlider:
CoolSlider constructor parameters:
dimensions of leftmost image - 96x42
dimensions of left image - 96x42
dimensions of thumbImageNormal image - 42x42
dimensions of thumbImageHover image - 42x42
dimensions of thumbImagePressed image - 42x42
dimensions of right image - 96x42
dimensions of rightmost image - 96x42
snapValues:
max = 768
min = 0
increment = 96
I also call setBounds with the following parameters: (40, 104, 768, 64)
New code starts at "if (width == 0){" and ends at "else if(width < 0){":
private void doMoveThumbHori
int width = (int)x - thumb.getBounds
if(width > getClientArea(
width = getClientArea(
}
if (width == 0){
// button hasn't moved so exit
return;
}
else if(width < 0){
int mW = leftmostRegion.
if(mW < 0){
mW = 0;
}
leftmostRegi
width = 0;
}else{
leftmostRegi
}
leftRegion.
layout();
if(update){
double percentage = x/(getClientAre
if(snapStyle){
percentage = Math.round(
}else{
percentage = (leftmostRegion
}
updateToolti
updatePostio
previousPosition = percentage;
}
}
Overall the control has worked great, thanks for your hard work on this project.
Related branches
description: | updated |
Thanks for logging the bug...
Looking at the code again scares me ... I have to suppress the urge to re-write it all :(
Anyway ... I'll submit your change, I also added the same fix to the doMoveThumbVert ically( ...) .
BTW: Launchpad as a really neat code review feature, if you use bazaar to propose a merge for your change ...