This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via 5e645909989e30e94ffe9eacf2177f441d44c2d6 (commit) via 9655adbc1de7cf63dd3510bb57f6fec95248c010 (commit) via 761929b143cb585ace1dd3c97cbe2f6be2952b80 (commit) via a21a7b420ab39c6c833aa878898295f61978c909 (commit) from 31c18f79b0e5a2b49f3ad6315ab7605935b2fc56 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/5e645909989e30e94ffe9eacf2177f441d44c...
commit 5e645909989e30e94ffe9eacf2177f441d44c2d6 Merge: 9655adb 31c18f7 Author: Cyril Hrubis metan@ucw.cz Date: Fri Nov 25 23:52:18 2011 +0100
Merge ssh://repo.or.cz/srv/git/gfxprim
http://repo.or.cz/w/gfxprim.git/commit/9655adbc1de7cf63dd3510bb57f6fec95248c...
commit 9655adbc1de7cf63dd3510bb57f6fec95248c010 Author: Cyril Hrubis metan@ucw.cz Date: Fri Nov 25 19:17:49 2011 +0100
text: Starting on redoing the text interface.
diff --git a/demos/fbshow/fbshow.c b/demos/fbshow/fbshow.c index bf18f3f..082c888 100644 --- a/demos/fbshow/fbshow.c +++ b/demos/fbshow/fbshow.c @@ -77,17 +77,17 @@ static void *image_loader(void *ptr) char buf[100]; snprintf(buf, sizeof(buf), "Loading '%s'", params->img_path); GP_Fill(&fb->context, black_pixel); - GP_BoxCenteredText(&fb->context, NULL, 0, 0, - fb->context.w, fb->context.h, - buf, white_pixel); + //GP_BoxCenteredText(&fb->context, NULL, 0, 0, + // fb->context.w, fb->context.h, + // buf, white_pixel); }
GP_Context *img = NULL;
if (GP_LoadImage(params->img_path, &img, &callback) != 0) { - GP_BoxCenteredText(&fb->context, NULL, 0, 0, - fb->context.w, fb->context.h, - "Failed to load image", white_pixel); + // GP_BoxCenteredText(&fb->context, NULL, 0, 0, + // fb->context.w, fb->context.h, + // "Failed to load image", white_pixel); return NULL; }
diff --git a/include/text/GP_Font.h b/include/text/GP_Font.h index e84d459..a3cd434 100644 --- a/include/text/GP_Font.h +++ b/include/text/GP_Font.h @@ -19,12 +19,12 @@ * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * * jiri.bluebear.dluhos@gmail.com * * * - * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2011 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
-#ifndef GP_FONT_H -#define GP_FONT_H +#ifndef TEXT_GP_FONT_H +#define TEXT_GP_FONT_H
#include <stdint.h>
@@ -159,4 +159,4 @@ unsigned int GP_GetFontDataSize(const GP_Font *font); GP_RetCode GP_FontLoad(GP_Font **font, const char *filename); GP_RetCode GP_FontSave(const GP_Font *font, const char *filename);
-#endif /* GP_FONT_H */ +#endif /* TEXT_GP_FONT_H */ diff --git a/include/text/GP_Text.h b/include/text/GP_Text.h index 2c0177e..9cfdb7d 100644 --- a/include/text/GP_Text.h +++ b/include/text/GP_Text.h @@ -23,8 +23,8 @@ * * *****************************************************************************/
-#ifndef GP_TEXT_H -#define GP_TEXT_H +#ifndef TEXT_GP_TEXT_H +#define TEXT_GP_TEXT_H
#include "core/GP_Context.h"
@@ -42,7 +42,7 @@ * - GP_VALIGN_BASELINE places the text baseline at the point * - GP_VALIGN_BELOW (or BOTTOM) draws the text below the point */ -typedef enum GP_TextAlign { +typedef enum GP_TextAttr { GP_ALIGN_LEFT = 0x01, GP_ALIGN_CENTER = 0x02, GP_ALIGN_RIGHT = 0x03, @@ -52,22 +52,44 @@ typedef enum GP_TextAlign { GP_VALIGN_BASELINE = 0x30, GP_VALIGN_BELOW = 0x40, GP_VALIGN_BOTTOM = GP_VALIGN_BELOW, -} GP_TextAlign; +} GP_TextAttr;
-GP_RetCode GP_Text_Raw(GP_Context *context, const GP_TextStyle *style, - GP_Coord x, GP_Coord y, int align, - const char *str, GP_Pixel pixel); +void GP_Text_Raw(GP_Context *context, const GP_TextStyle *style, + GP_Coord x, GP_Coord y, int align, + GP_Pixel fg_color, GP_Pixel bg_color, const char *str);
-GP_RetCode GP_Text(GP_Context *context, const GP_TextStyle *style, - GP_Coord x, GP_Coord y, int align, - const char *str, GP_Pixel pixel); +/* + * Draws a string. + * + * The string is rendered to context (horizontally) with defined text style. + * The x and y coordinates determines point defined by aligment flags. + * + * The background color is ignored for 1bpp font formats. + */ +void GP_Text(GP_Context *context, const GP_TextStyle *style, + GP_Coord x, GP_Coord y, int align, + GP_Pixel fg_color, GP_Pixel bg_color, const char *str); + +/* + * Same as above, but printf like and returns text width in pixels. + */ +GP_Size GP_Print(GP_Context *context, const GP_TextStyle *style, + GP_Coord x, GP_Coord y, int align, + GP_Pixel fg_color, GP_Pixel bg_color, const char *fmt, ...) + __attribute__ ((format (printf, 8, 9)));
-GP_RetCode GP_BoxCenteredText_Raw(GP_Context *context, const GP_TextStyle *style, - GP_Coord x, GP_Coord y, GP_Size w, GP_Size h, - const char *str, GP_Pixel pixel); +/* + * Clears rectangle that would be used to draw text of size pixels. + */ +void GP_TextClear(GP_Context *context, const GP_TextStyle *style, + GP_Coord x, GP_Coord y, int align, + GP_Pixel bg_color, GP_Size size);
-GP_RetCode GP_BoxCenteredText(GP_Context *context, const GP_TextStyle *style, - GP_Coord x, GP_Coord y, GP_Size w, GP_Size h, - const char *str, GP_Pixel pixel); +/* + * Dtto, but with string. + */ +void GP_TextClearStr(GP_Context *context, const GP_TextStyle *style, + GP_Coord x, GP_Coord y, int align, + GP_Pixel bg_color, const char *str);
-#endif /* GP_TEXT_H */ +#endif /* TEXT_GP_TEXT_H */ diff --git a/include/text/GP_TextMetric.h b/include/text/GP_TextMetric.h index d9f4ffb..16d44bc 100644 --- a/include/text/GP_TextMetric.h +++ b/include/text/GP_TextMetric.h @@ -19,44 +19,47 @@ * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * * jiri.bluebear.dluhos@gmail.com * * * - * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2011 Cyril Hrubis metan@ucw.cz * * * ****************************************************************************/
-#ifndef GP_TEXT_METRIC_H -#define GP_TEXT_METRIC_H +#ifndef TEXT_GP_TEXT_METRIC_H +#define TEXT_GP_TEXT_METRIC_H
+#include "core/GP_Types.h" #include "GP_TextStyle.h"
/* * Calculates the width of the string drawn in the given style, in pixels. */ -unsigned int GP_TextWidth(const GP_TextStyle *style, const char *str); +GP_Size GP_TextWidth(const GP_TextStyle *style, const char *str);
/* * Maximal text width for string with len characters. */ -unsigned int GP_TextMaxWidth(const GP_TextStyle *style, unsigned int len); +GP_Size GP_TextMaxWidth(const GP_TextStyle *style, unsigned int len);
/* * Returns maximal width for text written with len characters from str. */ -unsigned int GP_TextMaxStrWidth(const GP_TextStyle *style, const char *str, - unsigned int len); +GP_Size GP_TextMaxStrWidth(const GP_TextStyle *style, const char *str, + unsigned int len);
/* * Returns maximal text height, in pixels. */ -unsigned int GP_TextHeight(const GP_TextStyle *style); +GP_Size GP_TextHeight(const GP_TextStyle *style);
-/* Returns the ascent (height from the baseline to the top of characters), +/* + * Returns the ascent (height from the baseline to the top of characters), * for the given text style. (Result is in pixels.) */ -unsigned int GP_TextAscent(const GP_TextStyle *style); +GP_Size GP_TextAscent(const GP_TextStyle *style);
-/* Returns the descent (height from the baseline to the bottom of characters), +/* + * Returns the descent (height from the baseline to the bottom of characters), * for the given text style. (Result is in pixels.) */ -unsigned int GP_TextDescent(const GP_TextStyle *style); +GP_Size GP_TextDescent(const GP_TextStyle *style);
-#endif /* GP_TEXT_METRIC_H */ +#endif /* TEXT_GP_TEXT_METRIC_H */ diff --git a/include/text/GP_TextStyle.h b/include/text/GP_TextStyle.h index d57e678..58b6886 100644 --- a/include/text/GP_TextStyle.h +++ b/include/text/GP_TextStyle.h @@ -23,8 +23,8 @@ * * *****************************************************************************/
-#ifndef GP_TEXTSTYLE_H -#define GP_TEXTSTYLE_H +#ifndef TEXT_GP_TEXTSTYLE_H +#define TEXT_GP_TEXTSTYLE_H
#include "GP_Font.h" #include "core/GP_RetCode.h" @@ -68,4 +68,4 @@ void GP_DefaultTextStyle(GP_TextStyle *style); GP_CHECK_FONT(style->font); } while(0)
-#endif /* GP_TEXTSTYLE_H */ +#endif /* TEXT_GP_TEXTSTYLE_H */ diff --git a/libs/text/GP_Text.c b/libs/text/GP_Text.c index c6fce34..56033d2 100644 --- a/libs/text/GP_Text.c +++ b/libs/text/GP_Text.c @@ -23,168 +23,153 @@ * * *****************************************************************************/
+#include <stdarg.h> #include "algo/Text.algo.h" #include "gfx/GP_Gfx.h" #include "core/GP_FnPerBpp.h" +#include "core/GP_Debug.h" #include "GP_Text.h"
GP_TextStyle GP_DefaultStyle = GP_DEFAULT_TEXT_STYLE;
+static int do_align(GP_Coord *topleft_x, GP_Coord *topleft_y, int align, + GP_Coord x, GP_Coord y, const GP_TextStyle *style, + GP_Size width) +{ + int height = GP_TextHeight(style); + + switch (align & 0x0f) { + case GP_ALIGN_LEFT: + *topleft_x = x - width + 1; + break; + case GP_ALIGN_RIGHT: + *topleft_x = x; + break; + case GP_ALIGN_CENTER: + *topleft_x = x - width/2; + break; + default: + GP_DEBUG(1, "ALIGN 0x%0xn", align); + return 1; + } + + switch (align & 0xf0) { + case GP_VALIGN_ABOVE: + *topleft_y = y - height + 1; + break; + case GP_VALIGN_CENTER: + *topleft_y = y - height/2; + break; + case GP_VALIGN_BASELINE: + *topleft_y = y - height + style->font->baseline; + break; + case GP_VALIGN_BELOW: + *topleft_y = y; + break; + default: + GP_DEBUG(1, "VALIGN 0x%0xn", align); + return 1; + } + + return 0; +} + /* Generate drawing functions for various bit depths. */ GP_DEF_FILL_FN_PER_BPP(GP_Text_Raw, DEF_TEXT_FN)
-GP_RetCode GP_Text_Raw(GP_Context *context, const GP_TextStyle *style, - GP_Coord x, GP_Coord y, int align, - const char *str, GP_Pixel pixel) +void GP_Text_Raw(GP_Context *context, const GP_TextStyle *style, + GP_Coord x, GP_Coord y, int align, + GP_Pixel fg_color, GP_Pixel bg_color, const char *str) { + (void) bg_color; + GP_CHECK_CONTEXT(context);
if (str == NULL) - return GP_ENULLPTR; + return;
if (style == NULL) style = &GP_DefaultStyle; GP_CHECK_TEXT_STYLE(style);
- int width = GP_TextWidth(style, str); - int height = GP_TextHeight(style); + GP_Coord topleft_x, topleft_y; + GP_Size w = GP_TextWidth(style, str);
- int topleft_x, topleft_y; - switch (align & 0x0f) { - case GP_ALIGN_LEFT: - topleft_x = x - width + 1; - break; - case GP_ALIGN_RIGHT: - topleft_x = x; - break; - case GP_ALIGN_CENTER: - topleft_x = x - width/2; - break; - default: - return GP_EINVAL; - } - switch (align & 0xf0) { - case GP_VALIGN_ABOVE: - topleft_y = y - height + 1; - break; - case GP_VALIGN_CENTER: - topleft_y = y - height/2; - break; - case GP_VALIGN_BASELINE: - topleft_y = y - height + style->font->baseline; - break; - case GP_VALIGN_BELOW: - topleft_y = y; - break; - default: - return GP_EINVAL; - } + GP_ASSERT(do_align(&topleft_x, &topleft_y, align, x, y, style, w) == 0, + "Invalid aligment flags");
GP_FN_PER_BPP_CONTEXT(GP_Text_Raw, context, context, style, - topleft_x, topleft_y, str, pixel); - - return GP_ESUCCESS; + topleft_x, topleft_y, str, fg_color); }
DEF_TEXT_FN(GP_Text_internal, GP_Context *, GP_Pixel, GP_HLine)
-GP_RetCode GP_Text(GP_Context *context, const GP_TextStyle *style, - GP_Coord x, GP_Coord y, int align, - const char *str, GP_Pixel pixel) +void GP_Text(GP_Context *context, const GP_TextStyle *style, + GP_Coord x, GP_Coord y, int align, + GP_Pixel fg_color, GP_Pixel bg_color, + const char *str) { + (void) bg_color; + GP_CHECK_CONTEXT(context); - + if (str == NULL) - return GP_ENULLPTR; + return;
if (style == NULL) style = &GP_DefaultStyle; GP_CHECK_TEXT_STYLE(style); + + GP_Coord topleft_x, topleft_y; + GP_Size w = GP_TextWidth(style, str);
- int width = GP_TextWidth(style, str); - int height = GP_TextHeight(style); - - int topleft_x, topleft_y; - switch (align & 0x0f) { - case GP_ALIGN_LEFT: - topleft_x = x - width; - break; - case GP_ALIGN_RIGHT: - topleft_x = x; - break; - case GP_ALIGN_CENTER: - topleft_x = x - width/2; - break; - default: - return GP_EINVAL; - } - switch (align & 0xf0) { - case GP_VALIGN_ABOVE: - topleft_y = y - height; - break; - case GP_VALIGN_CENTER: - topleft_y = y - height/2; - break; - case GP_VALIGN_BASELINE: - topleft_y = y - height + style->font->baseline; - break; - case GP_VALIGN_BELOW: - topleft_y = y; - break; - default: - return GP_EINVAL; - } + GP_ASSERT(do_align(&topleft_x, &topleft_y, align, x, y, style, w) == 0, + "Invalid aligment flags");
- GP_Text_internal(context, style, topleft_x, topleft_y, str, pixel); - return GP_ESUCCESS; + GP_Text_internal(context, style, topleft_x, topleft_y, str, fg_color); }
-GP_RetCode GP_BoxCenteredText_Raw(GP_Context *context, const GP_TextStyle *style, - GP_Coord x, GP_Coord y, GP_Size w, GP_Size h, - const char *str, GP_Pixel pixel) -{ - GP_CHECK_CONTEXT(context);
- if (str == NULL) - return GP_ENULLPTR; +GP_Size GP_Print(GP_Context *context, const GP_TextStyle *style, + GP_Coord x, GP_Coord y, int align, + GP_Pixel fg_color, GP_Pixel bg_color, const char *fmt, ...) +{ + va_list va, vac; + int size;
- if (style == NULL) - style = &GP_DefaultStyle; - - GP_CHECK_TEXT_STYLE(style); + va_start(va, fmt); + va_copy(vac, va); + size = vsnprintf(NULL, 0, fmt, va); + va_end(va); + char buf[size+1]; + vsnprintf(buf, sizeof(buf), fmt, vac); + va_end(vac);
- const int mid_x = x + w/2; - const int mid_y = y + h/2; - const int font_ascent = GP_TextAscent(style); + GP_Text(context, style, x, y, align, fg_color, bg_color, buf);
- return GP_Text_Raw(context, style, mid_x, - mid_y + font_ascent/2, - GP_ALIGN_CENTER | GP_VALIGN_BASELINE, - str, pixel); + return GP_TextWidth(style, buf); }
-GP_RetCode GP_BoxCenteredText(GP_Context *context, const GP_TextStyle *style, - GP_Coord x, GP_Coord y, GP_Size w, GP_Size h, - const char *str, GP_Pixel pixel) -{ - GP_CHECK_CONTEXT(context);
- if (str == NULL) - return GP_ENULLPTR; +void GP_TextClear(GP_Context *context, const GP_TextStyle *style, + GP_Coord x, GP_Coord y, int align, + GP_Pixel bg_color, GP_Size size) +{ + GP_Coord topleft_x, topleft_y;
- if (style == NULL) - style = &GP_DefaultStyle; - - GP_CHECK_TEXT_STYLE(style); + GP_ASSERT(do_align(&topleft_x, &topleft_y, align, x, y, style, size) == 0, + "Invalid aligment flags");
- const int mid_x = x + w/2; - const int mid_y = y + h/2; - const int font_ascent = GP_TextAscent(style); + GP_FillRectXYWH(context, topleft_x, topleft_y, + size, GP_TextHeight(style), bg_color); +}
- return GP_Text(context, style, mid_x, - mid_y + font_ascent/2, - GP_ALIGN_CENTER | GP_VALIGN_BASELINE, - str, pixel); +void GP_TextClearStr(GP_Context *context, const GP_TextStyle *style, + GP_Coord x, GP_Coord y, int align, + GP_Pixel bg_color, const char *str) +{ + GP_TextClear(context, style, x, y, align, + bg_color, GP_TextWidth(style, str)); } diff --git a/tests/SDL/blittest.c b/tests/SDL/blittest.c index 1a4ed83..bfedaa7 100644 --- a/tests/SDL/blittest.c +++ b/tests/SDL/blittest.c @@ -85,7 +85,8 @@ void redraw_screen(void)
SDL_LockSurface(display);
- GP_Text(&context, NULL, 20, 20, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM, text_buf, white); + GP_Text(&context, NULL, 20, 20, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM, + white, black, text_buf); GP_Blit(bitmap, 0, 0, bitmap->w, bitmap->h, &context, bitmap_x, bitmap_y);
SDL_UpdateRect(display, bitmap_x, bitmap_y, bitmap->w, bitmap->h); diff --git a/tests/SDL/fileview.c b/tests/SDL/fileview.c index c01a7fc..1899da9 100644 --- a/tests/SDL/fileview.c +++ b/tests/SDL/fileview.c @@ -92,7 +92,8 @@ void redraw_screen(void) for (i = 0; i < 30; i++) { if (line == NULL) break; - GP_Text(&context, &style, 16, 16*i + 16, align, line->text, black_pixel); + GP_Text(&context, &style, 16, 16*i + 16, align, + black_pixel, black_pixel, line->text); line = line->next; }
diff --git a/tests/SDL/fonttest.c b/tests/SDL/fonttest.c index 602c526..4bfa945 100644 --- a/tests/SDL/fonttest.c +++ b/tests/SDL/fonttest.c @@ -98,20 +98,23 @@ void redraw_screen(void) style.font->height + 1, blue_pixel);
- GP_Text(&context, &style, 16, 100*i + 16, align, test_string, white_pixel); + GP_Text(&context, &style, 16, 100*i + 16, align, + white_pixel, black_pixel, test_string);
style.pixel_xmul = 2; style.pixel_ymul = 2; style.pixel_yspace = 1;
- GP_Text(&context, &style, 34, 100*i + 38, align, test_string, gray_pixel); + GP_Text(&context, &style, 34, 100*i + 38, align, + white_pixel, black_pixel, test_string);
style.pixel_xmul = 4; style.pixel_ymul = 2; style.pixel_xspace = 1; style.pixel_yspace = 1;
- GP_Text(&context, &style, 64, 100*i + 72, align, test_string, dark_gray_pixel); + GP_Text(&context, &style, 64, 100*i + 72, align, + dark_gray_pixel, black_pixel, test_string); }
SDL_UnlockSurface(display); @@ -188,7 +191,9 @@ void print_character_metadata(const GP_Font *font, int c) int main(int argc, char *argv[]) { print_instructions(); - + + GP_SetDebugLevel(10); + if (argc > 1) { GP_RetCode err; fprintf(stderr, "nLoading font '%s'n", argv[1]); diff --git a/tests/SDL/input.c b/tests/SDL/input.c index c420b09..c2b1cde 100644 --- a/tests/SDL/input.c +++ b/tests/SDL/input.c @@ -48,12 +48,17 @@ Uint32 timer_callback(__attribute__((unused)) Uint32 interval,
static void draw_event(GP_Event *ev) { + static GP_Size size = 0; + if (ev->type != GP_EV_KEY) return; + + int align = GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM;
- GP_FillRect(&context, 0, 0, 150, 35, black_pixel); - GP_Text(&context, NULL, 20, 20, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM, - GP_EventKeyName(ev->val.key.key), white_pixel); + GP_TextClear(&context, NULL, 20, 20, align, black_pixel, size); + size = GP_Print(&context, NULL, 20, 20, align, + white_pixel, black_pixel, "Key=%s", + GP_EventKeyName(ev->val.key.key)); SDL_Flip(display); }
@@ -94,12 +99,21 @@ static void event_loop(void) break; case GP_EV_REL: switch (ev.code) { + static int size = 0; case GP_EV_REL_POS: if (GP_EventGetKey(&ev, GP_BTN_LEFT)) { GP_PutPixel(&context, ev.cursor_x, ev.cursor_y, green_pixel); SDL_Flip(display); } + int align = GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM; + + GP_TextClear(&context, NULL, 20, 40, align, + black_pixel, size); + size = GP_Print(&context, NULL, 20, 40, align, + white_pixel, black_pixel, "X=%3u Y=%3u", + ev.cursor_x, ev.cursor_y); + SDL_Flip(display); break; } break; diff --git a/tests/SDL/shapetest.c b/tests/SDL/shapetest.c index d270528..8435e10 100644 --- a/tests/SDL/shapetest.c +++ b/tests/SDL/shapetest.c @@ -273,7 +273,7 @@ void redraw_screen(void) }
GP_Text(&context, &style, 16, 16, GP_ALIGN_RIGHT|GP_VALIGN_BELOW, - title, white); + white, black, title);
SDL_UnlockSurface(display); } diff --git a/tests/SDL/subcontext.c b/tests/SDL/subcontext.c index 25db7fb..5147ddf 100644 --- a/tests/SDL/subcontext.c +++ b/tests/SDL/subcontext.c @@ -128,7 +128,7 @@ static void draw_text(GP_Context *dest, GP_Coord x, GP_Coord y, x1 = random() % (w - tw) + x; y1 = random() % (h - th) + y;
- GP_Text(dest, NULL, x1, y1, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM, TEXT, col); + GP_Text(dest, NULL, x1, y1, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM, col, black, TEXT); }
void redraw_screen(void) diff --git a/tests/SDL/textaligntest.c b/tests/SDL/textaligntest.c index 507b560..b6ac351 100644 --- a/tests/SDL/textaligntest.c +++ b/tests/SDL/textaligntest.c @@ -65,20 +65,20 @@ void redraw_screen(void) style.pixel_xspace = 4; style.pixel_yspace = 4;
- GP_BoxCenteredText(&context, &style, 0, 0, X, Y, - "Hello world!", darkgray_pixel); + //GP_BoxCenteredText(&context, &style, 0, 0, X, Y, + // "Hello world!", darkgray_pixel);
style.pixel_xspace = 0; style.pixel_yspace = 0;
GP_Text(&context, &style, X/2, Y/2, GP_ALIGN_LEFT|GP_VALIGN_BELOW, - "bottom left", yellow_pixel); + yellow_pixel, black_pixel, "bottom left"); GP_Text(&context, &style, X/2, Y/2, GP_ALIGN_RIGHT|GP_VALIGN_BELOW, - "bottom right", red_pixel); + red_pixel, black_pixel, "bottom right"); GP_Text(&context, &style, X/2, Y/2, GP_ALIGN_RIGHT|GP_VALIGN_ABOVE, - "top right", blue_pixel); + blue_pixel, black_pixel, "top right"); GP_Text(&context, &style, X/2, Y/2, GP_ALIGN_LEFT|GP_VALIGN_ABOVE, - "top left", green_pixel); + green_pixel, black_pixel, "top left");
SDL_UnlockSurface(display); } diff --git a/tests/drivers/framebuffer_test.c b/tests/drivers/framebuffer_test.c index c5aceb9..c2595d2 100644 --- a/tests/drivers/framebuffer_test.c +++ b/tests/drivers/framebuffer_test.c @@ -77,7 +77,7 @@ int main(void) GP_Pixel gray, black;
gray = GP_RGBToContextPixel(200, 200, 200, &fb->context); - black = GP_RGBToContextPixel( 0, 0, 0, &fb->context); + black = GP_RGBToContextPixel(0, 0, 0, &fb->context); const char *text = "Framebuffer test";
@@ -86,7 +86,7 @@ int main(void) GP_Line(&fb->context, 0, fb->context.h, fb->context.w, 0, black); GP_Text(&fb->context, &style, (fb->context.w - GP_TextWidth(&style, text))/2, - 16, GP_ALIGN_RIGHT|GP_VALIGN_BELOW, text, black); + 16, GP_ALIGN_RIGHT|GP_VALIGN_BELOW, black, gray, text);
draw(&fb->context, fb->context.w / 2, 2.00 * fb->context.h / 3, 60);
http://repo.or.cz/w/gfxprim.git/commit/761929b143cb585ace1dd3c97cbe2f6be2952...
commit 761929b143cb585ace1dd3c97cbe2f6be2952b80 Author: Cyril Hrubis metan@ucw.cz Date: Fri Nov 25 18:36:20 2011 +0100
filters: Complete filter param & fix tests.
diff --git a/include/filters/GP_FilterParam.h b/include/filters/GP_FilterParam.h index d073305..f997ed5 100644 --- a/include/filters/GP_FilterParam.h +++ b/include/filters/GP_FilterParam.h @@ -84,6 +84,23 @@ int GP_FilterParamCheckChannels(GP_FilterParam params[], #define GP_FILTER_PARAMS(pixel_type, name) GP_FilterParam name[GP_PixelTypes[pixel_type].numchannels + 1]; GP_FilterParamInitChannels(name, pixel_type); + +#define GP_FILTER_PARAMS_INT(pixel_type, name, val) + GP_FILTER_PARAMS(pixel_type, name) + GP_FilterParamSetIntAll(name, val); + +#define GP_FILTER_PARAMS_UINT(pixel_type, name, val) + GP_FILTER_PARAMS(pixel_type, name) + GP_FilterParamSetUIntAll(name, val); + +#define GP_FILTER_PARAMS_FLOAT(pixel_type, name, val) + GP_FILTER_PARAMS(pixel_type, name) + GP_FilterParamSetFloatAll(name, val); + +#define GP_FILTER_PARAMS_PTR(pixel_type, name, ptr) + GP_FILTER_PARAMS(pixel_type, name) + GP_FilterParamSetPtrAll(name, ptr); + /* * Initalize param names and terminator. * @@ -116,4 +133,12 @@ void GP_FilterParamSetUIntAll(GP_FilterParam params[], void GP_FilterParamSetPtrAll(GP_FilterParam params[], void *ptr);
+/* + * Functions to print the array. + */ +void GP_FilterParamPrintInt(GP_FilterParam params[]); +void GP_FilterParamPrintUInt(GP_FilterParam params[]); +void GP_FilterParamPrintFloat(GP_FilterParam params[]); +void GP_FilterParamPrintPtr(GP_FilterParam params[]); + #endif /* FILTERS_GP_FILTER_PARAM_H */ diff --git a/libs/filters/GP_FilterParam.c b/libs/filters/GP_FilterParam.c index c5ef345..a07b3de 100644 --- a/libs/filters/GP_FilterParam.c +++ b/libs/filters/GP_FilterParam.c @@ -141,3 +141,35 @@ void GP_FilterParamSetPtrAll(GP_FilterParam params[], for (i = 0; params[i].channel_name[0] != '0'; i++) params[i].val.ptr = ptr; } + +void GP_FilterParamPrintInt(GP_FilterParam params[]) +{ + unsigned int i; + + for (i = 0; params[i].channel_name[0] != '0'; i++) + printf("Chann '%s' = %in", params[i].channel_name, params[i].val.i); +} + +void GP_FilterParamPrintUInt(GP_FilterParam params[]) +{ + unsigned int i; + + for (i = 0; params[i].channel_name[0] != '0'; i++) + printf("Chann '%s' = %un", params[i].channel_name, params[i].val.ui); +} + +void GP_FilterParamPrintFloat(GP_FilterParam params[]) +{ + unsigned int i; + + for (i = 0; params[i].channel_name[0] != '0'; i++) + printf("Chann '%s' = %fn", params[i].channel_name, params[i].val.f); +} + +void GP_FilterParamPrintPtr(GP_FilterParam params[]) +{ + unsigned int i; + + for (i = 0; params[i].channel_name[0] != '0'; i++) + printf("Chann '%s' = %pn", params[i].channel_name, params[i].val.ptr); +} diff --git a/tests/SDL/showimage.c b/tests/SDL/showimage.c index 9df416d..b0f0839 100644 --- a/tests/SDL/showimage.c +++ b/tests/SDL/showimage.c @@ -47,17 +47,18 @@ void event_loop(void) return; case SDLK_UP: brightness+=2; - case SDLK_DOWN: + case SDLK_DOWN: { brightness-=1;
- res = GP_FilterBrightness(bitmap, NULL, brightness, NULL); + GP_FILTER_PARAMS_INT(bitmap->pixel_type, param, brightness); + res = GP_FilterBrightness(bitmap, NULL, param, NULL); printf("brightness = %i %ux%un", brightness, res->w, res->h);
GP_Blit(res, 0, 0, res->w, res->h, &context, 0, 0); SDL_Flip(display); GP_ContextFree(res); - break; + } break; default: break; }
http://repo.or.cz/w/gfxprim.git/commit/a21a7b420ab39c6c833aa878898295f61978c...
commit a21a7b420ab39c6c833aa878898295f61978c909 Author: Cyril Hrubis metan@ucw.cz Date: Fri Nov 25 18:32:09 2011 +0100
filters: Fix point filter template.
diff --git a/pylib/templates/filter.point.c.t b/pylib/templates/filter.point.c.t index 750c448..88bd6c8 100644 --- a/pylib/templates/filter.point.c.t +++ b/pylib/templates/filter.point.c.t @@ -178,7 +178,7 @@ GP_Context *GP_Filter{{ name }}(const GP_Context *src, GP_Context *dst{{ maybe_o "Destination is not big enough"); }
- if (GP_Filter{{ name }}_Raw(src, dst{{ maybe_opts(params) }}, callback)) { + if (GP_Filter{{ name }}_Raw(src, res{{ maybe_opts(params) }}, callback)) { GP_DEBUG(1, "Operation aborted");
if (dst == NULL)
-----------------------------------------------------------------------
Summary of changes: demos/fbshow/fbshow.c | 12 +- include/filters/GP_FilterParam.h | 25 +++++ include/text/GP_Font.h | 8 +- include/text/GP_Text.h | 56 +++++++--- include/text/GP_TextMetric.h | 29 +++--- include/text/GP_TextStyle.h | 6 +- libs/filters/GP_FilterParam.c | 32 ++++++ libs/text/GP_Text.c | 215 ++++++++++++++++++-------------------- pylib/templates/filter.point.c.t | 2 +- tests/SDL/blittest.c | 3 +- tests/SDL/fileview.c | 3 +- tests/SDL/fonttest.c | 13 ++- tests/SDL/input.c | 20 +++- tests/SDL/shapetest.c | 2 +- tests/SDL/showimage.c | 7 +- tests/SDL/subcontext.c | 2 +- tests/SDL/textaligntest.c | 12 +- tests/drivers/framebuffer_test.c | 4 +- 18 files changed, 270 insertions(+), 181 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.