Changeset d63623f in mainline
- Timestamp:
- 2021-07-16T17:45:12Z (3 years ago)
- Branches:
- master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4afb6c9
- Parents:
- 61bf9dd9
- Location:
- uspace/lib
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/gfxfont/include/gfx/text.h
r61bf9dd9 rd63623f 1 1 /* 2 * Copyright (c) 202 0Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 46 46 extern errno_t gfx_puttext(gfx_font_t *, gfx_coord2_t *, gfx_text_fmt_t *, 47 47 const char *); 48 extern void gfx_text_start_pos(gfx_font_t *, gfx_coord2_t *, gfx_text_fmt_t *, 49 const char *, gfx_coord2_t *); 50 extern size_t gfx_text_find_pos(gfx_font_t *, gfx_coord2_t *, gfx_text_fmt_t *, 51 const char *, gfx_coord2_t *); 48 52 49 53 #endif -
uspace/lib/gfxfont/src/text.c
r61bf9dd9 rd63623f 1 1 /* 2 * Copyright (c) 202 0Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 167 167 } 168 168 169 /** Render text.169 /** Get text starting position. 170 170 * 171 171 * @param font Font … … 173 173 * @param fmt Text formatting 174 174 * @param str String 175 * @param spos Place to store starting position 176 * @return EOK on success or an error code 177 */ 178 void gfx_text_start_pos(gfx_font_t *font, gfx_coord2_t *pos, 179 gfx_text_fmt_t *fmt, const char *str, gfx_coord2_t *spos) 180 { 181 gfx_font_metrics_t fmetrics; 182 gfx_coord2_t cpos; 183 gfx_coord_t width; 184 185 *spos = *pos; 186 187 /* Adjust position for horizontal alignment */ 188 if (fmt->halign != gfx_halign_left) { 189 width = gfx_text_width(font, str); 190 switch (fmt->halign) { 191 case gfx_halign_center: 192 spos->x -= width / 2; 193 break; 194 case gfx_halign_right: 195 spos->x -= width - 1; 196 break; 197 default: 198 break; 199 } 200 } 201 202 /* Adjust position for vertical alignment */ 203 gfx_font_get_metrics(font, &fmetrics); 204 205 if (fmt->valign != gfx_valign_baseline) { 206 switch (fmt->valign) { 207 case gfx_valign_top: 208 spos->y += fmetrics.ascent; 209 break; 210 case gfx_valign_center: 211 spos->y += fmetrics.ascent / 2; 212 break; 213 case gfx_valign_bottom: 214 cpos.y -= fmetrics.descent; 215 break; 216 default: 217 break; 218 } 219 } 220 } 221 222 /** Render text. 223 * 224 * @param font Font 225 * @param pos Anchor position 226 * @param fmt Text formatting 227 * @param str String 175 228 * @return EOK on success or an error code 176 229 */ … … 178 231 gfx_text_fmt_t *fmt, const char *str) 179 232 { 180 gfx_font_metrics_t fmetrics;181 233 gfx_glyph_metrics_t gmetrics; 182 234 size_t stradv; … … 184 236 gfx_glyph_t *glyph; 185 237 gfx_coord2_t cpos; 186 gfx_coord_t width;187 238 errno_t rc; 188 239 189 cpos = *pos; 190 191 /* Adjust position for horizontal alignment */ 192 if (fmt->halign != gfx_halign_left) { 193 width = gfx_text_width(font, str); 194 switch (fmt->halign) { 195 case gfx_halign_center: 196 cpos.x -= width / 2; 197 break; 198 case gfx_halign_right: 199 cpos.x -= width - 1; 200 break; 201 default: 202 break; 203 } 204 } 205 206 /* Adjust position for vertical alignment */ 207 gfx_font_get_metrics(font, &fmetrics); 208 209 if (fmt->valign != gfx_valign_baseline) { 210 switch (fmt->valign) { 211 case gfx_valign_top: 212 cpos.y += fmetrics.ascent; 213 break; 214 case gfx_valign_center: 215 cpos.y += fmetrics.ascent / 2; 216 break; 217 case gfx_valign_bottom: 218 cpos.y -= fmetrics.descent; 219 break; 220 default: 221 break; 222 } 223 } 240 gfx_text_start_pos(font, pos, fmt, str, &cpos); 224 241 225 242 /* Text mode */ … … 252 269 } 253 270 271 /** Find character position in string by X coordinate. 272 * 273 * @param font Font 274 * @param pos Anchor position 275 * @param fmt Text formatting 276 * @param str String 277 * @param fpos Position for which we need to find offset 278 * 279 * @return Byte offset in @a str of character corresponding to position 280 * @a fpos. Note that the position is rounded, that is, 281 * if it is before the center of character A, it will return 282 * offset of A, if it is after the center of A, it will return 283 * offset of the following character. 284 */ 285 size_t gfx_text_find_pos(gfx_font_t *font, gfx_coord2_t *pos, 286 gfx_text_fmt_t *fmt, const char *str, gfx_coord2_t *fpos) 287 { 288 gfx_glyph_metrics_t gmetrics; 289 size_t stradv; 290 const char *cp; 291 gfx_glyph_t *glyph; 292 gfx_coord2_t cpos; 293 size_t off; 294 size_t strsize; 295 errno_t rc; 296 297 gfx_text_start_pos(font, pos, fmt, str, &cpos); 298 299 /* Text mode */ 300 if ((font->finfo->props.flags & gff_text_mode) != 0) { 301 off = 0; 302 strsize = str_size(str); 303 while (off < strsize) { 304 if (fpos->x <= cpos.x) 305 return off; 306 (void) str_decode(str, &off, strsize); 307 cpos.x++; 308 } 309 310 return off; 311 } 312 313 cp = str; 314 off = 0; 315 while (*cp != '\0') { 316 rc = gfx_font_search_glyph(font, cp, &glyph, &stradv); 317 if (rc != EOK) { 318 ++cp; 319 continue; 320 } 321 322 gfx_glyph_get_metrics(glyph, &gmetrics); 323 324 if (fpos->x < cpos.x + gmetrics.advance / 2) 325 return off; 326 327 cp += stradv; 328 off += stradv; 329 cpos.x += gmetrics.advance; 330 } 331 332 return off; 333 } 334 254 335 /** @} 255 336 */ -
uspace/lib/gfxfont/test/text.c
r61bf9dd9 rd63623f 30 30 #include <gfx/context.h> 31 31 #include <gfx/font.h> 32 #include <gfx/glyph.h> 32 33 #include <gfx/text.h> 33 34 #include <gfx/typeface.h> … … 144 145 gfx_typeface_destroy(tface); 145 146 gfx_color_delete(color); 147 148 rc = gfx_context_delete(gc); 149 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 150 } 151 152 /** gfx_text_start_pos() correctly computes text start position */ 153 PCUT_TEST(text_start_pos) 154 { 155 gfx_font_props_t props; 156 gfx_font_metrics_t metrics; 157 gfx_typeface_t *tface; 158 gfx_font_t *font; 159 gfx_context_t *gc; 160 gfx_color_t *color; 161 gfx_text_fmt_t fmt; 162 gfx_coord2_t pos; 163 test_gc_t tgc; 164 errno_t rc; 165 166 rc = gfx_context_new(&test_ops, (void *)&tgc, &gc); 167 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 168 169 rc = gfx_color_new_rgb_i16(0, 0, 0, &color); 170 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 171 172 rc = gfx_typeface_create(gc, &tface); 173 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 174 175 gfx_font_props_init(&props); 176 gfx_font_metrics_init(&metrics); 177 metrics.ascent = 10; // XXX 178 metrics.descent = 10; // XXX 179 rc = gfx_font_create(tface, &props, &metrics, &font); 180 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 181 182 gfx_text_fmt_init(&fmt); 183 fmt.color = color; 184 pos.x = 0; 185 pos.y = 0; 186 187 rc = gfx_puttext(font, &pos, &fmt, "Hello world!"); 188 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 189 190 gfx_font_close(font); 191 gfx_typeface_destroy(tface); 192 gfx_color_delete(color); 193 194 rc = gfx_context_delete(gc); 195 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 196 } 197 198 /** gfx_text_find_pos() finds position in text */ 199 PCUT_TEST(text_find_pos) 200 { 201 gfx_font_props_t props; 202 gfx_font_metrics_t metrics; 203 gfx_typeface_t *tface; 204 gfx_font_t *font; 205 gfx_glyph_metrics_t gmetrics; 206 gfx_glyph_t *glyph1; 207 gfx_glyph_t *glyph2; 208 gfx_context_t *gc; 209 gfx_text_fmt_t fmt; 210 gfx_coord2_t anchor; 211 gfx_coord2_t fpos; 212 size_t off; 213 test_gc_t tgc; 214 errno_t rc; 215 216 rc = gfx_context_new(&test_ops, (void *)&tgc, &gc); 217 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 218 219 rc = gfx_typeface_create(gc, &tface); 220 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 221 222 gfx_font_props_init(&props); 223 gfx_font_metrics_init(&metrics); 224 rc = gfx_font_create(tface, &props, &metrics, &font); 225 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 226 227 /* Need to create some glyphs with metrics */ 228 gfx_glyph_metrics_init(&gmetrics); 229 gmetrics.advance = 10; 230 231 rc = gfx_glyph_create(font, &gmetrics, &glyph1); 232 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 233 234 rc = gfx_glyph_set_pattern(glyph1, "A"); 235 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 236 237 gfx_glyph_metrics_init(&gmetrics); 238 gmetrics.advance = 1; 239 240 rc = gfx_glyph_create(font, &gmetrics, &glyph2); 241 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 242 243 rc = gfx_glyph_set_pattern(glyph2, "i"); 244 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 245 246 gfx_text_fmt_init(&fmt); 247 anchor.x = 10; 248 anchor.y = 0; 249 250 fpos.x = 9; 251 fpos.y = 0; 252 off = gfx_text_find_pos(font, &anchor, &fmt, "Aii", &fpos); 253 PCUT_ASSERT_INT_EQUALS(0, off); 254 255 fpos.x = 10; 256 fpos.y = 0; 257 off = gfx_text_find_pos(font, &anchor, &fmt, "Aii", &fpos); 258 PCUT_ASSERT_INT_EQUALS(0, off); 259 260 fpos.x = 11; 261 fpos.y = 0; 262 off = gfx_text_find_pos(font, &anchor, &fmt, "Aii", &fpos); 263 PCUT_ASSERT_INT_EQUALS(0, off); 264 265 fpos.x = 19; 266 fpos.y = 0; 267 off = gfx_text_find_pos(font, &anchor, &fmt, "Aii", &fpos); 268 PCUT_ASSERT_INT_EQUALS(1, off); 269 270 fpos.x = 20; 271 fpos.y = 0; 272 off = gfx_text_find_pos(font, &anchor, &fmt, "Aii", &fpos); 273 PCUT_ASSERT_INT_EQUALS(2, off); 274 275 fpos.x = 21; 276 fpos.y = 0; 277 off = gfx_text_find_pos(font, &anchor, &fmt, "Aii", &fpos); 278 PCUT_ASSERT_INT_EQUALS(3, off); 279 280 fpos.x = 22; 281 fpos.y = 0; 282 off = gfx_text_find_pos(font, &anchor, &fmt, "Aii", &fpos); 283 PCUT_ASSERT_INT_EQUALS(3, off); 284 285 gfx_glyph_destroy(glyph1); 286 gfx_glyph_destroy(glyph2); 287 288 gfx_font_close(font); 289 gfx_typeface_destroy(tface); 290 291 rc = gfx_context_delete(gc); 292 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 293 } 294 295 /** gfx_text_find_pos() finds position in text in text mode */ 296 PCUT_TEST(text_find_pos_text) 297 { 298 gfx_typeface_t *tface; 299 gfx_font_t *font; 300 gfx_context_t *gc; 301 test_gc_t tgc; 302 size_t off; 303 gfx_text_fmt_t fmt; 304 gfx_coord2_t anchor; 305 gfx_coord2_t fpos; 306 errno_t rc; 307 308 rc = gfx_context_new(&test_ops, (void *)&tgc, &gc); 309 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 310 311 rc = gfx_typeface_create(gc, &tface); 312 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 313 314 rc = gfx_font_create_textmode(tface, &font); 315 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 316 317 anchor.x = 10; 318 anchor.y = 0; 319 gfx_text_fmt_init(&fmt); 320 321 fpos.x = 9; 322 fpos.y = 0; 323 off = gfx_text_find_pos(font, &anchor, &fmt, "Abc", &fpos); 324 PCUT_ASSERT_INT_EQUALS(0, off); 325 326 fpos.x = 10; 327 fpos.y = 0; 328 off = gfx_text_find_pos(font, &anchor, &fmt, "Abc", &fpos); 329 PCUT_ASSERT_INT_EQUALS(0, off); 330 331 fpos.x = 11; 332 fpos.y = 0; 333 off = gfx_text_find_pos(font, &anchor, &fmt, "Abc", &fpos); 334 PCUT_ASSERT_INT_EQUALS(1, off); 335 336 fpos.x = 12; 337 fpos.y = 0; 338 off = gfx_text_find_pos(font, &anchor, &fmt, "Abc", &fpos); 339 PCUT_ASSERT_INT_EQUALS(2, off); 340 341 fpos.x = 13; 342 fpos.y = 0; 343 off = gfx_text_find_pos(font, &anchor, &fmt, "Abc", &fpos); 344 PCUT_ASSERT_INT_EQUALS(3, off); 345 346 fpos.x = 14; 347 fpos.y = 0; 348 off = gfx_text_find_pos(font, &anchor, &fmt, "Abc", &fpos); 349 PCUT_ASSERT_INT_EQUALS(3, off); 350 351 gfx_font_close(font); 352 gfx_typeface_destroy(tface); 146 353 147 354 rc = gfx_context_delete(gc); -
uspace/lib/ui/include/ui/paint.h
r61bf9dd9 rd63623f 45 45 extern errno_t ui_paint_bevel(gfx_context_t *, gfx_rect_t *, gfx_color_t *, 46 46 gfx_color_t *, gfx_coord_t, gfx_rect_t *); 47 extern void ui_paint_get_bevel_inside(gfx_context_t *, gfx_rect_t *, 48 gfx_coord_t, gfx_rect_t *); 47 49 extern errno_t ui_paint_inset_frame(ui_resource_t *, gfx_rect_t *, 50 gfx_rect_t *); 51 extern void ui_paint_get_inset_frame_inside(ui_resource_t *, gfx_rect_t *, 48 52 gfx_rect_t *); 49 53 extern errno_t ui_paint_outset_frame(ui_resource_t *, gfx_rect_t *, -
uspace/lib/ui/private/entry.h
r61bf9dd9 rd63623f 66 66 }; 67 67 68 /** Text entry geometry. 69 * 70 * Computed geometry of text entry elements. 71 */ 72 typedef struct { 73 /** Interior rectangle */ 74 gfx_rect_t interior_rect; 75 /** Text anchor position */ 76 gfx_coord2_t text_pos; 77 } ui_entry_geom_t; 78 68 79 extern errno_t ui_entry_insert_str(ui_entry_t *, const char *); 69 80 extern ui_evclaim_t ui_entry_key_press_unmod(ui_entry_t *, kbd_event_t *); 81 extern void ui_entry_get_geom(ui_entry_t *, ui_entry_geom_t *); 82 extern size_t ui_entry_find_pos(ui_entry_t *, gfx_coord2_t *); 70 83 extern void ui_entry_activate(ui_entry_t *); 71 84 extern void ui_entry_deactivate(ui_entry_t *); -
uspace/lib/ui/src/entry.c
r61bf9dd9 rd63623f 256 256 { 257 257 ui_resource_t *res; 258 ui_entry_geom_t geom; 258 259 gfx_text_fmt_t fmt; 259 260 gfx_coord2_t pos; 260 gfx_coord_t hpad;261 gfx_coord_t vpad;262 gfx_coord_t width;263 261 gfx_rect_t inside; 264 262 errno_t rc; … … 266 264 res = ui_window_get_res(entry->window); 267 265 268 if (res->textmode) { 269 hpad = ui_entry_hpad_text; 270 vpad = ui_entry_vpad_text; 271 } else { 272 hpad = ui_entry_hpad; 273 vpad = ui_entry_vpad; 274 } 266 ui_entry_get_geom(entry, &geom); 275 267 276 268 if (res->textmode == false) { … … 293 285 goto error; 294 286 295 width = gfx_text_width(res->font, entry->text); 296 297 switch (entry->halign) { 298 case gfx_halign_left: 299 case gfx_halign_justify: 300 pos.x = inside.p0.x + hpad; 301 break; 302 case gfx_halign_center: 303 pos.x = (inside.p0.x + inside.p1.x) / 2 - width / 2; 304 break; 305 case gfx_halign_right: 306 pos.x = inside.p1.x - hpad - 1 - width; 307 break; 308 } 309 310 pos.y = inside.p0.y + vpad; 287 pos = geom.text_pos; 311 288 312 289 gfx_text_fmt_init(&fmt); … … 347 324 error: 348 325 return rc; 326 } 327 328 /** Find position in text entry. 329 * 330 * @param entry Text entry 331 * @param fpos Position for which we need to find text offset 332 * @return Corresponding byte offset in entry text 333 */ 334 size_t ui_entry_find_pos(ui_entry_t *entry, gfx_coord2_t *fpos) 335 { 336 ui_resource_t *res; 337 ui_entry_geom_t geom; 338 gfx_text_fmt_t fmt; 339 340 res = ui_window_get_res(entry->window); 341 342 ui_entry_get_geom(entry, &geom); 343 344 gfx_text_fmt_init(&fmt); 345 fmt.halign = gfx_halign_left; 346 fmt.valign = gfx_valign_top; 347 348 return gfx_text_find_pos(res->font, &geom.text_pos, &fmt, 349 entry->text, fpos); 349 350 } 350 351 … … 567 568 568 569 if (gfx_pix_inside_rect(&pos, &entry->rect)) { 569 ui_entry_activate(entry); 570 entry->pos = ui_entry_find_pos(entry, &pos); 571 if (entry->active) 572 ui_entry_paint(entry); 573 else 574 ui_entry_activate(entry); 570 575 571 576 return ui_claimed; … … 604 609 } 605 610 611 /** Get text entry geometry. 612 * 613 * @param entry Text entry 614 * @param geom Structure to fill in with computed geometry 615 */ 616 void ui_entry_get_geom(ui_entry_t *entry, ui_entry_geom_t *geom) 617 { 618 gfx_coord_t hpad; 619 gfx_coord_t vpad; 620 gfx_coord_t width; 621 ui_resource_t *res; 622 623 res = ui_window_get_res(entry->window); 624 625 if (res->textmode) { 626 hpad = ui_entry_hpad_text; 627 vpad = ui_entry_vpad_text; 628 } else { 629 hpad = ui_entry_hpad; 630 vpad = ui_entry_vpad; 631 } 632 633 if (res->textmode == false) { 634 ui_paint_get_inset_frame_inside(res, &entry->rect, 635 &geom->interior_rect); 636 } else { 637 geom->interior_rect = entry->rect; 638 } 639 640 width = gfx_text_width(res->font, entry->text); 641 642 switch (entry->halign) { 643 case gfx_halign_left: 644 case gfx_halign_justify: 645 geom->text_pos.x = geom->interior_rect.p0.x + hpad; 646 break; 647 case gfx_halign_center: 648 geom->text_pos.x = (geom->interior_rect.p0.x + 649 geom->interior_rect.p1.x) / 2 - width / 2; 650 break; 651 case gfx_halign_right: 652 geom->text_pos.x = geom->interior_rect.p1.x - hpad - 1 - width; 653 break; 654 } 655 656 geom->text_pos.y = geom->interior_rect.p0.y + vpad; 657 } 658 606 659 /** Activate text entry. 607 660 * … … 618 671 619 672 entry->active = true; 620 entry->pos = str_size(entry->text);621 673 (void) ui_entry_paint(entry); 622 674 -
uspace/lib/ui/src/paint.c
r61bf9dd9 rd63623f 49 49 * @param thickness Bevel thickness in pixels 50 50 * @param inside Place to store rectangle of the interior or @c NULL 51 * @re utrn EOK on success or an error code51 * @return EOK on success or an error code 52 52 */ 53 53 errno_t ui_paint_bevel(gfx_context_t *gc, gfx_rect_t *rect, … … 107 107 } 108 108 109 if (inside != NULL) { 110 inside->p0.x = rect->p0.x + thickness; 111 inside->p0.y = rect->p0.y + thickness; 112 inside->p1.x = rect->p1.x - thickness; 113 inside->p1.y = rect->p1.y - thickness; 114 } 109 if (inside != NULL) 110 ui_paint_get_bevel_inside(gc, rect, thickness, inside); 115 111 116 112 return EOK; 117 113 error: 118 114 return rc; 115 } 116 117 /** Get bevel interior rectangle. 118 * 119 * Get the bevel interior rectangle without painting it. 120 * 121 * @param gc Graphic context 122 * @param rect Rectangle to paint into 123 * @param thickness Bevel thickness in pixels 124 * @param inside Place to store rectangle of the interior 125 */ 126 void ui_paint_get_bevel_inside(gfx_context_t *gc, gfx_rect_t *rect, 127 gfx_coord_t thickness, gfx_rect_t *inside) 128 { 129 inside->p0.x = rect->p0.x + thickness; 130 inside->p0.y = rect->p0.y + thickness; 131 inside->p1.x = rect->p1.x - thickness; 132 inside->p1.y = rect->p1.y - thickness; 119 133 } 120 134 … … 147 161 error: 148 162 return rc; 163 } 164 165 /** Get inset frame interior rectangle. 166 * 167 * This allows one to get the interior rectangle without actually painting 168 * the inset frame. 169 * 170 * @param resource UI resource 171 * @param rect Rectangle to paint onto 172 * @param inside Place to store inside rectangle or @c NULL 173 */ 174 void ui_paint_get_inset_frame_inside(ui_resource_t *resource, gfx_rect_t *rect, 175 gfx_rect_t *inside) 176 { 177 ui_paint_get_bevel_inside(resource->gc, rect, 2, inside); 149 178 } 150 179 -
uspace/lib/ui/test/paint.c
r61bf9dd9 rd63623f 96 96 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 97 97 98 rect.p0.x = 10; 99 rect.p0.y = 20; 100 rect.p1.x = 30; 101 rect.p1.y = 40; 102 98 103 /* Paint bevel with NULL 'inside' output parameter */ 99 104 rc = ui_paint_bevel(gc, &rect, color1, color2, 2, NULL); … … 110 115 } 111 116 117 /** Get bevel inside */ 118 PCUT_TEST(get_bevel_inside) 119 { 120 errno_t rc; 121 gfx_context_t *gc = NULL; 122 test_gc_t tgc; 123 gfx_rect_t rect; 124 gfx_rect_t inside; 125 126 memset(&tgc, 0, sizeof(tgc)); 127 rc = gfx_context_new(&ops, &tgc, &gc); 128 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 129 130 rect.p0.x = 10; 131 rect.p0.y = 20; 132 rect.p1.x = 30; 133 rect.p1.y = 40; 134 135 ui_paint_get_bevel_inside(gc, &rect, 2, &inside); 136 PCUT_ASSERT_INT_EQUALS(12, inside.p0.x); 137 PCUT_ASSERT_INT_EQUALS(22, inside.p0.y); 138 PCUT_ASSERT_INT_EQUALS(28, inside.p1.x); 139 PCUT_ASSERT_INT_EQUALS(38, inside.p1.y); 140 141 rc = gfx_context_delete(gc); 142 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 143 } 144 112 145 /** Paint inset frame */ 113 146 PCUT_TEST(inset_frame) … … 128 161 PCUT_ASSERT_NOT_NULL(resource); 129 162 163 rect.p0.x = 10; 164 rect.p0.y = 20; 165 rect.p1.x = 30; 166 rect.p1.y = 40; 167 130 168 /* Paint inset frame with NULL 'inside' output parameter */ 131 169 rc = ui_paint_inset_frame(resource, &rect, NULL); … … 135 173 rc = ui_paint_inset_frame(resource, &rect, &inside); 136 174 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 175 176 ui_resource_destroy(resource); 177 rc = gfx_context_delete(gc); 178 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 179 } 180 181 /** Get inset frame inside */ 182 PCUT_TEST(get_inset_frame_inside) 183 { 184 errno_t rc; 185 gfx_context_t *gc = NULL; 186 ui_resource_t *resource = NULL; 187 test_gc_t tgc; 188 gfx_rect_t rect; 189 gfx_rect_t inside; 190 191 memset(&tgc, 0, sizeof(tgc)); 192 rc = gfx_context_new(&ops, &tgc, &gc); 193 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 194 195 rc = ui_resource_create(gc, false, &resource); 196 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 197 PCUT_ASSERT_NOT_NULL(resource); 198 199 rect.p0.x = 10; 200 rect.p0.y = 20; 201 rect.p1.x = 30; 202 rect.p1.y = 40; 203 204 ui_paint_get_inset_frame_inside(resource, &rect, &inside); 205 PCUT_ASSERT_INT_EQUALS(12, inside.p0.x); 206 PCUT_ASSERT_INT_EQUALS(22, inside.p0.y); 207 PCUT_ASSERT_INT_EQUALS(28, inside.p1.x); 208 PCUT_ASSERT_INT_EQUALS(38, inside.p1.y); 137 209 138 210 ui_resource_destroy(resource);
Note:
See TracChangeset
for help on using the changeset viewer.