Activity log for bug #768451

Date Who What changed Old value New value Message
2011-04-21 16:47:25 Ryan Pedersen bug added bug
2011-04-21 16:47:25 Ryan Pedersen attachment added CoolSlider with modification https://bugs.launchpad.net/bugs/768451/+attachment/2080053/+files/CoolSlider.java
2011-04-21 17:49:23 Craig Hewetson rcptoolbox: status New Fix Committed
2011-04-21 17:49:26 Craig Hewetson rcptoolbox: importance Undecided Medium
2011-04-21 17:49:30 Craig Hewetson rcptoolbox: assignee Craig Hewetson (craighewetson)
2011-04-21 17:50:35 Launchpad Janitor branch linked lp:rcptoolbox
2011-04-21 18:22:03 Ryan Pedersen 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 doMoveThumbHorizontally which would exit if the width variable was 0 the problem went away (shown below). 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 doMoveThumbHorizontally(double x, boolean update){ int width = (int)x - thumb.getBounds().width/2 - leftmostRegion.getBounds().width; if(width > getClientArea().width-thumb.getBounds().width-rightmostRegion.getBounds().width){ width = getClientArea().width-thumb.getBounds().width-rightmostRegion.getBounds().width; } if (width == 0){ // button hasn't moved so exit return; } else if(width < 0){ int mW = leftmostRegion.getBounds().width + width; if(mW < 0){ mW = 0; } leftmostRegion.updatePosition(mW); width = 0; }else{ leftmostRegion.resetToDefault(); } leftRegion.updatePosition(width); layout(); if(update){ double percentage = x/(getClientArea().width); if(snapStyle){ percentage = Math.round((maximum-minimum)*percentage)+minimum; }else{ percentage = (leftmostRegion.getBounds().width+leftRegion.getBounds().width*1.0) /(getClientArea().width-thumb.getBounds().width); } updateTooltipMoving(percentage); updatePostionListeners(percentage); previousPosition = percentage; } } Overall the control has worked great, thanks for your hard work on this project. 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 doMoveThumbHorizontally which would exit if the width variable was 0 the problem went away (shown below). 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 doMoveThumbHorizontally(double x, boolean update){   int width = (int)x - thumb.getBounds().width/2 - leftmostRegion.getBounds().width;   if(width > getClientArea().width-thumb.getBounds().width-rightmostRegion.getBounds().width){    width = getClientArea().width-thumb.getBounds().width-rightmostRegion.getBounds().width;   }   if (width == 0){    // button hasn't moved so exit    return;   }   else if(width < 0){    int mW = leftmostRegion.getBounds().width + width;    if(mW < 0){     mW = 0;    }    leftmostRegion.updatePosition(mW);    width = 0;   }else{    leftmostRegion.resetToDefault();   }   leftRegion.updatePosition(width);   layout();   if(update){    double percentage = x/(getClientArea().width);    if(snapStyle){     percentage = Math.round((maximum-minimum)*percentage)+minimum;    }else{     percentage = (leftmostRegion.getBounds().width+leftRegion.getBounds().width*1.0)         /(getClientArea().width-thumb.getBounds().width);    }    updateTooltipMoving(percentage);    updatePostionListeners(percentage);    previousPosition = percentage;   }  } Overall the control has worked great, thanks for your hard work on this project.