Branch: Tag:

2000-12-21

2000-12-21 05:32:35 by Per Hedbor <ph@opera.com>

Support gbutton images without the 'frame' layer. Also added two new arguments: textalpha=float and textmode=valid-layer-mode. The first sets the main alpha component of the text (to get semi-transparent text), and the latter sets the layer mode (to get almost any kind of effect), we do need a list of valid layer modes as documentation, though

Rev: server/modules/graphics/gbutton.pike:1.73

25:   // must also be aligned left or right.       - constant cvs_version = "$Id: gbutton.pike,v 1.72 2000/12/16 02:16:12 per Exp $"; + constant cvs_version = "$Id: gbutton.pike,v 1.73 2000/12/21 05:32:35 per Exp $";   constant thread_safe = 1;      #include <module.h>
277:    Image.Layer mask;       int left, right, top, middle, bottom; /* offsets */ -  int req_width; +  int req_width, noframe;       mapping ll = ([]);   
301:    if( args->border_image )    set_image( roxen.load_layers(args->border_image, id) );    +     // otherwise load default images -  if ( !frame ) +  if ( !frame && !background && !mask )    {    string data = Stdio.read_file("roxen-images/gbutton.xcf");    if (!data)
322:    "(roxen-images/gbutton.xcf).\n");    }    +  if( !frame ) +  { +  noframe = 1; +  frame = background || mask; // for sizes offsets et.al. +  }       // Translate frame image to 0,0 (left layers are most likely to the    // left of the frame image) -  -  +     int x0 = frame->xoffset();    int y0 = frame->yoffset();    if( x0 || y0 )
342:       array x = ({});    array y = ({}); +     foreach( frame->get_misc_value( "image_guides" ), object g ) -  if( g->pos < 4096 ) +     if( g->vertical ) -  x += ({ g->pos-x0 }); +  x += ({ g->pos - x0 });    else -  y += ({ g->pos-y0 }); +  y += ({ g->pos - y0 });       sort( y );    sort( x );
533:    l += ({ ll[q] });    l-=({ 0 });    if( sizeof( l ) ) -  frame = Image.lay( l+({frame}) ); +  frame = Image.lay( l+(noframe?({}):({frame})) );    }       if( args->extra_mask_layers )
566:    mask->set_image( i, m );    mask = stretch_layer( mask, left, right, req_width );    } +  if( frame != background )    frame = stretch_layer( frame, left, right, req_width );    array(Image.Layer) button_layers = ({    Image.Layer( Image.Image(req_width, frame->ysize(), args->bg),
587:    }    }    -  +  if( !noframe ) +  {    button_layers += ({ frame });    frame->set_mode( "value" ); -  +  }       if( args->dim )    {
623:       // Draw text    if(text_img) -  button_layers += ({ +  { +  float ta = args->txtalpha?args->txtalpha:1.0; +  button_layers += +  ({    Image.Layer(([ -  "alpha_value":(args->dim ? 0.5 : 1.0), +  "mode":args->txtmode,    "image":text_img->color(0,0,0)->invert()->color(@args->txt), -  "alpha":text_img, +  "alpha":(text_img*(args->dim?0.5*ta:ta)),    "xoffset":txt_x,    "yoffset":txt_y,    ]))    }); -  +  }       // 'plain' extra layers are added on top of everything else    if( args->extra_layers )
747:    id->misc->defines->theme_bgcolor ||    id->misc->defines->fgcolor ||    "#000000"), // Text color +  "txtalpha": (args->textalpha?(float)args->textalpha:1.0), +  "txtmode": (args->textmode||"normal"),    "cnd" : (args->condensed || // Condensed text    (lower_case(args->textstyle || "") == "condensed")),    "wi" : (int) args->width, // Min button width