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.43 2000/04/04 20:21:55 marcus Exp $";
+ constant cvs_version = "$Id: gbutton.pike,v 1.44 2000/04/04 20:45:09 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:75: Inside #if defined(manual)
"<tr><td><b>align_icon</b></td><td>Icon alignment: "
"<tt>left|center_before|center_after|right</tt></td></tr>"
"</table><p>"
"There are some alignment restrictions: when text alignment is "
"either <tt>left</tt> or <tt>right</tt>, icons must also be "
"aligned <tt>left</tt> or <tt>right</tt>."
*/
#endif
+ function TIMER( function f )
+ {
+ #if 0
+ return lambda(mixed ... args) {
+ int h = gethrtime();
+ mixed res;
+ werror("Drawing ... ");
+ res = f( @args );
+ werror(" %.1fms\n", (gethrtime()-h)/1000000.0 );
+ return res;
+ };
+ #endif
+ return f;
+ }
void start()
{
- button_cache = roxen.ImageCache("gbutton", draw_button);
+ button_cache = roxen.ImageCache("gbutton", TIMER(draw_button));
}
Image.Layer layer_slice( Image.Layer l, int from, int to )
{
return Image.Layer( ([
"image":l->image()->copy( from,0, to-1, l->ysize()-1 ),
"alpha":l->alpha()->copy( from,0, to-1, l->ysize()-1 ),
]) );
}
Roxen.git/server/modules/graphics/gbutton.pike:281:
case "right":
icn_x = req_width - right - i_width;
txt_x = icn_x - i_spc - t_width;
break;
}
break;
}
if( args->extra_frame_layers )
{
- array l = ({ frame });
+ array l = ({ });
foreach( args->extra_frame_layers/",", string q )
l += ({ ll[q] });
l-=({ 0 });
- if( sizeof( l ) > 1)
- frame = Image.lay( l );
+ if( sizeof( l ) )
+ frame = Image.lay( l+({frame}) );
}
if( args->extra_mask_layers )
{
array l = ({ });
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 = ({ });
- 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 );
array(Image.Layer) button_layers = ({
Image.Layer( Image.Image(req_width, frame->ysize(), args->bg),
- mask->alpha()),
+ mask->alpha()->scale(req_width,frame->ysize())),
});
- if( background )
+
+ if( args->extra_background_layers || background)
{
- if( !background->alpha() )
- background->set_image( background->image(),
- Image.Image( background->xsize(),
- background->ysize(),
- ({255,255,255}) ) );
+ array l = ({ background });
+ foreach( (args->extra_background_layers||"")/","-({""}), string q )
+ l += ({ ll[q] });
+ l-=({ 0 });
+ foreach( l, object ll )
+ {
if( args->dim )
- background->set_alpha_value( 0.3 );
- background = stretch_layer( background, left, right, req_width );
- button_layers += ({ background });
+ ll->set_alpha_value( 0.3 );
+ button_layers += ({ stretch_layer( ll, left, right, req_width ) });
}
- button_layers += ({ frame });
+ }
-
+
+ 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;
Roxen.git/server/modules/graphics/gbutton.pike:391:
"xoffset":txt_x,
"yoffset":top,
]))
});
// '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});
- if( sizeof( q ) > 1)
- button_layers += ({stretch_layer(Image.lay(q),left,right,req_width)});
- else if( sizeof( q ) )
- button_layers += ({ stretch_layer( q[0], left, right, req_width ) });
+ foreach( q, object ll )
+ {
+ if( args->dim )
+ ll->set_alpha_value( 0.3 );
+ button_layers += ({stretch_layer(ll,left,right,req_width)});
}
-
+ }
-
+
button_layers -= ({ 0 });
// 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 });
Roxen.git/server/modules/graphics/gbutton.pike:444:
q->set_offset( button_layers[0]->xsize()+
button_layers[0]->xoffset(),0);
button_layers += ({ q });
}
}
button_layers = ({Image.lay( button_layers )});
// fix transparency (somewhat)
if( !equal( args->pagebg, args->bg ) )
- button_layers +=
+ return button_layers +
({
Image.Layer(([
"fill":args->pagebg,
"alpha":button_layers[0]->alpha()->invert(),
]))
});
-
+
return button_layers;
}
mapping find_internal(string f, RequestID id)
{
return button_cache->http_file_answer(f, id);
}