Re: Round dial




Russell Nelson <nelson@crynwr.com> writes:

> Russell Nelson writes:
>  > Jens Christian Restemeier writes:
>  >  > This is the first try for a round dial, based on the gtk-tutorial widget
>  >  > "Dial". Please give me some comments.
>  > 
>  > It uses GtkArgFunc and so must be written to gtk+-0.99.2.
> 
> Change it to GtkArgSetFunc, and it runs (no idea what lossage may
> ensue).  Speaking of lossage, it kind of forgets where you grabbed the
> knob if you try to rotate it past the stops.  

Yes, this is quite annoying. I had similar problems with my
first attempt at a dial widget until I changed the way I computed
angles.

The easy way to get this right is to save _two_ angles at the initial
button press - the angle of the button press and the angle of the knob
initially, and then recompute the new angle at each point. You'll
have to be a bit carefull about wrap-around issues so that the
dial turns to to the stops in both directions, but that should just
take a little thought.

On the other, some people might want infinite knobs (no stops) as an
option on their dials, in which case you would have to use a
compute-the-change-at-each-step mechanism. Fixing that up wouldn't
be too hard either - you'd just have to store the computed angle
separately from the angle that is displayed/reflected in the 
value. 

> And the lighting model
> on the triangle/pointer is a little too quantized.

Hmmm, this is probably not too solvable within the GtkStyle
mechanism, but there does seem to be a bug in drawing shaded
polygons (look at the surrounding oval...)

The widget definitely needs to use backing store to prevent
flashing - I didn't do this for the original GtkDial to keep
things simpler, but it is only a few lines of code. (Look
at the scrollbar or entry widgets)

I wonder if it would be worth giving the programmer the choice
of the original "dial" look or the new "knob" look. It would
be pretty easy to implement ... but since they have equivalent
functionality, perhaps it is more of a "themes" issue. 
(It wouldn't be implementable by pixmap switching though.
Would people want both in the same application? )

Generally, looks good.

Regards,
                                        Owen



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