Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ui/src/list.c

    rf6304727 r28ca31ed  
    11/*
    2  * Copyright (c) 2026 Jiri Svoboda
     2 * Copyright (c) 2024 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    471471        ui_list_scrollbar_rect(list, &srect);
    472472        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);
    477473}
    478474
     
    16561652}
    16571653
    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 
    17141654/** @}
    17151655 */
Note: See TracChangeset for help on using the changeset viewer.