Changeset 1026cc4 in mainline
- Timestamp:
- 2022-03-20T19:51:09Z (3 years ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 26c90dd
- Parents:
- 5ef85c0
- Location:
- uspace
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/uidemo/uidemo.c
r5ef85c0 r1026cc4 89 89 static void scrollbar_up(ui_scrollbar_t *, void *); 90 90 static void scrollbar_down(ui_scrollbar_t *, void *); 91 static void scrollbar_page_up(ui_scrollbar_t *, void *); 92 static void scrollbar_page_down(ui_scrollbar_t *, void *); 91 93 static void scrollbar_moved(ui_scrollbar_t *, void *, gfx_coord_t); 92 94 … … 94 96 .up = scrollbar_up, 95 97 .down = scrollbar_down, 98 .page_up = scrollbar_page_up, 99 .page_down = scrollbar_page_down, 96 100 .moved = scrollbar_moved 97 101 }; … … 232 236 static void scrollbar_up(ui_scrollbar_t *scrollbar, void *arg) 233 237 { 234 ui_demo_t *demo = (ui_demo_t *) arg;235 238 gfx_coord_t pos; 236 char *str;237 errno_t rc;238 int rv;239 239 240 240 pos = ui_scrollbar_get_pos(scrollbar); … … 242 242 243 243 pos = ui_scrollbar_get_pos(scrollbar); 244 245 rv = asprintf(&str, "Scrollbar: %d of %d", (int) pos, 246 ui_scrollbar_move_length(scrollbar)); 247 if (rv < 0) { 248 printf("Out of memory.\n"); 249 return; 250 } 251 252 rc = ui_entry_set_text(demo->entry, str); 253 if (rc != EOK) 254 printf("Error changing entry text.\n"); 255 (void) ui_entry_paint(demo->entry); 256 257 free(str); 244 scrollbar_moved(scrollbar, arg, pos); 258 245 } 259 246 … … 265 252 static void scrollbar_down(ui_scrollbar_t *scrollbar, void *arg) 266 253 { 267 ui_demo_t *demo = (ui_demo_t *) arg;268 254 gfx_coord_t pos; 269 char *str;270 errno_t rc;271 int rv;272 255 273 256 pos = ui_scrollbar_get_pos(scrollbar); … … 275 258 276 259 pos = ui_scrollbar_get_pos(scrollbar); 277 278 rv = asprintf(&str, "Scrollbar: %d of %d", (int) pos, 279 ui_scrollbar_move_length(scrollbar)); 280 if (rv < 0) { 281 printf("Out of memory.\n"); 282 return; 283 } 284 285 rc = ui_entry_set_text(demo->entry, str); 286 if (rc != EOK) 287 printf("Error changing entry text.\n"); 288 (void) ui_entry_paint(demo->entry); 289 290 free(str); 260 scrollbar_moved(scrollbar, arg, pos); 261 } 262 263 /** Scrollbar page up event. 264 * 265 * @param scrollbar Scrollbar 266 * @param arg Argument (demo) 267 */ 268 static void scrollbar_page_up(ui_scrollbar_t *scrollbar, void *arg) 269 { 270 gfx_coord_t pos; 271 272 pos = ui_scrollbar_get_pos(scrollbar); 273 ui_scrollbar_set_pos(scrollbar, pos - 274 ui_scrollbar_through_length(scrollbar) / 4); 275 276 pos = ui_scrollbar_get_pos(scrollbar); 277 scrollbar_moved(scrollbar, arg, pos); 278 } 279 280 /** Scrollbar page down event. 281 * 282 * @param scrollbar Scrollbar 283 * @param arg Argument (demo) 284 */ 285 static void scrollbar_page_down(ui_scrollbar_t *scrollbar, void *arg) 286 { 287 gfx_coord_t pos; 288 289 pos = ui_scrollbar_get_pos(scrollbar); 290 ui_scrollbar_set_pos(scrollbar, pos + 291 ui_scrollbar_through_length(scrollbar) / 4); 292 293 pos = ui_scrollbar_get_pos(scrollbar); 294 scrollbar_moved(scrollbar, arg, pos); 291 295 } 292 296 -
uspace/lib/ui/include/ui/scrollbar.h
r5ef85c0 r1026cc4 57 57 extern void ui_scrollbar_set_thumb_length(ui_scrollbar_t *, gfx_coord_t); 58 58 extern void ui_scrollbar_set_pos(ui_scrollbar_t *, gfx_coord_t); 59 extern void ui_scrollbar_press(ui_scrollbar_t *, gfx_coord2_t *); 59 extern void ui_scrollbar_thumb_press(ui_scrollbar_t *, gfx_coord2_t *); 60 extern void ui_scrollbar_up_through_press(ui_scrollbar_t *); 61 extern void ui_scrollbar_down_through_press(ui_scrollbar_t *); 60 62 extern void ui_scrollbar_release(ui_scrollbar_t *, gfx_coord2_t *); 61 63 extern void ui_scrollbar_update(ui_scrollbar_t *, gfx_coord2_t *); 62 64 extern void ui_scrollbar_up(ui_scrollbar_t *); 63 65 extern void ui_scrollbar_down(ui_scrollbar_t *); 66 extern void ui_scrollbar_page_up(ui_scrollbar_t *); 67 extern void ui_scrollbar_page_down(ui_scrollbar_t *); 64 68 extern void ui_scrollbar_moved(ui_scrollbar_t *, gfx_coord_t); 65 69 extern ui_evclaim_t ui_scrollbar_pos_event(ui_scrollbar_t *, pos_event_t *); -
uspace/lib/ui/private/resource.h
r5ef85c0 r1026cc4 116 116 /** Scrollbar through color */ 117 117 gfx_color_t *sbar_through_color; 118 /** Scrollbar active through color */ 119 gfx_color_t *sbar_act_through_color; 118 120 119 121 /** Expose callback or @c NULL */ -
uspace/lib/ui/private/scrollbar.h
r5ef85c0 r1026cc4 63 63 struct ui_pbutton *btn_down; 64 64 /** Thumb is currently held down */ 65 bool held; 65 bool thumb_held; 66 /** Up through is currently held down */ 67 bool up_through_held; 68 /** Down through is currently held down */ 69 bool down_through_held; 66 70 /** Position where thumb was pressed */ 67 71 gfx_coord2_t press_pos; … … 81 85 /** Through rectangle */ 82 86 gfx_rect_t through_rect; 87 /** Up through rectangle */ 88 gfx_rect_t up_through_rect; 83 89 /** Thumb rectangle */ 84 90 gfx_rect_t thumb_rect; 91 /** Down through rectangle */ 92 gfx_rect_t down_through_rect; 85 93 /** Down button rectangle */ 86 94 gfx_rect_t down_btn_rect; -
uspace/lib/ui/src/resource.c
r5ef85c0 r1026cc4 85 85 gfx_color_t *entry_sel_text_bg_color = NULL; 86 86 gfx_color_t *sbar_through_color = NULL; 87 gfx_color_t *sbar_act_through_color = NULL; 87 88 errno_t rc; 88 89 … … 211 212 rc = gfx_color_new_rgb_i16(0xe4e4, 0xe4e4, 0xe4e4, 212 213 &sbar_through_color); 214 if (rc != EOK) 215 goto error; 216 217 rc = gfx_color_new_rgb_i16(0x5858, 0x5858, 0x5858, 218 &sbar_act_through_color); 213 219 if (rc != EOK) 214 220 goto error; … … 248 254 249 255 resource->sbar_through_color = sbar_through_color; 256 resource->sbar_act_through_color = sbar_act_through_color; 250 257 251 258 *rresource = resource; … … 306 313 if (sbar_through_color != NULL) 307 314 gfx_color_delete(sbar_through_color); 315 if (sbar_act_through_color != NULL) 316 gfx_color_delete(sbar_act_through_color); 308 317 309 318 if (tface != NULL) … … 350 359 gfx_color_t *entry_act_bg_color = NULL; 351 360 gfx_color_t *sbar_through_color = NULL; 361 gfx_color_t *sbar_act_through_color = NULL; 352 362 errno_t rc; 353 363 … … 462 472 463 473 rc = gfx_color_new_ega(0x07, &sbar_through_color); 474 if (rc != EOK) 475 goto error; 476 477 rc = gfx_color_new_ega(0x07, &sbar_act_through_color); 464 478 if (rc != EOK) 465 479 goto error; … … 499 513 500 514 resource->sbar_through_color = sbar_through_color; 515 resource->sbar_act_through_color = sbar_act_through_color; 501 516 502 517 *rresource = resource; … … 556 571 if (sbar_through_color != NULL) 557 572 gfx_color_delete(sbar_through_color); 573 if (sbar_act_through_color != NULL) 574 gfx_color_delete(sbar_act_through_color); 558 575 559 576 if (tface != NULL) … … 615 632 616 633 gfx_color_delete(resource->sbar_through_color); 634 gfx_color_delete(resource->sbar_act_through_color); 617 635 618 636 gfx_font_close(resource->font); -
uspace/lib/ui/src/scrollbar.c
r5ef85c0 r1026cc4 32 32 /** 33 33 * @file Scrollbar 34 * 35 * Anatomy of a horizontal scrollbar: 36 * 37 * Up Down 38 * through through 39 * +---+------+--------+---------+---+ 40 * | < | | ||| | | > | 41 * +---+------+--------+---------+---+ 42 * Up Thumb Down 43 * button button 44 * 45 * +-------- Through --------+ 46 * 47 * Scrollbar uses the same terminology whether it is running in horizontal 48 * or vertical mode, in horizontal mode up means left, down means right 49 * (i.e. lower and higher coordinates, respectively). 50 * 51 * The thumb can be dragged to a specific position, resulting in a move 52 * event. The up/down buttons generate up/down events. Pressing a mouse 53 * button on the up/down through generates page up / page down events. 54 * 55 * TODO: Up/down buttons/throughs should be equipped with an autorepeat 56 * mechanism: after an initial delay, start repeating at a preset rate. 34 57 */ 35 58 … … 391 414 goto error; 392 415 393 /* Paint scrollbar through */ 394 416 /* Paint scrollbar up through */ 395 417 rc = gfx_set_color(scrollbar->res->gc, 418 scrollbar->up_through_held ? 419 scrollbar->res->sbar_act_through_color : 396 420 scrollbar->res->sbar_through_color); 397 421 if (rc != EOK) 398 422 goto error; 399 423 400 rc = gfx_fill_rect(scrollbar->res->gc, &geom.through_rect); 424 rc = gfx_fill_rect(scrollbar->res->gc, &geom.up_through_rect); 425 if (rc != EOK) 426 goto error; 427 428 /* Paint scrollbar down through */ 429 430 rc = gfx_set_color(scrollbar->res->gc, 431 scrollbar->down_through_held ? 432 scrollbar->res->sbar_act_through_color : 433 scrollbar->res->sbar_through_color); 434 if (rc != EOK) 435 goto error; 436 437 rc = gfx_fill_rect(scrollbar->res->gc, &geom.down_through_rect); 401 438 if (rc != EOK) 402 439 goto error; … … 582 619 geom->thumb_rect.p1.y = orect.p1.y; 583 620 621 /* Up through */ 622 geom->up_through_rect.p0 = geom->through_rect.p0; 623 geom->up_through_rect.p1.x = geom->thumb_rect.p0.x; 624 geom->up_through_rect.p1.y = geom->through_rect.p1.y; 625 626 /* Down through */ 627 geom->down_through_rect.p0.x = geom->thumb_rect.p1.x; 628 geom->down_through_rect.p0.y = geom->through_rect.p0.y; 629 geom->down_through_rect.p1 = geom->through_rect.p1; 630 584 631 /* Down button */ 585 632 geom->down_btn_rect.p0.x = geom->through_rect.p1.x; … … 618 665 } 619 666 620 /** Press down scrollbar .667 /** Press down scrollbar thumb. 621 668 * 622 669 * @param scrollbar Scrollbar 623 670 * @param pos Pointer position 624 671 */ 625 void ui_scrollbar_ press(ui_scrollbar_t *scrollbar, gfx_coord2_t *pos)626 { 627 if (scrollbar-> held)672 void ui_scrollbar_thumb_press(ui_scrollbar_t *scrollbar, gfx_coord2_t *pos) 673 { 674 if (scrollbar->thumb_held) 628 675 return; 629 676 630 scrollbar-> held = true;677 scrollbar->thumb_held = true; 631 678 scrollbar->press_pos = *pos; 632 679 scrollbar->last_pos = scrollbar->pos; … … 635 682 } 636 683 684 /** Press down scrollbar up through. 685 * 686 * @param scrollbar Scrollbar 687 */ 688 void ui_scrollbar_up_through_press(ui_scrollbar_t *scrollbar) 689 { 690 if (scrollbar->up_through_held) 691 return; 692 693 scrollbar->up_through_held = true; 694 (void) ui_scrollbar_paint(scrollbar); 695 696 ui_scrollbar_page_up(scrollbar); 697 } 698 699 /** Press down scrollbar down through. 700 * 701 * @param scrollbar Scrollbar 702 */ 703 void ui_scrollbar_down_through_press(ui_scrollbar_t *scrollbar) 704 { 705 if (scrollbar->down_through_held) 706 return; 707 708 scrollbar->down_through_held = true; 709 (void) ui_scrollbar_paint(scrollbar); 710 711 ui_scrollbar_page_down(scrollbar); 712 } 713 637 714 /** Release scrollbar. 638 715 * … … 642 719 void ui_scrollbar_release(ui_scrollbar_t *scrollbar, gfx_coord2_t *pos) 643 720 { 644 if (!scrollbar->held) 645 return; 646 647 ui_scrollbar_update(scrollbar, pos); 648 scrollbar->held = false; 721 if (scrollbar->thumb_held) { 722 ui_scrollbar_update(scrollbar, pos); 723 scrollbar->thumb_held = false; 724 } 725 726 if (scrollbar->up_through_held || scrollbar->down_through_held) { 727 scrollbar->up_through_held = false; 728 scrollbar->down_through_held = false; 729 (void) ui_scrollbar_paint(scrollbar); 730 } 649 731 } 650 732 … … 658 740 gfx_coord_t spos; 659 741 660 if (scrollbar-> held) {742 if (scrollbar->thumb_held) { 661 743 spos = scrollbar->last_pos + pos->x - scrollbar->press_pos.x; 662 744 ui_scrollbar_set_pos(scrollbar, spos); … … 680 762 void ui_scrollbar_down(ui_scrollbar_t *scrollbar) 681 763 { 682 if (scrollbar->cb != NULL && scrollbar->cb-> up!= NULL)764 if (scrollbar->cb != NULL && scrollbar->cb->down != NULL) 683 765 scrollbar->cb->down(scrollbar, scrollbar->arg); 766 } 767 768 /** Scrollbar up through was pressed. 769 * 770 * @param scrollbar Scrollbar 771 */ 772 void ui_scrollbar_page_up(ui_scrollbar_t *scrollbar) 773 { 774 if (scrollbar->cb != NULL && scrollbar->cb->page_up != NULL) 775 scrollbar->cb->page_up(scrollbar, scrollbar->arg); 776 } 777 778 /** Scrollbar down through was pressed. 779 * 780 * @param scrollbar Scrollbar 781 */ 782 void ui_scrollbar_page_down(ui_scrollbar_t *scrollbar) 783 { 784 if (scrollbar->cb != NULL && scrollbar->cb->page_down != NULL) 785 scrollbar->cb->page_down(scrollbar, scrollbar->arg); 684 786 } 685 787 … … 703 805 { 704 806 gfx_coord2_t pos; 705 gfx_rect_t rect;706 807 ui_evclaim_t claimed; 808 ui_scrollbar_geom_t geom; 809 810 ui_scrollbar_get_geom(scrollbar, &geom); 707 811 708 812 pos.x = event->hpos; … … 719 823 switch (event->type) { 720 824 case POS_PRESS: 721 ui_scrollbar_thumb_rect(scrollbar, &rect); 722 if (gfx_pix_inside_rect(&pos, &rect)) { 723 ui_scrollbar_press(scrollbar, &pos); 724 scrollbar->press_pos = pos; 825 if (gfx_pix_inside_rect(&pos, &geom.thumb_rect)) { 826 ui_scrollbar_thumb_press(scrollbar, &pos); 827 return ui_claimed; 828 } 829 if (gfx_pix_inside_rect(&pos, &geom.up_through_rect)) { 830 ui_scrollbar_up_through_press(scrollbar); 831 return ui_claimed; 832 } 833 if (gfx_pix_inside_rect(&pos, &geom.down_through_rect)) { 834 ui_scrollbar_down_through_press(scrollbar); 725 835 return ui_claimed; 726 836 } 727 837 break; 728 838 case POS_RELEASE: 729 if (scrollbar->held) { 839 if (scrollbar->thumb_held || scrollbar->up_through_held || 840 scrollbar->down_through_held) { 730 841 ui_scrollbar_release(scrollbar, &pos); 731 842 return ui_claimed; -
uspace/lib/ui/test/scrollbar.c
r5ef85c0 r1026cc4 65 65 static void test_scrollbar_up(ui_scrollbar_t *, void *); 66 66 static void test_scrollbar_down(ui_scrollbar_t *, void *); 67 static void test_scrollbar_page_up(ui_scrollbar_t *, void *); 68 static void test_scrollbar_page_down(ui_scrollbar_t *, void *); 67 69 static void test_scrollbar_moved(ui_scrollbar_t *, void *, gfx_coord_t); 68 70 … … 70 72 .up = test_scrollbar_up, 71 73 .down = test_scrollbar_down, 74 .page_up = test_scrollbar_page_up, 75 .page_down = test_scrollbar_page_down, 72 76 .moved = test_scrollbar_moved 73 77 }; … … 96 100 bool up; 97 101 bool down; 102 bool page_up; 103 bool page_down; 98 104 bool moved; 99 105 gfx_coord_t pos; … … 295 301 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 296 302 297 PCUT_ASSERT_FALSE(scrollbar-> held);303 PCUT_ASSERT_FALSE(scrollbar->thumb_held); 298 304 299 305 rect.p0.x = 10; … … 337 343 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 338 344 339 PCUT_ASSERT_FALSE(scrollbar-> held);345 PCUT_ASSERT_FALSE(scrollbar->thumb_held); 340 346 341 347 rect.p0.x = 10; … … 379 385 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 380 386 381 PCUT_ASSERT_FALSE(scrollbar-> held);387 PCUT_ASSERT_FALSE(scrollbar->thumb_held); 382 388 383 389 rect.p0.x = 10; … … 419 425 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 420 426 421 PCUT_ASSERT_FALSE(scrollbar-> held);427 PCUT_ASSERT_FALSE(scrollbar->thumb_held); 422 428 423 429 rect.p0.x = 10; … … 459 465 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 460 466 461 PCUT_ASSERT_FALSE(scrollbar-> held);467 PCUT_ASSERT_FALSE(scrollbar->thumb_held); 462 468 463 469 rect.p0.x = 10; … … 489 495 } 490 496 491 /** Press and release scrollbar */492 PCUT_TEST( press_release)497 /** Press and release scrollbar thumb */ 498 PCUT_TEST(thumb_press_release) 493 499 { 494 500 errno_t rc; … … 521 527 ui_scrollbar_set_cb(scrollbar, &test_scrollbar_cb, &resp); 522 528 523 PCUT_ASSERT_FALSE(scrollbar-> held);529 PCUT_ASSERT_FALSE(scrollbar->thumb_held); 524 530 525 531 pos.x = 11; 526 532 pos.y = 22; 527 533 528 ui_scrollbar_ press(scrollbar, &pos);529 PCUT_ASSERT_TRUE(scrollbar-> held);534 ui_scrollbar_thumb_press(scrollbar, &pos); 535 PCUT_ASSERT_TRUE(scrollbar->thumb_held); 530 536 PCUT_ASSERT_FALSE(resp.moved); 531 537 … … 534 540 535 541 ui_scrollbar_release(scrollbar, &pos); 536 PCUT_ASSERT_FALSE(scrollbar-> held);542 PCUT_ASSERT_FALSE(scrollbar->thumb_held); 537 543 PCUT_ASSERT_TRUE(resp.moved); 538 544 PCUT_ASSERT_INT_EQUALS(10, scrollbar->pos); … … 577 583 ui_scrollbar_set_cb(scrollbar, &test_scrollbar_cb, &resp); 578 584 579 PCUT_ASSERT_FALSE(scrollbar-> held);585 PCUT_ASSERT_FALSE(scrollbar->thumb_held); 580 586 581 587 pos.x = 11; 582 588 pos.y = 22; 583 589 584 ui_scrollbar_ press(scrollbar, &pos);585 PCUT_ASSERT_TRUE(scrollbar-> held);590 ui_scrollbar_thumb_press(scrollbar, &pos); 591 PCUT_ASSERT_TRUE(scrollbar->thumb_held); 586 592 PCUT_ASSERT_FALSE(resp.moved); 587 593 … … 590 596 591 597 ui_scrollbar_update(scrollbar, &pos); 592 PCUT_ASSERT_TRUE(scrollbar-> held);598 PCUT_ASSERT_TRUE(scrollbar->thumb_held); 593 599 PCUT_ASSERT_TRUE(resp.moved); 594 600 PCUT_ASSERT_INT_EQUALS(10, scrollbar->pos); … … 598 604 599 605 ui_scrollbar_release(scrollbar, &pos); 600 PCUT_ASSERT_FALSE(scrollbar-> held);606 PCUT_ASSERT_FALSE(scrollbar->thumb_held); 601 607 PCUT_ASSERT_TRUE(resp.moved); 602 608 PCUT_ASSERT_INT_EQUALS(20, scrollbar->pos); … … 683 689 ui_scrollbar_down(scrollbar); 684 690 PCUT_ASSERT_TRUE(resp.down); 691 692 ui_scrollbar_destroy(scrollbar); 693 ui_resource_destroy(resource); 694 695 rc = gfx_context_delete(gc); 696 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 697 } 698 699 /** ui_scrollbar_page_up() delivers page up event */ 700 PCUT_TEST(page_up) 701 { 702 ui_scrollbar_t *scrollbar; 703 errno_t rc; 704 gfx_context_t *gc = NULL; 705 test_gc_t tgc; 706 ui_resource_t *resource = NULL; 707 test_cb_resp_t resp; 708 709 memset(&tgc, 0, sizeof(tgc)); 710 rc = gfx_context_new(&ops, &tgc, &gc); 711 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 712 713 rc = ui_resource_create(gc, false, &resource); 714 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 715 PCUT_ASSERT_NOT_NULL(resource); 716 717 rc = ui_scrollbar_create(resource, &scrollbar); 718 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 719 720 /* Page up with no callbacks set */ 721 ui_scrollbar_page_up(scrollbar); 722 723 /* Pge up with callback not implementing page up */ 724 ui_scrollbar_set_cb(scrollbar, &dummy_scrollbar_cb, NULL); 725 ui_scrollbar_page_up(scrollbar); 726 727 /* Page up with real callback set */ 728 resp.page_up = false; 729 ui_scrollbar_set_cb(scrollbar, &test_scrollbar_cb, &resp); 730 ui_scrollbar_page_up(scrollbar); 731 PCUT_ASSERT_TRUE(resp.page_up); 732 733 ui_scrollbar_destroy(scrollbar); 734 ui_resource_destroy(resource); 735 736 rc = gfx_context_delete(gc); 737 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 738 } 739 740 /** ui_scrollbar_page_down() delivers page down event */ 741 PCUT_TEST(page_down) 742 { 743 ui_scrollbar_t *scrollbar; 744 errno_t rc; 745 gfx_context_t *gc = NULL; 746 test_gc_t tgc; 747 ui_resource_t *resource = NULL; 748 test_cb_resp_t resp; 749 750 memset(&tgc, 0, sizeof(tgc)); 751 rc = gfx_context_new(&ops, &tgc, &gc); 752 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 753 754 rc = ui_resource_create(gc, false, &resource); 755 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 756 PCUT_ASSERT_NOT_NULL(resource); 757 758 rc = ui_scrollbar_create(resource, &scrollbar); 759 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 760 761 /* Page down with no callbacks set */ 762 ui_scrollbar_page_down(scrollbar); 763 764 /* Page down with callback not implementing page down */ 765 ui_scrollbar_set_cb(scrollbar, &dummy_scrollbar_cb, NULL); 766 ui_scrollbar_page_down(scrollbar); 767 768 /* Page down with real callback set */ 769 resp.page_down = false; 770 ui_scrollbar_set_cb(scrollbar, &test_scrollbar_cb, &resp); 771 ui_scrollbar_page_down(scrollbar); 772 PCUT_ASSERT_TRUE(resp.page_down); 685 773 686 774 ui_scrollbar_destroy(scrollbar); … … 757 845 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 758 846 759 PCUT_ASSERT_FALSE(scrollbar-> held);847 PCUT_ASSERT_FALSE(scrollbar->thumb_held); 760 848 761 849 rect.p0.x = 20; … … 770 858 event.vpos = 2; 771 859 claim = ui_scrollbar_pos_event(scrollbar, &event); 772 PCUT_ASSERT_FALSE(scrollbar-> held);860 PCUT_ASSERT_FALSE(scrollbar->thumb_held); 773 861 PCUT_ASSERT_EQUALS(ui_unclaimed, claim); 774 862 … … 778 866 event.vpos = 20; 779 867 claim = ui_scrollbar_pos_event(scrollbar, &event); 780 PCUT_ASSERT_TRUE(scrollbar-> held);868 PCUT_ASSERT_TRUE(scrollbar->thumb_held); 781 869 PCUT_ASSERT_EQUALS(ui_claimed, claim); 782 870 … … 786 874 event.vpos = 32; 787 875 claim = ui_scrollbar_pos_event(scrollbar, &event); 788 PCUT_ASSERT_FALSE(scrollbar-> held);876 PCUT_ASSERT_FALSE(scrollbar->thumb_held); 789 877 PCUT_ASSERT_EQUALS(ui_claimed, claim); 790 878 … … 819 907 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 820 908 821 PCUT_ASSERT_FALSE(scrollbar-> held);909 PCUT_ASSERT_FALSE(scrollbar->thumb_held); 822 910 823 911 rect.p0.x = 20; … … 865 953 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 866 954 867 PCUT_ASSERT_FALSE(scrollbar-> held);955 PCUT_ASSERT_FALSE(scrollbar->thumb_held); 868 956 869 957 rect.p0.x = 20; … … 994 1082 } 995 1083 1084 static void test_scrollbar_page_up(ui_scrollbar_t *scrollbar, void *arg) 1085 { 1086 test_cb_resp_t *resp = (test_cb_resp_t *) arg; 1087 1088 resp->page_up = true; 1089 } 1090 1091 static void test_scrollbar_page_down(ui_scrollbar_t *scrollbar, void *arg) 1092 { 1093 test_cb_resp_t *resp = (test_cb_resp_t *) arg; 1094 1095 resp->page_down = true; 1096 } 1097 996 1098 static void test_scrollbar_moved(ui_scrollbar_t *scrollbar, void *arg, gfx_coord_t pos) 997 1099 {
Note:
See TracChangeset
for help on using the changeset viewer.