Roxen.git / server / modules / graphics / gbutton.pike

version» Context lines:

Roxen.git/server/modules/graphics/gbutton.pike:18:   // icon-data -- inline icon data   // align -- left|center|right text alignment   // align-icon -- left|center-before|center-after|right icon alignment   // valign-icon -- above|middle|below icon vertical alignment   // >Button text</gbutton>   //   // Alignment restriction: when text alignment is either left or right, icons   // 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>   inherit "module";      roxen.ImageCache button_cache;      constant module_type = MODULE_TAG;   constant module_name = "GButton";   constant module_doc =
Roxen.git/server/modules/graphics/gbutton.pike:270:   array(Image.Layer) draw_button(mapping args, string text, object id)   {    Image.Image text_img;    mapping icon;       Image.Layer background;    Image.Layer frame;    Image.Layer mask;       int left, right, top, middle, bottom; /* offsets */ -  int req_width; +  int req_width, noframe;       mapping ll = ([]);       void set_image( array layers )    {    foreach( layers||({}), object l )    {    if(!l->get_misc_value( "name" ) ) // Hm. Probably PSD    continue;   
Roxen.git/server/modules/graphics/gbutton.pike:294:    case "background": background = l; break;    case "frame": frame = l; break;    case "mask": mask = l; break;    }    }    };       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)    error ("Failed to load default frame image "    "(roxen-images/gbutton.xcf): " + strerror (errno()));    mixed err = catch {    set_image(Image.XCF.decode_layers(data));    };    if( !frame )    if (err) {    catch (err[0] = "Failed to decode default frame image "    "(roxen-images/gbutton.xcf): " + err[0]);    throw (err);    }    else    error("Failed to decode default frame image "    "(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 )    foreach( values( ll ), object l )    {    int x = l->xoffset();    int y = l->yoffset();    l->set_offset( x-x0, y-y0 );    }       if( !mask )    mask = frame;       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 );       if(sizeof( x ) < 2)    x = ({ 5, frame->xsize()-5 });       if(sizeof( y ) < 2)    y = ({ 2, frame->ysize()-2 });   
Roxen.git/server/modules/graphics/gbutton.pike:526:    break;    }       if( args->extra_frame_layers )    {    array l = ({ });    foreach( args->extra_frame_layers/",", string q )    l += ({ ll[q] });    l-=({ 0 });    if( sizeof( l ) ) -  frame = Image.lay( l+({frame}) ); +  frame = Image.lay( l+(noframe?({}):({frame})) );    }       if( args->extra_mask_layers )    {    array l = ({ });    foreach( args->extra_mask_layers/",", string q )    l += ({ ll[q] });    l-=({ 0 });    if( sizeof( l ) )    {
Roxen.git/server/modules/graphics/gbutton.pike:559:    int y0 = -mask->yoffset();    int x1 = frame->xsize()-1+x0;    int y1 = frame->ysize()-1+y0;       i = i->copy(x0,y0, x1,y1);    if( m )    m = m->copy(x0,y0, x1,y1);    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),    mask->alpha()->copy(0,0,req_width-1,frame->ysize()-1)),    });          if( args->extra_background_layers || background)    {    array l = ({ background });
Roxen.git/server/modules/graphics/gbutton.pike:580:    l += ({ ll[q] });    l-=({ 0 });    foreach( l, object ll )    {    if( args->dim )    ll->set_alpha_value( 0.3 );    button_layers += ({ stretch_layer( ll, left, right, req_width ) });    }    }    -  +  if( !noframe ) +  {    button_layers += ({ frame });    frame->set_mode( "value" ); -  +  }       if( args->dim )    {    // Adjust dimmed border intensity to the background    int bg_value = Image.Color(@args->bg)->hsv()[2];    int dim_high, dim_low;    if (bg_value < 128) {    dim_low = max(bg_value - 64, 0);    dim_high = dim_low + 128;    } else {
Roxen.git/server/modules/graphics/gbutton.pike:616:    Image.Layer( ([    "alpha_value":(args->dim ? 0.3 : 1.0),    "image":icon->img,    "alpha":icon->alpha,    "xoffset":icn_x,    "yoffset":icn_y    ]) )});       // 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 )    {    array q = map(args->extra_layers/",",    lambda(string q) { return ll[q]; } )-({0});    foreach( q, object ll )    {    if( args->dim )    ll->set_alpha_value( 0.3 );
Roxen.git/server/modules/graphics/gbutton.pike:740:    args->bgcolor ||    "#eeeeee"), // _page_ bg color    "bg" : parse_color(args->bgcolor ||    id->misc->defines->theme_bgcolor ||    id->misc->defines->bgcolor ||    "#eeeeee"), // Background color    "txt" : parse_color(args->textcolor ||    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    "al" : args->align || "left", // Text alignment    "dim" : (args->dim || // Button dimming    (< "dim", "disabled" >)[lower_case(args->state || "")]),    "icn" : args->icon_src &&    Roxen.fix_relative(args->icon_src, id), // Icon URL    "icd" : args->icon_data, // Inline icon data    "ica" : lower_case(args->align_icon || "left"), // Icon alignment