Changes in uspace/lib/ui/src/list.c [28ca31ed:f6304727] in mainline
- File:
-
- 1 edited
-
uspace/lib/ui/src/list.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/src/list.c
r28ca31ed rf6304727 1 1 /* 2 * Copyright (c) 202 4Jiri Svoboda2 * Copyright (c) 2026 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 471 471 ui_list_scrollbar_rect(list, &srect); 472 472 ui_scrollbar_set_rect(list->scrollbar, &srect); 473 474 /* Make sure cursor stays on page after resize. */ 475 if (list->cursor != NULL) 476 ui_list_cursor_move(list, list->cursor, list->cursor_idx); 473 477 } 474 478 … … 1652 1656 } 1653 1657 1658 /** Save list position for later. 1659 * 1660 * The position will be valid even if the list is cleaned and re-populated 1661 * (it just counts position from the top.) 1662 * 1663 * @param list UI list 1664 * @param pos Place to store position 1665 */ 1666 void ui_list_save_pos(ui_list_t *list, ui_list_pos_t *pos) 1667 { 1668 pos->page_idx = list->page_idx; 1669 pos->cursor_idx = list->cursor_idx; 1670 } 1671 1672 /** Restore saved list position. 1673 * 1674 * The position will be valid even if the list is cleaned and re-populated 1675 * (it just counts position from the top.) 1676 * 1677 * @param list UI list 1678 * @param pos Saved list position 1679 */ 1680 void ui_list_restore_pos(ui_list_t *list, ui_list_pos_t *pos) 1681 { 1682 size_t idx, i; 1683 ui_list_entry_t *entry, *next; 1684 1685 idx = 0; 1686 entry = ui_list_first(list); 1687 1688 for (i = 0; i < pos->cursor_idx; i++) { 1689 next = ui_list_next(entry); 1690 if (next != NULL) { 1691 entry = next; 1692 ++idx; 1693 } 1694 } 1695 1696 list->cursor = entry; 1697 list->cursor_idx = idx; 1698 1699 idx = 0; 1700 entry = ui_list_first(list); 1701 1702 for (i = 0; i < pos->page_idx; i++) { 1703 next = ui_list_next(entry); 1704 if (next != NULL) { 1705 entry = next; 1706 ++idx; 1707 } 1708 } 1709 1710 list->page = entry; 1711 list->page_idx = idx; 1712 } 1713 1654 1714 /** @} 1655 1715 */
Note:
See TracChangeset
for help on using the changeset viewer.
