Changeset a0aeb8f in mainline
- Timestamp:
- 2021-09-05T08:11:37Z (3 years ago)
- Branches:
- master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8ce56a6
- Parents:
- ab3bfc1
- git-author:
- Jiri Svoboda <jiri@…> (2021-09-05 08:09:56)
- git-committer:
- Jiri Svoboda <jiri@…> (2021-09-05 08:11:37)
- Location:
- uspace
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/hello/hello.c
rab3bfc1 ra0aeb8f 1 1 /* 2 * Copyright (c) 202 0Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 80 80 ui_wnd_params_init(¶ms); 81 81 params.caption = "Hello World"; 82 params.rect.p0.x = 0; 83 params.rect.p0.y = 0; 84 params.rect.p1.x = 200; 85 params.rect.p1.y = 60; 82 if (ui_is_textmode(ui)) { 83 params.rect.p0.x = 0; 84 params.rect.p0.y = 0; 85 params.rect.p1.x = 24; 86 params.rect.p1.y = 5; 87 } else { 88 params.rect.p0.x = 0; 89 params.rect.p0.y = 0; 90 params.rect.p1.x = 200; 91 params.rect.p1.y = 60; 92 } 86 93 87 94 memset((void *) &hello, 0, sizeof(hello)); … … 111 118 } 112 119 113 rect.p0.x = 10; 114 rect.p0.y = 35; 115 rect.p1.x = 190; 116 rect.p1.y = 50; 120 ui_window_get_app_rect(window, &rect); 117 121 ui_label_set_rect(hello.label, &rect); 118 122 ui_label_set_halign(hello.label, gfx_halign_center); 123 ui_label_set_valign(hello.label, gfx_valign_center); 119 124 120 125 rc = ui_fixed_add(hello.fixed, ui_label_ctl(hello.label)); -
uspace/lib/gfxfont/src/text.c
rab3bfc1 ra0aeb8f 178 178 { 179 179 gfx_font_metrics_t fmetrics; 180 gfx_coord2_t cpos;181 180 gfx_coord_t width; 182 181 … … 210 209 break; 211 210 case gfx_valign_bottom: 212 cpos.y -= fmetrics.descent + 1;211 spos->y -= fmetrics.descent + 1; 213 212 break; 214 213 default: -
uspace/lib/ui/include/ui/label.h
rab3bfc1 ra0aeb8f 1 1 /* 2 * Copyright (c) 202 0Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 50 50 extern void ui_label_set_rect(ui_label_t *, gfx_rect_t *); 51 51 extern void ui_label_set_halign(ui_label_t *, gfx_halign_t); 52 extern void ui_label_set_valign(ui_label_t *, gfx_valign_t); 52 53 extern errno_t ui_label_set_text(ui_label_t *, const char *); 53 54 extern errno_t ui_label_paint(ui_label_t *); -
uspace/lib/ui/private/label.h
rab3bfc1 ra0aeb8f 1 1 /* 2 * Copyright (c) 202 0Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 54 54 /** Horizontal alignment */ 55 55 gfx_halign_t halign; 56 /** Vertical alignment */ 57 gfx_valign_t valign; 56 58 /** Text */ 57 59 char *text; -
uspace/lib/ui/src/label.c
rab3bfc1 ra0aeb8f 136 136 } 137 137 138 /** Set label vertical text alignment. 139 * 140 * @param label Label 141 * @param valign Vertical alignment 142 */ 143 void ui_label_set_valign(ui_label_t *label, gfx_valign_t valign) 144 { 145 label->valign = valign; 146 } 147 138 148 /** Set label text. 139 149 * … … 190 200 } 191 201 192 pos.y = label->rect.p0.y; 202 switch (label->valign) { 203 case gfx_valign_top: 204 pos.y = label->rect.p0.y; 205 break; 206 case gfx_valign_center: 207 pos.y = (label->rect.p0.y + label->rect.p1.y) / 2; 208 break; 209 case gfx_valign_bottom: 210 pos.y = label->rect.p1.y; 211 break; 212 case gfx_valign_baseline: 213 return EINVAL; 214 } 193 215 194 216 gfx_text_fmt_init(&fmt);
Note:
See TracChangeset
for help on using the changeset viewer.