Re: GtkRange widget




plex <dadler@gwdg.de> writes:

> hi,
> 
> i just hacked a bit gtkrange widgets and I found some mystique lines here
> in the default_motion callbacks in gtkrange:
> 
>   if (range->digits >= 0)
>     {
>       char buffer[64];
>   
>       sprintf (buffer, "%0.*f", range->digits, range->adjustment->value);
>       sscanf (buffer, "%f", &range->adjustment->value);
>     }
> 
> this looks like some performance gap for me, is there really a use to round the
> float value ?
 
Performance gap? I really doubt it. A quick timing of this
code indicates that the time to do that rounding is 
approxmimately 2 microseconds on my machine.

> I mean, if someone needs to round a float, he can do it in its
> application, or?

Well, one advantage of this is that the value is rounded to
exactly the value that is displayed. I think the main reason why
this is done this way is that the thumb will snap to the 
allowed positions.

Regards,
                                        Owen



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]