Re: fixing GtkScale default quantization



On 25 Jan 2002, Havoc Pennington wrote:

> 
> Tim Janik <timj gtk org> writes:
> > 
> > i just meant to fix default value quantization in scales to
> > %.1f digits, and ran across GtkScale.digits. what's the deal
> > with that field? there's not even a compatibility issue there,
> > as 1.2 doesn't have it.
> > it just completely duplicates GTK_RANGE (scale)->round_digits.
> > 
> > i intend to apply the following patch, any comments?
> > 
> 
> The patch makes sense to me, I don't have any memory of why there's a
> separate digits field in GtkScale. (The only reason I can think of is
> that scale->digits doesn't actually change what's in the adjustment,
> only changes what's displayed; while range->round_digits does change 
> what goes in the adjustment; but probably the displayed value should
> match what gets set on the adjustment.)
> 
> However IMO the default should remain 1 not -1, because for the vast
> majority of scales you never want to see numbers like 5.234265109 and
> you don't want the number of displayed decimal places to keep
> changing. Perhaps the default should be 2 or 3, but it should be a
> small fixed number.

i see, this is about the number _display_.
the main point of my patch is fixing the value quantization however.
by default, sliders with an adjustment ranging from say 0.3 to 0.6 shouldn't
snap to 0.3, 0.4, 0.5, 0.6 as the only possible positions.
i.e. gtk_scale_set_digits() should affect the printf format only, but
not range->round_digits.
there should be extra API for when snapping is desired, and that'll also
need a scaling factor, e.g. when you want the snapping, but for numbers
like 30, 40, 50, 60.

however, that's an argument for keeping the ->digits field.

> A bug I noticed while looking at this is that "digits" gets clamped to
> 16, but the propery has a max of G_MAXINT. So we should have 
> #define MAX_DIGITS and use that for the clamp and the property max.

ok, done in my local tree.

> 
> Havoc
> 

---
ciaoTJ




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