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

version» Context lines:

Roxen.git/server/modules/graphics/gbutton.pike:18:   // icon_src -- icon reference   // icon_data -- inline icon data   // align -- left|center|right text alignment   // align_icon -- left|center_before|center_after|right icon 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.28 2000/02/11 10:46:05 jonasw Exp $"; + constant cvs_version = "$Id: gbutton.pike,v 1.29 2000/02/21 17:50:48 per Exp $";   constant thread_safe = 1;      #include <module.h>   inherit "module";   inherit "roxenlib";         roxen.ImageCache button_cache;      constant module_type = MODULE_PARSER;
Roxen.git/server/modules/graphics/gbutton.pike:135:       Image.Layer background;    Image.Layer frame;    Image.Layer mask;       int left, right, top, bottom; /* offsets */    int req_width;       mapping ll = ([]);    -  if( args->border_image ) +  void set_image( array layers )    { -  array layers = roxen.load_layers(args->border_image, id); -  if(layers) -  foreach( layers, object l ) +  foreach( layers||({}), object l )    { -  ll[l->get_misc_value( "name" )] = l; -  switch( lower_case((l->get_misc_value( "name" )/" ")[0]) ) +  if(!l->get_misc_value( "name" ) ) // Hm. +  continue; +  ll[lower_case(l->get_misc_value( "name" ))] = l; +  switch( lower_case(l->get_misc_value( "name" )) )    {    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 ) -  +  set_image( roxen.load_layers("roxen-images/gbutton.xcf", id) ); +  +  +  // 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 )    { -  array layers = roxen.load_layers("roxen-images/gbutton.xcf", id); -  foreach( layers, object l ) -  { -  ll[l->get_misc_value( "name" )] = l; -  switch( lower_case((l->get_misc_value( "name" )/" ")[0]) ) -  { -  case "background": background = l; break; -  case "frame": frame = l; break; -  case "mask": mask = l; break; +  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 }); +  x += ({ g->pos-x0 });    else -  y += ({ g->pos }); +  y += ({ g->pos-y0 });    -  sort( y ); sort( x ); +  sort( y ); +  sort( x ); +     if(sizeof( x ) < 2)    x = ({ 5, frame->xsize()-5 }); -  +     if(sizeof( y ) < 2)    y = ({ 2, frame->ysize()-2 });       left = x[0]; right = x[-1]; top = y[0]; bottom = y[-1];    right = frame->xsize()-right;       int text_height = bottom - top;       // Get icon    if (args->icn)
Roxen.git/server/modules/graphics/gbutton.pike:288:    }    break;    }       if( args->extra_frame_layers )    {    array l = ({ frame });    foreach( args->extra_frame_layers/",", string q )    l += ({ ll[q] });    l-=({ 0 }); -  if( sizeof( l ) ) -  mask = Image.lay( l ); +  if( sizeof( l ) > 1) +  frame = Image.lay( l );    }       if( args->extra_mask_layers )    {    array l = ({ }); -  if( mask ) -  l = ({ mask }); +     foreach( args->extra_mask_layers/",", string q )    l += ({ ll[q] });    l-=({ 0 });    if( sizeof( l ) ) -  +  { +  if( mask ) +  l = ({ mask })+l;    mask = Image.lay( l );    } -  +  }       if( args->extra_background_layers )    {    array l = ({ }); -  if( background ) -  l = ({ background }); +     foreach( args->extra_background_layers/",", string q )    l += ({ ll[q] });    l-=({ 0 });    if( sizeof( l ) ) -  +  { +  if( background ) +  l = ({ background })+l;    background = Image.lay( l );    } -  +  }          right = frame->xsize()-right;    frame = stretch_layer( frame, left, right, req_width );    if (mask != frame)    mask = stretch_layer( mask, left, right, req_width );       if( background )    {    if( !background->alpha() )
Roxen.git/server/modules/graphics/gbutton.pike:398:    }       // Draw text    if (args->dim)    for (int i = 0; i < 3; i++)    args->txt[i] = (args->txt[i] + args->bg[i]) / 2;       if(text_img)    button->paste_alpha_color(text_img, args->txt, txt_x, top);    +  // 'plain' extra layers are added on top of everything else    if( args->extra_layers )    {    array l = ({ });    foreach( args->extra_layers/",", string q )    l += ({ ll[q] });    l-=({ 0 });    if( sizeof( l ) )    {    object q = Image.lay( l );    q = stretch_layer( q, left, right, req_width );    button->paste_mask( q->image(), q->alpha() );    }    }    -  +  // left layers are added to the left of the image, and the mask is +  // extended using their mask. There is no corresponding 'mask' layers +  // for these, but that is not a problem most of the time. +  if( args->extra_left_layers ) +  { +  array l = ({ }); +  foreach( args->extra_left_layers/",", string q ) +  l += ({ ll[q] }); +  l-=({ 0 }); +  if( sizeof( l ) ) +  { +  object q = Image.lay( l ); +  object b2 = Image.Image( button->xsize()+q->xsize(), +  button->ysize(), @args->pagebg ); +  b2->paste( button, q->xsize() ); +  b2->paste_mask( q->image(), q->alpha() ); +  button = b2; +  mask = Image.lay( ({q, mask->set_offset( q->xsize(),0 )}) ); +  } +  }    -  return ([ +  // right layers are added to the right of the image, and the mask is +  // extended using their mask. There is no corresponding 'mask' layers +  // for these, but that is not a problem most of the time. +  if( args->extra_right_layers ) +  { +  array l = ({ }); +  foreach( args->extra_right_layers/",", string q ) +  l += ({ ll[q] }); +  l-=({ 0 }); +  if( sizeof( l ) ) +  { +  object q = Image.lay( l ); +  object b2 = Image.Image( button->xsize()+q->xsize(), +  button->ysize(), @args->pagebg ); +  b2->paste( button ); +  b2->paste_mask( q->image(), q->alpha(), button->xsize(), 0 ); +  button = b2; +  mask = Image.lay( ({q->set_offset( mask->xsize(),0), mask }) ); +  } +  } +  +  return +  ([    "img":button,    "alpha":mask->alpha()->threshold( 40 ),    ]);   }         mapping find_internal(string f, RequestID id)   {    return button_cache->http_file_answer(f, id);   }
Roxen.git/server/modules/graphics/gbutton.pike:455:    "al" : args->align || "left", // Text alignment    "dim" : args->dim || // Button dimming    (< "dim", "disabled" >)[lower_case(args->state || "")],    "icn" : args->icon_src && fix_relative(args->icon_src, id), // Icon URL    "icd" : args->icon_data, // Inline icon data    "ica" : args->align_icon || "left", // Icon alignment    "font": (args->font||id->misc->defines->font||    roxen->query("default_font")),    "border_image":fi,    "extra_layers":args["extra-layers"], +  "extra_left_layers":args["extra-left-layers"], +  "extra_right_layers":args["extra-right-layers"],    "extra_background_layers":args["extra-background-layers"],    "extra_mask_layers":args["extra-mask-layers"],    "extra_frame_layers":args["extra-frame-layers"],    ]);       new_args->quant = args->quant || 128;    foreach(glob("*-*", indices(args)), string n)    new_args[n] = args[n];       string img_src =