[MPlayer-dev-eng] [PATCH] GUI: Implement a true rotary potmeter

Ingo Brückl ib at wupperonline.de
Wed Apr 2 20:40:56 CEST 2014


Hans-Dieter Kosch wrote on Wed, 02 Apr 2014 04:24:47 +0200:

> I regard a rotary poti just like a linear one. The difference is that a
> circle has basically no start and no end...

Well, what about the following then?

Let the default definition for a rpotmeter be default;x;y;X;Y. Now be:

start = atan2 transformation of x,y
end   = atan2 transformation of X,Y
range = end - start (add 1 if <= 0)
gap   = 1 - range

To handle the rpotmeter similar to the linear ones, let a point x,y clicked
on be p:

p = atan2 transformation of x,y - start (add 1 if <= 0)

We have a kind of linear potmeter starting with 0 of width range now and
calculating the item's value is simple:

     if p <= range          then value = (p / range) * 100
else if p < range + gap / 2 then value = 100
else                             value = 0

So, guiItem only needs to provide start and range. (All names are just
examples.)

Attached is a quick and dirty proof of concept (for plastic skin and main.c
only; although more universal, because it should work for arbitrary start and
stop points, it seems simpler).

Can you detect any faulty reasoning? Anything I might have missed?

Ingo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: main.c.patch
Type: text/x-diff
Size: 2665 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20140402/1de34a52/attachment.bin>


More information about the MPlayer-dev-eng mailing list