Changeset c0757e1f in mainline for uspace/lib/ui
- Timestamp:
- 2023-04-19T11:13:06Z (3 years ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 37087c8
- Parents:
- ec8ef12
- Location:
- uspace/lib/ui
- Files:
-
- 5 added
- 14 edited
-
include/types/ui/selectdialog.h (added)
-
include/ui/entry.h (modified) (1 diff)
-
include/ui/list.h (modified) (2 diffs)
-
include/ui/selectdialog.h (added)
-
include/ui/tab.h (modified) (1 diff)
-
meson.build (modified) (2 diffs)
-
private/entry.h (modified) (1 diff)
-
private/filelist.h (modified) (1 diff)
-
private/list.h (modified) (1 diff)
-
private/promptdialog.h (modified) (1 diff)
-
private/selectdialog.h (added)
-
src/filelist.c (modified) (3 diffs)
-
src/list.c (modified) (9 diffs)
-
src/promptdialog.c (modified) (3 diffs)
-
src/selectdialog.c (added)
-
test/filelist.c (modified) (2 diffs)
-
test/list.c (modified) (3 diffs)
-
test/main.c (modified) (2 diffs)
-
test/selectdialog.c (added)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/include/ui/entry.h
rec8ef12 rc0757e1f 54 54 extern const char *ui_entry_get_text(ui_entry_t *); 55 55 extern errno_t ui_entry_paint(ui_entry_t *); 56 extern errno_t ui_entry_insert_str(ui_entry_t *, const char *); 56 57 extern void ui_entry_activate(ui_entry_t *); 57 58 extern void ui_entry_deactivate(ui_entry_t *); -
uspace/lib/ui/include/ui/list.h
rec8ef12 rc0757e1f 48 48 extern ui_control_t *ui_list_ctl(ui_list_t *); 49 49 extern void ui_list_set_cb(ui_list_t *, ui_list_cb_t *, void *); 50 extern void *ui_list_get_cb_arg(ui_list_t *); 50 51 extern void ui_list_set_rect(ui_list_t *, gfx_rect_t *); 51 52 extern errno_t ui_list_activate(ui_list_t *); 52 53 extern void ui_list_deactivate(ui_list_t *); 53 54 extern ui_list_entry_t *ui_list_get_cursor(ui_list_t *); 55 extern void ui_list_set_cursor(ui_list_t *, ui_list_entry_t *); 54 56 extern void ui_list_entry_attr_init(ui_list_entry_attr_t *); 55 57 extern errno_t ui_list_entry_append(ui_list_t *, … … 57 59 extern void ui_list_entry_delete(ui_list_entry_t *); 58 60 extern void *ui_list_entry_get_arg(ui_list_entry_t *); 61 extern ui_list_t *ui_list_entry_get_list(ui_list_entry_t *); 59 62 extern size_t ui_list_entries_cnt(ui_list_t *); 60 63 extern errno_t ui_list_sort(ui_list_t *); -
uspace/lib/ui/include/ui/tab.h
rec8ef12 rc0757e1f 43 43 #include <stdbool.h> 44 44 #include <types/common.h> 45 #include <types/ui/control.h> 45 46 #include <types/ui/tab.h> 46 47 #include <types/ui/tabset.h> -
uspace/lib/ui/meson.build
rec8ef12 rc0757e1f 52 52 'src/resource.c', 53 53 'src/scrollbar.c', 54 'src/selectdialog.c', 54 55 'src/slider.c', 55 56 'src/tab.c', … … 85 86 'test/resource.c', 86 87 'test/scrollbar.c', 88 'test/selectdialog.c', 87 89 'test/slider.c', 88 90 'test/tab.c', -
uspace/lib/ui/private/entry.h
rec8ef12 rc0757e1f 92 92 } ui_entry_geom_t; 93 93 94 extern errno_t ui_entry_insert_str(ui_entry_t *, const char *);95 94 extern ui_evclaim_t ui_entry_key_press_ctrl(ui_entry_t *, kbd_event_t *); 96 95 extern ui_evclaim_t ui_entry_key_press_shift(ui_entry_t *, kbd_event_t *); -
uspace/lib/ui/private/filelist.h
rec8ef12 rc0757e1f 103 103 104 104 extern bool ui_file_list_is_active(ui_file_list_t *); 105 extern void ui_file_list_entry_de lete(ui_file_list_entry_t *);105 extern void ui_file_list_entry_destroy(ui_file_list_entry_t *); 106 106 extern void ui_file_list_clear_entries(ui_file_list_t *); 107 107 extern errno_t ui_file_list_sort(ui_file_list_t *); -
uspace/lib/ui/private/list.h
rec8ef12 rc0757e1f 136 136 extern int ui_list_entry_ptr_cmp(const void *, const void *); 137 137 extern size_t ui_list_entry_get_idx(ui_list_entry_t *); 138 extern void ui_list_entry_destroy(ui_list_entry_t *); 138 139 139 140 #endif -
uspace/lib/ui/private/promptdialog.h
rec8ef12 rc0757e1f 45 45 /** Dialog window */ 46 46 struct ui_window *window; 47 /** File nameentry */47 /** Text entry */ 48 48 struct ui_entry *ename; 49 49 /** OK button */ -
uspace/lib/ui/src/filelist.c
rec8ef12 rc0757e1f 46 46 #include <qsort.h> 47 47 #include "../private/filelist.h" 48 #include "../private/list.h" 48 49 #include "../private/resource.h" 49 50 … … 290 291 * @param entry File list entry 291 292 */ 292 void ui_file_list_entry_de lete(ui_file_list_entry_t *entry)293 { 294 ui_list_entry_de lete(entry->entry);293 void ui_file_list_entry_destroy(ui_file_list_entry_t *entry) 294 { 295 ui_list_entry_destroy(entry->entry); 295 296 free(entry->name); 296 297 free(entry); … … 307 308 entry = ui_file_list_first(flist); 308 309 while (entry != NULL) { 309 ui_file_list_entry_de lete(entry);310 ui_file_list_entry_destroy(entry); 310 311 entry = ui_file_list_first(flist); 311 312 } -
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); -
uspace/lib/ui/src/promptdialog.c
rec8ef12 rc0757e1f 327 327 { 328 328 ui_prompt_dialog_t *dialog = (ui_prompt_dialog_t *) arg; 329 const char * fname;329 const char *text; 330 330 331 331 if (event->type == KEY_PRESS && … … 334 334 /* Confirm */ 335 335 if (dialog->cb != NULL && dialog->cb->bok != NULL) { 336 fname= ui_entry_get_text(dialog->ename);337 dialog->cb->bok(dialog, dialog->arg, fname);336 text = ui_entry_get_text(dialog->ename); 337 dialog->cb->bok(dialog, dialog->arg, text); 338 338 return; 339 339 } … … 358 358 { 359 359 ui_prompt_dialog_t *dialog = (ui_prompt_dialog_t *) arg; 360 const char * fname;360 const char *text; 361 361 362 362 if (dialog->cb != NULL && dialog->cb->bok != NULL) { 363 fname= ui_entry_get_text(dialog->ename);364 dialog->cb->bok(dialog, dialog->arg, fname);363 text = ui_entry_get_text(dialog->ename); 364 dialog->cb->bok(dialog, dialog->arg, text); 365 365 } 366 366 } -
uspace/lib/ui/test/filelist.c
rec8ef12 rc0757e1f 350 350 } 351 351 352 /** ui_file_list_entry_de lete() deletes entry */353 PCUT_TEST(entry_de lete)352 /** ui_file_list_entry_destroy() destroys entry */ 353 PCUT_TEST(entry_destroy) 354 354 { 355 355 ui_t *ui; … … 386 386 387 387 entry = ui_file_list_first(flist); 388 ui_file_list_entry_de lete(entry);388 ui_file_list_entry_destroy(entry); 389 389 390 390 PCUT_ASSERT_INT_EQUALS(1, ui_list_entries_cnt(flist->list)); 391 391 392 392 entry = ui_file_list_first(flist); 393 ui_file_list_entry_de lete(entry);393 ui_file_list_entry_destroy(entry); 394 394 395 395 PCUT_ASSERT_INT_EQUALS(0, ui_list_entries_cnt(flist->list)); -
uspace/lib/ui/test/list.c
rec8ef12 rc0757e1f 119 119 } 120 120 121 //XXX 122 PCUT_TEST(get_cb_arg) 123 { 124 } 125 121 126 /** ui_list_entry_height() gives the correct height */ 122 127 PCUT_TEST(entry_height) … … 751 756 } 752 757 758 //XXX TODO 759 PCUT_TEST(set_cursor) 760 { 761 } 762 753 763 /** ui_list_entry_attr_init() initializes entry attribute structure */ 754 764 PCUT_TEST(entry_attr_init) … … 902 912 ui_window_destroy(window); 903 913 ui_destroy(ui); 914 } 915 916 //XXX 917 PCUT_TEST(entry_get_list) 918 { 904 919 } 905 920 -
uspace/lib/ui/test/main.c
rec8ef12 rc0757e1f 52 52 PCUT_IMPORT(resource); 53 53 PCUT_IMPORT(scrollbar); 54 PCUT_IMPORT(select_dialog); 54 55 PCUT_IMPORT(slider); 55 56 PCUT_IMPORT(tab); … … 59 60 PCUT_IMPORT(wdecor); 60 61 PCUT_IMPORT(window); 62 61 63 PCUT_MAIN();
Note:
See TracChangeset
for help on using the changeset viewer.
