aboutsummaryrefslogtreecommitdiff
path: root/generic
diff options
context:
space:
mode:
Diffstat (limited to 'generic')
-rw-r--r--generic/Arc.c90
1 files changed, 84 insertions, 6 deletions
diff --git a/generic/Arc.c b/generic/Arc.c
index 69966cd..10bcb9c 100644
--- a/generic/Arc.c
+++ b/generic/Arc.c
@@ -80,6 +80,8 @@ typedef struct _ArcItemStruct {
LineStyle line_style;
ZnLineEnd first_end;
ZnLineEnd last_end;
+ int line_alpha;
+ int fill_alpha;
char *tile_name;
unsigned char flags;
@@ -90,6 +92,8 @@ typedef struct _ArcItemStruct {
ZnPoint center2;
ZnImage tile;
ZnList render_shape;
+ ArtSVP *outline_svp;
+ ArtSVP *fill_svp;
} ArcItemStruct, *ArcItem;
@@ -104,6 +108,8 @@ static ZnAttrConfig arc_attrs[] = {
ZN_COORDS_FLAG, False },
{ ZN_CONFIG_ANGLE, "-extent", NULL,
Tk_Offset(ArcItemStruct, angle_extent), 0, ZN_COORDS_FLAG, False },
+ { ZN_CONFIG_UINT, "-fillalpha", NULL,
+ Tk_Offset(ArcItemStruct, fill_alpha), 0, ZN_DRAW_FLAG, False },
{ ZN_CONFIG_GRADIENT_COLOR, "-fillcolor", NULL,
Tk_Offset(ArcItemStruct, fill_color), 0, ZN_DRAW_FLAG, False },
{ ZN_CONFIG_BOOL, "-filled", NULL,
@@ -116,6 +122,8 @@ static ZnAttrConfig arc_attrs[] = {
Tk_Offset(ArcItemStruct, grad_geom), 0, ZN_COORDS_FLAG, False },
{ ZN_CONFIG_LINE_END, "-lastend", NULL,
Tk_Offset(ArcItemStruct, last_end), 0, ZN_COORDS_FLAG, False },
+ { ZN_CONFIG_UINT, "-linealpha", NULL,
+ Tk_Offset(ArcItemStruct, line_alpha), 0, ZN_DRAW_FLAG, False },
{ ZN_CONFIG_COLOR, "-linecolor", NULL,
Tk_Offset(ArcItemStruct, line_color), 0,
ZN_DRAW_FLAG|ZN_BORDER_FLAG, False },
@@ -226,10 +234,13 @@ Init(Item item,
(*args)++;
(*argc)--;
+ arc->fill_alpha = 255;
arc->fill_color = ZnGetColorGradient(wi->interp, wi->win,
ZnNameOfColor(wi->fore_color));
+ arc->line_alpha = 255;
arc->line_color = ZnGetColorByValue(wi->win, wi->fore_color);
arc->grad_geom = NULL;
+ arc->outline_svp = arc->fill_svp = NULL;
return ZN_OK;
}
@@ -275,6 +286,7 @@ Clone(Item item)
if (arc->grad_geom) {
arc->grad_geom = GradientGeomDuplicate(arc->grad_geom);
}
+ arc->outline_svp = arc->fill_svp = NULL;
arc->render_shape = NULL;
}
@@ -295,6 +307,12 @@ Destroy(Item item)
if (arc->render_shape) {
ZnListFree(arc->render_shape);
}
+ if (arc->outline_svp) {
+ art_svp_free(arc->outline_svp);
+ }
+ if (arc->fill_svp) {
+ art_svp_free(arc->fill_svp);
+ }
if (arc->first_end) {
LineEndDelete(arc->first_end);
}
@@ -508,7 +526,7 @@ ComputeCoordinates(Item item,
width_2 = (arc->coords[1].x - arc->coords[0].x)/2.0;
height_2 = (arc->coords[1].y - arc->coords[0].y)/2.0;
if (((angle >= PRECISION_LIMIT) && ((width_2 - height_2) > PRECISION_LIMIT)) ||
- arc->grad_geom) {
+ arc->grad_geom || wi->local_render) {
SET(arc->flags, USING_POLY_BIT);
if (!arc->render_shape) {
arc->render_shape = ZnListNew(4, sizeof(ZnPoint));
@@ -517,10 +535,13 @@ ComputeCoordinates(Item item,
DegreesToRadian(arc->start_angle+arc->angle_extent),
(ISCLEAR(arc->flags, CLOSED_BIT) ? 0 :
ISCLEAR(arc->flags, PIE_SLICE_BIT) ? 1 : 2), arc->render_shape);
- p_list = (ZnPoint *) ZnListArray(arc->render_shape);
- num_p = ZnListSize(arc->render_shape);
+
ox = (arc->coords[1].x + arc->coords[0].x)/2.0;
oy = (arc->coords[1].y + arc->coords[0].y)/2.0;
+
+ p_list = (ZnPoint *) ZnListArray(arc->render_shape);
+ num_p = ZnListSize(arc->render_shape);
+
for (i = 0; i < num_p; i++, p_list++) {
p.x = ox + p_list->x*width_2;
p.y = oy + p_list->y*height_2;
@@ -533,7 +554,7 @@ ComputeCoordinates(Item item,
item->item_bounding_box.orig.y -= tmp;
item->item_bounding_box.corner.x += tmp;
item->item_bounding_box.corner.y += tmp;
-
+
/*
* Add the arrows if any.
*/
@@ -547,6 +568,46 @@ ComputeCoordinates(Item item,
arc->last_end, end_points);
AddPointsToBBox(&item->item_bounding_box, end_points, LINE_END_POINTS);
}
+
+ if (wi->local_render) {
+ ArtVpath *vpath;
+
+ GetBezierPath(arc->render_shape, wi->work_pts);
+ p_list = (ZnPoint *) ZnListArray(wi->work_pts);
+ num_p = ZnListSize(wi->work_pts);
+ p_list = &p_list[num_p-1];
+ vpath = (ArtVpath *) ZnMalloc((num_p+2) * sizeof(ArtVpath));
+ for (i = 0; i < num_p; i++, p_list--) {
+ vpath[i].code = ART_LINETO;
+ vpath[i].x = p_list->x;
+ vpath[i].y = p_list->y;
+ }
+ vpath[0].code = ART_MOVETO;
+ vpath[i].code = ART_LINETO;
+ vpath[i].x = vpath[0].x;
+ vpath[i].y = vpath[0].y;
+ i++;
+ vpath[i].code = ART_END;
+
+ if (arc->fill_svp) {
+ art_svp_free(arc->fill_svp);
+ arc->fill_svp = NULL;
+ }
+ if (ISSET(arc->flags, FILLED_BIT)) {
+ arc->fill_svp = art_svp_from_vpath(vpath);
+ }
+ if (arc->outline_svp) {
+ art_svp_free(arc->outline_svp);
+ arc->outline_svp = NULL;
+ }
+ if (arc->line_width) {
+ arc->outline_svp = art_svp_vpath_stroke(vpath,
+ ART_PATH_STROKE_JOIN_ROUND,
+ ART_PATH_STROKE_CAP_ROUND,
+ arc->line_width, 2, 1);
+ }
+ ZnFree(vpath);
+ }
return;
}
@@ -1158,9 +1219,26 @@ Draw(Item item)
static void
Render(Item item)
{
- /*WidgetInfo *wi = item->wi;
- ArcItem arc = (ArcItem) item;*/
+ WidgetInfo *wi = item->wi;
+ ArcItem arc = (ArcItem) item;
+ XColor *color = ZnColorGradientMidColor(wi->win, arc->fill_color);
+ ArtPixBuf *pixbuf = NULL;
+
+ if (arc->fill_svp != NULL) {
+ if (strlen(arc->tile_name) != 0) {
+ pixbuf = GetImagePixbuf(wi->win, arc->tile_name, arc->tile);
+ }
+ ITEM_P.RenderSVP(wi, arc->fill_svp, color->red, color->green,
+ color->blue, arc->fill_alpha & 0xff,
+ item->item_bounding_box.orig.x,
+ item->item_bounding_box.orig.y, pixbuf);
+ }
+ if (arc->outline_svp != NULL) {
+ ITEM_P.RenderSVP(wi, arc->outline_svp, arc->line_color->red,
+ arc->line_color->green, arc->line_color->blue,
+ arc->line_alpha & 0xff, 0, 0, NULL);
+ }
}