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

Ingo Brückl ib at wupperonline.de
Tue Apr 1 20:41:14 CEST 2014


Hans-Dieter Kosch wrote on Mon, 31 Mar 2014 01:44:10 +0200:

> Here now the patch for the GTK GUI

First of all, nice work!

Looking through your patch was a nice brush-up in trigonometry. ;-)

I have a few first questions and comments though.

> +                   double dx = X - item->x - item->width / 2;
> +                   double dy = Y - item->y - item->height / 2;
> +
> +                   last_rpotmeter_angle = (dx == 0 && dy == 0) ? 0 : (atan2(dx, -dy) + M_PI) / (2*M_PI);

The variable name (last_rpotmeter_angle) is confusing, since stricly speaking
it isn't an angle (in degrees).

I was expecting something like "atan2(-dy, dx) / M_PI * 180" here.

Well, it seems that you've fixed where 0% is. Have you given plastic skin
a go? ;-)

It is hard to say where 0 for a poti should be (I actually don't remember the
old radios with potis that snapped and clicked into place), but since the
zero point is arbitrary I'd say we need a different approach. (And think of
these modern "endless" rotary potis you have nowadays, a 1-phase potmeter or
a potmeter without mark/button. Where is its 0%?)

I've not completely thought about it, but it seems that we would need some
additional information about the zero point of a rpotmeter, or mouse clicks
can't be handled else.

A mouse drag simply is a difference to the degree/radian from wsPLMouseButton
and the item's value should be adjusted according to this difference then.
For the mouse wheel it's just a simple value adjustment (currently unchecked
by the way), but a mouse click is tricky.

Since rpotmeters don't yet exist at the moment, we can set up the rules for
them without breaking existing skins. However, I want to remain as compatible
as possible with the other potmeters.

What do you think?

> +                   // CW angle, 0..1, 0 at center/bottom

You should be verbose (CW in this case; clockwise?).

> +                   a = FFMAX( a, RPOTMETER_STOP_GAP );
> +                   a = FFMIN( a, 1-RPOTMETER_STOP_GAP );
> +                   value = ((a - RPOTMETER_STOP_GAP) / (1-2*RPOTMETER_STOP_GAP)) * 100.0;

How did you determine RPOTMETER_STOP_GAP?

> +                   // Stop rotating when crossing 0 until crossing in opposite direction
> +                   if (last_rpotmeter_angle < 0.25 && a > 0.75) rpotmeter_stop = rpotmeter_stop == 1 ? 0 : -1;
> +                   if (last_rpotmeter_angle > 0.75 && a < 0.25) rpotmeter_stop = rpotmeter_stop == -1 ? 0 : 1;

Where do the numeric constants (0.25, 0.75) come from?

Ingo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: plastic.patch
Type: text/x-diff
Size: 495 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20140401/573ff180/attachment.bin>


More information about the MPlayer-dev-eng mailing list