[AD] d_slider_proc patches

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Here is a patch that makes the d_slider_proc() only call its callback
function if the slider position has changed. i.e. it used to call the
function if the user pressed an arrow key no matter if the slider actually
was moved. I also removed an unnecessary if later on in the function. This
patch is called uncall.dif.

btw, why is the following code in d_slider_proc() a loop:

   while (1) {
      d->d2 = d->d2+delta;
      slpos = slratio*d->d2;
      slp = fixtoi(slpos);
      if ((slp != oldpos) || (d->d2 <= 0) || (d->d2 >= d->d1))
         break;
   }

(d->d2 is the slider position, delta is 1 if KEY_RIGHT was pressed and -1
if KEY_LEFT was pressed, slp is calculated to be the position in pixels of
the slider and oldpos is the previous position in pixels of the slider.)
So this loop just makes sure that the slider is moved at least one pixel,
in case it takes more values than there are pixels. Why? If the programmer
makes the slider take more values than there are pixels, then surely there
is some reson to do that, and the user should be able to adjust it with the
given precision? I made it work this way in the other patch, unloop.dif.
This should be applied on top of uncall.dif if you decide to use it.

Sven

Attachment: slider.zip
Description: Zip archive







Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/