Changeset c0757e1f in mainline for uspace/lib/ui/src/list.c
- Timestamp:
- 2023-04-19T11:13:06Z (20 months ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 37087c8
- Parents:
- ec8ef12
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/src/list.c
rec8ef12 rc0757e1f 149 149 list->cb = cb; 150 150 list->cb_arg = arg; 151 } 152 153 /** Get UI list callback argument. 154 * 155 * @param list UI list 156 * @return Callback argument 157 */ 158 void *ui_list_get_cb_arg(ui_list_t *list) 159 { 160 return list->cb_arg; 151 161 } 152 162 … … 701 711 } 702 712 703 /** Delete UI list entry. 713 /** Destroy UI list entry. 714 * 715 * This is the quick way, but does not update cursor or page position. 704 716 * 705 717 * @param entry UI list entry 706 718 */ 707 void ui_list_entry_de lete(ui_list_entry_t *entry)719 void ui_list_entry_destroy(ui_list_entry_t *entry) 708 720 { 709 721 if (entry->list->cursor == entry) … … 718 730 } 719 731 732 /** Delete UI list entry. 733 * 734 * If required, update cursor and page position and repaint. 735 * 736 * @param entry UI list entry 737 */ 738 void ui_list_entry_delete(ui_list_entry_t *entry) 739 { 740 /* Try to make sure entry does not disappear between cursor and page */ 741 if (entry->list->cursor == entry) 742 ui_list_cursor_up(entry->list); 743 if (entry->list->cursor == entry) 744 ui_list_cursor_down(entry->list); 745 if (entry->list->page == entry) 746 ui_list_scroll_up(entry->list); 747 if (entry->list->page == entry) 748 ui_list_scroll_down(entry->list); 749 750 ui_list_entry_destroy(entry); 751 } 752 720 753 /** Get entry argument. 721 754 * … … 728 761 } 729 762 763 /** Get containing list. 764 * 765 * @param entry UI list entry 766 * @return Containing list 767 */ 768 ui_list_t *ui_list_entry_get_list(ui_list_entry_t *entry) 769 { 770 return entry->list; 771 } 772 730 773 /** Clear UI list entry list. 731 774 * … … 738 781 entry = ui_list_first(list); 739 782 while (entry != NULL) { 740 ui_list_entry_de lete(entry);783 ui_list_entry_destroy(entry); 741 784 entry = ui_list_first(list); 742 785 } … … 858 901 { 859 902 return list->cursor; 903 } 904 905 /** Set new cursor position. 906 * 907 * O(N) in list size, use with caution. 908 * 909 * @param list UI list 910 * @param entry New cursor position 911 */ 912 void ui_list_set_cursor(ui_list_t *list, ui_list_entry_t *entry) 913 { 914 size_t idx; 915 916 idx = ui_list_entry_get_idx(entry); 917 ui_list_cursor_move(list, entry, idx); 860 918 } 861 919 … … 912 970 /* Find first page entry (go back rows - 1) */ 913 971 e = entry; 914 for (i = 0; i < rows - 1; i++) {972 for (i = 0; i + 1 < rows; i++) { 915 973 e = ui_list_prev(e); 916 974 } … … 1098 1156 ui_list_entry_t *prev; 1099 1157 1158 if (list->page == NULL) 1159 return; 1160 1100 1161 prev = ui_list_prev(list->page); 1101 1162 if (prev == NULL) … … 1120 1181 size_t i; 1121 1182 size_t rows; 1183 1184 if (list->page == NULL) 1185 return; 1122 1186 1123 1187 next = ui_list_next(list->page);
Note:
See TracChangeset
for help on using the changeset viewer.