[MPlayer-dev-eng] [PATCH] OSD menu support mouse select.

Ulion ulion2002 at gmail.com
Tue Dec 18 12:45:34 CET 2007


2007/12/18, Reimar Döffinger <Reimar.Doeffinger at stud.uni-karlsruhe.de>:
> Hello,
> On Tue, Dec 18, 2007 at 06:03:00PM +0800, Ulion wrote:
> > +  if (menu_mouse_pos_updated) {
> > +    int bg_x = x < 0 ? (mpi->w-bg_w)/2 : x-mpriv->minb;
> > +    int by = dy;
> > +    mouse_x = menu_mouse_x * w;
> > +    mouse_y = menu_mouse_y * h;
> > +    if (mouse_x >= bg_x && mouse_x < bg_x + bg_w) {
> > +      list_entry_t* e = m;
> > +      for( ; e != NULL && by + vo_font->height < dh ; e = e->next ) {
> > +        if(e->hide) continue;
> > +        if (mouse_y < by+y-mpriv->vspace/2)
> > +          break;
> > +        if (mouse_y < by+y+mpriv->vspace/2+vo_font->height) {
>
> A lot of these calculations are duplicated from the selection_x etc.
> stuff below, can't you move it there or alternatively make a
> get_selection_bounds function or so?

Can't move to there, because before that loop, must decide whether we
need to change mpriv->current that's the current selected menu item
should be highlight displayed (with a bg box).
These won't possible be done in that loop because that loop depends on
which menu item is 'current' that could be changed by our this loop.

A function is not likely possible because many input parameter only
available in current this list_draw function, and already quite much
preparation for calculate  current box position and size already be
done before this loop, current loop and the final loop are just using
those calculated result and the last loop depends on current loop's
result.

But I can clean the code to make looks cleaner than current code.

>
> >      if(m == mpriv->current) {
> > +      selection_x = x < 0 ? (mpi->w - bg_w) / 2 : x - mpriv->minb;
>
> Not related to this patch, but this seems a bit weird to me, why
> is the condition x < 0 and not x < mpriv->minb?
> Is selection_x < 0 valid and treated correctly?

Here x<0 mean user did not specify a user preferred offset position
for current menu, that means the menu should be displayed align center
in x direction and align top in y direction.
and if x >=0, x must be greater or equals than the mpriv->minb,
because there's already a x+=mpriv->minb before these code when x>0
(should be x>=0, I will fix it soon).

-- 
Ulion



More information about the MPlayer-dev-eng mailing list