Changeset 46bd63c9 in mainline
- Timestamp:
- 2023-09-08T08:47:30Z (16 months ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1af103e
- Parents:
- 0b6fad9
- git-author:
- Jiri Svoboda <jiri@…> (2023-09-07 18:47:09)
- git-committer:
- Jiri Svoboda <jiri@…> (2023-09-08 08:47:30)
- Location:
- uspace
- Files:
-
- 5 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/calculator/calculator.c
r0b6fad9 r46bd63c9 1 1 /* 2 * Copyright (c) 202 2Jiri Svoboda2 * Copyright (c) 2023 Jiri Svoboda 3 3 * Copyright (c) 2016 Martin Decky 4 4 * All rights reserved. … … 46 46 #include <ui/entry.h> 47 47 #include <ui/fixed.h> 48 #include <ui/menu.h> 48 49 #include <ui/menubar.h> 49 #include <ui/menu .h>50 #include <ui/menudd.h> 50 51 #include <ui/menuentry.h> 51 52 #include <ui/pbutton.h> … … 896 897 } 897 898 898 rc = ui_menu_ create(calc.menubar, "~F~ile", &mfile);899 rc = ui_menu_dd_create(calc.menubar, "~F~ile", NULL, &mfile); 899 900 if (rc != EOK) { 900 901 printf("Error creating menu.\n"); … … 910 911 ui_menu_entry_set_cb(mexit, calc_file_exit, (void *) &calc); 911 912 912 rc = ui_menu_ create(calc.menubar, "~E~dit", &medit);913 rc = ui_menu_dd_create(calc.menubar, "~E~dit", NULL, &medit); 913 914 if (rc != EOK) { 914 915 printf("Error creating menu.\n"); -
uspace/app/edit/edit.c
r0b6fad9 r46bd63c9 1 1 /* 2 * Copyright (c) 202 2Jiri Svoboda2 * Copyright (c) 2023 Jiri Svoboda 3 3 * Copyright (c) 2012 Martin Sucha 4 4 * All rights reserved. … … 60 60 #include <ui/menu.h> 61 61 #include <ui/menubar.h> 62 #include <ui/menudd.h> 62 63 #include <ui/menuentry.h> 63 64 #include <ui/promptdialog.h> … … 430 431 } 431 432 432 rc = ui_menu_ create(edit->menubar, "~F~ile", &mfile);433 rc = ui_menu_dd_create(edit->menubar, "~F~ile", NULL, &mfile); 433 434 if (rc != EOK) { 434 435 printf("Error creating menu.\n"); … … 466 467 ui_menu_entry_set_cb(mexit, edit_file_exit, (void *) edit); 467 468 468 rc = ui_menu_ create(edit->menubar, "~E~dit", &medit);469 rc = ui_menu_dd_create(edit->menubar, "~E~dit", NULL, &medit); 469 470 if (rc != EOK) { 470 471 printf("Error creating menu.\n"); … … 518 519 ui_menu_entry_set_cb(mselall, edit_edit_select_all, (void *) edit); 519 520 520 rc = ui_menu_ create(edit->menubar, "~S~earch", &msearch);521 rc = ui_menu_dd_create(edit->menubar, "~S~earch", NULL, &msearch); 521 522 if (rc != EOK) { 522 523 printf("Error creating menu.\n"); -
uspace/app/nav/menu.c
r0b6fad9 r46bd63c9 1 1 /* 2 * Copyright (c) 202 2Jiri Svoboda2 * Copyright (c) 2023 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 39 39 #include <ui/menu.h> 40 40 #include <ui/menubar.h> 41 #include <ui/menudd.h> 41 42 #include <ui/menuentry.h> 42 43 #include "menu.h" … … 72 73 goto error; 73 74 74 rc = ui_menu_ create(menu->menubar, "~F~ile", &mfile);75 rc = ui_menu_dd_create(menu->menubar, "~F~ile", NULL, &mfile); 75 76 if (rc != EOK) 76 77 goto error; -
uspace/app/uidemo/uidemo.c
r0b6fad9 r46bd63c9 45 45 #include <ui/label.h> 46 46 #include <ui/list.h> 47 #include <ui/menu.h> 47 48 #include <ui/menubar.h> 49 #include <ui/menudd.h> 48 50 #include <ui/menuentry.h> 49 #include <ui/menu.h>50 51 #include <ui/msgdialog.h> 51 52 #include <ui/pbutton.h> … … 764 765 } 765 766 766 rc = ui_menu_ create(demo.mbar, "~F~ile", &demo.mfile);767 rc = ui_menu_dd_create(demo.mbar, "~F~ile", NULL, &demo.mfile); 767 768 if (rc != EOK) { 768 769 printf("Error creating menu.\n"); … … 818 819 ui_menu_entry_set_cb(mexit, uidemo_file_exit, (void *) &demo); 819 820 820 rc = ui_menu_ create(demo.mbar, "~E~dit", &demo.medit);821 rc = ui_menu_dd_create(demo.mbar, "~E~dit", NULL, &demo.medit); 821 822 if (rc != EOK) { 822 823 printf("Error creating menu.\n"); … … 842 843 (void *) &demo); 843 844 844 rc = ui_menu_create(demo.mbar, "~P~references", &demo.mpreferences); 845 rc = ui_menu_dd_create(demo.mbar, "~P~references", NULL, 846 &demo.mpreferences); 845 847 if (rc != EOK) { 846 848 printf("Error creating menu.\n"); … … 848 850 } 849 851 850 rc = ui_menu_ create(demo.mbar, "~H~elp", &demo.mhelp);852 rc = ui_menu_dd_create(demo.mbar, "~H~elp", NULL, &demo.mhelp); 851 853 if (rc != EOK) { 852 854 printf("Error creating menu.\n"); -
uspace/lib/ui/include/types/ui/menu.h
r0b6fad9 r46bd63c9 1 1 /* 2 * Copyright (c) 202 1Jiri Svoboda2 * Copyright (c) 2023 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 37 37 #define _UI_TYPES_MENU_H 38 38 39 #include <types/common.h> 40 39 41 struct ui_menu; 40 42 typedef struct ui_menu ui_menu_t; 43 44 /** Menu callbacks */ 45 typedef struct ui_menu_cb { 46 /** Left arrow pressed */ 47 void (*left)(ui_menu_t *, void *, sysarg_t); 48 /** Right arrow pressed */ 49 void (*right)(ui_menu_t *, void *, sysarg_t); 50 /** Request menu closure */ 51 void (*close_req)(ui_menu_t *, void *); 52 /** Accelerator key pressed */ 53 void (*press_accel)(ui_menu_t *, void *, char32_t, sysarg_t); 54 } ui_menu_cb_t; 41 55 42 56 #endif -
uspace/lib/ui/include/ui/menu.h
r0b6fad9 r46bd63c9 43 43 #include <stdbool.h> 44 44 #include <types/common.h> 45 #include <types/ui/event.h> 45 46 #include <types/ui/menu.h> 46 47 #include <types/ui/menubar.h> 47 #include <types/ui/ event.h>48 #include <types/ui/window.h> 48 49 #include <uchar.h> 49 50 50 extern errno_t ui_menu_create(ui_ menu_bar_t *, const char*, ui_menu_t **);51 extern errno_t ui_menu_create(ui_window_t *, ui_menu_t **); 51 52 extern void ui_menu_destroy(ui_menu_t *); 52 extern ui_menu_t *ui_menu_first(ui_menu_bar_t *); 53 extern ui_menu_t *ui_menu_next(ui_menu_t *); 54 extern ui_menu_t *ui_menu_last(ui_menu_bar_t *); 55 extern ui_menu_t *ui_menu_prev(ui_menu_t *); 56 extern const char *ui_menu_caption(ui_menu_t *); 57 extern void ui_menu_get_rect(ui_menu_t *, gfx_coord2_t *, gfx_rect_t *); 58 extern char32_t ui_menu_get_accel(ui_menu_t *); 53 extern void ui_menu_set_cb(ui_menu_t *, ui_menu_cb_t *, void *); 59 54 extern errno_t ui_menu_open(ui_menu_t *, gfx_rect_t *, sysarg_t); 60 55 extern void ui_menu_close(ui_menu_t *); -
uspace/lib/ui/meson.build
r0b6fad9 r46bd63c9 43 43 'src/menu.c', 44 44 'src/menubar.c', 45 'src/menudd.c', 45 46 'src/menuentry.c', 46 47 'src/msgdialog.c', … … 77 78 'test/menu.c', 78 79 'test/menubar.c', 80 'test/menudd.c', 79 81 'test/menuentry.c', 80 82 'test/msgdialog.c', -
uspace/lib/ui/private/menu.h
r0b6fad9 r46bd63c9 1 1 /* 2 * Copyright (c) 202 2Jiri Svoboda2 * Copyright (c) 2023 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 41 41 #include <gfx/coord.h> 42 42 #include <stdbool.h> 43 #include <types/common.h> 43 44 #include <types/ui/menu.h> 44 45 #include <types/ui/resource.h> … … 49 50 */ 50 51 struct ui_menu { 51 /** Containing menu bar */ 52 struct ui_menu_bar *mbar; 53 /** Link to @c bar->menus */ 54 link_t lmenus; 52 /** Parent window */ 53 struct ui_window *parent; 55 54 /** Caption */ 56 55 char *caption; … … 67 66 /** Menu entries (ui_menu_entry_t) */ 68 67 list_t entries; 68 /** Callbacks */ 69 struct ui_menu_cb *cb; 70 /** Callback argument */ 71 void *arg; 69 72 }; 70 73 … … 86 89 extern void ui_menu_up(ui_menu_t *); 87 90 extern void ui_menu_down(ui_menu_t *); 91 extern void ui_menu_left(ui_menu_t *, sysarg_t); 92 extern void ui_menu_right(ui_menu_t *, sysarg_t); 93 extern void ui_menu_close_req(ui_menu_t *); 94 extern void ui_menu_press_accel(ui_menu_t *, char32_t, sysarg_t); 88 95 89 96 #endif -
uspace/lib/ui/private/menubar.h
r0b6fad9 r46bd63c9 42 42 #include <stdbool.h> 43 43 #include <types/common.h> 44 #include <types/ui/menu.h>45 44 #include <types/ui/menubar.h> 45 #include <types/ui/menudd.h> 46 46 47 47 /** Actual structure of menu bar. … … 60 60 /** Menu bar is active */ 61 61 bool active; 62 /** Selected menu or @c NULL */63 struct ui_menu *selected;64 /** List of menu s (ui_menu_t) */65 list_t menu s;62 /** Selected menu drop-down or @c NULL */ 63 struct ui_menu_dd *selected; 64 /** List of menu drop-downs (ui_menu_dd_t) */ 65 list_t menudds; 66 66 }; 67 67 68 extern void ui_menu_bar_select(ui_menu_bar_t *, ui_menu_ t *, bool, sysarg_t);68 extern void ui_menu_bar_select(ui_menu_bar_t *, ui_menu_dd_t *, bool, sysarg_t); 69 69 extern void ui_menu_bar_left(ui_menu_bar_t *, sysarg_t); 70 70 extern void ui_menu_bar_right(ui_menu_bar_t *, sysarg_t); 71 71 extern ui_evclaim_t ui_menu_bar_key_press_unmod(ui_menu_bar_t *, kbd_event_t *); 72 extern void ui_menu_bar_entry_rect(ui_menu_bar_t *, ui_menu_t *, gfx_rect_t *); 72 extern void ui_menu_bar_entry_rect(ui_menu_bar_t *, ui_menu_dd_t *, 73 gfx_rect_t *); 73 74 74 75 #endif -
uspace/lib/ui/src/menu.c
r0b6fad9 r46bd63c9 44 44 #include <str.h> 45 45 #include <uchar.h> 46 #include <ui/ui.h> 46 47 #include <ui/accel.h> 47 48 #include <ui/control.h> … … 49 50 #include <ui/popup.h> 50 51 #include <ui/menu.h> 51 #include <ui/menubar.h>52 52 #include <ui/menuentry.h> 53 53 #include <ui/resource.h> 54 54 #include <ui/window.h> 55 #include "../private/menubar.h"56 55 #include "../private/menu.h" 57 56 #include "../private/resource.h" … … 78 77 /** Create new menu. 79 78 * 79 * @param parent Parent window 80 80 * @param mbar Menu bar 81 * @param caption Caption82 81 * @param rmenu Place to store pointer to new menu 83 82 * @return EOK on success, ENOMEM if out of memory 84 83 */ 85 errno_t ui_menu_create(ui_menu_bar_t *mbar, const char *caption, 86 ui_menu_t **rmenu) 84 errno_t ui_menu_create(ui_window_t *parent, ui_menu_t **rmenu) 87 85 { 88 86 ui_menu_t *menu; … … 92 90 return ENOMEM; 93 91 94 menu->caption = str_dup(caption); 95 if (menu->caption == NULL) { 96 free(menu); 97 return ENOMEM; 98 } 99 100 menu->mbar = mbar; 101 list_append(&menu->lmenus, &mbar->menus); 92 menu->parent = parent; 102 93 list_initialize(&menu->entries); 103 94 … … 124 115 } 125 116 126 list_remove(&menu->lmenus);127 117 free(menu->caption); 128 118 free(menu); 129 119 } 130 120 131 /** Get first menu in menu bar. 132 * 133 * @param mbar Menu bar 134 * @return First menu or @c NULL if there is none 135 */ 136 ui_menu_t *ui_menu_first(ui_menu_bar_t *mbar) 137 { 138 link_t *link; 139 140 link = list_first(&mbar->menus); 141 if (link == NULL) 142 return NULL; 143 144 return list_get_instance(link, ui_menu_t, lmenus); 145 } 146 147 /** Get next menu in menu bar. 148 * 149 * @param cur Current menu 150 * @return Next menu or @c NULL if @a cur is the last one 151 */ 152 ui_menu_t *ui_menu_next(ui_menu_t *cur) 153 { 154 link_t *link; 155 156 link = list_next(&cur->lmenus, &cur->mbar->menus); 157 if (link == NULL) 158 return NULL; 159 160 return list_get_instance(link, ui_menu_t, lmenus); 161 } 162 163 /** Get last menu in menu bar. 164 * 165 * @param mbar Menu bar 166 * @return Last menu or @c NULL if there is none 167 */ 168 ui_menu_t *ui_menu_last(ui_menu_bar_t *mbar) 169 { 170 link_t *link; 171 172 link = list_last(&mbar->menus); 173 if (link == NULL) 174 return NULL; 175 176 return list_get_instance(link, ui_menu_t, lmenus); 177 } 178 179 /** Get previous menu in menu bar. 180 * 181 * @param cur Current menu 182 * @return Previous menu or @c NULL if @a cur is the fist one 183 */ 184 ui_menu_t *ui_menu_prev(ui_menu_t *cur) 185 { 186 link_t *link; 187 188 link = list_prev(&cur->lmenus, &cur->mbar->menus); 189 if (link == NULL) 190 return NULL; 191 192 return list_get_instance(link, ui_menu_t, lmenus); 193 } 194 195 /** Get menu caption. 196 * 197 * @param menu Menu 198 * @return Caption (owned by @a menu) 199 */ 200 const char *ui_menu_caption(ui_menu_t *menu) 201 { 202 return menu->caption; 121 /** Set menu callbacks. 122 * 123 * @param menu Menu 124 * @param cb Callbacks 125 * @param arg Callback argument 126 */ 127 void ui_menu_set_cb(ui_menu_t *menu, ui_menu_cb_t *cb, void *arg) 128 { 129 menu->cb = cb; 130 menu->arg = arg; 203 131 } 204 132 … … 212 140 ui_menu_geom_t *geom) 213 141 { 214 ui_resource_t *res;215 142 gfx_coord2_t edim; 216 143 gfx_coord_t frame_w; 217 144 gfx_coord_t frame_h; 218 219 res = ui_window_get_res(menu->mbar->window); 145 ui_resource_t *res; 146 147 res = ui_window_get_res(menu->parent); 220 148 221 149 if (res->textmode) { … … 241 169 } 242 170 243 /** Get menu rectangle.244 *245 * @param menu Menu246 * @param spos Starting position (top-left corner)247 * @param rect Place to store menu rectangle248 */249 void ui_menu_get_rect(ui_menu_t *menu, gfx_coord2_t *spos, gfx_rect_t *rect)250 {251 ui_menu_geom_t geom;252 253 ui_menu_get_geom(menu, spos, &geom);254 *rect = geom.outer_rect;255 }256 257 /** Get menu accelerator character.258 *259 * @param menu Menu260 * @return Accelerator character (lowercase) or the null character if261 * the menu has no accelerator.262 */263 char32_t ui_menu_get_accel(ui_menu_t *menu)264 {265 return ui_accel_get(menu->caption);266 }267 268 171 /** Get UI resource from menu. 269 172 * … … 304 207 params.idev_id = idev_id; 305 208 306 rc = ui_popup_create( menu->mbar->ui, menu->mbar->window, ¶ms,307 &p opup);209 rc = ui_popup_create(ui_window_get_ui(menu->parent), menu->parent, 210 ¶ms, &popup); 308 211 if (rc != EOK) 309 212 return rc; … … 503 406 /* Press outside menu - close it */ 504 407 if (event->type == POS_PRESS) 505 ui_menu_ bar_deactivate(menu->mbar);408 ui_menu_close_req(menu); 506 409 } 507 410 … … 524 427 if (event->type == KEY_PRESS && (event->mods & KM_ALT) != 0 && 525 428 (event->mods & (KM_CTRL | KM_SHIFT)) == 0 && event->c != '\0') 526 ui_menu_ bar_press_accel(menu->mbar, event->c, event->kbd_id);429 ui_menu_press_accel(menu, event->c, event->kbd_id); 527 430 528 431 return ui_claimed; … … 615 518 switch (event->key) { 616 519 case KC_ESCAPE: 617 ui_menu_ bar_deactivate(menu->mbar);520 ui_menu_close_req(menu); 618 521 break; 619 522 case KC_LEFT: 620 ui_menu_ bar_left(menu->mbar, event->kbd_id);523 ui_menu_left(menu, event->kbd_id); 621 524 break; 622 525 case KC_RIGHT: 623 ui_menu_ bar_right(menu->mbar, event->kbd_id);526 ui_menu_right(menu, event->kbd_id); 624 527 break; 625 528 case KC_UP: … … 658 561 ui_menu_t *menu = (ui_menu_t *)arg; 659 562 660 /* Deactivate menu bar, close menu*/661 ui_menu_ bar_deactivate(menu->mbar);563 /* Forward close request to caller */ 564 ui_menu_close_req(menu); 662 565 } 663 566 … … 691 594 } 692 595 596 /** Send menu left event. 597 * 598 * @param menu Menu 599 * @param idev_id Input device ID 600 */ 601 void ui_menu_left(ui_menu_t *menu, sysarg_t idev_id) 602 { 603 if (menu->cb != NULL && menu->cb->left != NULL) 604 menu->cb->left(menu, menu->arg, idev_id); 605 } 606 607 /** Send menu right event. 608 * 609 * @param menu Menu 610 * @param idev_id Input device ID 611 */ 612 void ui_menu_right(ui_menu_t *menu, sysarg_t idev_id) 613 { 614 if (menu->cb != NULL && menu->cb->right != NULL) 615 menu->cb->right(menu, menu->arg, idev_id); 616 } 617 618 /** Send menu close request event. 619 * 620 * @param menu Menu 621 */ 622 void ui_menu_close_req(ui_menu_t *menu) 623 { 624 if (menu->cb != NULL && menu->cb->close_req != NULL) 625 menu->cb->close_req(menu, menu->arg); 626 } 627 628 /** Send menu accelerator key press event. 629 * 630 * @param menu Menu 631 * @param c Character 632 * @param kbd_id Keyboard ID 633 */ 634 void ui_menu_press_accel(ui_menu_t *menu, char32_t c, sysarg_t kbd_id) 635 { 636 if (menu->cb != NULL && menu->cb->press_accel != NULL) 637 menu->cb->press_accel(menu, menu->arg, c, kbd_id); 638 } 639 693 640 /** @} 694 641 */ -
uspace/lib/ui/src/menubar.c
r0b6fad9 r46bd63c9 45 45 #include <ui/control.h> 46 46 #include <ui/paint.h> 47 #include <ui/menu.h>48 47 #include <ui/menubar.h> 48 #include <ui/menudd.h> 49 49 #include <ui/window.h> 50 50 #include "../private/menubar.h" … … 95 95 mbar->ui = ui; 96 96 mbar->window = window; 97 list_initialize(&mbar->menu s);97 list_initialize(&mbar->menudds); 98 98 *rmbar = mbar; 99 99 return EOK; … … 106 106 void ui_menu_bar_destroy(ui_menu_bar_t *mbar) 107 107 { 108 ui_menu_ t *menu;108 ui_menu_dd_t *mdd; 109 109 110 110 if (mbar == NULL) 111 111 return; 112 112 113 /* Destroy menu s */114 m enu = ui_menu_first(mbar);115 while (m enu!= NULL) {116 ui_menu_d estroy(menu);117 m enu = ui_menu_first(mbar);113 /* Destroy menu drop-downs */ 114 mdd = ui_menu_dd_first(mbar); 115 while (mdd != NULL) { 116 ui_menu_dd_destroy(mdd); 117 mdd = ui_menu_dd_first(mbar); 118 118 } 119 119 … … 155 155 gfx_rect_t rect; 156 156 gfx_color_t *bg_color; 157 ui_menu_ t *menu;157 ui_menu_dd_t *mdd; 158 158 const char *caption; 159 159 gfx_coord_t width; … … 189 189 fmt.valign = gfx_valign_top; 190 190 191 m enu = ui_menu_first(mbar);192 while (m enu!= NULL) {193 caption = ui_menu_ caption(menu);191 mdd = ui_menu_dd_first(mbar); 192 while (mdd != NULL) { 193 caption = ui_menu_dd_caption(mdd); 194 194 width = ui_text_width(res->font, caption) + 2 * hpad; 195 195 tpos.x = pos.x + hpad; … … 200 200 rect.p1.y = mbar->rect.p1.y; 201 201 202 if (m enu== mbar->selected) {202 if (mdd == mbar->selected) { 203 203 fmt.color = res->wnd_sel_text_color; 204 204 fmt.hgl_color = res->wnd_sel_text_hgl_color; … … 223 223 224 224 pos.x += width; 225 m enu = ui_menu_next(menu);225 mdd = ui_menu_dd_next(mdd); 226 226 } 227 227 … … 241 241 * 242 242 * @param mbar Menu bar 243 * @param m enu Menuto select (or deselect if selected) or @c NULL243 * @param mdd Menu drop-down to select (or deselect if selected) or @c NULL 244 244 * @param openup Open menu even if not currently open 245 245 * @param idev_id Input device ID associated with the selecting seat 246 246 */ 247 void ui_menu_bar_select(ui_menu_bar_t *mbar, ui_menu_ t *menu, bool openup,247 void ui_menu_bar_select(ui_menu_bar_t *mbar, ui_menu_dd_t *mdd, bool openup, 248 248 sysarg_t idev_id) 249 249 { 250 ui_menu_ t *old_menu;250 ui_menu_dd_t *old_mdd; 251 251 gfx_rect_t rect; 252 252 bool was_open; 253 253 254 old_m enu= mbar->selected;255 256 mbar->selected = m enu;257 258 /* Close previously open menu */259 if (old_m enu != NULL && ui_menu_is_open(old_menu)) {254 old_mdd = mbar->selected; 255 256 mbar->selected = mdd; 257 258 /* Close previously open menu drop-down */ 259 if (old_mdd != NULL && ui_menu_dd_is_open(old_mdd)) { 260 260 was_open = true; 261 (void) ui_menu_ close(old_menu);261 (void) ui_menu_dd_close(old_mdd); 262 262 } else { 263 263 was_open = false; … … 270 270 if (openup || was_open) { 271 271 /* 272 * Open the newly selected menu if either273 * the old menu was open or @a openup was272 * Open the newly selected menu drop-down if either 273 * the old menu drop-down was open or @a openup was 274 274 * specified. 275 275 */ 276 (void) ui_menu_ open(mbar->selected, &rect, idev_id);276 (void) ui_menu_dd_open(mbar->selected, &rect, idev_id); 277 277 } 278 278 } … … 289 289 void ui_menu_bar_left(ui_menu_bar_t *mbar, sysarg_t idev_id) 290 290 { 291 ui_menu_ t *nmenu;291 ui_menu_dd_t *nmdd; 292 292 293 293 if (mbar->selected == NULL) 294 294 return; 295 295 296 nm enu = ui_menu_prev(mbar->selected);297 if (nm enu== NULL)298 nm enu = ui_menu_last(mbar);299 300 if (nm enu!= mbar->selected)301 ui_menu_bar_select(mbar, nm enu, false, idev_id);296 nmdd = ui_menu_dd_prev(mbar->selected); 297 if (nmdd == NULL) 298 nmdd = ui_menu_dd_last(mbar); 299 300 if (nmdd != mbar->selected) 301 ui_menu_bar_select(mbar, nmdd, false, idev_id); 302 302 } 303 303 … … 312 312 void ui_menu_bar_right(ui_menu_bar_t *mbar, sysarg_t idev_id) 313 313 { 314 ui_menu_ t *nmenu;314 ui_menu_dd_t *nmdd; 315 315 316 316 if (mbar->selected == NULL) 317 317 return; 318 318 319 nm enu = ui_menu_next(mbar->selected);320 if (nm enu== NULL)321 nm enu = ui_menu_first(mbar);322 323 if (nm enu!= mbar->selected)324 ui_menu_bar_select(mbar, nm enu, false, idev_id);319 nmdd = ui_menu_dd_next(mbar->selected); 320 if (nmdd == NULL) 321 nmdd = ui_menu_dd_first(mbar); 322 323 if (nmdd != mbar->selected) 324 ui_menu_bar_select(mbar, nmdd, false, idev_id); 325 325 } 326 326 … … 355 355 356 356 if (event->key == KC_ENTER || event->key == KC_DOWN) { 357 if (mbar->selected != NULL && !ui_menu_is_open(mbar->selected)) { 357 if (mbar->selected != NULL && 358 !ui_menu_dd_is_open(mbar->selected)) { 358 359 ui_menu_bar_entry_rect(mbar, mbar->selected, 359 360 &rect); 360 ui_menu_ open(mbar->selected, &rect, event->kbd_id);361 ui_menu_dd_open(mbar->selected, &rect, event->kbd_id); 361 362 } 362 363 … … 364 365 } 365 366 366 if (event->c != '\0' && !ui_menu_ is_open(mbar->selected)) {367 if (event->c != '\0' && !ui_menu_dd_is_open(mbar->selected)) { 367 368 /* Check if it is an accelerator. */ 368 369 ui_menu_bar_press_accel(mbar, event->c, event->kbd_id); … … 407 408 void ui_menu_bar_press_accel(ui_menu_bar_t *mbar, char32_t c, sysarg_t kbd_id) 408 409 { 409 ui_menu_ t *menu;410 ui_menu_dd_t *mdd; 410 411 char32_t maccel; 411 412 412 m enu = ui_menu_first(mbar);413 while (m enu!= NULL) {414 maccel = ui_menu_ get_accel(menu);413 mdd = ui_menu_dd_first(mbar); 414 while (mdd != NULL) { 415 maccel = ui_menu_dd_get_accel(mdd); 415 416 if (c == maccel) { 416 ui_menu_bar_select(mbar, m enu, true, kbd_id);417 ui_menu_bar_select(mbar, mdd, true, kbd_id); 417 418 return; 418 419 } 419 420 420 m enu = ui_menu_next(menu);421 mdd = ui_menu_dd_next(mdd); 421 422 } 422 423 } … … 433 434 gfx_coord2_t pos; 434 435 gfx_rect_t rect; 435 ui_menu_ t *menu;436 ui_menu_dd_t *mdd; 436 437 const char *caption; 437 438 gfx_coord_t width; … … 454 455 pos_id = event->pos_id; 455 456 456 m enu = ui_menu_first(mbar);457 while (m enu!= NULL) {458 caption = ui_menu_ caption(menu);457 mdd = ui_menu_dd_first(mbar); 458 while (mdd != NULL) { 459 caption = ui_menu_dd_caption(mdd); 459 460 width = ui_text_width(res->font, caption) + 2 * hpad; 460 461 … … 469 470 470 471 /* Open the menu, close if already open. */ 471 if (m enu== mbar->selected)472 if (mdd == mbar->selected) 472 473 ui_menu_bar_select(mbar, NULL, false, pos_id); 473 474 else 474 ui_menu_bar_select(mbar, m enu, true, pos_id);475 ui_menu_bar_select(mbar, mdd, true, pos_id); 475 476 476 477 return ui_claimed; … … 478 479 479 480 pos.x += width; 480 m enu = ui_menu_next(menu);481 mdd = ui_menu_dd_next(mdd); 481 482 } 482 483 … … 487 488 * 488 489 * @param mbar Menu bar 489 * @param m enu Menuwhose entry's rectangle is to be returned490 * @param mdd Menu drop-down whose entry's rectangle is to be returned 490 491 * @param rrect Place to store entry rectangle 491 492 */ 492 void ui_menu_bar_entry_rect(ui_menu_bar_t *mbar, ui_menu_ t *menu,493 void ui_menu_bar_entry_rect(ui_menu_bar_t *mbar, ui_menu_dd_t *mdd, 493 494 gfx_rect_t *rrect) 494 495 { … … 496 497 gfx_coord2_t pos; 497 498 gfx_rect_t rect; 498 ui_menu_ t *cur;499 ui_menu_dd_t *cur; 499 500 const char *caption; 500 501 gfx_coord_t width; … … 511 512 pos = mbar->rect.p0; 512 513 513 cur = ui_menu_ first(mbar);514 cur = ui_menu_dd_first(mbar); 514 515 while (cur != NULL) { 515 caption = ui_menu_ caption(cur);516 caption = ui_menu_dd_caption(cur); 516 517 width = ui_text_width(res->font, caption) + 2 * hpad; 517 518 … … 520 521 rect.p1.y = mbar->rect.p1.y; 521 522 522 if (cur == m enu) {523 if (cur == mdd) { 523 524 *rrect = rect; 524 525 return; … … 526 527 527 528 pos.x += width; 528 cur = ui_menu_ next(cur);529 cur = ui_menu_dd_next(cur); 529 530 } 530 531 … … 544 545 mbar->active = true; 545 546 if (mbar->selected == NULL) 546 mbar->selected = ui_menu_ first(mbar);547 mbar->selected = ui_menu_dd_first(mbar); 547 548 548 549 (void) ui_menu_bar_paint(mbar); -
uspace/lib/ui/src/menuentry.c
r0b6fad9 r46bd63c9 1 1 /* 2 * Copyright (c) 202 2Jiri Svoboda2 * Copyright (c) 2023 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 241 241 * This needs to work even if the menu is not open, so we cannot 242 242 * use the menu's resource, which is only created after the menu 243 * is open (and its window is created). Use the menu bar's243 * is open (and its window is created). Use the parent window's 244 244 * resource instead. 245 245 */ 246 res = ui_window_get_res(mentry->menu-> mbar->window);246 res = ui_window_get_res(mentry->menu->parent); 247 247 248 248 *caption_w = ui_text_width(res->font, mentry->caption); … … 267 267 * This needs to work even if the menu is not open, so we cannot 268 268 * use the menu's resource, which is only created after the menu 269 * is open (and its window is created). Use the menu bar's269 * is open (and its window is created). Use the parent window's 270 270 * resource instead. 271 271 */ 272 res = ui_window_get_res(menu-> mbar->window);272 res = ui_window_get_res(menu->parent); 273 273 274 274 if (res->textmode) … … 306 306 * This needs to work even if the menu is not open, so we cannot 307 307 * use the menu's resource, which is only created after the menu 308 * is open (and its window is created). Use the menu bar's308 * is open (and its window is created). Use the parent window's 309 309 * resource instead. 310 310 */ 311 res = ui_window_get_res(mentry->menu-> mbar->window);311 res = ui_window_get_res(mentry->menu->parent); 312 312 313 313 if (res->textmode) { … … 474 474 void ui_menu_entry_activate(ui_menu_entry_t *mentry) 475 475 { 476 /* Deactivate menu bar, close menu */477 ui_menu_ bar_deactivate(mentry->menu->mbar);476 /* Close menu */ 477 ui_menu_close_req(mentry->menu); 478 478 479 479 /* Call back */ -
uspace/lib/ui/test/main.c
r0b6fad9 r46bd63c9 44 44 PCUT_IMPORT(menu); 45 45 PCUT_IMPORT(menubar); 46 PCUT_IMPORT(menudd); 46 47 PCUT_IMPORT(menuentry); 47 48 PCUT_IMPORT(msg_dialog); -
uspace/lib/ui/test/menu.c
r0b6fad9 r46bd63c9 46 46 PCUT_TEST_SUITE(menu); 47 47 48 typedef struct { 49 bool left_called; 50 bool right_called; 51 bool close_req_called; 52 bool press_accel_called; 53 ui_menu_t *menu; 54 sysarg_t idev_id; 55 char32_t c; 56 } test_resp_t; 57 58 static void testmenu_left(ui_menu_t *, void *, sysarg_t); 59 static void testmenu_right(ui_menu_t *, void *, sysarg_t); 60 static void testmenu_close_req(ui_menu_t *, void *); 61 static void testmenu_press_accel(ui_menu_t *, void *, char32_t, sysarg_t); 62 63 ui_menu_cb_t testmenu_cb = { 64 .left = testmenu_left, 65 .right = testmenu_right, 66 .close_req = testmenu_close_req, 67 .press_accel = testmenu_press_accel 68 }; 69 70 ui_menu_cb_t dummy_cb = { 71 }; 72 48 73 /** Create and destroy menu */ 49 74 PCUT_TEST(create_destroy) 50 75 { 51 ui_menu_bar_t *mbar = NULL; 52 ui_menu_t *menu = NULL; 53 errno_t rc; 54 55 rc = ui_menu_bar_create(NULL, NULL, &mbar); 56 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 57 58 rc = ui_menu_create(mbar, "Test", &menu); 59 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 60 PCUT_ASSERT_NOT_NULL(menu); 61 62 /* 63 * Normally we don't need to destroy a menu explicitly, it will 64 * be destroyed along with menu bar, but here we'll test destroying 65 * it explicitly. 66 */ 67 ui_menu_destroy(menu); 68 ui_menu_bar_destroy(mbar); 76 ui_menu_t *menu = NULL; 77 errno_t rc; 78 79 rc = ui_menu_create(NULL, &menu); 80 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 81 PCUT_ASSERT_NOT_NULL(menu); 82 83 ui_menu_destroy(menu); 69 84 } 70 85 … … 75 90 } 76 91 77 /** ui_menu_first() / ui_menu_next() iterate over menus */ 78 PCUT_TEST(first_next) 79 { 80 ui_t *ui = NULL; 81 ui_window_t *window = NULL; 82 ui_wnd_params_t params; 83 ui_menu_bar_t *mbar = NULL; 84 ui_menu_t *menu1 = NULL; 85 ui_menu_t *menu2 = NULL; 86 ui_menu_t *m; 87 errno_t rc; 88 89 rc = ui_create_disp(NULL, &ui); 90 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 91 92 ui_wnd_params_init(¶ms); 93 params.caption = "Hello"; 94 95 rc = ui_window_create(ui, ¶ms, &window); 96 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 97 PCUT_ASSERT_NOT_NULL(window); 98 99 rc = ui_menu_bar_create(ui, window, &mbar); 100 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 101 PCUT_ASSERT_NOT_NULL(mbar); 102 103 rc = ui_menu_create(mbar, "Test 1", &menu1); 104 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 105 PCUT_ASSERT_NOT_NULL(menu1); 106 107 rc = ui_menu_create(mbar, "Test 1", &menu2); 108 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 109 PCUT_ASSERT_NOT_NULL(menu2); 110 111 m = ui_menu_first(mbar); 112 PCUT_ASSERT_EQUALS(menu1, m); 113 114 m = ui_menu_next(m); 115 PCUT_ASSERT_EQUALS(menu2, m); 116 117 m = ui_menu_next(m); 118 PCUT_ASSERT_NULL(m); 119 120 ui_menu_bar_destroy(mbar); 121 ui_window_destroy(window); 122 ui_destroy(ui); 123 } 124 125 /** ui_menu_last() / ui_menu_prev() iterate over menus in reverse */ 126 PCUT_TEST(last_prev) 127 { 128 ui_t *ui = NULL; 129 ui_window_t *window = NULL; 130 ui_wnd_params_t params; 131 ui_menu_bar_t *mbar = NULL; 132 ui_menu_t *menu1 = NULL; 133 ui_menu_t *menu2 = NULL; 134 ui_menu_t *m; 135 errno_t rc; 136 137 rc = ui_create_disp(NULL, &ui); 138 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 139 140 ui_wnd_params_init(¶ms); 141 params.caption = "Hello"; 142 143 rc = ui_window_create(ui, ¶ms, &window); 144 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 145 PCUT_ASSERT_NOT_NULL(window); 146 147 rc = ui_menu_bar_create(ui, window, &mbar); 148 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 149 PCUT_ASSERT_NOT_NULL(mbar); 150 151 rc = ui_menu_create(mbar, "Test 1", &menu1); 152 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 153 PCUT_ASSERT_NOT_NULL(menu1); 154 155 rc = ui_menu_create(mbar, "Test 1", &menu2); 156 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 157 PCUT_ASSERT_NOT_NULL(menu2); 158 159 m = ui_menu_last(mbar); 160 PCUT_ASSERT_EQUALS(menu2, m); 161 162 m = ui_menu_prev(m); 163 PCUT_ASSERT_EQUALS(menu1, m); 164 165 m = ui_menu_prev(m); 166 PCUT_ASSERT_NULL(m); 167 168 ui_menu_bar_destroy(mbar); 169 ui_window_destroy(window); 170 ui_destroy(ui); 171 } 172 173 /** ui_menu_caption() returns the menu's caption */ 174 PCUT_TEST(caption) 175 { 176 ui_t *ui = NULL; 177 ui_window_t *window = NULL; 178 ui_wnd_params_t params; 179 ui_menu_bar_t *mbar = NULL; 180 ui_menu_t *menu = NULL; 181 const char *caption; 182 errno_t rc; 183 184 rc = ui_create_disp(NULL, &ui); 185 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 186 187 ui_wnd_params_init(¶ms); 188 params.caption = "Hello"; 189 190 rc = ui_window_create(ui, ¶ms, &window); 191 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 192 PCUT_ASSERT_NOT_NULL(window); 193 194 rc = ui_menu_bar_create(ui, window, &mbar); 195 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 196 PCUT_ASSERT_NOT_NULL(mbar); 197 198 rc = ui_menu_create(mbar, "Test", &menu); 199 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 200 PCUT_ASSERT_NOT_NULL(menu); 201 202 caption = ui_menu_caption(menu); 203 PCUT_ASSERT_NOT_NULL(caption); 204 205 PCUT_ASSERT_INT_EQUALS(0, str_cmp(caption, "Test")); 206 207 ui_menu_bar_destroy(mbar); 208 ui_window_destroy(window); 209 ui_destroy(ui); 210 } 211 212 /** ui_menu_get_rect() returns outer menu rectangle */ 213 PCUT_TEST(get_rect) 214 { 215 ui_t *ui = NULL; 216 ui_window_t *window = NULL; 217 ui_wnd_params_t params; 218 ui_menu_bar_t *mbar = NULL; 219 ui_menu_t *menu = NULL; 220 gfx_coord2_t pos; 221 gfx_rect_t rect; 222 const char *caption; 223 errno_t rc; 224 225 rc = ui_create_disp(NULL, &ui); 226 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 227 228 ui_wnd_params_init(¶ms); 229 params.caption = "Hello"; 230 231 rc = ui_window_create(ui, ¶ms, &window); 232 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 233 PCUT_ASSERT_NOT_NULL(window); 234 235 rc = ui_menu_bar_create(ui, window, &mbar); 236 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 237 PCUT_ASSERT_NOT_NULL(mbar); 238 239 rc = ui_menu_create(mbar, "Test", &menu); 240 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 241 PCUT_ASSERT_NOT_NULL(menu); 242 243 caption = ui_menu_caption(menu); 244 PCUT_ASSERT_NOT_NULL(caption); 245 246 pos.x = 0; 247 pos.y = 0; 248 ui_menu_get_rect(menu, &pos, &rect); 249 250 PCUT_ASSERT_INT_EQUALS(0, rect.p0.x); 251 PCUT_ASSERT_INT_EQUALS(0, rect.p0.y); 252 PCUT_ASSERT_INT_EQUALS(16, rect.p1.x); 253 PCUT_ASSERT_INT_EQUALS(8, rect.p1.y); 254 255 ui_menu_bar_destroy(mbar); 256 ui_window_destroy(window); 257 ui_destroy(ui); 258 } 259 260 /** Open and close menu with ui_menu_open() / ui_menu_close() */ 261 PCUT_TEST(open_close) 262 { 263 ui_t *ui = NULL; 264 ui_window_t *window = NULL; 265 ui_wnd_params_t params; 266 ui_menu_bar_t *mbar = NULL; 267 ui_menu_t *menu = NULL; 268 gfx_rect_t prect; 269 errno_t rc; 270 271 rc = ui_create_disp(NULL, &ui); 272 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 273 274 ui_wnd_params_init(¶ms); 275 params.caption = "Hello"; 276 277 rc = ui_window_create(ui, ¶ms, &window); 278 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 279 PCUT_ASSERT_NOT_NULL(window); 280 281 rc = ui_menu_bar_create(ui, window, &mbar); 282 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 283 PCUT_ASSERT_NOT_NULL(mbar); 284 285 rc = ui_menu_create(mbar, "Test", &menu); 286 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 287 PCUT_ASSERT_NOT_NULL(menu); 288 289 prect.p0.x = 0; 290 prect.p0.y = 0; 291 prect.p1.x = 0; 292 prect.p1.y = 0; 293 294 /* Open and close */ 295 rc = ui_menu_open(menu, &prect, 0); 296 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 297 298 ui_menu_close(menu); 299 300 ui_menu_bar_destroy(mbar); 301 ui_window_destroy(window); 302 ui_destroy(ui); 303 } 304 305 /** ui_menu_is_open() correctly returns menu state */ 306 PCUT_TEST(is_open) 307 { 308 ui_t *ui = NULL; 309 ui_window_t *window = NULL; 310 ui_wnd_params_t params; 311 ui_menu_bar_t *mbar = NULL; 312 ui_menu_t *menu = NULL; 313 gfx_rect_t prect; 314 bool open; 315 errno_t rc; 316 317 rc = ui_create_disp(NULL, &ui); 318 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 319 320 ui_wnd_params_init(¶ms); 321 params.caption = "Hello"; 322 323 rc = ui_window_create(ui, ¶ms, &window); 324 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 325 PCUT_ASSERT_NOT_NULL(window); 326 327 rc = ui_menu_bar_create(ui, window, &mbar); 328 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 329 PCUT_ASSERT_NOT_NULL(mbar); 330 331 rc = ui_menu_create(mbar, "Test", &menu); 332 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 333 PCUT_ASSERT_NOT_NULL(menu); 334 335 prect.p0.x = 0; 336 prect.p0.y = 0; 337 prect.p1.x = 0; 338 prect.p1.y = 0; 339 340 open = ui_menu_is_open(menu); 341 PCUT_ASSERT_FALSE(open); 342 343 rc = ui_menu_open(menu, &prect, 0); 344 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 345 346 open = ui_menu_is_open(menu); 347 PCUT_ASSERT_TRUE(open); 348 349 ui_menu_close(menu); 350 351 open = ui_menu_is_open(menu); 352 PCUT_ASSERT_FALSE(open); 353 354 ui_menu_bar_destroy(mbar); 355 ui_window_destroy(window); 356 ui_destroy(ui); 357 } 358 359 /** Paint background in graphics mode */ 360 PCUT_TEST(paint_bg_gfx) 361 { 362 ui_t *ui = NULL; 363 ui_window_t *window = NULL; 364 ui_wnd_params_t params; 365 ui_menu_bar_t *mbar = NULL; 366 ui_menu_t *menu = NULL; 367 gfx_rect_t prect; 368 gfx_coord2_t pos; 369 errno_t rc; 370 371 rc = ui_create_disp(NULL, &ui); 372 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 373 374 ui_wnd_params_init(¶ms); 375 params.caption = "Hello"; 376 377 rc = ui_window_create(ui, ¶ms, &window); 378 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 379 PCUT_ASSERT_NOT_NULL(window); 380 381 rc = ui_menu_bar_create(ui, window, &mbar); 382 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 383 PCUT_ASSERT_NOT_NULL(mbar); 384 385 rc = ui_menu_create(mbar, "Test", &menu); 386 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 387 PCUT_ASSERT_NOT_NULL(menu); 388 389 prect.p0.x = 0; 390 prect.p0.y = 0; 391 prect.p1.x = 0; 392 prect.p1.y = 0; 393 394 /* Menu needs to be open to be able to paint it */ 395 rc = ui_menu_open(menu, &prect, 0); 396 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 397 398 pos.x = 0; 399 pos.y = 0; 400 rc = ui_menu_paint_bg_gfx(menu, &pos); 401 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 402 403 ui_menu_bar_destroy(mbar); 404 ui_window_destroy(window); 405 ui_destroy(ui); 406 } 407 408 /** Paint background in text mode */ 409 PCUT_TEST(paint_bg_text) 410 { 411 ui_t *ui = NULL; 412 ui_window_t *window = NULL; 413 ui_wnd_params_t params; 414 ui_menu_bar_t *mbar = NULL; 415 ui_menu_t *menu = NULL; 416 gfx_rect_t prect; 417 gfx_coord2_t pos; 418 errno_t rc; 419 420 rc = ui_create_disp(NULL, &ui); 421 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 422 423 ui_wnd_params_init(¶ms); 424 params.caption = "Hello"; 425 426 rc = ui_window_create(ui, ¶ms, &window); 427 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 428 PCUT_ASSERT_NOT_NULL(window); 429 430 rc = ui_menu_bar_create(ui, window, &mbar); 431 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 432 PCUT_ASSERT_NOT_NULL(mbar); 433 434 rc = ui_menu_create(mbar, "Test", &menu); 435 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 436 PCUT_ASSERT_NOT_NULL(menu); 437 438 prect.p0.x = 0; 439 prect.p0.y = 0; 440 prect.p1.x = 0; 441 prect.p1.y = 0; 442 443 /* Menu needs to be open to be able to paint it */ 444 rc = ui_menu_open(menu, &prect, 0); 445 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 446 447 pos.x = 0; 448 pos.y = 0; 449 rc = ui_menu_paint_bg_text(menu, &pos); 450 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 451 452 ui_menu_bar_destroy(mbar); 453 ui_window_destroy(window); 454 ui_destroy(ui); 455 } 456 457 /** Paint menu */ 458 PCUT_TEST(paint) 459 { 460 ui_t *ui = NULL; 461 ui_window_t *window = NULL; 462 ui_wnd_params_t params; 463 ui_menu_bar_t *mbar = NULL; 464 ui_menu_t *menu = NULL; 465 gfx_rect_t prect; 466 gfx_coord2_t pos; 467 errno_t rc; 468 469 rc = ui_create_disp(NULL, &ui); 470 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 471 472 ui_wnd_params_init(¶ms); 473 params.caption = "Hello"; 474 475 rc = ui_window_create(ui, ¶ms, &window); 476 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 477 PCUT_ASSERT_NOT_NULL(window); 478 479 rc = ui_menu_bar_create(ui, window, &mbar); 480 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 481 PCUT_ASSERT_NOT_NULL(mbar); 482 483 rc = ui_menu_create(mbar, "Test", &menu); 484 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 485 PCUT_ASSERT_NOT_NULL(menu); 486 487 prect.p0.x = 0; 488 prect.p0.y = 0; 489 prect.p1.x = 0; 490 prect.p1.y = 0; 491 492 /* Menu needs to be open to be able to paint it */ 493 rc = ui_menu_open(menu, &prect, 0); 494 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 495 496 pos.x = 0; 497 pos.y = 0; 498 rc = ui_menu_paint(menu, &pos); 499 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 500 501 ui_menu_bar_destroy(mbar); 502 ui_window_destroy(window); 503 ui_destroy(ui); 504 } 505 506 /** ui_menu_up() with empty menu does nothing */ 507 PCUT_TEST(up_empty) 508 { 509 ui_t *ui = NULL; 510 ui_window_t *window = NULL; 511 ui_wnd_params_t params; 512 ui_menu_bar_t *mbar = NULL; 513 ui_menu_t *menu = NULL; 514 gfx_rect_t prect; 515 errno_t rc; 516 517 rc = ui_create_disp(NULL, &ui); 518 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 519 520 ui_wnd_params_init(¶ms); 521 params.caption = "Hello"; 522 523 rc = ui_window_create(ui, ¶ms, &window); 524 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 525 PCUT_ASSERT_NOT_NULL(window); 526 527 rc = ui_menu_bar_create(ui, window, &mbar); 528 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 529 PCUT_ASSERT_NOT_NULL(mbar); 530 531 rc = ui_menu_create(mbar, "Test", &menu); 532 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 533 PCUT_ASSERT_NOT_NULL(menu); 534 535 prect.p0.x = 0; 536 prect.p0.y = 0; 537 prect.p1.x = 0; 538 prect.p1.y = 0; 539 540 /* Menu needs to be open to be able to move around it */ 541 rc = ui_menu_open(menu, &prect, 0); 542 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 543 544 ui_menu_up(menu); 545 546 ui_menu_bar_destroy(mbar); 547 ui_window_destroy(window); 548 ui_destroy(ui); 549 } 550 551 /** ui_menu_up() moves one entry up, skips separators, wraps around */ 552 PCUT_TEST(up) 553 { 554 ui_t *ui = NULL; 555 ui_window_t *window = NULL; 556 ui_wnd_params_t params; 557 ui_menu_bar_t *mbar = NULL; 558 ui_menu_t *menu = NULL; 559 ui_menu_entry_t *mentry1 = NULL; 560 ui_menu_entry_t *mentry2 = NULL; 561 ui_menu_entry_t *mentry3 = NULL; 562 gfx_rect_t prect; 563 errno_t rc; 564 565 rc = ui_create_disp(NULL, &ui); 566 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 567 568 ui_wnd_params_init(¶ms); 569 params.caption = "Hello"; 570 571 rc = ui_window_create(ui, ¶ms, &window); 572 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 573 PCUT_ASSERT_NOT_NULL(window); 574 575 rc = ui_menu_bar_create(ui, window, &mbar); 576 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 577 PCUT_ASSERT_NOT_NULL(mbar); 578 579 rc = ui_menu_create(mbar, "Test", &menu); 580 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 581 PCUT_ASSERT_NOT_NULL(menu); 582 583 rc = ui_menu_entry_create(menu, "Foo", "F1", &mentry1); 584 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 585 PCUT_ASSERT_NOT_NULL(mentry1); 586 587 rc = ui_menu_entry_sep_create(menu, &mentry2); 588 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 589 PCUT_ASSERT_NOT_NULL(mentry2); 590 591 rc = ui_menu_entry_create(menu, "Bar", "F2", &mentry3); 592 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 593 PCUT_ASSERT_NOT_NULL(mentry3); 594 595 prect.p0.x = 0; 596 prect.p0.y = 0; 597 prect.p1.x = 0; 598 prect.p1.y = 0; 599 600 /* Menu needs to be open to be able to move around it */ 601 rc = ui_menu_open(menu, &prect, 0); 602 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 603 604 /* When menu is open, the first entry is selected */ 605 PCUT_ASSERT_EQUALS(mentry1, menu->selected); 606 607 ui_menu_up(menu); 608 609 /* Now we've wrapped around to the last entry */ 610 PCUT_ASSERT_EQUALS(mentry3, menu->selected); 611 612 ui_menu_up(menu); 613 614 /* mentry2 is a separator and was skipped */ 615 PCUT_ASSERT_EQUALS(mentry1, menu->selected); 616 617 ui_menu_bar_destroy(mbar); 618 ui_window_destroy(window); 619 ui_destroy(ui); 620 } 621 622 /** ui_menu_down() with empty menu does nothing */ 623 PCUT_TEST(down_empty) 624 { 625 ui_t *ui = NULL; 626 ui_window_t *window = NULL; 627 ui_wnd_params_t params; 628 ui_menu_bar_t *mbar = NULL; 629 ui_menu_t *menu = NULL; 630 gfx_rect_t prect; 631 errno_t rc; 632 633 rc = ui_create_disp(NULL, &ui); 634 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 635 636 ui_wnd_params_init(¶ms); 637 params.caption = "Hello"; 638 639 rc = ui_window_create(ui, ¶ms, &window); 640 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 641 PCUT_ASSERT_NOT_NULL(window); 642 643 rc = ui_menu_bar_create(ui, window, &mbar); 644 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 645 PCUT_ASSERT_NOT_NULL(mbar); 646 647 rc = ui_menu_create(mbar, "Test", &menu); 648 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 649 PCUT_ASSERT_NOT_NULL(menu); 650 651 prect.p0.x = 0; 652 prect.p0.y = 0; 653 prect.p1.x = 0; 654 prect.p1.y = 0; 655 656 /* Menu needs to be open to be able to move around it */ 657 rc = ui_menu_open(menu, &prect, 0); 658 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 659 660 ui_menu_down(menu); 661 662 ui_menu_bar_destroy(mbar); 663 ui_window_destroy(window); 664 ui_destroy(ui); 665 } 666 667 /** ui_menu_down() moves one entry down, skips separators, wraps around */ 668 PCUT_TEST(down) 669 { 670 ui_t *ui = NULL; 671 ui_window_t *window = NULL; 672 ui_wnd_params_t params; 673 ui_menu_bar_t *mbar = NULL; 674 ui_menu_t *menu = NULL; 675 ui_menu_entry_t *mentry1 = NULL; 676 ui_menu_entry_t *mentry2 = NULL; 677 ui_menu_entry_t *mentry3 = NULL; 678 gfx_rect_t prect; 679 errno_t rc; 680 681 rc = ui_create_disp(NULL, &ui); 682 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 683 684 ui_wnd_params_init(¶ms); 685 params.caption = "Hello"; 686 687 rc = ui_window_create(ui, ¶ms, &window); 688 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 689 PCUT_ASSERT_NOT_NULL(window); 690 691 rc = ui_menu_bar_create(ui, window, &mbar); 692 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 693 PCUT_ASSERT_NOT_NULL(mbar); 694 695 rc = ui_menu_create(mbar, "Test", &menu); 696 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 697 PCUT_ASSERT_NOT_NULL(menu); 698 699 rc = ui_menu_entry_create(menu, "Foo", "F1", &mentry1); 700 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 701 PCUT_ASSERT_NOT_NULL(mentry1); 702 703 rc = ui_menu_entry_sep_create(menu, &mentry2); 704 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 705 PCUT_ASSERT_NOT_NULL(mentry2); 706 707 rc = ui_menu_entry_create(menu, "Bar", "F2", &mentry3); 708 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 709 PCUT_ASSERT_NOT_NULL(mentry3); 710 711 prect.p0.x = 0; 712 prect.p0.y = 0; 713 prect.p1.x = 0; 714 prect.p1.y = 0; 715 716 /* Menu needs to be open to be able to move around it */ 717 rc = ui_menu_open(menu, &prect, 0); 718 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 719 720 /* When menu is open, the first entry is selected */ 721 PCUT_ASSERT_EQUALS(mentry1, menu->selected); 722 723 ui_menu_down(menu); 724 725 /* mentry2 is a separator and was skipped */ 726 PCUT_ASSERT_EQUALS(mentry3, menu->selected); 727 728 ui_menu_up(menu); 729 730 /* Now we've wrapped around to the first entry */ 731 PCUT_ASSERT_EQUALS(mentry1, menu->selected); 732 733 ui_menu_bar_destroy(mbar); 734 ui_window_destroy(window); 735 ui_destroy(ui); 736 } 737 738 /** ui_menu_pos_event() inside menu is claimed */ 739 PCUT_TEST(pos_event_inside) 740 { 741 ui_t *ui = NULL; 742 ui_window_t *window = NULL; 743 ui_wnd_params_t params; 744 ui_menu_bar_t *mbar = NULL; 745 ui_menu_t *menu = NULL; 746 ui_evclaim_t claimed; 747 gfx_coord2_t pos; 748 pos_event_t event; 749 errno_t rc; 750 751 rc = ui_create_disp(NULL, &ui); 752 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 753 754 ui_wnd_params_init(¶ms); 755 params.caption = "Hello"; 756 757 rc = ui_window_create(ui, ¶ms, &window); 758 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 759 PCUT_ASSERT_NOT_NULL(window); 760 761 rc = ui_menu_bar_create(ui, window, &mbar); 762 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 763 PCUT_ASSERT_NOT_NULL(mbar); 764 765 rc = ui_menu_create(mbar, "Test", &menu); 766 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 767 PCUT_ASSERT_NOT_NULL(menu); 768 769 pos.x = 0; 770 pos.y = 0; 771 event.type = POS_PRESS; 772 event.hpos = 0; 773 event.vpos = 0; 774 claimed = ui_menu_pos_event(menu, &pos, &event); 775 PCUT_ASSERT_EQUALS(ui_claimed, claimed); 776 777 ui_menu_bar_destroy(mbar); 778 ui_window_destroy(window); 779 ui_destroy(ui); 92 /** ui_menu_set_cb() sets the internal fields */ 93 PCUT_TEST(set_cb) 94 { 95 ui_menu_t *menu = NULL; 96 ui_menu_cb_t cb; 97 int obj; 98 errno_t rc; 99 100 rc = ui_menu_create(NULL, &menu); 101 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 102 PCUT_ASSERT_NOT_NULL(menu); 103 104 ui_menu_set_cb(menu, &cb, (void *)&obj); 105 PCUT_ASSERT_EQUALS(&cb, menu->cb); 106 PCUT_ASSERT_EQUALS((void *)&obj, menu->arg); 107 108 ui_menu_destroy(menu); 780 109 } 781 110 … … 786 115 ui_window_t *window = NULL; 787 116 ui_wnd_params_t params; 788 ui_menu_bar_t *mbar = NULL;789 117 ui_menu_t *menu = NULL; 790 118 ui_menu_geom_t geom; … … 802 130 PCUT_ASSERT_NOT_NULL(window); 803 131 804 rc = ui_menu_bar_create(ui, window, &mbar); 805 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 806 PCUT_ASSERT_NOT_NULL(mbar); 807 808 rc = ui_menu_create(mbar, "Test", &menu); 132 rc = ui_menu_create(window, &menu); 809 133 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 810 134 PCUT_ASSERT_NOT_NULL(menu); … … 823 147 PCUT_ASSERT_INT_EQUALS(4, geom.entries_rect.p1.y); 824 148 825 ui_menu_bar_destroy(mbar); 826 ui_window_destroy(window); 827 ui_destroy(ui); 149 ui_menu_destroy(menu); 150 ui_window_destroy(window); 151 ui_destroy(ui); 152 } 153 154 /** ui_menu_get_res() gets the menu's resource */ 155 PCUT_TEST(get_res) 156 { 157 ui_t *ui = NULL; 158 ui_window_t *window = NULL; 159 ui_wnd_params_t params; 160 ui_menu_t *menu = NULL; 161 ui_resource_t *res; 162 gfx_rect_t prect; 163 errno_t rc; 164 165 rc = ui_create_disp(NULL, &ui); 166 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 167 168 ui_wnd_params_init(¶ms); 169 params.caption = "Hello"; 170 171 rc = ui_window_create(ui, ¶ms, &window); 172 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 173 PCUT_ASSERT_NOT_NULL(window); 174 175 rc = ui_menu_create(window, &menu); 176 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 177 PCUT_ASSERT_NOT_NULL(menu); 178 179 prect.p0.x = 0; 180 prect.p0.y = 0; 181 prect.p1.x = 0; 182 prect.p1.y = 0; 183 184 /* The menu must be open first */ 185 rc = ui_menu_open(menu, &prect, 0); 186 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 187 188 res = ui_menu_get_res(menu); 189 PCUT_ASSERT_NOT_NULL(res); 190 191 ui_menu_destroy(menu); 192 193 ui_window_destroy(window); 194 ui_destroy(ui); 195 } 196 197 /** Open and close menu with ui_menu_open() / ui_menu_close() */ 198 PCUT_TEST(open_close) 199 { 200 ui_t *ui = NULL; 201 ui_window_t *window = NULL; 202 ui_wnd_params_t params; 203 ui_menu_t *menu = NULL; 204 gfx_rect_t prect; 205 errno_t rc; 206 207 rc = ui_create_disp(NULL, &ui); 208 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 209 210 ui_wnd_params_init(¶ms); 211 params.caption = "Hello"; 212 213 rc = ui_window_create(ui, ¶ms, &window); 214 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 215 PCUT_ASSERT_NOT_NULL(window); 216 217 rc = ui_menu_create(window, &menu); 218 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 219 PCUT_ASSERT_NOT_NULL(menu); 220 221 prect.p0.x = 0; 222 prect.p0.y = 0; 223 prect.p1.x = 0; 224 prect.p1.y = 0; 225 226 /* Open and close */ 227 rc = ui_menu_open(menu, &prect, 0); 228 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 229 230 ui_menu_close(menu); 231 232 ui_menu_destroy(menu); 233 ui_window_destroy(window); 234 ui_destroy(ui); 235 } 236 237 /** ui_menu_is_open() correctly returns menu state */ 238 PCUT_TEST(is_open) 239 { 240 ui_t *ui = NULL; 241 ui_window_t *window = NULL; 242 ui_wnd_params_t params; 243 ui_menu_t *menu = NULL; 244 gfx_rect_t prect; 245 bool open; 246 errno_t rc; 247 248 rc = ui_create_disp(NULL, &ui); 249 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 250 251 ui_wnd_params_init(¶ms); 252 params.caption = "Hello"; 253 254 rc = ui_window_create(ui, ¶ms, &window); 255 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 256 PCUT_ASSERT_NOT_NULL(window); 257 258 rc = ui_menu_create(window, &menu); 259 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 260 PCUT_ASSERT_NOT_NULL(menu); 261 262 prect.p0.x = 0; 263 prect.p0.y = 0; 264 prect.p1.x = 0; 265 prect.p1.y = 0; 266 267 open = ui_menu_is_open(menu); 268 PCUT_ASSERT_FALSE(open); 269 270 rc = ui_menu_open(menu, &prect, 0); 271 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 272 273 open = ui_menu_is_open(menu); 274 PCUT_ASSERT_TRUE(open); 275 276 ui_menu_close(menu); 277 278 open = ui_menu_is_open(menu); 279 PCUT_ASSERT_FALSE(open); 280 281 ui_menu_destroy(menu); 282 ui_window_destroy(window); 283 ui_destroy(ui); 284 } 285 286 /** Paint background in graphics mode */ 287 PCUT_TEST(paint_bg_gfx) 288 { 289 ui_t *ui = NULL; 290 ui_window_t *window = NULL; 291 ui_wnd_params_t params; 292 ui_menu_t *menu = NULL; 293 gfx_rect_t prect; 294 gfx_coord2_t pos; 295 errno_t rc; 296 297 rc = ui_create_disp(NULL, &ui); 298 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 299 300 ui_wnd_params_init(¶ms); 301 params.caption = "Hello"; 302 303 rc = ui_window_create(ui, ¶ms, &window); 304 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 305 PCUT_ASSERT_NOT_NULL(window); 306 307 rc = ui_menu_create(window, &menu); 308 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 309 PCUT_ASSERT_NOT_NULL(menu); 310 311 prect.p0.x = 0; 312 prect.p0.y = 0; 313 prect.p1.x = 0; 314 prect.p1.y = 0; 315 316 /* Menu needs to be open to be able to paint it */ 317 rc = ui_menu_open(menu, &prect, 0); 318 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 319 320 pos.x = 0; 321 pos.y = 0; 322 rc = ui_menu_paint_bg_gfx(menu, &pos); 323 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 324 325 ui_window_destroy(window); 326 ui_destroy(ui); 327 } 328 329 /** Paint background in text mode */ 330 PCUT_TEST(paint_bg_text) 331 { 332 ui_t *ui = NULL; 333 ui_window_t *window = NULL; 334 ui_wnd_params_t params; 335 ui_menu_t *menu = NULL; 336 gfx_rect_t prect; 337 gfx_coord2_t pos; 338 errno_t rc; 339 340 rc = ui_create_disp(NULL, &ui); 341 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 342 343 ui_wnd_params_init(¶ms); 344 params.caption = "Hello"; 345 346 rc = ui_window_create(ui, ¶ms, &window); 347 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 348 PCUT_ASSERT_NOT_NULL(window); 349 350 rc = ui_menu_create(window, &menu); 351 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 352 PCUT_ASSERT_NOT_NULL(menu); 353 354 prect.p0.x = 0; 355 prect.p0.y = 0; 356 prect.p1.x = 0; 357 prect.p1.y = 0; 358 359 /* Menu needs to be open to be able to paint it */ 360 rc = ui_menu_open(menu, &prect, 0); 361 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 362 363 pos.x = 0; 364 pos.y = 0; 365 rc = ui_menu_paint_bg_text(menu, &pos); 366 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 367 368 ui_window_destroy(window); 369 ui_destroy(ui); 370 } 371 372 /** Paint menu */ 373 PCUT_TEST(paint) 374 { 375 ui_t *ui = NULL; 376 ui_window_t *window = NULL; 377 ui_wnd_params_t params; 378 ui_menu_t *menu = NULL; 379 gfx_rect_t prect; 380 gfx_coord2_t pos; 381 errno_t rc; 382 383 rc = ui_create_disp(NULL, &ui); 384 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 385 386 ui_wnd_params_init(¶ms); 387 params.caption = "Hello"; 388 389 rc = ui_window_create(ui, ¶ms, &window); 390 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 391 PCUT_ASSERT_NOT_NULL(window); 392 393 rc = ui_menu_create(window, &menu); 394 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 395 PCUT_ASSERT_NOT_NULL(menu); 396 397 prect.p0.x = 0; 398 prect.p0.y = 0; 399 prect.p1.x = 0; 400 prect.p1.y = 0; 401 402 /* Menu needs to be open to be able to paint it */ 403 rc = ui_menu_open(menu, &prect, 0); 404 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 405 406 pos.x = 0; 407 pos.y = 0; 408 rc = ui_menu_paint(menu, &pos); 409 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 410 411 ui_window_destroy(window); 412 ui_destroy(ui); 413 } 414 415 /** ui_menu_pos_event() inside menu is claimed */ 416 PCUT_TEST(pos_event_inside) 417 { 418 ui_t *ui = NULL; 419 ui_window_t *window = NULL; 420 ui_wnd_params_t params; 421 ui_menu_t *menu = NULL; 422 ui_evclaim_t claimed; 423 gfx_coord2_t pos; 424 pos_event_t event; 425 errno_t rc; 426 427 rc = ui_create_disp(NULL, &ui); 428 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 429 430 ui_wnd_params_init(¶ms); 431 params.caption = "Hello"; 432 433 rc = ui_window_create(ui, ¶ms, &window); 434 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 435 PCUT_ASSERT_NOT_NULL(window); 436 437 rc = ui_menu_create(window, &menu); 438 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 439 PCUT_ASSERT_NOT_NULL(menu); 440 441 pos.x = 0; 442 pos.y = 0; 443 event.type = POS_PRESS; 444 event.hpos = 0; 445 event.vpos = 0; 446 claimed = ui_menu_pos_event(menu, &pos, &event); 447 PCUT_ASSERT_EQUALS(ui_claimed, claimed); 448 449 ui_window_destroy(window); 450 ui_destroy(ui); 451 } 452 453 /** ui_menu_up() with empty menu does nothing */ 454 PCUT_TEST(up_empty) 455 { 456 ui_t *ui = NULL; 457 ui_window_t *window = NULL; 458 ui_wnd_params_t params; 459 ui_menu_t *menu = NULL; 460 gfx_rect_t prect; 461 errno_t rc; 462 463 rc = ui_create_disp(NULL, &ui); 464 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 465 466 ui_wnd_params_init(¶ms); 467 params.caption = "Hello"; 468 469 rc = ui_window_create(ui, ¶ms, &window); 470 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 471 PCUT_ASSERT_NOT_NULL(window); 472 473 rc = ui_menu_create(window, &menu); 474 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 475 PCUT_ASSERT_NOT_NULL(menu); 476 477 prect.p0.x = 0; 478 prect.p0.y = 0; 479 prect.p1.x = 0; 480 prect.p1.y = 0; 481 482 /* Menu needs to be open to be able to move around it */ 483 rc = ui_menu_open(menu, &prect, 0); 484 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 485 486 ui_menu_up(menu); 487 488 ui_window_destroy(window); 489 ui_destroy(ui); 490 } 491 492 /** ui_menu_up() moves one entry up, skips separators, wraps around */ 493 PCUT_TEST(up) 494 { 495 ui_t *ui = NULL; 496 ui_window_t *window = NULL; 497 ui_wnd_params_t params; 498 ui_menu_t *menu = NULL; 499 ui_menu_entry_t *mentry1 = NULL; 500 ui_menu_entry_t *mentry2 = NULL; 501 ui_menu_entry_t *mentry3 = NULL; 502 gfx_rect_t prect; 503 errno_t rc; 504 505 rc = ui_create_disp(NULL, &ui); 506 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 507 508 ui_wnd_params_init(¶ms); 509 params.caption = "Hello"; 510 511 rc = ui_window_create(ui, ¶ms, &window); 512 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 513 PCUT_ASSERT_NOT_NULL(window); 514 515 rc = ui_menu_create(window, &menu); 516 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 517 PCUT_ASSERT_NOT_NULL(menu); 518 519 rc = ui_menu_entry_create(menu, "Foo", "F1", &mentry1); 520 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 521 PCUT_ASSERT_NOT_NULL(mentry1); 522 523 rc = ui_menu_entry_sep_create(menu, &mentry2); 524 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 525 PCUT_ASSERT_NOT_NULL(mentry2); 526 527 rc = ui_menu_entry_create(menu, "Bar", "F2", &mentry3); 528 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 529 PCUT_ASSERT_NOT_NULL(mentry3); 530 531 prect.p0.x = 0; 532 prect.p0.y = 0; 533 prect.p1.x = 0; 534 prect.p1.y = 0; 535 536 /* Menu needs to be open to be able to move around it */ 537 rc = ui_menu_open(menu, &prect, 0); 538 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 539 540 /* When menu is open, the first entry is selected */ 541 PCUT_ASSERT_EQUALS(mentry1, menu->selected); 542 543 ui_menu_up(menu); 544 545 /* Now we've wrapped around to the last entry */ 546 PCUT_ASSERT_EQUALS(mentry3, menu->selected); 547 548 ui_menu_up(menu); 549 550 /* mentry2 is a separator and was skipped */ 551 PCUT_ASSERT_EQUALS(mentry1, menu->selected); 552 553 ui_window_destroy(window); 554 ui_destroy(ui); 555 } 556 557 /** ui_menu_down() with empty menu does nothing */ 558 PCUT_TEST(down_empty) 559 { 560 ui_t *ui = NULL; 561 ui_window_t *window = NULL; 562 ui_wnd_params_t params; 563 ui_menu_t *menu = NULL; 564 gfx_rect_t prect; 565 errno_t rc; 566 567 rc = ui_create_disp(NULL, &ui); 568 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 569 570 ui_wnd_params_init(¶ms); 571 params.caption = "Hello"; 572 573 rc = ui_window_create(ui, ¶ms, &window); 574 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 575 PCUT_ASSERT_NOT_NULL(window); 576 577 rc = ui_menu_create(window, &menu); 578 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 579 PCUT_ASSERT_NOT_NULL(menu); 580 581 prect.p0.x = 0; 582 prect.p0.y = 0; 583 prect.p1.x = 0; 584 prect.p1.y = 0; 585 586 /* Menu needs to be open to be able to move around it */ 587 rc = ui_menu_open(menu, &prect, 0); 588 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 589 590 ui_menu_down(menu); 591 592 ui_window_destroy(window); 593 ui_destroy(ui); 594 } 595 596 /** ui_menu_down() moves one entry down, skips separators, wraps around */ 597 PCUT_TEST(down) 598 { 599 ui_t *ui = NULL; 600 ui_window_t *window = NULL; 601 ui_wnd_params_t params; 602 ui_menu_t *menu = NULL; 603 ui_menu_entry_t *mentry1 = NULL; 604 ui_menu_entry_t *mentry2 = NULL; 605 ui_menu_entry_t *mentry3 = NULL; 606 gfx_rect_t prect; 607 errno_t rc; 608 609 rc = ui_create_disp(NULL, &ui); 610 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 611 612 ui_wnd_params_init(¶ms); 613 params.caption = "Hello"; 614 615 rc = ui_window_create(ui, ¶ms, &window); 616 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 617 PCUT_ASSERT_NOT_NULL(window); 618 619 rc = ui_menu_create(window, &menu); 620 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 621 PCUT_ASSERT_NOT_NULL(menu); 622 623 rc = ui_menu_entry_create(menu, "Foo", "F1", &mentry1); 624 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 625 PCUT_ASSERT_NOT_NULL(mentry1); 626 627 rc = ui_menu_entry_sep_create(menu, &mentry2); 628 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 629 PCUT_ASSERT_NOT_NULL(mentry2); 630 631 rc = ui_menu_entry_create(menu, "Bar", "F2", &mentry3); 632 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 633 PCUT_ASSERT_NOT_NULL(mentry3); 634 635 prect.p0.x = 0; 636 prect.p0.y = 0; 637 prect.p1.x = 0; 638 prect.p1.y = 0; 639 640 /* Menu needs to be open to be able to move around it */ 641 rc = ui_menu_open(menu, &prect, 0); 642 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 643 644 /* When menu is open, the first entry is selected */ 645 PCUT_ASSERT_EQUALS(mentry1, menu->selected); 646 647 ui_menu_down(menu); 648 649 /* mentry2 is a separator and was skipped */ 650 PCUT_ASSERT_EQUALS(mentry3, menu->selected); 651 652 ui_menu_up(menu); 653 654 /* Now we've wrapped around to the first entry */ 655 PCUT_ASSERT_EQUALS(mentry1, menu->selected); 656 657 ui_window_destroy(window); 658 ui_destroy(ui); 659 } 660 661 /** Sending an unhandled event does nothing. */ 662 PCUT_TEST(send_unhandled) 663 { 664 ui_menu_t *menu = NULL; 665 errno_t rc; 666 sysarg_t idev_id; 667 char32_t c; 668 669 rc = ui_menu_create(NULL, &menu); 670 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 671 PCUT_ASSERT_NOT_NULL(menu); 672 673 /* Send events without setting callback */ 674 c = 'A'; 675 idev_id = 42; 676 ui_menu_left(menu, idev_id); 677 ui_menu_right(menu, idev_id); 678 ui_menu_close_req(menu); 679 ui_menu_press_accel(menu, c, idev_id); 680 681 /* Set dummy callback structure */ 682 ui_menu_set_cb(menu, &dummy_cb, NULL); 683 684 /* Send unhandled events */ 685 ui_menu_left(menu, idev_id); 686 ui_menu_right(menu, idev_id); 687 ui_menu_close_req(menu); 688 ui_menu_press_accel(menu, c, idev_id); 689 690 ui_menu_destroy(menu); 691 } 692 693 /** ui_menu_left() sends left event */ 694 PCUT_TEST(left) 695 { 696 ui_menu_t *menu = NULL; 697 errno_t rc; 698 test_resp_t resp; 699 sysarg_t idev_id; 700 701 rc = ui_menu_create(NULL, &menu); 702 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 703 PCUT_ASSERT_NOT_NULL(menu); 704 705 ui_menu_set_cb(menu, &testmenu_cb, (void *)&resp); 706 707 memset(&resp, 0, sizeof(resp)); 708 PCUT_ASSERT_FALSE(resp.left_called); 709 710 idev_id = 42; 711 ui_menu_left(menu, idev_id); 712 713 PCUT_ASSERT_TRUE(resp.left_called); 714 PCUT_ASSERT_EQUALS(menu, resp.menu); 715 PCUT_ASSERT_INT_EQUALS(idev_id, resp.idev_id); 716 717 ui_menu_destroy(menu); 718 } 719 720 /** ui_menu_right() sends right event */ 721 PCUT_TEST(right) 722 { 723 ui_menu_t *menu = NULL; 724 errno_t rc; 725 test_resp_t resp; 726 sysarg_t idev_id; 727 728 rc = ui_menu_create(NULL, &menu); 729 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 730 PCUT_ASSERT_NOT_NULL(menu); 731 732 ui_menu_set_cb(menu, &testmenu_cb, (void *)&resp); 733 734 memset(&resp, 0, sizeof(resp)); 735 PCUT_ASSERT_FALSE(resp.right_called); 736 737 idev_id = 42; 738 ui_menu_right(menu, idev_id); 739 740 PCUT_ASSERT_TRUE(resp.right_called); 741 PCUT_ASSERT_EQUALS(menu, resp.menu); 742 PCUT_ASSERT_INT_EQUALS(idev_id, resp.idev_id); 743 744 ui_menu_destroy(menu); 745 } 746 747 /** ui_menu_close_req() sends close_req event */ 748 PCUT_TEST(close_req) 749 { 750 ui_menu_t *menu = NULL; 751 errno_t rc; 752 test_resp_t resp; 753 754 rc = ui_menu_create(NULL, &menu); 755 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 756 PCUT_ASSERT_NOT_NULL(menu); 757 758 ui_menu_set_cb(menu, &testmenu_cb, (void *)&resp); 759 760 memset(&resp, 0, sizeof(resp)); 761 PCUT_ASSERT_FALSE(resp.close_req_called); 762 763 ui_menu_close_req(menu); 764 765 PCUT_ASSERT_TRUE(resp.close_req_called); 766 PCUT_ASSERT_EQUALS(menu, resp.menu); 767 768 ui_menu_destroy(menu); 769 } 770 771 /** ui_menu_press_accel() sends press_accel event */ 772 PCUT_TEST(press_accel) 773 { 774 ui_menu_t *menu = NULL; 775 errno_t rc; 776 test_resp_t resp; 777 char32_t c; 778 sysarg_t idev_id; 779 780 rc = ui_menu_create(NULL, &menu); 781 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 782 PCUT_ASSERT_NOT_NULL(menu); 783 784 ui_menu_set_cb(menu, &testmenu_cb, (void *)&resp); 785 786 memset(&resp, 0, sizeof(resp)); 787 PCUT_ASSERT_FALSE(resp.press_accel_called); 788 789 c = 'A'; 790 idev_id = 42; 791 ui_menu_press_accel(menu, c, idev_id); 792 793 PCUT_ASSERT_TRUE(resp.press_accel_called); 794 PCUT_ASSERT_EQUALS(menu, resp.menu); 795 PCUT_ASSERT_EQUALS(c, resp.c); 796 PCUT_ASSERT_INT_EQUALS(idev_id, resp.idev_id); 797 798 ui_menu_destroy(menu); 799 } 800 801 /** Test menu left callback */ 802 static void testmenu_left(ui_menu_t *menu, void *arg, sysarg_t idev_id) 803 { 804 test_resp_t *resp = (test_resp_t *)arg; 805 806 resp->left_called = true; 807 resp->menu = menu; 808 resp->idev_id = idev_id; 809 } 810 811 /** Test menu right callback */ 812 static void testmenu_right(ui_menu_t *menu, void *arg, sysarg_t idev_id) 813 { 814 test_resp_t *resp = (test_resp_t *)arg; 815 816 resp->right_called = true; 817 resp->menu = menu; 818 resp->idev_id = idev_id; 819 } 820 821 /** Test menu close callback */ 822 static void testmenu_close_req(ui_menu_t *menu, void *arg) 823 { 824 test_resp_t *resp = (test_resp_t *)arg; 825 826 resp->close_req_called = true; 827 resp->menu = menu; 828 } 829 830 /** Test menu press accel callback */ 831 static void testmenu_press_accel(ui_menu_t *menu, void *arg, 832 char32_t c, sysarg_t kbd_id) 833 { 834 test_resp_t *resp = (test_resp_t *)arg; 835 836 resp->press_accel_called = true; 837 resp->menu = menu; 838 resp->c = c; 839 resp->idev_id = kbd_id; 828 840 } 829 841 -
uspace/lib/ui/test/menubar.c
r0b6fad9 r46bd63c9 32 32 #include <stdbool.h> 33 33 #include <ui/control.h> 34 #include <ui/menu.h>35 34 #include <ui/menubar.h> 35 #include <ui/menudd.h> 36 36 #include <ui/ui.h> 37 37 #include <ui/window.h> … … 182 182 ui_menu_bar_set_rect(mbar, &rect); 183 183 184 rc = ui_menu_ create(mbar, "Test", &menu);184 rc = ui_menu_dd_create(mbar, "Test", NULL, &menu); 185 185 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 186 186 PCUT_ASSERT_NOT_NULL(menu); … … 206 206 ui_menu_bar_t *mbar = NULL; 207 207 ui_menu_t *menu = NULL; 208 ui_menu_dd_t *mdd = NULL; 208 209 gfx_rect_t rect; 209 210 errno_t rc; … … 229 230 ui_menu_bar_set_rect(mbar, &rect); 230 231 231 rc = ui_menu_create(mbar, "~T~est", &menu); 232 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 232 rc = ui_menu_dd_create(mbar, "~T~est", &mdd, &menu); 233 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 234 PCUT_ASSERT_NOT_NULL(mdd); 233 235 PCUT_ASSERT_NOT_NULL(menu); 234 236 235 PCUT_ASSERT_FALSE(ui_menu_ is_open(menu));237 PCUT_ASSERT_FALSE(ui_menu_dd_is_open(mdd)); 236 238 237 239 ui_menu_bar_press_accel(mbar, 't', 0); 238 240 239 PCUT_ASSERT_TRUE(ui_menu_ is_open(menu));241 PCUT_ASSERT_TRUE(ui_menu_dd_is_open(mdd)); 240 242 241 243 ui_menu_bar_destroy(mbar); … … 252 254 ui_menu_bar_t *mbar = NULL; 253 255 ui_menu_t *menu = NULL; 256 ui_menu_dd_t *mdd = NULL; 254 257 ui_evclaim_t claimed; 255 258 pos_event_t event; … … 277 280 ui_menu_bar_set_rect(mbar, &rect); 278 281 279 rc = ui_menu_ create(mbar, "Test", &menu);282 rc = ui_menu_dd_create(mbar, "Test", &mdd, &menu); 280 283 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 281 284 PCUT_ASSERT_NOT_NULL(menu); … … 288 291 PCUT_ASSERT_EQUALS(ui_claimed, claimed); 289 292 290 /* Clicking the menu bar entry should select menu */291 PCUT_ASSERT_EQUALS(m enu, mbar->selected);293 /* Clicking the menu bar entry should select menu drop-down */ 294 PCUT_ASSERT_EQUALS(mdd, mbar->selected); 292 295 293 296 ui_menu_bar_destroy(mbar); … … 303 306 ui_wnd_params_t params; 304 307 ui_menu_bar_t *mbar = NULL; 305 ui_menu_ t *menu1 = NULL;306 ui_menu_ t *menu2 = NULL;307 errno_t rc; 308 309 rc = ui_create_disp(NULL, &ui); 310 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 311 312 ui_wnd_params_init(¶ms); 313 params.caption = "Hello"; 314 315 rc = ui_window_create(ui, ¶ms, &window); 316 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 317 PCUT_ASSERT_NOT_NULL(window); 318 319 rc = ui_menu_bar_create(ui, window, &mbar); 320 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 321 PCUT_ASSERT_NOT_NULL(mbar); 322 323 rc = ui_menu_ create(mbar, "Test 1", &menu1);324 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 325 PCUT_ASSERT_NOT_NULL(m enu1);326 327 rc = ui_menu_ create(mbar, "Test 2", &menu2);328 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 329 PCUT_ASSERT_NOT_NULL(m enu2);330 331 ui_menu_bar_select(mbar, m enu1, true, 0);332 PCUT_ASSERT_EQUALS(m enu1, mbar->selected);308 ui_menu_dd_t *mdd1 = NULL; 309 ui_menu_dd_t *mdd2 = NULL; 310 errno_t rc; 311 312 rc = ui_create_disp(NULL, &ui); 313 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 314 315 ui_wnd_params_init(¶ms); 316 params.caption = "Hello"; 317 318 rc = ui_window_create(ui, ¶ms, &window); 319 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 320 PCUT_ASSERT_NOT_NULL(window); 321 322 rc = ui_menu_bar_create(ui, window, &mbar); 323 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 324 PCUT_ASSERT_NOT_NULL(mbar); 325 326 rc = ui_menu_dd_create(mbar, "Test 1", &mdd1, NULL); 327 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 328 PCUT_ASSERT_NOT_NULL(mdd1); 329 330 rc = ui_menu_dd_create(mbar, "Test 2", &mdd2, NULL); 331 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 332 PCUT_ASSERT_NOT_NULL(mdd2); 333 334 ui_menu_bar_select(mbar, mdd1, true, 0); 335 PCUT_ASSERT_EQUALS(mdd1, mbar->selected); 333 336 334 337 /* Selecting different menu should select it */ 335 ui_menu_bar_select(mbar, m enu2, true, 0);336 PCUT_ASSERT_EQUALS(m enu2, mbar->selected);338 ui_menu_bar_select(mbar, mdd2, true, 0); 339 PCUT_ASSERT_EQUALS(mdd2, mbar->selected); 337 340 338 341 ui_menu_bar_destroy(mbar); … … 348 351 ui_wnd_params_t params; 349 352 ui_menu_bar_t *mbar = NULL; 350 ui_menu_ t *menu= NULL;351 errno_t rc; 352 353 rc = ui_create_disp(NULL, &ui); 354 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 355 356 ui_wnd_params_init(¶ms); 357 params.caption = "Hello"; 358 359 rc = ui_window_create(ui, ¶ms, &window); 360 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 361 PCUT_ASSERT_NOT_NULL(window); 362 363 rc = ui_menu_bar_create(ui, window, &mbar); 364 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 365 PCUT_ASSERT_NOT_NULL(mbar); 366 367 rc = ui_menu_ create(mbar, "Test", &menu);368 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 369 PCUT_ASSERT_NOT_NULL(m enu);353 ui_menu_dd_t *mdd = NULL; 354 errno_t rc; 355 356 rc = ui_create_disp(NULL, &ui); 357 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 358 359 ui_wnd_params_init(¶ms); 360 params.caption = "Hello"; 361 362 rc = ui_window_create(ui, ¶ms, &window); 363 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 364 PCUT_ASSERT_NOT_NULL(window); 365 366 rc = ui_menu_bar_create(ui, window, &mbar); 367 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 368 PCUT_ASSERT_NOT_NULL(mbar); 369 370 rc = ui_menu_dd_create(mbar, "Test", &mdd, NULL); 371 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 372 PCUT_ASSERT_NOT_NULL(mdd); 370 373 371 374 ui_menu_bar_activate(mbar); 372 PCUT_ASSERT_EQUALS(m enu, mbar->selected);375 PCUT_ASSERT_EQUALS(mdd, mbar->selected); 373 376 374 377 ui_menu_bar_deactivate(mbar); -
uspace/lib/ui/test/menuentry.c
r0b6fad9 r46bd63c9 35 35 #include <ui/menu.h> 36 36 #include <ui/menubar.h> 37 #include <ui/menudd.h> 37 38 #include <ui/menuentry.h> 38 39 #include <ui/ui.h> … … 75 76 PCUT_ASSERT_NOT_NULL(mbar); 76 77 77 rc = ui_menu_ create(mbar, "Test", &menu);78 rc = ui_menu_dd_create(mbar, "Test", NULL, &menu); 78 79 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 79 80 PCUT_ASSERT_NOT_NULL(menu); … … 116 117 PCUT_ASSERT_NOT_NULL(mbar); 117 118 118 rc = ui_menu_ create(mbar, "Test", &menu);119 rc = ui_menu_dd_create(mbar, "Test", NULL, &menu); 119 120 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 120 121 PCUT_ASSERT_NOT_NULL(menu); … … 164 165 PCUT_ASSERT_NOT_NULL(mbar); 165 166 166 rc = ui_menu_ create(mbar, "Test", &menu);167 rc = ui_menu_dd_create(mbar, "Test", NULL, &menu); 167 168 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 168 169 PCUT_ASSERT_NOT_NULL(menu); … … 210 211 PCUT_ASSERT_NOT_NULL(mbar); 211 212 212 rc = ui_menu_ create(mbar, "Test", &menu);213 rc = ui_menu_dd_create(mbar, "Test", NULL, &menu); 213 214 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 214 215 PCUT_ASSERT_NOT_NULL(menu); … … 263 264 PCUT_ASSERT_NOT_NULL(mbar); 264 265 265 rc = ui_menu_ create(mbar, "Test", &menu);266 rc = ui_menu_dd_create(mbar, "Test", NULL, &menu); 266 267 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 267 268 PCUT_ASSERT_NOT_NULL(menu); … … 318 319 PCUT_ASSERT_NOT_NULL(mbar); 319 320 320 rc = ui_menu_ create(mbar, "Test", &menu);321 rc = ui_menu_dd_create(mbar, "Test", NULL, &menu); 321 322 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 322 323 PCUT_ASSERT_NOT_NULL(menu); … … 368 369 PCUT_ASSERT_NOT_NULL(mbar); 369 370 370 rc = ui_menu_ create(mbar, "Test", &menu);371 rc = ui_menu_dd_create(mbar, "Test", NULL, &menu); 371 372 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 372 373 PCUT_ASSERT_NOT_NULL(menu); … … 419 420 PCUT_ASSERT_NOT_NULL(mbar); 420 421 421 rc = ui_menu_ create(mbar, "Test", &menu);422 rc = ui_menu_dd_create(mbar, "Test", NULL, &menu); 422 423 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 423 424 PCUT_ASSERT_NOT_NULL(menu); … … 476 477 PCUT_ASSERT_NOT_NULL(mbar); 477 478 478 rc = ui_menu_ create(mbar, "Test", &menu);479 rc = ui_menu_dd_create(mbar, "Test", NULL, &menu); 479 480 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 480 481 PCUT_ASSERT_NOT_NULL(menu); … … 539 540 PCUT_ASSERT_NOT_NULL(mbar); 540 541 541 rc = ui_menu_ create(mbar, "Test", &menu);542 rc = ui_menu_dd_create(mbar, "Test", NULL, &menu); 542 543 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 543 544 PCUT_ASSERT_NOT_NULL(menu); … … 607 608 PCUT_ASSERT_NOT_NULL(mbar); 608 609 609 rc = ui_menu_ create(mbar, "Test", &menu);610 rc = ui_menu_dd_create(mbar, "Test", NULL, &menu); 610 611 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 611 612 PCUT_ASSERT_NOT_NULL(menu); … … 679 680 PCUT_ASSERT_NOT_NULL(mbar); 680 681 681 rc = ui_menu_ create(mbar, "Test", &menu);682 rc = ui_menu_dd_create(mbar, "Test", NULL, &menu); 682 683 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 683 684 PCUT_ASSERT_NOT_NULL(menu); … … 737 738 PCUT_ASSERT_NOT_NULL(mbar); 738 739 739 rc = ui_menu_ create(mbar, "Test", &menu);740 rc = ui_menu_dd_create(mbar, "Test", NULL, &menu); 740 741 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 741 742 PCUT_ASSERT_NOT_NULL(menu); … … 797 798 PCUT_ASSERT_NOT_NULL(mbar); 798 799 799 rc = ui_menu_ create(mbar, "Test", &menu);800 rc = ui_menu_dd_create(mbar, "Test", NULL, &menu); 800 801 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 801 802 PCUT_ASSERT_NOT_NULL(menu); … … 857 858 PCUT_ASSERT_NOT_NULL(mbar); 858 859 859 rc = ui_menu_ create(mbar, "Test", &menu);860 rc = ui_menu_dd_create(mbar, "Test", NULL, &menu); 860 861 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 861 862 PCUT_ASSERT_NOT_NULL(menu); … … 920 921 PCUT_ASSERT_NOT_NULL(mbar); 921 922 922 rc = ui_menu_ create(mbar, "Test", &menu);923 rc = ui_menu_dd_create(mbar, "Test", NULL, &menu); 923 924 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 924 925 PCUT_ASSERT_NOT_NULL(menu);
Note:
See TracChangeset
for help on using the changeset viewer.