mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 04:20:27 +01:00
wrlib: add explicit type definition in API to allow compiler Type Checks (3/3)
When defining enums as types instead of simple enums allows to use these types at the places where the corresponding enum values are expected, then allowing the compiler to check that, potentially reporting incorrect use of values to the user. This patch adds the type for the gradient style for RRender*Gradient. Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
committed by
Carlos R. Mafra
parent
bc4084e679
commit
a772f2797d
@@ -556,7 +556,7 @@ static Pixmap renderTexture(WMScreen * scr, WMPropList * texture, int width, int
|
||||
|
||||
image = RRenderInterwovenGradient(width, height, c1, t1, c2, t2);
|
||||
} else if (strcasecmp(&type[1], "gradient") == 0) {
|
||||
int style;
|
||||
RGradientStyle style;
|
||||
RColor rcolor2;
|
||||
|
||||
switch (toupper(type[0])) {
|
||||
@@ -580,7 +580,7 @@ static Pixmap renderTexture(WMScreen * scr, WMPropList * texture, int width, int
|
||||
|
||||
image = RRenderGradient(width, height, &rcolor, &rcolor2, style);
|
||||
} else if (strcasecmp(&type[2], "gradient") == 0 && toupper(type[0]) == 'T') {
|
||||
int style;
|
||||
RGradientStyle style;
|
||||
RColor rcolor2;
|
||||
int i;
|
||||
RImage *grad = NULL;
|
||||
@@ -615,7 +615,7 @@ static Pixmap renderTexture(WMScreen * scr, WMPropList * texture, int width, int
|
||||
RReleaseImage(grad);
|
||||
|
||||
} else if (strcasecmp(&type[2], "gradient") == 0 && toupper(type[0]) == 'M') {
|
||||
int style;
|
||||
RGradientStyle style;
|
||||
RColor **colors;
|
||||
int i, j;
|
||||
|
||||
|
||||
@@ -326,7 +326,7 @@ static BackgroundTexture *parseTexture(RContext * rc, char *text)
|
||||
RColor color1, color2;
|
||||
RImage *image;
|
||||
Pixmap pixmap;
|
||||
int gtype;
|
||||
RGradientStyle gtype;
|
||||
int iwidth, iheight;
|
||||
|
||||
GETSTRORGOTO(val, tmp, 1, error);
|
||||
@@ -396,7 +396,7 @@ static BackgroundTexture *parseTexture(RContext * rc, char *text)
|
||||
RImage *image;
|
||||
Pixmap pixmap;
|
||||
int i, j;
|
||||
int gtype;
|
||||
RGradientStyle gtype;
|
||||
int iwidth, iheight;
|
||||
|
||||
colors = malloc(sizeof(RColor *) * (count - 1));
|
||||
@@ -587,7 +587,7 @@ static BackgroundTexture *parseTexture(RContext * rc, char *text)
|
||||
Pixmap pixmap;
|
||||
int opaq;
|
||||
char *file;
|
||||
int gtype;
|
||||
RGradientStyle gtype;
|
||||
int twidth, theight;
|
||||
|
||||
GETSTRORGOTO(val, file, 1, error);
|
||||
|
||||
@@ -39,7 +39,7 @@ static RImage *renderMHGradient(unsigned width, unsigned height, RColor ** color
|
||||
static RImage *renderMVGradient(unsigned width, unsigned height, RColor ** colors, int count);
|
||||
static RImage *renderMDGradient(unsigned width, unsigned height, RColor ** colors, int count);
|
||||
|
||||
RImage *RRenderMultiGradient(unsigned width, unsigned height, RColor ** colors, int style)
|
||||
RImage *RRenderMultiGradient(unsigned width, unsigned height, RColor **colors, RGradientStyle style)
|
||||
{
|
||||
int count;
|
||||
|
||||
@@ -65,7 +65,7 @@ RImage *RRenderMultiGradient(unsigned width, unsigned height, RColor ** colors,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
RImage *RRenderGradient(unsigned width, unsigned height, const RColor * from, const RColor * to, int style)
|
||||
RImage *RRenderGradient(unsigned width, unsigned height, const RColor *from, const RColor *to, RGradientStyle style)
|
||||
{
|
||||
switch (style) {
|
||||
case RHorizontalGradient:
|
||||
|
||||
@@ -254,11 +254,11 @@ enum {
|
||||
/* 2 pixel width */
|
||||
#define RBEV_RAISED3 3
|
||||
|
||||
enum {
|
||||
typedef enum {
|
||||
RHorizontalGradient = 2,
|
||||
RVerticalGradient = 3,
|
||||
RDiagonalGradient = 4
|
||||
};
|
||||
} RGradientStyle;
|
||||
/* for backwards compatibility */
|
||||
#define RGRD_HORIZONTAL RHorizontalGradient
|
||||
#define RGRD_VERTICAL RVerticalGradient
|
||||
@@ -426,11 +426,11 @@ void RFillImage(RImage *image, const RColor *color);
|
||||
void RBevelImage(RImage *image, int bevel_type);
|
||||
|
||||
RImage *RRenderGradient(unsigned width, unsigned height, const RColor *from,
|
||||
const RColor *to, int style);
|
||||
const RColor *to, RGradientStyle style);
|
||||
|
||||
|
||||
RImage *RRenderMultiGradient(unsigned width, unsigned height, RColor **colors,
|
||||
int style);
|
||||
RGradientStyle style);
|
||||
|
||||
|
||||
RImage *RRenderInterwovenGradient(unsigned width, unsigned height,
|
||||
|
||||
Reference in New Issue
Block a user