Changeset 58a67050 in mainline
- Timestamp:
- 2020-10-21T22:26:33Z (4 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 08a79303
- Parents:
- a2f173b
- Location:
- uspace
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/uidemo/uidemo.c
ra2f173b r58a67050 259 259 rect.p1.y = 50; 260 260 ui_label_set_rect(demo.label, &rect); 261 ui_label_set_halign(demo.label, gfx_halign_center); 261 262 262 263 rc = ui_pbutton_create(ui_res, "Confirm", &demo.pb1); -
uspace/lib/ui/include/ui/label.h
ra2f173b r58a67050 39 39 #include <errno.h> 40 40 #include <gfx/coord.h> 41 #include <gfx/text.h> 41 42 #include <types/ui/label.h> 42 43 #include <types/ui/resource.h> … … 46 47 extern void ui_label_destroy(ui_label_t *); 47 48 extern void ui_label_set_rect(ui_label_t *, gfx_rect_t *); 49 extern void ui_label_set_halign(ui_label_t *, gfx_halign_t); 48 50 extern errno_t ui_label_set_text(ui_label_t *, const char *); 49 51 extern errno_t ui_label_paint(ui_label_t *); -
uspace/lib/ui/private/label.h
ra2f173b r58a67050 39 39 40 40 #include <gfx/coord.h> 41 #include <gfx/text.h> 41 42 42 43 /** Actual structure of label. … … 49 50 /** Label rectangle */ 50 51 gfx_rect_t rect; 52 /** Horizontal alignment */ 53 gfx_halign_t halign; 51 54 /** Text */ 52 55 char *text; -
uspace/lib/ui/src/label.c
ra2f173b r58a67050 68 68 69 69 label->res = resource; 70 label->halign = gfx_halign_left; 70 71 *rlabel = label; 71 72 return EOK; … … 92 93 { 93 94 label->rect = *rect; 95 } 96 97 /** Set label horizontal text alignment. 98 * 99 * @param label Label 100 * @param halign Horizontal alignment 101 */ 102 void ui_label_set_halign(ui_label_t *label, gfx_halign_t halign) 103 { 104 label->halign = halign; 94 105 } 95 106 … … 135 146 goto error; 136 147 137 pos = label->rect.p0; 148 switch (label->halign) { 149 case gfx_halign_left: 150 case gfx_halign_justify: 151 pos.x = label->rect.p0.x; 152 break; 153 case gfx_halign_center: 154 pos.x = (label->rect.p0.x + label->rect.p1.x) / 2; 155 break; 156 case gfx_halign_right: 157 pos.y = label->rect.p1.x; 158 break; 159 } 160 161 pos.y = label->rect.p0.y; 138 162 139 163 gfx_text_fmt_init(&fmt); 140 fmt.halign = gfx_halign_left;164 fmt.halign = label->halign; 141 165 fmt.valign = gfx_valign_top; 142 166 -
uspace/lib/ui/test/label.c
ra2f173b r58a67050 121 121 } 122 122 123 /** Set button text horizontal alignment sets internal field */ 124 PCUT_TEST(set_halign) 125 { 126 ui_label_t *label; 127 errno_t rc; 128 129 rc = ui_label_create(NULL, "Hello", &label); 130 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 131 132 ui_label_set_halign(label, gfx_halign_left); 133 PCUT_ASSERT_EQUALS(gfx_halign_left, label->halign); 134 ui_label_set_halign(label, gfx_halign_center); 135 PCUT_ASSERT_EQUALS(gfx_halign_center, label->halign); 136 137 ui_label_destroy(label); 138 } 139 123 140 /** Set button rectangle sets internal field */ 124 141 PCUT_TEST(set_text)
Note:
See TracChangeset
for help on using the changeset viewer.