[MPlayer-dev-eng] [PATCH] GUI: Potmeter button corrections

Hans-Dieter Kosch hdkosch at kabelbw.de
Wed Mar 26 01:05:27 CET 2014


Ingo Brückl wrote:

> Hans-Dieter Kosch wrote on Mon, 24 Mar 2014 01:20:57 +0100:
> 
>> 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.

You're right. I missed that. There's no value range check like in 'case 
wsMoveMouse:' (nevertheless, I noticed exactly the expected behaviour, though (?) ).

> 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.

Agreed. The issue is currently that we have an indirect feedback from the mouse 
position to the position of the related displayed object. The mouse position 
yields an item value, and then in turn, the item value yields an object 
position. If the forward and reverse calculations differ, arbitrarily wierd 
displays can result.

> Seems I really have to commence revising render.c now...

I'm looking forward...

PS: The rpotmeter is working now at least for the GTK GUI (I have still nothing 
to test Win32). But before posting, I like to review and see if changes result 
from the current discussions.

Hans-Dieter


More information about the MPlayer-dev-eng mailing list