Changeset 901b302 in mainline
- Timestamp:
- 2022-11-18T19:45:24Z (22 months ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f2d4a46
- Parents:
- a130983
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/gfxdemo/gfxdemo.c
ra130983 r901b302 244 244 245 245 pos.x = w / 2; 246 pos.y = h - 1;246 pos.y = h; 247 247 rc = gfx_puttext(&pos, &fmt, text); 248 248 if (rc != EOK) { … … 801 801 } 802 802 803 /** Run text abbreviation demo on a graphic context. 804 * 805 * @param gc Graphic context 806 * @param w Width 807 * @param h Height 808 */ 809 static errno_t demo_text_abbr(gfx_context_t *gc, gfx_coord_t w, gfx_coord_t h) 810 { 811 gfx_color_t *color = NULL; 812 gfx_rect_t rect; 813 gfx_coord2_t pos; 814 gfx_text_fmt_t fmt; 815 int i; 816 errno_t rc; 817 818 if (quit) 819 return EOK; 820 821 rc = demo_begin(gc, w, h, "Text abbreviation"); 822 if (rc != EOK) 823 goto error; 824 825 for (i = 0; i < 11; i++) { 826 827 rc = gfx_color_new_rgb_i16(0, 0, 0x8000, &color); 828 if (rc != EOK) 829 goto error; 830 831 rc = gfx_set_color(gc, color); 832 if (rc != EOK) 833 goto error; 834 835 rect.p0.x = w / 20; 836 rect.p0.y = (2 + 2 * i) * h / 25; 837 rect.p1.x = w - w / 20 - w * i / 12; 838 rect.p1.y = (3 + 2 * i) * h / 25; 839 840 rc = gfx_fill_rect(gc, &rect); 841 if (rc != EOK) 842 goto error; 843 844 gfx_color_delete(color); 845 846 if (demo_is_text(w, h)) { 847 rc = gfx_color_new_ega(0x1f, &color); 848 if (rc != EOK) 849 goto error; 850 } else { 851 rc = gfx_color_new_rgb_i16(0xffff, 0xffff, 0xffff, 852 &color); 853 if (rc != EOK) 854 goto error; 855 } 856 857 gfx_text_fmt_init(&fmt); 858 fmt.font = font; 859 fmt.color = color; 860 fmt.abbreviate = true; 861 fmt.width = rect.p1.x - rect.p0.x; 862 863 pos.x = rect.p0.x; 864 pos.y = rect.p0.y; 865 rc = gfx_puttext(&pos, &fmt, 866 "The quick brow fox jumps over the lazy dog!"); 867 if (rc != EOK) { 868 printf("Error rendering text.\n"); 869 goto error; 870 } 871 } 872 873 for (i = 0; i < 10; i++) { 874 fibril_usleep(500 * 1000); 875 if (quit) 876 break; 877 } 878 879 return EOK; 880 error: 881 return rc; 882 } 883 803 884 /** Run clipping demo on a graphic context. 804 885 * … … 933 1014 934 1015 rc = demo_text(gc, w, h); 1016 if (rc != EOK) 1017 goto error; 1018 1019 rc = demo_text_abbr(gc, w, h); 935 1020 if (rc != EOK) 936 1021 goto error;
Note:
See TracChangeset
for help on using the changeset viewer.