Преглед изворни кода

Rename dt_style to dt_color

Léo Gaspard пре 8 година
родитељ
комит
b5e26e4890
3 измењених фајлова са 17 додато и 17 уклоњено
  1. 5 5
      dtext.c
  2. 2 2
      dtext.h
  3. 10 10
      examples/basic.c

+ 5 - 5
dtext.c

@@ -160,7 +160,7 @@ dt_box(dt_context *ctx, dt_font *fnt, dt_bbox *bbox, wchar_t const *txt)
 }
 
 dt_error
-dt_draw(dt_context *ctx, dt_font *fnt, dt_style const *style,
+dt_draw(dt_context *ctx, dt_font *fnt, dt_color const *color,
         uint32_t x, uint32_t y, wchar_t const *txt)
 {
 	dt_error err;
@@ -168,10 +168,10 @@ dt_draw(dt_context *ctx, dt_font *fnt, dt_style const *style,
 	size_t len;
 	size_t i;
 
-	col.red   = (style->red   << 8) + style->red;
-	col.green = (style->green << 8) + style->green;
-	col.blue  = (style->blue  << 8) + style->blue;
-	col.alpha = 0xFFFF - ((style->alpha << 8) + style->alpha);
+	col.red   = (color->red   << 8) + color->red;
+	col.green = (color->green << 8) + color->green;
+	col.blue  = (color->blue  << 8) + color->blue;
+	col.alpha = 0xFFFF - ((color->alpha << 8) + color->alpha);
 	XRenderFillRectangle(ctx->dpy, PictOpSrc, ctx->fill, &col, 0, 0, 1, 1);
 
 	len = wcslen(txt);

+ 2 - 2
dtext.h

@@ -51,7 +51,7 @@ typedef struct {
 	uint8_t green;
 	uint8_t blue;
 	uint8_t alpha; // 0 means opaque
-} dt_style;
+} dt_color;
 
 dt_error dt_init(dt_context **ctx, Display *dpy, Window win);
 void dt_quit(dt_context *ctx);
@@ -61,5 +61,5 @@ void dt_free(dt_context *ctx, dt_font *fnt);
 
 dt_error dt_box(dt_context *ctx, dt_font *fnt, dt_bbox *bbox,
                 wchar_t const *txt);
-dt_error dt_draw(dt_context *ctx, dt_font *fnt, dt_style const *style,
+dt_error dt_draw(dt_context *ctx, dt_font *fnt, dt_color const *color,
                  uint32_t x, uint32_t y, wchar_t const *txt);

+ 10 - 10
examples/basic.c

@@ -24,8 +24,8 @@ GC gc;
 
 dt_context *ctx;
 dt_font *fnt;
-dt_style style;
-dt_style style_inv;
+dt_color color;
+dt_color color_inv;
 
 static void setup_x();
 static void setup_dt();
@@ -83,25 +83,25 @@ static void setup_x()
 
 static void setup_dt()
 {
-	memset(&style, 0, sizeof(style));
-	memset(&style_inv, 0, sizeof(style_inv));
-	style_inv.red = 0xFF;
-	style_inv.green = 0xFF;
-	style_inv.blue = 0xFF;
+	memset(&color, 0, sizeof(color));
+	memset(&color_inv, 0, sizeof(color_inv));
+	color_inv.red = 0xFF;
+	color_inv.green = 0xFF;
+	color_inv.blue = 0xFF;
 }
 
 static void draw()
 {
 	dt_bbox bbox;
 
-	assert(!dt_draw(ctx, fnt, &style, 10, 50, TEXT));
+	assert(!dt_draw(ctx, fnt, &color, 10, 50, TEXT));
 
 	assert(!dt_box(ctx, fnt, &bbox, TEXT));
 	XFillRectangle(dpy, win, gc, 10 + bbox.x, 100 + bbox.y, bbox.w, bbox.h);
-	assert(!dt_draw(ctx, fnt, &style_inv, 10, 100, TEXT));
+	assert(!dt_draw(ctx, fnt, &color_inv, 10, 100, TEXT));
 
 	XFillRectangle(dpy, win, gc, 10 + bbox.x, 150 - fnt->ascent, bbox.w, fnt->height);
-	assert(!dt_draw(ctx, fnt, &style_inv, 10, 150, TEXT));
+	assert(!dt_draw(ctx, fnt, &color_inv, 10, 150, TEXT));
 
 	XFlush(dpy);
 }