Changeset 297b1b3 in mainline
- Timestamp:
- 2021-08-13T15:58:50Z (3 years ago)
- Branches:
- master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 320abf3
- Parents:
- 307d4d2
- Location:
- uspace
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/uidemo/uidemo.c
r307d4d2 r297b1b3 752 752 (void *) &demo); 753 753 754 rect.p0.x = 15; 755 rect.p0.y = 220; 756 rect.p1.x = 140; 757 rect.p1.y = 240; 754 /* FIXME: Auto layout */ 755 if (ui_is_textmode(ui)) { 756 rect.p0.x = 20; 757 rect.p0.y = 14; 758 rect.p1.x = 40; 759 rect.p1.y = 15; 760 } else { 761 rect.p0.x = 15; 762 rect.p0.y = 220; 763 rect.p1.x = 140; 764 rect.p1.y = 240; 765 } 758 766 ui_rbutton_set_rect(demo.rbleft, &rect); 759 767 … … 771 779 } 772 780 773 rect.p0.x = 15; 774 rect.p0.y = 250; 775 rect.p1.x = 140; 776 rect.p1.y = 270; 781 /* FIXME: Auto layout */ 782 if (ui_is_textmode(ui)) { 783 rect.p0.x = 20; 784 rect.p0.y = 15; 785 rect.p1.x = 40; 786 rect.p1.y = 16; 787 } else { 788 rect.p0.x = 15; 789 rect.p0.y = 250; 790 rect.p1.x = 140; 791 rect.p1.y = 270; 792 } 777 793 ui_rbutton_set_rect(demo.rbcenter, &rect); 778 794 ui_rbutton_select(demo.rbcenter); … … 791 807 } 792 808 793 rect.p0.x = 15; 794 rect.p0.y = 280; 795 rect.p1.x = 140; 796 rect.p1.y = 300; 809 /* FIXME: Auto layout */ 810 if (ui_is_textmode(ui)) { 811 rect.p0.x = 20; 812 rect.p0.y = 16; 813 rect.p1.x = 40; 814 rect.p1.y = 17; 815 } else { 816 rect.p0.x = 15; 817 rect.p0.y = 280; 818 rect.p1.x = 140; 819 rect.p1.y = 300; 820 } 797 821 ui_rbutton_set_rect(demo.rbright, &rect); 798 822 -
uspace/lib/ui/private/rbutton.h
r307d4d2 r297b1b3 77 77 }; 78 78 79 extern errno_t ui_rbutton_paint_gfx(ui_rbutton_t *); 80 extern errno_t ui_rbutton_paint_text(ui_rbutton_t *); 81 79 82 #endif 80 83 -
uspace/lib/ui/src/rbutton.c
r307d4d2 r297b1b3 186 186 } 187 187 188 /** Paint radio button .188 /** Paint radio button in graphics mode. 189 189 * 190 190 * @param rbutton Radio button 191 191 * @return EOK on success or an error code 192 192 */ 193 errno_t ui_rbutton_paint (ui_rbutton_t *rbutton)193 errno_t ui_rbutton_paint_gfx(ui_rbutton_t *rbutton) 194 194 { 195 195 gfx_coord2_t pos; … … 202 202 center.y = rbutton->rect.p0.y + rbutton_oframe_r; 203 203 204 /* Paint r button frame */204 /* Paint radio button frame */ 205 205 206 206 rc = gfx_set_color(rbutton->group->res->gc, … … 244 244 goto error; 245 245 246 /* Paint r button interior */246 /* Paint radio button interior */ 247 247 depressed = rbutton->held && rbutton->inside; 248 248 … … 294 294 error: 295 295 return rc; 296 } 297 298 /** Paint radio button in text mode. 299 * 300 * @param rbutton Radio button 301 * @return EOK on success or an error code 302 */ 303 errno_t ui_rbutton_paint_text(ui_rbutton_t *rbutton) 304 { 305 gfx_coord2_t pos; 306 gfx_text_fmt_t fmt; 307 bool depressed; 308 errno_t rc; 309 310 /* Paint radio button */ 311 312 depressed = rbutton->held && rbutton->inside; 313 314 pos.x = rbutton->rect.p0.x; 315 pos.y = rbutton->rect.p0.y; 316 317 gfx_text_fmt_init(&fmt); 318 fmt.color = depressed ? rbutton->group->res->entry_act_bg_color : 319 rbutton->group->res->wnd_text_color; 320 fmt.halign = gfx_halign_left; 321 fmt.valign = gfx_valign_top; 322 323 rc = gfx_puttext(rbutton->group->res->font, &pos, &fmt, 324 rbutton->group->selected == rbutton ? "(*)" : "( )"); 325 if (rc != EOK) 326 goto error; 327 328 /* Paint radio button label */ 329 330 pos.x += 4; 331 332 gfx_text_fmt_init(&fmt); 333 fmt.color = rbutton->group->res->wnd_text_color; 334 fmt.halign = gfx_halign_left; 335 fmt.valign = gfx_valign_center; 336 337 rc = gfx_puttext(rbutton->group->res->font, &pos, &fmt, 338 rbutton->caption); 339 if (rc != EOK) 340 goto error; 341 342 rc = gfx_update(rbutton->group->res->gc); 343 if (rc != EOK) 344 goto error; 345 346 return EOK; 347 error: 348 return rc; 349 } 350 351 /** Paint radio button. 352 * 353 * @param rbutton Radio button 354 * @return EOK on success or an error code 355 */ 356 errno_t ui_rbutton_paint(ui_rbutton_t *rbutton) 357 { 358 if (rbutton->group->res->textmode) 359 return ui_rbutton_paint_text(rbutton); 360 else 361 return ui_rbutton_paint_gfx(rbutton); 296 362 } 297 363 -
uspace/lib/ui/test/checkbox.c
r307d4d2 r297b1b3 194 194 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 195 195 196 rc = ui_resource_create(gc, true, &resource);196 rc = ui_resource_create(gc, false, &resource); 197 197 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 198 198 PCUT_ASSERT_NOT_NULL(resource); -
uspace/lib/ui/test/rbutton.c
r307d4d2 r297b1b3 166 166 } 167 167 168 /** Paint radio button */169 PCUT_TEST(paint )168 /** Paint radio button in graphics mode */ 169 PCUT_TEST(paint_gfx) 170 170 { 171 171 errno_t rc; … … 190 190 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 191 191 192 rc = ui_rbutton_paint(rbutton); 192 rc = ui_rbutton_paint_gfx(rbutton); 193 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 194 195 ui_rbutton_destroy(rbutton); 196 ui_rbutton_group_destroy(group); 197 ui_resource_destroy(resource); 198 199 rc = gfx_context_delete(gc); 200 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 201 } 202 203 /** Paint radio button in text mode */ 204 PCUT_TEST(paint_text) 205 { 206 errno_t rc; 207 gfx_context_t *gc = NULL; 208 test_gc_t tgc; 209 ui_rbutton_group_t *group = NULL; 210 ui_resource_t *resource = NULL; 211 ui_rbutton_t *rbutton; 212 213 memset(&tgc, 0, sizeof(tgc)); 214 rc = gfx_context_new(&ops, &tgc, &gc); 215 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 216 217 rc = ui_resource_create(gc, false, &resource); 218 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 219 PCUT_ASSERT_NOT_NULL(resource); 220 221 rc = ui_rbutton_group_create(resource, &group); 222 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 223 224 rc = ui_rbutton_create(group, "Hello", NULL, &rbutton); 225 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 226 227 rc = ui_rbutton_paint_text(rbutton); 193 228 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 194 229
Note:
See TracChangeset
for help on using the changeset viewer.