[MPlayer-dev-eng] [PATCH] GUI: Potmeter button corrections
Ingo Brückl
ib at wupperonline.de
Tue Mar 25 10:36:50 CET 2014
Hans-Dieter Kosch wrote on Mon, 24 Mar 2014 01:20:57 +0100:
> while coding the rpotmeter, I came across the following:
> 1)
> When rendering the [hv]potmeter, the button width/height is regarded, so
> that the button doesn't exceed the potmeter edges. However, the counterpart
> in the mouse handling doesn't do the exact inverse calculation. The button
> is drifting under the mouse pointer from its one edge to its other when
> moving it from one end of the potmeter to the other. Only in the middle of
> the pot, the button is centered under the mouse.
> The attached 'potmeter_button_adjust.patch' corrects the mouse calculations
> to keep the button always centered under the mouse (like one might expect).
> Index: gui/ui/main.c
> ===================================================================
> +++ gui/ui/main.c (working copy)
> @@ -148,10 +148,10 @@
> switch( itemtype )
> {
> case itHPotmeter:
> - value=100.0 * ( X - item->x ) / item->width;
> + value=100.0 * ( X - item->x - item->pwidth / 2.0 ) / ( item->width - item->pwidth );
> break;
> case itVPotmeter:
> - value=100.0 - 100.0 * ( Y - item->y ) / item->height;
> + value=100.0 - 100.0 * ( Y - item->y - item->pheight / 2.0 ) / ( item->height - item->pheight );
> break;
> }
> uiEvent( item->message,value );
This will go beyond the boundaries, resulting in an uiEvent() call with an
illegal value.
I'm not against a "centered" potmeter button, but I don't think that this is
the right place to achieve this.
The job of the mouse handler is to return the exact mouse position, not to
"prettify" it. It's the job of the renderer to interpret the item properties
and to produce a pleasant result.
Seems I really have to commence revising render.c now...
Ingo
More information about the MPlayer-dev-eng
mailing list