Changeset ef4d684 in mainline
- Timestamp:
- 2023-11-29T12:39:32Z (13 months ago)
- Branches:
- master, topic/simplify-dev-export
- Children:
- 0e2eee1
- Parents:
- 84d29a2
- Location:
- uspace
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/uidemo/uidemo.c
r84d29a2 ref4d684 288 288 pos = ui_scrollbar_get_pos(scrollbar); 289 289 ui_scrollbar_set_pos(scrollbar, pos - 290 ui_scrollbar_t hrough_length(scrollbar) / 4);290 ui_scrollbar_trough_length(scrollbar) / 4); 291 291 292 292 pos = ui_scrollbar_get_pos(scrollbar); … … 305 305 pos = ui_scrollbar_get_pos(scrollbar); 306 306 ui_scrollbar_set_pos(scrollbar, pos + 307 ui_scrollbar_t hrough_length(scrollbar) / 4);307 ui_scrollbar_trough_length(scrollbar) / 4); 308 308 309 309 pos = ui_scrollbar_get_pos(scrollbar); … … 1270 1270 1271 1271 ui_scrollbar_set_thumb_length(demo.hscrollbar, 1272 ui_scrollbar_t hrough_length(demo.hscrollbar) / 4);1272 ui_scrollbar_trough_length(demo.hscrollbar) / 4); 1273 1273 1274 1274 rc = ui_fixed_add(demo.bfixed, ui_scrollbar_ctl(demo.hscrollbar)); … … 1302 1302 1303 1303 ui_scrollbar_set_thumb_length(demo.vscrollbar, 1304 ui_scrollbar_t hrough_length(demo.vscrollbar) / 4);1304 ui_scrollbar_trough_length(demo.vscrollbar) / 4); 1305 1305 1306 1306 rc = ui_fixed_add(demo.bfixed, ui_scrollbar_ctl(demo.vscrollbar)); -
uspace/lib/ui/include/ui/scrollbar.h
r84d29a2 ref4d684 1 1 /* 2 * Copyright (c) 202 2Jiri Svoboda2 * Copyright (c) 2023 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 54 54 extern void ui_scrollbar_set_rect(ui_scrollbar_t *, gfx_rect_t *); 55 55 extern errno_t ui_scrollbar_paint(ui_scrollbar_t *); 56 extern gfx_coord_t ui_scrollbar_t hrough_length(ui_scrollbar_t *);56 extern gfx_coord_t ui_scrollbar_trough_length(ui_scrollbar_t *); 57 57 extern gfx_coord_t ui_scrollbar_move_length(ui_scrollbar_t *); 58 58 extern gfx_coord_t ui_scrollbar_get_pos(ui_scrollbar_t *); … … 60 60 extern void ui_scrollbar_set_pos(ui_scrollbar_t *, gfx_coord_t); 61 61 extern void ui_scrollbar_thumb_press(ui_scrollbar_t *, gfx_coord2_t *); 62 extern void ui_scrollbar_up _through_press(ui_scrollbar_t *);63 extern void ui_scrollbar_ down_through_press(ui_scrollbar_t *);62 extern void ui_scrollbar_upper_trough_press(ui_scrollbar_t *); 63 extern void ui_scrollbar_lower_trough_press(ui_scrollbar_t *); 64 64 extern void ui_scrollbar_release(ui_scrollbar_t *, gfx_coord2_t *); 65 65 extern void ui_scrollbar_update(ui_scrollbar_t *, gfx_coord2_t *); 66 extern void ui_scrollbar_t hroughs_update(ui_scrollbar_t *, gfx_coord2_t *);66 extern void ui_scrollbar_troughs_update(ui_scrollbar_t *, gfx_coord2_t *); 67 67 extern void ui_scrollbar_up(ui_scrollbar_t *); 68 68 extern void ui_scrollbar_down(ui_scrollbar_t *); -
uspace/lib/ui/private/resource.h
r84d29a2 ref4d684 118 118 gfx_color_t *entry_sel_text_bg_color; 119 119 120 /** Scrollbar t hrough color */121 gfx_color_t *sbar_t hrough_color;122 /** Scrollbar active t hrough color */123 gfx_color_t *sbar_act_t hrough_color;120 /** Scrollbar trough color */ 121 gfx_color_t *sbar_trough_color; 122 /** Scrollbar active trough color */ 123 gfx_color_t *sbar_act_trough_color; 124 124 125 125 /** Expose callback or @c NULL */ -
uspace/lib/ui/private/scrollbar.h
r84d29a2 ref4d684 1 1 /* 2 * Copyright (c) 202 2Jiri Svoboda2 * Copyright (c) 2023 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 69 69 /** Thumb is currently held down */ 70 70 bool thumb_held; 71 /** Up through is currently held down */72 bool up _through_held;73 /** Pointer is inside up through */74 bool up _through_inside;75 /** Down through is currently held down */76 bool down_through_held;77 /** Pointer is inside down through */78 bool down_through_inside;71 /** Upper trough is currently held down */ 72 bool upper_trough_held; 73 /** Pointer is inside upper trough */ 74 bool upper_trough_inside; 75 /** Lower trough is currently held down */ 76 bool lower_trough_held; 77 /** Pointer is inside lower trough */ 78 bool lower_trough_inside; 79 79 /** Position where thumb was pressed */ 80 80 gfx_coord2_t press_pos; … … 83 83 /** Thumb position */ 84 84 gfx_coord_t pos; 85 /** Last cursor position (when t hrough is held) */85 /** Last cursor position (when trough is held) */ 86 86 gfx_coord2_t last_curs_pos; 87 87 }; … … 94 94 /** Up button rectangle */ 95 95 gfx_rect_t up_btn_rect; 96 /** T hrough rectangle */97 gfx_rect_t t hrough_rect;98 /** Up through rectangle */99 gfx_rect_t up _through_rect;96 /** Trough rectangle */ 97 gfx_rect_t trough_rect; 98 /** Upper trough rectangle */ 99 gfx_rect_t upper_trough_rect; 100 100 /** Thumb rectangle */ 101 101 gfx_rect_t thumb_rect; 102 /** Down through rectangle */103 gfx_rect_t down_through_rect;102 /** Lower trough rectangle */ 103 gfx_rect_t lower_trough_rect; 104 104 /** Down button rectangle */ 105 105 gfx_rect_t down_btn_rect; -
uspace/lib/ui/src/clickmatic.c
r84d29a2 ref4d684 1 1 /* 2 * Copyright (c) 202 2Jiri Svoboda2 * Copyright (c) 2023 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 35 35 * Clickmatic is used to periodically generate events in particular cases 36 36 * when a mouse button is held down, such as when holding the button or 37 * t hrough of a scrollbar.37 * trough of a scrollbar. 38 38 */ 39 39 -
uspace/lib/ui/src/resource.c
r84d29a2 ref4d684 86 86 gfx_color_t *entry_sel_text_fg_color = NULL; 87 87 gfx_color_t *entry_sel_text_bg_color = NULL; 88 gfx_color_t *sbar_t hrough_color = NULL;89 gfx_color_t *sbar_act_t hrough_color = NULL;88 gfx_color_t *sbar_trough_color = NULL; 89 gfx_color_t *sbar_act_trough_color = NULL; 90 90 errno_t rc; 91 91 … … 221 221 222 222 rc = gfx_color_new_rgb_i16(0xe4e4, 0xe4e4, 0xe4e4, 223 &sbar_t hrough_color);223 &sbar_trough_color); 224 224 if (rc != EOK) 225 225 goto error; 226 226 227 227 rc = gfx_color_new_rgb_i16(0x5858, 0x5858, 0x5858, 228 &sbar_act_t hrough_color);228 &sbar_act_trough_color); 229 229 if (rc != EOK) 230 230 goto error; … … 265 265 resource->entry_sel_text_bg_color = entry_sel_text_bg_color; 266 266 267 resource->sbar_t hrough_color = sbar_through_color;268 resource->sbar_act_t hrough_color = sbar_act_through_color;267 resource->sbar_trough_color = sbar_trough_color; 268 resource->sbar_act_trough_color = sbar_act_trough_color; 269 269 270 270 *rresource = resource; … … 327 327 gfx_color_delete(entry_act_bg_color); 328 328 329 if (sbar_t hrough_color != NULL)330 gfx_color_delete(sbar_t hrough_color);331 if (sbar_act_t hrough_color != NULL)332 gfx_color_delete(sbar_act_t hrough_color);329 if (sbar_trough_color != NULL) 330 gfx_color_delete(sbar_trough_color); 331 if (sbar_act_trough_color != NULL) 332 gfx_color_delete(sbar_act_trough_color); 333 333 334 334 if (tface != NULL) … … 376 376 gfx_color_t *entry_sel_text_bg_color = NULL; 377 377 gfx_color_t *entry_act_bg_color = NULL; 378 gfx_color_t *sbar_t hrough_color = NULL;379 gfx_color_t *sbar_act_t hrough_color = NULL;378 gfx_color_t *sbar_trough_color = NULL; 379 gfx_color_t *sbar_act_trough_color = NULL; 380 380 errno_t rc; 381 381 … … 497 497 goto error; 498 498 499 rc = gfx_color_new_ega(0x07, &sbar_t hrough_color);500 if (rc != EOK) 501 goto error; 502 503 rc = gfx_color_new_ega(0x07, &sbar_act_t hrough_color);499 rc = gfx_color_new_ega(0x07, &sbar_trough_color); 500 if (rc != EOK) 501 goto error; 502 503 rc = gfx_color_new_ega(0x07, &sbar_act_trough_color); 504 504 if (rc != EOK) 505 505 goto error; … … 540 540 resource->entry_sel_text_bg_color = entry_sel_text_bg_color; 541 541 542 resource->sbar_t hrough_color = sbar_through_color;543 resource->sbar_act_t hrough_color = sbar_act_through_color;542 resource->sbar_trough_color = sbar_trough_color; 543 resource->sbar_act_trough_color = sbar_act_trough_color; 544 544 545 545 *rresource = resource; … … 601 601 if (entry_sel_text_bg_color != NULL) 602 602 gfx_color_delete(entry_sel_text_bg_color); 603 if (sbar_t hrough_color != NULL)604 gfx_color_delete(sbar_t hrough_color);605 if (sbar_act_t hrough_color != NULL)606 gfx_color_delete(sbar_act_t hrough_color);603 if (sbar_trough_color != NULL) 604 gfx_color_delete(sbar_trough_color); 605 if (sbar_act_trough_color != NULL) 606 gfx_color_delete(sbar_act_trough_color); 607 607 608 608 if (tface != NULL) … … 665 665 gfx_color_delete(resource->entry_sel_text_bg_color); 666 666 667 gfx_color_delete(resource->sbar_t hrough_color);668 gfx_color_delete(resource->sbar_act_t hrough_color);667 gfx_color_delete(resource->sbar_trough_color); 668 gfx_color_delete(resource->sbar_act_trough_color); 669 669 670 670 gfx_font_close(resource->font); -
uspace/lib/ui/src/scrollbar.c
r84d29a2 ref4d684 1 1 /* 2 * Copyright (c) 202 2Jiri Svoboda2 * Copyright (c) 2023 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 35 35 * Anatomy of a horizontal scrollbar: 36 36 * 37 * Up Down38 * through through39 * +---+------+--------+---------+---+40 * | < | | ||| | | > |41 * +---+------+--------+---------+---+42 * Up Thumb Down43 * button button44 * 45 * +-------- T hrough --------+37 * Upper Lower 38 * trough trough 39 * +---+------+--------+---------+---+ 40 * | < | | ||| | | > | 41 * +---+------+--------+---------+---+ 42 * Up Thumb Down 43 * button button 44 * 45 * +-------- Trough --------+ 46 46 * 47 47 * Scrollbar uses the same terminology whether it is running in horizontal … … 51 51 * The thumb can be dragged to a specific position, resulting in a move 52 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 * Pressing and holding down mouse button on up / down button or up / down56 * through will auto-scroll (using clickmatic).53 * button on the upper/lower trough generates page up / page down events. 54 * 55 * Pressing and holding down mouse button on up / down button or upper / 56 * lower trough will auto-scroll (using clickmatic). 57 57 */ 58 58 … … 360 360 } 361 361 362 /** Determine scrollbar t hrough length.362 /** Determine scrollbar trough length. 363 363 * 364 364 * Return the size of the space within which the thumb can move … … 366 366 * 367 367 * @param scrollbar Scrollbar 368 * @return Scrollbar t hrough length in pixels369 */ 370 gfx_coord_t ui_scrollbar_t hrough_length(ui_scrollbar_t *scrollbar)368 * @return Scrollbar trough length in pixels 369 */ 370 gfx_coord_t ui_scrollbar_trough_length(ui_scrollbar_t *scrollbar) 371 371 { 372 372 ui_resource_t *resource; … … 396 396 gfx_coord_t ui_scrollbar_move_length(ui_scrollbar_t *scrollbar) 397 397 { 398 return ui_scrollbar_t hrough_length(scrollbar) -398 return ui_scrollbar_trough_length(scrollbar) - 399 399 scrollbar->thumb_len; 400 400 } … … 417 417 ui_scrollbar_min_thumb_len; 418 418 419 max_len = ui_scrollbar_t hrough_length(scrollbar);419 max_len = ui_scrollbar_trough_length(scrollbar); 420 420 if (len < min_len) 421 421 len = min_len; … … 459 459 scrollbar->pos = pos; 460 460 (void) ui_scrollbar_paint(scrollbar); 461 ui_scrollbar_t hroughs_update(scrollbar,461 ui_scrollbar_troughs_update(scrollbar, 462 462 &scrollbar->last_curs_pos); 463 463 } … … 487 487 goto error; 488 488 489 /* Paint scrollbar up through */489 /* Paint scrollbar upper trough */ 490 490 rc = gfx_set_color(resource->gc, 491 scrollbar->up _through_held && scrollbar->up_through_inside ?492 resource->sbar_act_t hrough_color :493 resource->sbar_t hrough_color);494 if (rc != EOK) 495 goto error; 496 497 rc = gfx_fill_rect(resource->gc, &geom.up _through_rect);498 if (rc != EOK) 499 goto error; 500 501 /* Paint scrollbar down through */491 scrollbar->upper_trough_held && scrollbar->upper_trough_inside ? 492 resource->sbar_act_trough_color : 493 resource->sbar_trough_color); 494 if (rc != EOK) 495 goto error; 496 497 rc = gfx_fill_rect(resource->gc, &geom.upper_trough_rect); 498 if (rc != EOK) 499 goto error; 500 501 /* Paint scrollbar lower trough */ 502 502 503 503 rc = gfx_set_color(resource->gc, 504 scrollbar-> down_through_held && scrollbar->down_through_inside ?505 resource->sbar_act_t hrough_color :506 resource->sbar_t hrough_color);507 if (rc != EOK) 508 goto error; 509 510 rc = gfx_fill_rect(resource->gc, &geom. down_through_rect);504 scrollbar->lower_trough_held && scrollbar->lower_trough_inside ? 505 resource->sbar_act_trough_color : 506 resource->sbar_trough_color); 507 if (rc != EOK) 508 goto error; 509 510 rc = gfx_fill_rect(resource->gc, &geom.lower_trough_rect); 511 511 if (rc != EOK) 512 512 goto error; … … 561 561 ui_scrollbar_get_geom(scrollbar, &geom); 562 562 563 /* Paint scrollbar t hrough */564 565 rc = ui_paint_text_rect(resource, &geom.t hrough_rect,566 resource->sbar_t hrough_color, "\u2592");563 /* Paint scrollbar trough */ 564 565 rc = ui_paint_text_rect(resource, &geom.trough_rect, 566 resource->sbar_trough_color, "\u2592"); 567 567 if (rc != EOK) 568 568 goto error; … … 571 571 572 572 rc = ui_paint_text_rect(resource, &geom.thumb_rect, 573 resource->sbar_t hrough_color, "\u25a0");573 resource->sbar_trough_color, "\u25a0"); 574 574 if (rc != EOK) 575 575 goto error; … … 647 647 geom->up_btn_rect.p1.y = orect.p1.y; 648 648 649 /* T hrough */650 geom->t hrough_rect.p0.x = geom->up_btn_rect.p1.x;651 geom->t hrough_rect.p0.y = irect.p0.y;652 geom->t hrough_rect.p1.x = orect.p1.x - btn_len;653 geom->t hrough_rect.p1.y = irect.p1.y;649 /* Trough */ 650 geom->trough_rect.p0.x = geom->up_btn_rect.p1.x; 651 geom->trough_rect.p0.y = irect.p0.y; 652 geom->trough_rect.p1.x = orect.p1.x - btn_len; 653 geom->trough_rect.p1.y = irect.p1.y; 654 654 655 655 /* Thumb */ … … 661 661 geom->thumb_rect.p1.y = orect.p1.y; 662 662 663 /* Up through */664 geom->up _through_rect.p0 = geom->through_rect.p0;665 geom->up _through_rect.p1.x = geom->thumb_rect.p0.x;666 geom->up _through_rect.p1.y = geom->through_rect.p1.y;667 668 /* Down through */669 geom-> down_through_rect.p0.x = geom->thumb_rect.p1.x;670 geom-> down_through_rect.p0.y = geom->through_rect.p0.y;671 geom-> down_through_rect.p1 = geom->through_rect.p1;663 /* Upper trough */ 664 geom->upper_trough_rect.p0 = geom->trough_rect.p0; 665 geom->upper_trough_rect.p1.x = geom->thumb_rect.p0.x; 666 geom->upper_trough_rect.p1.y = geom->trough_rect.p1.y; 667 668 /* Lower trough */ 669 geom->lower_trough_rect.p0.x = geom->thumb_rect.p1.x; 670 geom->lower_trough_rect.p0.y = geom->trough_rect.p0.y; 671 geom->lower_trough_rect.p1 = geom->trough_rect.p1; 672 672 673 673 /* Down button */ 674 geom->down_btn_rect.p0.x = geom->t hrough_rect.p1.x;674 geom->down_btn_rect.p0.x = geom->trough_rect.p1.x; 675 675 geom->down_btn_rect.p0.y = orect.p0.y; 676 676 geom->down_btn_rect.p1.x = orect.p1.x; … … 683 683 geom->up_btn_rect.p1.y = orect.p0.y + btn_len; 684 684 685 /* T hrough */686 geom->t hrough_rect.p0.x = irect.p0.x;687 geom->t hrough_rect.p0.y = geom->up_btn_rect.p1.y;688 geom->t hrough_rect.p1.x = irect.p1.x;689 geom->t hrough_rect.p1.y = orect.p1.y - btn_len;685 /* Trough */ 686 geom->trough_rect.p0.x = irect.p0.x; 687 geom->trough_rect.p0.y = geom->up_btn_rect.p1.y; 688 geom->trough_rect.p1.x = irect.p1.x; 689 geom->trough_rect.p1.y = orect.p1.y - btn_len; 690 690 691 691 /* Thumb */ … … 697 697 scrollbar->thumb_len; 698 698 699 /* Up through */700 geom->up _through_rect.p0 = geom->through_rect.p0;701 geom->up _through_rect.p1.x = geom->through_rect.p1.x;702 geom->up _through_rect.p1.y = geom->thumb_rect.p0.y;703 704 /* Down through */705 geom-> down_through_rect.p0.x = geom->through_rect.p0.x;706 geom-> down_through_rect.p0.y = geom->thumb_rect.p1.y;707 geom-> down_through_rect.p1 = geom->through_rect.p1;699 /* Upper trough */ 700 geom->upper_trough_rect.p0 = geom->trough_rect.p0; 701 geom->upper_trough_rect.p1.x = geom->trough_rect.p1.x; 702 geom->upper_trough_rect.p1.y = geom->thumb_rect.p0.y; 703 704 /* Lower trough */ 705 geom->lower_trough_rect.p0.x = geom->trough_rect.p0.x; 706 geom->lower_trough_rect.p0.y = geom->thumb_rect.p1.y; 707 geom->lower_trough_rect.p1 = geom->trough_rect.p1; 708 708 709 709 /* Down button */ 710 710 geom->down_btn_rect.p0.x = orect.p0.x; 711 geom->down_btn_rect.p0.y = geom->t hrough_rect.p1.y;711 geom->down_btn_rect.p0.y = geom->trough_rect.p1.y; 712 712 geom->down_btn_rect.p1.x = orect.p1.x; 713 713 geom->down_btn_rect.p1.y = orect.p1.y; … … 732 732 } 733 733 734 /** Press down scrollbar up through.735 * 736 * @param scrollbar Scrollbar 737 */ 738 void ui_scrollbar_up _through_press(ui_scrollbar_t *scrollbar)734 /** Press down scrollbar upper trough. 735 * 736 * @param scrollbar Scrollbar 737 */ 738 void ui_scrollbar_upper_trough_press(ui_scrollbar_t *scrollbar) 739 739 { 740 740 ui_clickmatic_t *clickmatic = ui_get_clickmatic(scrollbar->ui); 741 741 742 scrollbar->up _through_held = true;743 scrollbar->up _through_inside = true;742 scrollbar->upper_trough_held = true; 743 scrollbar->upper_trough_inside = true; 744 744 745 745 ui_clickmatic_set_cb(clickmatic, &ui_scrollbar_clickmatic_page_up_cb, … … 748 748 } 749 749 750 /** Press down scrollbar down through.751 * 752 * @param scrollbar Scrollbar 753 */ 754 void ui_scrollbar_ down_through_press(ui_scrollbar_t *scrollbar)750 /** Press down scrollbar lower trough. 751 * 752 * @param scrollbar Scrollbar 753 */ 754 void ui_scrollbar_lower_trough_press(ui_scrollbar_t *scrollbar) 755 755 { 756 756 ui_clickmatic_t *clickmatic = ui_get_clickmatic(scrollbar->ui); 757 757 758 scrollbar-> down_through_held = true;759 scrollbar-> down_through_inside = true;758 scrollbar->lower_trough_held = true; 759 scrollbar->lower_trough_inside = true; 760 760 761 761 ui_clickmatic_set_cb(clickmatic, &ui_scrollbar_clickmatic_page_down_cb, … … 778 778 } 779 779 780 if (scrollbar->up _through_held || scrollbar->down_through_held) {780 if (scrollbar->upper_trough_held || scrollbar->lower_trough_held) { 781 781 clickmatic = ui_get_clickmatic(scrollbar->ui); 782 782 ui_clickmatic_release(clickmatic); 783 783 ui_clickmatic_set_cb(clickmatic, NULL, NULL); 784 784 785 scrollbar->up _through_held = false;786 scrollbar-> down_through_held = false;785 scrollbar->upper_trough_held = false; 786 scrollbar->lower_trough_held = false; 787 787 (void) ui_scrollbar_paint(scrollbar); 788 788 } … … 791 791 /** Update state of scrollbar throuhgs. 792 792 * 793 * Update state of scrollbar t hroughs after mouse cursor or thumb has moved.793 * Update state of scrollbar troughs after mouse cursor or thumb has moved. 794 794 * 795 795 * @param scrollbar Scrollbar 796 796 * @param pos Mouse cursor position 797 797 */ 798 void ui_scrollbar_t hroughs_update(ui_scrollbar_t *scrollbar, gfx_coord2_t *pos)798 void ui_scrollbar_troughs_update(ui_scrollbar_t *scrollbar, gfx_coord2_t *pos) 799 799 { 800 800 ui_scrollbar_geom_t geom; … … 804 804 ui_scrollbar_get_geom(scrollbar, &geom); 805 805 806 inside_up = gfx_pix_inside_rect(pos, &geom.up _through_rect);807 inside_down = gfx_pix_inside_rect(pos, &geom. down_through_rect);808 809 if (inside_up && !scrollbar->up _through_inside) {810 scrollbar->up _through_inside = true;806 inside_up = gfx_pix_inside_rect(pos, &geom.upper_trough_rect); 807 inside_down = gfx_pix_inside_rect(pos, &geom.lower_trough_rect); 808 809 if (inside_up && !scrollbar->upper_trough_inside) { 810 scrollbar->upper_trough_inside = true; 811 811 (void) ui_scrollbar_paint(scrollbar); 812 } else if (!inside_up && scrollbar->up _through_inside) {813 scrollbar->up _through_inside = false;812 } else if (!inside_up && scrollbar->upper_trough_inside) { 813 scrollbar->upper_trough_inside = false; 814 814 (void) ui_scrollbar_paint(scrollbar); 815 815 } 816 816 817 if (inside_down && !scrollbar-> down_through_inside) {818 scrollbar-> down_through_inside = true;817 if (inside_down && !scrollbar->lower_trough_inside) { 818 scrollbar->lower_trough_inside = true; 819 819 (void) ui_scrollbar_paint(scrollbar); 820 } else if (!inside_down && scrollbar-> down_through_inside) {821 scrollbar-> down_through_inside = false;820 } else if (!inside_down && scrollbar->lower_trough_inside) { 821 scrollbar->lower_trough_inside = false; 822 822 (void) ui_scrollbar_paint(scrollbar); 823 823 } … … 843 843 } 844 844 845 ui_scrollbar_t hroughs_update(scrollbar, pos);845 ui_scrollbar_troughs_update(scrollbar, pos); 846 846 } 847 847 … … 866 866 } 867 867 868 /** Scrollbar up through was pressed.868 /** Scrollbar upper trough was pressed. 869 869 * 870 870 * @param scrollbar Scrollbar … … 876 876 } 877 877 878 /** Scrollbar down through was pressed.878 /** Scrollbar lower trough was pressed. 879 879 * 880 880 * @param scrollbar Scrollbar … … 927 927 return ui_claimed; 928 928 } 929 if (gfx_pix_inside_rect(&pos, &geom.up _through_rect)) {930 ui_scrollbar_up _through_press(scrollbar);929 if (gfx_pix_inside_rect(&pos, &geom.upper_trough_rect)) { 930 ui_scrollbar_upper_trough_press(scrollbar); 931 931 return ui_claimed; 932 932 } 933 if (gfx_pix_inside_rect(&pos, &geom. down_through_rect)) {934 ui_scrollbar_ down_through_press(scrollbar);933 if (gfx_pix_inside_rect(&pos, &geom.lower_trough_rect)) { 934 ui_scrollbar_lower_trough_press(scrollbar); 935 935 return ui_claimed; 936 936 } 937 937 break; 938 938 case POS_RELEASE: 939 if (scrollbar->thumb_held || scrollbar->up _through_held ||940 scrollbar-> down_through_held) {939 if (scrollbar->thumb_held || scrollbar->upper_trough_held || 940 scrollbar->lower_trough_held) { 941 941 ui_scrollbar_release(scrollbar, &pos); 942 942 return ui_claimed; … … 1118 1118 } 1119 1119 1120 /** Scrollbar clickmatic up through click event.1120 /** Scrollbar clickmatic upper trough click event. 1121 1121 * 1122 1122 * @param clickmatic Clickmatic … … 1127 1127 ui_scrollbar_t *scrollbar = (ui_scrollbar_t *)arg; 1128 1128 1129 if (scrollbar->up _through_inside)1129 if (scrollbar->upper_trough_inside) 1130 1130 ui_scrollbar_page_up(scrollbar); 1131 1131 } 1132 1132 1133 /** Scrollbar clickmatic down through click event.1133 /** Scrollbar clickmatic lower trough click event. 1134 1134 * 1135 1135 * @param clickmatic Clickmatic … … 1140 1140 ui_scrollbar_t *scrollbar = (ui_scrollbar_t *)arg; 1141 1141 1142 if (scrollbar-> down_through_inside)1142 if (scrollbar->lower_trough_inside) 1143 1143 ui_scrollbar_page_down(scrollbar); 1144 1144 } -
uspace/lib/ui/test/scrollbar.c
r84d29a2 ref4d684 1 1 /* 2 * Copyright (c) 202 2Jiri Svoboda2 * Copyright (c) 2023 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 284 284 } 285 285 286 /** ui_scrollbar_t hrough_length() gives correct scrollbar through length */287 PCUT_TEST(t hrough_length)286 /** ui_scrollbar_trough_length() gives correct scrollbar trough length */ 287 PCUT_TEST(trough_length) 288 288 { 289 289 ui_t *ui = NULL; … … 316 316 ui_scrollbar_set_rect(scrollbar, &rect); 317 317 318 length = ui_scrollbar_t hrough_length(scrollbar);318 length = ui_scrollbar_trough_length(scrollbar); 319 319 320 320 /* Total length minus buttons */ … … 620 620 } 621 621 622 /** Press and release up through */623 PCUT_TEST(up _through_press_release)622 /** Press and release upper trough */ 623 PCUT_TEST(upper_trough_press_release) 624 624 { 625 625 ui_t *ui = NULL; … … 654 654 ui_scrollbar_set_cb(scrollbar, &test_scrollbar_cb, &resp); 655 655 656 PCUT_ASSERT_FALSE(scrollbar->up _through_held);657 658 ui_scrollbar_up _through_press(scrollbar);659 PCUT_ASSERT_TRUE(scrollbar->up _through_held);656 PCUT_ASSERT_FALSE(scrollbar->upper_trough_held); 657 658 ui_scrollbar_upper_trough_press(scrollbar); 659 PCUT_ASSERT_TRUE(scrollbar->upper_trough_held); 660 660 PCUT_ASSERT_TRUE(resp.page_up); 661 661 … … 665 665 666 666 ui_scrollbar_release(scrollbar, &pos); 667 PCUT_ASSERT_FALSE(scrollbar->up _through_held);668 669 ui_scrollbar_destroy(scrollbar); 670 ui_window_destroy(window); 671 ui_destroy(ui); 672 } 673 674 /** Press and release down through */675 PCUT_TEST( down_through_press_release)667 PCUT_ASSERT_FALSE(scrollbar->upper_trough_held); 668 669 ui_scrollbar_destroy(scrollbar); 670 ui_window_destroy(window); 671 ui_destroy(ui); 672 } 673 674 /** Press and release lower trough */ 675 PCUT_TEST(lower_trough_press_release) 676 676 { 677 677 ui_t *ui = NULL; … … 706 706 ui_scrollbar_set_cb(scrollbar, &test_scrollbar_cb, &resp); 707 707 708 PCUT_ASSERT_FALSE(scrollbar-> down_through_held);709 710 ui_scrollbar_ down_through_press(scrollbar);711 PCUT_ASSERT_TRUE(scrollbar-> down_through_held);708 PCUT_ASSERT_FALSE(scrollbar->lower_trough_held); 709 710 ui_scrollbar_lower_trough_press(scrollbar); 711 PCUT_ASSERT_TRUE(scrollbar->lower_trough_held); 712 712 PCUT_ASSERT_TRUE(resp.page_down); 713 713 … … 717 717 718 718 ui_scrollbar_release(scrollbar, &pos); 719 PCUT_ASSERT_FALSE(scrollbar-> down_through_held);720 721 ui_scrollbar_destroy(scrollbar); 722 ui_window_destroy(window); 723 ui_destroy(ui); 724 } 725 726 /** Updating state of t hroughs when cursor or thumb moves */727 PCUT_TEST(t hroughs_update)719 PCUT_ASSERT_FALSE(scrollbar->lower_trough_held); 720 721 ui_scrollbar_destroy(scrollbar); 722 ui_window_destroy(window); 723 ui_destroy(ui); 724 } 725 726 /** Updating state of troughs when cursor or thumb moves */ 727 PCUT_TEST(troughs_update) 728 728 { 729 729 ui_t *ui = NULL; … … 754 754 ui_scrollbar_set_rect(scrollbar, &rect); 755 755 756 PCUT_ASSERT_FALSE(scrollbar-> down_through_inside);756 PCUT_ASSERT_FALSE(scrollbar->lower_trough_inside); 757 757 758 758 pos.x = 60; 759 759 pos.y = 22; 760 760 761 ui_scrollbar_t hroughs_update(scrollbar, &pos);762 PCUT_ASSERT_TRUE(scrollbar-> down_through_inside);761 ui_scrollbar_troughs_update(scrollbar, &pos); 762 PCUT_ASSERT_TRUE(scrollbar->lower_trough_inside); 763 763 764 764 ui_scrollbar_destroy(scrollbar); … … 1082 1082 } 1083 1083 1084 /** ui_scrollbar_pos_event() detects up through press/release */1085 PCUT_TEST(pos_event_press_release_up _through)1084 /** ui_scrollbar_pos_event() detects upper trough press/release */ 1085 PCUT_TEST(pos_event_press_release_upper_trough) 1086 1086 { 1087 1087 ui_t *ui = NULL; … … 1107 1107 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1108 1108 1109 PCUT_ASSERT_FALSE(scrollbar->up _through_held);1109 PCUT_ASSERT_FALSE(scrollbar->upper_trough_held); 1110 1110 1111 1111 rect.p0.x = 20; … … 1115 1115 ui_scrollbar_set_rect(scrollbar, &rect); 1116 1116 1117 /* Need to move thumb so that up through can be accessed */1117 /* Need to move thumb so that upper trough can be accessed */ 1118 1118 ui_scrollbar_set_pos(scrollbar, 42); 1119 1119 1120 /* Press inside up through is claimed and depresses it */1120 /* Press inside upper trough is claimed and depresses it */ 1121 1121 event.type = POS_PRESS; 1122 1122 event.hpos = 50; 1123 1123 event.vpos = 20; 1124 1124 claim = ui_scrollbar_pos_event(scrollbar, &event); 1125 PCUT_ASSERT_TRUE(scrollbar->up _through_held);1125 PCUT_ASSERT_TRUE(scrollbar->upper_trough_held); 1126 1126 PCUT_ASSERT_EQUALS(ui_claimed, claim); 1127 1127 1128 /* Release outside (or anywhere) is claimed and relases up through */1128 /* Release outside (or anywhere) is claimed and relases upper trough */ 1129 1129 event.type = POS_RELEASE; 1130 1130 event.hpos = 41; 1131 1131 event.vpos = 32; 1132 1132 claim = ui_scrollbar_pos_event(scrollbar, &event); 1133 PCUT_ASSERT_FALSE(scrollbar->up _through_held);1133 PCUT_ASSERT_FALSE(scrollbar->upper_trough_held); 1134 1134 PCUT_ASSERT_EQUALS(ui_claimed, claim); 1135 1135 … … 1139 1139 } 1140 1140 1141 /** ui_scrollbar_pos_event() detects down through press/release */1142 PCUT_TEST(pos_event_press_release_ down_through)1141 /** ui_scrollbar_pos_event() detects lower trough press/release */ 1142 PCUT_TEST(pos_event_press_release_lower_trough) 1143 1143 { 1144 1144 ui_t *ui = NULL; … … 1164 1164 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1165 1165 1166 PCUT_ASSERT_FALSE(scrollbar->up _through_held);1166 PCUT_ASSERT_FALSE(scrollbar->upper_trough_held); 1167 1167 1168 1168 rect.p0.x = 20; … … 1172 1172 ui_scrollbar_set_rect(scrollbar, &rect); 1173 1173 1174 /* Press inside down through is claimed and depresses it */1174 /* Press inside lower trough is claimed and depresses it */ 1175 1175 event.type = POS_PRESS; 1176 1176 event.hpos = 70; 1177 1177 event.vpos = 20; 1178 1178 claim = ui_scrollbar_pos_event(scrollbar, &event); 1179 PCUT_ASSERT_TRUE(scrollbar-> down_through_held);1179 PCUT_ASSERT_TRUE(scrollbar->lower_trough_held); 1180 1180 PCUT_ASSERT_EQUALS(ui_claimed, claim); 1181 1181 1182 /* Release outside (or anywhere) is claimed and relases up through */1182 /* Release outside (or anywhere) is claimed and relases upper trough */ 1183 1183 event.type = POS_RELEASE; 1184 1184 event.hpos = 41; 1185 1185 event.vpos = 32; 1186 1186 claim = ui_scrollbar_pos_event(scrollbar, &event); 1187 PCUT_ASSERT_FALSE(scrollbar-> down_through_held);1187 PCUT_ASSERT_FALSE(scrollbar->lower_trough_held); 1188 1188 PCUT_ASSERT_EQUALS(ui_claimed, claim); 1189 1189
Note:
See TracChangeset
for help on using the changeset viewer.