aboutsummaryrefslogtreecommitdiff
path: root/generic/Rectangle.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/Rectangle.c')
-rw-r--r--generic/Rectangle.c44
1 files changed, 17 insertions, 27 deletions
diff --git a/generic/Rectangle.c b/generic/Rectangle.c
index 2779e80..a9989a2 100644
--- a/generic/Rectangle.c
+++ b/generic/Rectangle.c
@@ -68,8 +68,7 @@ typedef struct _RectangleItemStruct {
ZnColor line_color;
Pixmap fill_pattern;
Pixmap line_pattern;
- ZnColorGradient fill_color;
- ZnGradientGeom grad_geom;
+ ZnGradient *fill_color;
int line_alpha;
int fill_alpha;
char *tile_name;
@@ -77,7 +76,7 @@ typedef struct _RectangleItemStruct {
/* Private data */
ZnPoint dev[4];
ZnImage tile;
- ZnColorGradient gradient;
+ ZnGradient *gradient;
#ifdef LIBART
ArtSVP *outline_svp;
ArtSVP *fill_svp;
@@ -94,15 +93,13 @@ static ZnAttrConfig rect_attrs[] = {
ZN_COORDS_FLAG, False },
{ ZN_CONFIG_UINT, "-fillalpha", NULL,
Tk_Offset(RectangleItemStruct, fill_alpha), 0, ZN_DRAW_FLAG, False },
- { ZN_CONFIG_GRADIENT_COLOR, "-fillcolor", NULL,
+ { ZN_CONFIG_GRADIENT, "-fillcolor", NULL,
Tk_Offset(RectangleItemStruct, fill_color), 0,
ZN_DRAW_FLAG|ZN_BORDER_FLAG, False },
{ ZN_CONFIG_BOOL, "-filled", NULL,
Tk_Offset(RectangleItemStruct, flags), FILLED_BIT, ZN_COORDS_FLAG, False },
{ ZN_CONFIG_PATTERN, "-fillpattern", NULL,
Tk_Offset(RectangleItemStruct, fill_pattern), 0, ZN_DRAW_FLAG, False },
- { ZN_CONFIG_GRADIENT_GEOM, "-gradient", NULL,
- Tk_Offset(RectangleItemStruct, grad_geom), 0, ZN_DRAW_FLAG, False },
{ ZN_CONFIG_UINT, "-linealpha", NULL,
Tk_Offset(RectangleItemStruct, line_alpha), 0, ZN_DRAW_FLAG, False },
{ ZN_CONFIG_COLOR, "-linecolor", NULL,
@@ -210,10 +207,9 @@ Init(Item item,
rect->fill_pattern = ZnUnspecifiedPattern;
rect->line_color = ZnGetColorByValue(wi->win, wi->fore_color);
rect->line_alpha = 255;
- rect->fill_color = ZnGetColorGradient(wi->interp, wi->win,
- ZnNameOfColor(wi->fore_color));
+ rect->fill_color = ZnGetGradient(wi->interp, wi->win,
+ ZnNameOfColor(wi->fore_color));
rect->fill_alpha = 255;
- rect->grad_geom = NULL;
#ifdef LIBART
rect->outline_svp = rect->fill_svp = NULL;
#endif
@@ -237,7 +233,7 @@ Clone(Item item)
char *text;
if (rect->gradient) {
- rect->gradient = ZnGetColorGradientByValue(rect->gradient);
+ rect->gradient = ZnGetGradientByValue(rect->gradient);
}
if (strlen(rect->tile_name) != 0) {
text = ZnMalloc((strlen(rect->tile_name) + 1) * sizeof(char));
@@ -255,10 +251,7 @@ Clone(Item item)
Tk_NameOfBitmap(wi->dpy, rect->fill_pattern));
}
rect->line_color = ZnGetColorByValue(wi->win, rect->line_color);
- rect->fill_color = ZnGetColorGradientByValue(rect->fill_color);
- if (rect->grad_geom) {
- rect->grad_geom = GradientGeomDuplicate(rect->grad_geom);
- }
+ rect->fill_color = ZnGetGradientByValue(rect->fill_color);
#ifdef LIBART
rect->outline_svp = rect->fill_svp = NULL;
#endif
@@ -286,7 +279,7 @@ Destroy(Item item)
ZnFree(rect->tile_name);
}
if (rect->gradient) {
- ZnFreeColorGradient(rect->gradient);
+ ZnFreeGradient(rect->gradient);
}
if (rect->line_pattern != ZnUnspecifiedPattern) {
Tk_FreeBitmap(wi->dpy, rect->line_pattern);
@@ -294,11 +287,8 @@ Destroy(Item item)
if (rect->fill_pattern != ZnUnspecifiedPattern) {
Tk_FreeBitmap(wi->dpy, rect->fill_pattern);
}
- ZnFreeColorGradient(rect->fill_color);
+ ZnFreeGradient(rect->fill_color);
ZnFreeColor(rect->line_color);
- if (rect->grad_geom) {
- GradientGeomDelete(rect->grad_geom);
- }
#ifdef LIBART
if (rect->outline_svp) {
art_svp_free(rect->outline_svp);
@@ -331,12 +321,12 @@ Configure(Item item,
if (rect->gradient &&
(ISSET(*flags, ZN_BORDER_FLAG) || (rect->relief == RELIEF_FLAT))) {
- ZnFreeColorGradient(rect->gradient);
+ ZnFreeGradient(rect->gradient);
rect->gradient = NULL;
}
if ((rect->relief != RELIEF_FLAT) && !rect->gradient) {
rect->gradient = ZnGetReliefGradient(wi->interp, wi->win,
- ZnNameOfColor(ZnColorGradientMidColor(wi->win, rect->fill_color)));
+ ZnNameOfColor(ZnGetGradientColor(wi->win, rect->fill_color, 50.0)));
}
if (ISSET(*flags, ZN_TILE_FLAG)) {
Tk_Image tile;
@@ -575,19 +565,19 @@ Draw(Item item)
* Fill if requested.
*/
if (ISSET(rect->flags, FILLED_BIT)) {
- if (rect->grad_geom) {
+ if (!ZnGradientFlat(rect->fill_color)) {
if (ISSET(rect->flags, ALIGNED_BIT)) {
- DrawRectangleGradient(wi, rect->grad_geom, rect->fill_color, &r);
+ DrawRectangleGradient(wi, rect->fill_color, &r);
}
else {
ZnPoly poly;
POLY_CONTOUR1(&poly, rect->dev, 4);
- DrawPolygonGradient(wi, rect->grad_geom, rect->fill_color, &poly,
+ DrawPolygonGradient(wi, rect->fill_color, &poly,
&item->item_bounding_box);
}
}
else {
- values.foreground = ZnPixel(ZnColorGradientMidColor(wi->win, rect->fill_color));
+ values.foreground = ZnPixel(ZnGetGradientColor(wi->win, rect->fill_color, 50.0));
if (rect->tile != ZnUnspecifiedImage) { /* Fill tiled */
Pixmap pmap = GetImagePixmap(wi->win, rect->tile_name, rect->tile, NULL);
values.fill_style = FillTiled;
@@ -694,7 +684,7 @@ Render(Item item)
{
WidgetInfo *wi = item->wi;
RectangleItem rect = (RectangleItem) item;
- XColor *color = ZnColorGradientMidColor(wi->win, rect->fill_color);
+ XColor *color = ZnGetGradientColor(wi->win, rect->fill_color, 50.0);
#ifdef LIBART
ArtPixBuf *pixbuf = NULL;
@@ -719,7 +709,7 @@ Render(Item item)
if (ISSET(rect->flags, FILLED_BIT)) {
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
- if (rect->grad_geom) {
+ if (!ZnGradientFlat(rect->fill_color)) {
}
else {
if (rect->tile != ZnUnspecifiedImage) { /* Fill tiled */