Changeset b433f68 in mainline
- Timestamp:
- 2021-02-26T16:23:36Z (4 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 77ffa01
- Parents:
- fe40b67
- Location:
- uspace
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/fontedit/fontedit.c
rfe40b67 rb433f68 446 446 * @param fedit Font editor 447 447 * @param x Starting X coordinate 448 * @Param y Starting Y coordinate 448 * @param y Starting Y coordinate 449 * @param color Color 449 450 * @param str String 450 451 */ 451 452 static errno_t font_edit_paint_preview_str(font_edit_t *fedit, 452 gfx_coord_t x, gfx_coord_t y, const char *str)453 gfx_coord_t x, gfx_coord_t y, gfx_color_t *color, const char *str) 453 454 { 454 455 gfx_text_fmt_t fmt; … … 456 457 457 458 gfx_text_fmt_init(&fmt); 459 fmt.color = color; 458 460 459 461 pos.x = x; … … 480 482 goto error; 481 483 482 rc = font_edit_paint_preview_str(fedit, 20, 20, 484 rc = font_edit_paint_preview_str(fedit, 20, 20, color, 483 485 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); 484 486 if (rc != EOK) 485 487 goto error; 486 488 487 rc = font_edit_paint_preview_str(fedit, 20, 40, 489 rc = font_edit_paint_preview_str(fedit, 20, 40, color, 488 490 "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG"); 489 491 if (rc != EOK) 490 492 goto error; 491 493 492 rc = font_edit_paint_preview_str(fedit, 20, 60, 494 rc = font_edit_paint_preview_str(fedit, 20, 60, color, 493 495 "abcdefghijklmnopqrstuvwxyz"); 494 496 if (rc != EOK) 495 497 goto error; 496 498 497 rc = font_edit_paint_preview_str(fedit, 20, 80, 499 rc = font_edit_paint_preview_str(fedit, 20, 80, color, 498 500 "the quick brown fox jumps over the lazy dog"); 499 501 if (rc != EOK) 500 502 goto error; 501 503 502 rc = font_edit_paint_preview_str(fedit, 20, 100, 504 rc = font_edit_paint_preview_str(fedit, 20, 100, color, 503 505 "0123456789,./<>?;'\\:\"|[]{}`~!@#$%^&*()-_=+"); 504 506 if (rc != EOK) -
uspace/app/gfxdemo/gfxdemo.c
rfe40b67 rb433f68 556 556 goto error; 557 557 558 rc = gfx_set_color(gc, color);559 if (rc != EOK)560 goto error;561 562 558 gfx_text_fmt_init(&fmt); 559 fmt.color = color; 563 560 564 561 pos.x = rect.p0.x; … … 640 637 goto error; 641 638 642 rc = gfx_set_color(gc, color); 643 if (rc != EOK) 644 goto error; 639 fmt.color = color; 645 640 646 641 pos.x = w / 20; -
uspace/lib/gfxfont/include/types/gfx/text.h
rfe40b67 rb433f68 38 38 39 39 #include <types/gfx/coord.h> 40 #include <types/gfx/color.h> 40 41 41 42 /** Text horizontal alignment */ … … 65 66 /** Text formatting */ 66 67 typedef struct { 68 /** Text color */ 69 gfx_color_t *color; 67 70 /** Horizontal alignment */ 68 71 gfx_halign_t halign; -
uspace/lib/gfxfont/src/text.c
rfe40b67 rb433f68 36 36 #include <errno.h> 37 37 #include <gfx/bitmap.h> 38 #include <gfx/color.h> 38 39 #include <gfx/font.h> 39 40 #include <gfx/glyph.h> 41 #include <gfx/render.h> 40 42 #include <gfx/text.h> 41 43 #include <io/pixelmap.h> … … 97 99 * @param font Font 98 100 * @param pos Position of top-left corner of text 101 * @param color Text color 99 102 * @param str String 100 103 * @return EOK on success or an error code 101 104 */ 102 105 static errno_t gfx_puttext_textmode(gfx_font_t *font, gfx_coord2_t *pos, 103 const char *str)106 gfx_color_t *color, const char *str) 104 107 { 105 108 gfx_context_t *gc = font->typeface->gc; … … 107 110 gfx_bitmap_t *bitmap; 108 111 gfx_bitmap_alloc_t alloc; 112 uint16_t r, g, b; 109 113 pixelmap_t pmap; 110 114 gfx_coord_t x; … … 116 120 * the most efficient way. 117 121 */ 122 123 gfx_color_get_rgb_i16(color, &r, &g, &b); 124 125 /* 126 * We are setting the *background* color, the foreground color 127 * will be set to its complement. 128 */ 129 r = 0xff ^ (r >> 8); 130 g = 0xff ^ (g >> 8); 131 b = 0xff ^ (b >> 8); 118 132 119 133 gfx_bitmap_params_init(¶ms); … … 138 152 139 153 for (x = 0; x < params.rect.p1.x; x++) { 140 pixel = PIXEL(str[x], 0xff, 0xff, 0xff);154 pixel = PIXEL(str[x], r, g, b); 141 155 pixelmap_put_pixel(&pmap, x, 0, pixel); 142 156 } … … 206 220 /* Text mode */ 207 221 if ((font->finfo->props.flags & gff_text_mode) != 0) 208 return gfx_puttext_textmode(font, &cpos, str); 222 return gfx_puttext_textmode(font, &cpos, fmt->color, str); 223 224 rc = gfx_set_color(font->typeface->gc, fmt->color); 225 if (rc != EOK) 226 return rc; 209 227 210 228 cp = str; -
uspace/lib/gfxfont/test/text.c
rfe40b67 rb433f68 27 27 */ 28 28 29 #include <gfx/color.h> 29 30 #include <gfx/context.h> 30 31 #include <gfx/font.h> … … 110 111 gfx_font_t *font; 111 112 gfx_context_t *gc; 113 gfx_color_t *color; 112 114 gfx_text_fmt_t fmt; 113 115 gfx_coord2_t pos; … … 118 120 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 119 121 122 rc = gfx_color_new_rgb_i16(0, 0, 0, &color); 123 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 124 120 125 rc = gfx_typeface_create(gc, &tface); 121 126 PCUT_ASSERT_ERRNO_VAL(EOK, rc); … … 127 132 128 133 gfx_text_fmt_init(&fmt); 134 fmt.color = color; 129 135 pos.x = 0; 130 136 pos.y = 0; … … 135 141 gfx_font_close(font); 136 142 gfx_typeface_destroy(tface); 143 gfx_color_delete(color); 137 144 138 145 rc = gfx_context_delete(gc); -
uspace/lib/ui/src/checkbox.c
rfe40b67 rb433f68 192 192 193 193 gfx_text_fmt_init(&fmt); 194 fmt.color = checkbox->res->entry_fg_color; 194 195 fmt.halign = gfx_halign_center; 195 196 fmt.valign = gfx_valign_center; 196 197 rc = gfx_set_color(checkbox->res->gc,198 checkbox->res->entry_fg_color);199 if (rc != EOK)200 goto error;201 197 202 198 rc = gfx_puttext(checkbox->res->font, &box_center, &fmt, "X"); … … 207 203 /* Paint checkbox label */ 208 204 209 rc = gfx_set_color(checkbox->res->gc, checkbox->res->wnd_text_color);210 if (rc != EOK)211 goto error;212 213 /* Label position */214 205 pos.x = box_rect.p1.x + checkbox_label_margin; 215 206 pos.y = (box_rect.p0.y + box_rect.p1.y) / 2; 216 207 217 208 gfx_text_fmt_init(&fmt); 209 fmt.color = checkbox->res->wnd_text_color; 218 210 fmt.halign = gfx_halign_left; 219 211 fmt.valign = gfx_valign_center; -
uspace/lib/ui/src/entry.c
rfe40b67 rb433f68 208 208 209 209 gfx_text_fmt_init(&fmt); 210 fmt.color = entry->res->entry_fg_color; 210 211 fmt.halign = entry->halign; 211 212 fmt.valign = gfx_valign_top; 212 213 rc = gfx_set_color(entry->res->gc, entry->res->entry_fg_color);214 if (rc != EOK)215 goto error;216 213 217 214 rc = gfx_puttext(entry->res->font, &pos, &fmt, entry->text); -
uspace/lib/ui/src/label.c
rfe40b67 rb433f68 193 193 194 194 gfx_text_fmt_init(&fmt); 195 fmt.color = label->res->wnd_text_color; 195 196 fmt.halign = label->halign; 196 197 fmt.valign = gfx_valign_top; 197 198 rc = gfx_set_color(label->res->gc, label->res->wnd_text_color);199 if (rc != EOK)200 goto error;201 198 202 199 rc = gfx_puttext(label->res->font, &pos, &fmt, label->text); -
uspace/lib/ui/src/pbutton.c
rfe40b67 rb433f68 269 269 goto error; 270 270 271 rc = gfx_set_color(pbutton->res->gc, pbutton->res->btn_text_color);272 if (rc != EOK)273 goto error;274 275 271 /* Center of button rectangle */ 276 272 pos.x = (rect.p0.x + rect.p1.x) / 2; … … 283 279 284 280 gfx_text_fmt_init(&fmt); 281 fmt.color = pbutton->res->btn_text_color; 285 282 fmt.halign = gfx_halign_center; 286 283 fmt.valign = gfx_valign_center; -
uspace/lib/ui/src/rbutton.c
rfe40b67 rb433f68 274 274 /* Paint rbutton label */ 275 275 276 rc = gfx_set_color(rbutton->group->res->gc,277 rbutton->group->res->wnd_text_color);278 if (rc != EOK)279 goto error;280 281 /* Label position */282 276 pos.x = center.x + rbutton_oframe_r + rbutton_label_margin; 283 277 pos.y = center.y; 284 278 285 279 gfx_text_fmt_init(&fmt); 280 fmt.color = rbutton->group->res->wnd_text_color; 286 281 fmt.halign = gfx_halign_left; 287 282 fmt.valign = gfx_valign_center; -
uspace/lib/ui/src/wdecor.c
rfe40b67 rb433f68 213 213 214 214 gfx_text_fmt_init(&fmt); 215 fmt.color = wdecor->active ? 216 wdecor->res->tbar_act_text_color : 217 wdecor->res->tbar_inact_text_color; 215 218 fmt.halign = gfx_halign_center; 216 219 fmt.valign = gfx_valign_center; … … 218 221 pos.x = (trect.p0.x + trect.p1.x) / 2; 219 222 pos.y = (trect.p0.y + trect.p1.y) / 2; 220 221 rc = gfx_set_color(wdecor->res->gc, wdecor->active ?222 wdecor->res->tbar_act_text_color :223 wdecor->res->tbar_inact_text_color);224 if (rc != EOK)225 return rc;226 223 227 224 rc = gfx_puttext(wdecor->res->font, &pos, &fmt, wdecor->caption);
Note:
See TracChangeset
for help on using the changeset viewer.