Changeset 344f8b9 in mainline
- Timestamp:
- 2021-05-20T15:34:03Z (4 years ago)
- Children:
- f2416ec3
- Parents:
- da15002
- Location:
- uspace
- Files:
-
- 5 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/calculator/calculator.c
rda15002 r344f8b9 887 887 } 888 888 889 rc = ui_menu_bar_create(ui _res, &calc.menubar);889 rc = ui_menu_bar_create(ui, ui_res, &calc.menubar); 890 890 if (rc != EOK) { 891 891 printf("Error creating menu bar.\n"); -
uspace/app/uidemo/uidemo.c
rda15002 r344f8b9 331 331 } 332 332 333 rc = ui_menu_bar_create(ui _res, &demo.mbar);333 rc = ui_menu_bar_create(ui, ui_res, &demo.mbar); 334 334 if (rc != EOK) { 335 335 printf("Error creating menu bar.\n"); -
uspace/lib/ui/include/ui/menu.h
rda15002 r344f8b9 50 50 extern const char *ui_menu_caption(ui_menu_t *); 51 51 extern void ui_menu_get_rect(ui_menu_t *, gfx_coord2_t *, gfx_rect_t *); 52 extern errno_t ui_menu_open(ui_menu_t *, gfx_rect_t *); 53 extern void ui_menu_close(ui_menu_t *); 52 54 extern errno_t ui_menu_paint(ui_menu_t *, gfx_coord2_t *); 53 extern errno_t ui_menu_unpaint(ui_menu_t *);54 55 extern ui_evclaim_t ui_menu_pos_event(ui_menu_t *, gfx_coord2_t *, 55 56 pos_event_t *); -
uspace/lib/ui/include/ui/menubar.h
rda15002 r344f8b9 44 44 #include <types/ui/event.h> 45 45 #include <types/ui/resource.h> 46 #include <types/ui/ui.h> 46 47 47 extern errno_t ui_menu_bar_create(ui_ resource_t *,48 extern errno_t ui_menu_bar_create(ui_t *, ui_resource_t *, 48 49 ui_menu_bar_t **); 49 50 extern void ui_menu_bar_destroy(ui_menu_bar_t *); -
uspace/lib/ui/meson.build
rda15002 r344f8b9 42 42 'src/paint.c', 43 43 'src/pbutton.c', 44 'src/popup.c', 44 45 'src/rbutton.c', 45 46 'src/resource.c', … … 64 65 'test/paint.c', 65 66 'test/pbutton.c', 67 'test/popup.c', 66 68 'test/rbutton.c', 67 69 'test/resource.c', -
uspace/lib/ui/private/menu.h
rda15002 r344f8b9 42 42 #include <stdbool.h> 43 43 #include <types/ui/menu.h> 44 #include <types/ui/resource.h> 44 45 45 46 /** Actual structure of menu. … … 54 55 /** Caption */ 55 56 char *caption; 56 /** Menu iscurrently open */57 bool open;57 /** Popup window or @c NULL if menu is not currently open */ 58 struct ui_popup *popup; 58 59 /** Selected menu entry or @c NULL */ 59 60 struct ui_menu_entry *selected; … … 80 81 81 82 extern void ui_menu_get_geom(ui_menu_t *, gfx_coord2_t *, ui_menu_geom_t *); 83 extern ui_resource_t *ui_menu_get_res(ui_menu_t *); 82 84 83 85 #endif -
uspace/lib/ui/private/menubar.h
rda15002 r344f8b9 50 50 /** Base control object */ 51 51 struct ui_control *control; 52 /** UI resource */ 52 /** UI */ 53 struct ui *ui; 54 /** UI resource (for window containing menu bar) */ 53 55 struct ui_resource *res; 54 56 /** Menu bar rectangle */ … … 56 58 /** Selected menu or @c NULL */ 57 59 struct ui_menu *selected; 58 /** Position of selected entry */59 gfx_coord2_t sel_pos;60 60 /** List of menus (ui_menu_t) */ 61 61 list_t menus; 62 62 }; 63 63 64 extern void ui_menu_bar_select(ui_menu_bar_t *, gfx_ coord2_t *, ui_menu_t *);64 extern void ui_menu_bar_select(ui_menu_bar_t *, gfx_rect_t *, ui_menu_t *); 65 65 66 66 #endif -
uspace/lib/ui/src/menu.c
rda15002 r344f8b9 45 45 #include <ui/control.h> 46 46 #include <ui/paint.h> 47 #include <ui/popup.h> 47 48 #include <ui/menu.h> 48 49 #include <ui/menuentry.h> … … 59 60 }; 60 61 62 static void ui_menu_popup_pos(ui_popup_t *, void *, pos_event_t *); 63 64 static ui_popup_cb_t ui_menu_popup_cb = { 65 .pos = ui_menu_popup_pos 66 }; 67 61 68 /** Create new menu. 62 69 * … … 203 210 } 204 211 212 /** Get UI resource from menu. 213 * 214 * @param menu Menu 215 * @return UI resource 216 */ 217 ui_resource_t *ui_menu_get_res(ui_menu_t *menu) 218 { 219 return ui_popup_get_res(menu->popup); 220 } 221 222 /** Open menu. 223 * 224 * @param menu Menu 225 * @param prect Parent rectangle around which the menu should be placed 226 */ 227 errno_t ui_menu_open(ui_menu_t *menu, gfx_rect_t *prect) 228 { 229 ui_popup_t *popup = NULL; 230 ui_popup_params_t params; 231 ui_menu_geom_t geom; 232 gfx_coord2_t mpos; 233 errno_t rc; 234 235 /* Determine menu dimensions */ 236 237 mpos.x = 0; 238 mpos.y = 0; 239 ui_menu_get_geom(menu, &mpos, &geom); 240 241 ui_popup_params_init(¶ms); 242 params.rect = geom.outer_rect; 243 244 rc = ui_popup_create(menu->mbar->ui, ¶ms, &popup); 245 if (rc != EOK) 246 return rc; 247 248 menu->popup = popup; 249 ui_popup_set_cb(popup, &ui_menu_popup_cb, menu); 250 251 return ui_menu_paint(menu, &mpos); 252 } 253 254 /** Close menu. 255 * 256 * @param menu Menu 257 */ 258 void ui_menu_close(ui_menu_t *menu) 259 { 260 ui_popup_destroy(menu->popup); 261 menu->popup = NULL; 262 } 263 205 264 /** Paint menu. 206 265 * … … 218 277 errno_t rc; 219 278 220 res = menu->mbar->res;279 res = ui_menu_get_res(menu); 221 280 ui_menu_get_geom(menu, spos, &geom); 222 281 … … 261 320 error: 262 321 return rc; 263 }264 265 /** Unpaint menu.266 *267 * @param menu Menu268 * @return EOK on success or an error code269 */270 errno_t ui_menu_unpaint(ui_menu_t *menu)271 {272 ui_resource_expose(menu->mbar->res);273 return EOK;274 322 } 275 323 … … 312 360 } else { 313 361 /* Press outside menu - close it */ 314 if (event->type == POS_PRESS)315 ui_menu_bar_select(menu->mbar, NULL, NULL);362 // if (event->type == POS_PRESS) 363 // ui_menu_bar_select(menu->mbar, NULL, NULL); 316 364 } 317 365 … … 319 367 } 320 368 369 /** Handle position event in menu popup window. 370 * 371 * @param popup Menu popup window 372 * @param arg Argument (ui_menu_t *) 373 * @param event Position event 374 */ 375 static void ui_menu_popup_pos(ui_popup_t *popup, void *arg, pos_event_t *event) 376 { 377 ui_menu_t *menu = (ui_menu_t *)arg; 378 gfx_coord2_t spos; 379 380 spos.x = 0; 381 spos.y = 0; 382 ui_menu_pos_event(menu, &spos, event); 383 } 384 321 385 /** @} 322 386 */ -
uspace/lib/ui/src/menubar.c
rda15002 r344f8b9 72 72 /** Create new menu bar. 73 73 * 74 * @param ui UI 74 75 * @param res UI resource 75 76 * @param rmbar Place to store pointer to new menu bar 76 77 * @return EOK on success, ENOMEM if out of memory 77 78 */ 78 errno_t ui_menu_bar_create(ui_resource_t *res, ui_menu_bar_t **rmbar) 79 errno_t ui_menu_bar_create(ui_t *ui, ui_resource_t *res, 80 ui_menu_bar_t **rmbar) 79 81 { 80 82 ui_menu_bar_t *mbar; … … 91 93 } 92 94 95 mbar->ui = ui; 93 96 mbar->res = res; 94 97 list_initialize(&mbar->menus); … … 232 235 * 233 236 * @param mbar Menu bar 234 * @param pos Position (top-left corner) of menu bar entry237 * @param rect Menu bar entry rectangle 235 238 * @param menu Menu to select (or deselect if selected) or @c NULL 236 239 */ 237 void ui_menu_bar_select(ui_menu_bar_t *mbar, gfx_ coord2_t *pos,240 void ui_menu_bar_select(ui_menu_bar_t *mbar, gfx_rect_t *rect, 238 241 ui_menu_t *menu) 239 242 { 240 gfx_coord2_t spos;241 243 ui_menu_t *old_menu; 242 244 … … 248 250 mbar->selected = NULL; 249 251 250 /* Need to clear the menu has just been closed*/252 /* Close previously open menu */ 251 253 if (old_menu != NULL) 252 (void) ui_menu_ unpaint(old_menu);254 (void) ui_menu_close(old_menu); 253 255 254 256 (void) ui_menu_bar_paint(mbar); 255 257 256 258 if (mbar->selected != NULL) { 257 /* Cache position of selected entry */ 258 mbar->sel_pos = *pos; 259 260 /* Position menu under selected menu bar entry */ 261 spos.x = pos->x; 262 spos.y = mbar->rect.p1.y; 263 264 (void) ui_menu_paint(mbar->selected, &spos); 259 (void) ui_menu_open(mbar->selected, rect); 265 260 } 266 261 } … … 275 270 { 276 271 gfx_coord2_t pos; 277 gfx_coord2_t spos;278 272 gfx_rect_t rect; 279 273 ui_menu_t *menu; … … 282 276 gfx_coord_t hpad; 283 277 gfx_coord2_t ppos; 284 ui_evclaim_t claimed;285 278 286 279 ppos.x = event->hpos; … … 307 300 if (event->type == POS_PRESS && 308 301 gfx_pix_inside_rect(&ppos, &rect)) { 309 ui_menu_bar_select(mbar, & pos, menu);302 ui_menu_bar_select(mbar, &rect, menu); 310 303 return ui_claimed; 311 304 } 312 305 313 if (menu == mbar->selected) {314 /* Open menu is positioned below menu bar entry */315 spos.x = pos.x;316 spos.y = mbar->rect.p1.y;317 318 ui_menu_get_rect(menu, &spos, &rect);319 320 claimed = ui_menu_pos_event(menu, &spos, event);321 if (claimed == ui_claimed)322 return ui_claimed;323 }324 325 306 pos.x += width; 326 307 menu = ui_menu_next(menu); … … 336 317 void ui_menu_bar_unfocus(ui_menu_bar_t *mbar) 337 318 { 338 ui_menu_bar_select(mbar, NULL, NULL);319 // ui_menu_bar_select(mbar, NULL, NULL); 339 320 } 340 321 -
uspace/lib/ui/src/menuentry.c
rda15002 r344f8b9 203 203 ui_resource_t *res; 204 204 205 /* 206 * This needs to work even if the menu is not open, so we cannot 207 * use the menu's resource, which is only created after the menu 208 * is open (and its window is created). Use the menu bar's 209 * resource instead. 210 */ 205 211 res = mentry->menu->mbar->res; 206 212 … … 223 229 gfx_coord_t width; 224 230 231 /* 232 * This needs to work even if the menu is not open, so we cannot 233 * use the menu's resource, which is only created after the menu 234 * is open (and its window is created). Use the menu bar's 235 * resource instead. 236 */ 225 237 res = menu->mbar->res; 226 238 … … 256 268 gfx_coord_t vpad; 257 269 270 /* 271 * This needs to work even if the menu is not open, so we cannot 272 * use the menu's resource, which is only created after the menu 273 * is open (and its window is created). Use the menu bar's 274 * resource instead. 275 */ 258 276 res = mentry->menu->mbar->res; 259 277 … … 294 312 errno_t rc; 295 313 296 res = mentry->menu->mbar->res;314 res = ui_menu_get_res(mentry->menu); 297 315 298 316 ui_menu_entry_get_geom(mentry, pos, &geom); … … 379 397 if (mentry->inside) { 380 398 /* Close menu */ 381 ui_menu_bar_select(mentry->menu->mbar, 382 &mentry->menu->mbar->sel_pos, NULL); 399 ui_menu_bar_select(mentry->menu->mbar, NULL, NULL); 383 400 384 401 /* Call back */ … … 487 504 gfx_coord_t width; 488 505 489 res = mentry->menu->mbar->res;506 res = ui_menu_get_res(mentry->menu); 490 507 491 508 if (res->textmode) { -
uspace/lib/ui/src/window.c
rda15002 r344f8b9 336 336 * is added, the results are undefined. 337 337 * 338 * @param fixed Fixed layout338 * @param window Window 339 339 * @param control Control 340 340 * @return EOK on success, ENOMEM if out of memory … … 509 509 * 510 510 * @param window Window 511 * @param cb Window decorationcallbacks511 * @param cb Window callbacks 512 512 * @param arg Callback argument 513 513 */ -
uspace/lib/ui/test/main.c
rda15002 r344f8b9 42 42 PCUT_IMPORT(paint); 43 43 PCUT_IMPORT(pbutton); 44 PCUT_IMPORT(popup); 44 45 PCUT_IMPORT(rbutton); 45 46 PCUT_IMPORT(resource); -
uspace/lib/ui/test/menu.c
rda15002 r344f8b9 46 46 PCUT_TEST_SUITE(menu); 47 47 48 typedef struct {49 bool expose;50 } test_resp_t;51 52 static void test_expose(void *);53 54 48 /** Create and destroy menu */ 55 49 PCUT_TEST(create_destroy) … … 59 53 errno_t rc; 60 54 61 rc = ui_menu_bar_create(NULL, &mbar);55 rc = ui_menu_bar_create(NULL, NULL, &mbar); 62 56 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 63 57 … … 102 96 PCUT_ASSERT_NOT_NULL(resource); 103 97 104 rc = ui_menu_bar_create( resource, &mbar);98 rc = ui_menu_bar_create(NULL, resource, &mbar); 105 99 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 106 100 PCUT_ASSERT_NOT_NULL(mbar); … … 148 142 PCUT_ASSERT_NOT_NULL(resource); 149 143 150 rc = ui_menu_bar_create( resource, &mbar);144 rc = ui_menu_bar_create(NULL, resource, &mbar); 151 145 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 152 146 PCUT_ASSERT_NOT_NULL(mbar); … … 188 182 PCUT_ASSERT_NOT_NULL(resource); 189 183 190 rc = ui_menu_bar_create( resource, &mbar);184 rc = ui_menu_bar_create(NULL, resource, &mbar); 191 185 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 192 186 PCUT_ASSERT_NOT_NULL(mbar); … … 218 212 dummy_gc_t *dgc; 219 213 gfx_context_t *gc; 220 ui_resource_t *resource = NULL; 221 ui_menu_bar_t *mbar = NULL; 222 ui_menu_t *menu = NULL; 214 ui_t *ui = NULL; 215 ui_resource_t *resource = NULL; 216 ui_menu_bar_t *mbar = NULL; 217 ui_menu_t *menu = NULL; 218 gfx_rect_t prect; 223 219 gfx_coord2_t pos; 224 220 errno_t rc; … … 229 225 gc = dummygc_get_ctx(dgc); 230 226 231 rc = ui_resource_create(gc, false, &resource); 232 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 233 PCUT_ASSERT_NOT_NULL(resource); 234 235 rc = ui_menu_bar_create(resource, &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); 227 rc = ui_create_disp(NULL, &ui); 228 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 229 230 rc = ui_resource_create(gc, false, &resource); 231 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 232 PCUT_ASSERT_NOT_NULL(resource); 233 234 rc = ui_menu_bar_create(ui, resource, &mbar); 235 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 236 PCUT_ASSERT_NOT_NULL(mbar); 237 238 rc = ui_menu_create(mbar, "Test", &menu); 239 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 240 PCUT_ASSERT_NOT_NULL(menu); 241 242 prect.p0.x = 0; 243 prect.p0.y = 0; 244 prect.p1.x = 0; 245 prect.p1.y = 0; 246 247 /* Menu needs to be open to be able to paint it */ 248 rc = ui_menu_open(menu, &prect); 249 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 242 250 243 251 pos.x = 0; … … 248 256 ui_menu_bar_destroy(mbar); 249 257 ui_resource_destroy(resource); 250 dummygc_destroy(dgc); 251 } 252 253 /** ui_menu_unpaint() calls expose callback */ 254 PCUT_TEST(unpaint) 255 { 256 dummy_gc_t *dgc; 257 gfx_context_t *gc; 258 ui_resource_t *resource = NULL; 259 ui_menu_bar_t *mbar = NULL; 260 ui_menu_t *menu = NULL; 261 test_resp_t resp; 262 errno_t rc; 263 264 rc = dummygc_create(&dgc); 265 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 266 267 gc = dummygc_get_ctx(dgc); 268 269 rc = ui_resource_create(gc, false, &resource); 270 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 271 PCUT_ASSERT_NOT_NULL(resource); 272 273 rc = ui_menu_bar_create(resource, &mbar); 274 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 275 PCUT_ASSERT_NOT_NULL(mbar); 276 277 rc = ui_menu_create(mbar, "Test", &menu); 278 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 279 PCUT_ASSERT_NOT_NULL(menu); 280 281 ui_resource_set_expose_cb(resource, test_expose, &resp); 282 283 resp.expose = false; 284 rc = ui_menu_unpaint(menu); 285 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 286 PCUT_ASSERT_TRUE(resp.expose); 287 288 ui_menu_bar_destroy(mbar); 289 ui_resource_destroy(resource); 258 ui_destroy(ui); 290 259 dummygc_destroy(dgc); 291 260 } … … 313 282 PCUT_ASSERT_NOT_NULL(resource); 314 283 315 rc = ui_menu_bar_create( resource, &mbar);284 rc = ui_menu_bar_create(NULL, resource, &mbar); 316 285 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 317 286 PCUT_ASSERT_NOT_NULL(mbar); … … 334 303 } 335 304 336 /** ui_menu_pos_event() outside menu closes it */337 PCUT_TEST(pos_event_outside)338 {339 dummy_gc_t *dgc;340 gfx_context_t *gc;341 ui_resource_t *resource = NULL;342 ui_menu_bar_t *mbar = NULL;343 ui_menu_t *menu = NULL;344 ui_evclaim_t claimed;345 gfx_coord2_t pos;346 pos_event_t event;347 errno_t rc;348 349 rc = dummygc_create(&dgc);350 PCUT_ASSERT_ERRNO_VAL(EOK, rc);351 352 gc = dummygc_get_ctx(dgc);353 354 rc = ui_resource_create(gc, false, &resource);355 PCUT_ASSERT_ERRNO_VAL(EOK, rc);356 PCUT_ASSERT_NOT_NULL(resource);357 358 rc = ui_menu_bar_create(resource, &mbar);359 PCUT_ASSERT_ERRNO_VAL(EOK, rc);360 PCUT_ASSERT_NOT_NULL(mbar);361 362 rc = ui_menu_create(mbar, "Test", &menu);363 PCUT_ASSERT_ERRNO_VAL(EOK, rc);364 PCUT_ASSERT_NOT_NULL(menu);365 366 pos.x = 0;367 pos.y = 0;368 ui_menu_bar_select(mbar, &pos, menu);369 PCUT_ASSERT_EQUALS(menu, mbar->selected);370 371 pos.x = 10;372 pos.y = 0;373 event.type = POS_PRESS;374 event.hpos = 0;375 event.vpos = 0;376 claimed = ui_menu_pos_event(menu, &pos, &event);377 PCUT_ASSERT_EQUALS(ui_unclaimed, claimed);378 379 /* Press event outside menu should close it */380 PCUT_ASSERT_NULL(mbar->selected);381 382 ui_menu_bar_destroy(mbar);383 ui_resource_destroy(resource);384 dummygc_destroy(dgc);385 }386 387 305 /** Computing menu geometry */ 388 306 PCUT_TEST(get_geom) … … 406 324 PCUT_ASSERT_NOT_NULL(resource); 407 325 408 rc = ui_menu_bar_create( resource, &mbar);326 rc = ui_menu_bar_create(NULL, resource, &mbar); 409 327 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 410 328 PCUT_ASSERT_NOT_NULL(mbar); … … 432 350 } 433 351 434 static void test_expose(void *arg)435 {436 test_resp_t *resp = (test_resp_t *) arg;437 438 resp->expose = true;439 }440 441 352 PCUT_EXPORT(menu); -
uspace/lib/ui/test/menubar.c
rda15002 r344f8b9 50 50 errno_t rc; 51 51 52 rc = ui_menu_bar_create(NULL, &mbar);52 rc = ui_menu_bar_create(NULL, NULL, &mbar); 53 53 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 54 54 PCUT_ASSERT_NOT_NULL(mbar); … … 70 70 errno_t rc; 71 71 72 rc = ui_menu_bar_create(NULL, &mbar);72 rc = ui_menu_bar_create(NULL, NULL, &mbar); 73 73 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 74 74 PCUT_ASSERT_NOT_NULL(mbar); … … 99 99 PCUT_ASSERT_NOT_NULL(resource); 100 100 101 rc = ui_menu_bar_create( resource, &mbar);101 rc = ui_menu_bar_create(NULL, resource, &mbar); 102 102 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 103 103 PCUT_ASSERT_NOT_NULL(mbar); … … 137 137 PCUT_ASSERT_NOT_NULL(resource); 138 138 139 rc = ui_menu_bar_create( resource, &mbar);139 rc = ui_menu_bar_create(NULL, resource, &mbar); 140 140 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 141 141 PCUT_ASSERT_NOT_NULL(mbar); … … 154 154 dummy_gc_t *dgc; 155 155 gfx_context_t *gc; 156 ui_t *ui = NULL; 156 157 ui_resource_t *resource = NULL; 157 158 ui_menu_bar_t *mbar = NULL; … … 167 168 gc = dummygc_get_ctx(dgc); 168 169 169 rc = ui_resource_create(gc, false, &resource); 170 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 171 PCUT_ASSERT_NOT_NULL(resource); 172 173 rc = ui_menu_bar_create(resource, &mbar); 170 rc = ui_create_disp(NULL, &ui); 171 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 172 173 rc = ui_resource_create(gc, false, &resource); 174 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 175 PCUT_ASSERT_NOT_NULL(resource); 176 177 rc = ui_menu_bar_create(ui, resource, &mbar); 174 178 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 175 179 PCUT_ASSERT_NOT_NULL(mbar); … … 197 201 ui_menu_bar_destroy(mbar); 198 202 ui_resource_destroy(resource); 199 dummygc_destroy(dgc); 200 } 201 202 /** Position event is forwarded to menu */ 203 PCUT_TEST(pos_event_menu) 204 { 205 dummy_gc_t *dgc; 206 gfx_context_t *gc; 203 ui_destroy(ui); 204 dummygc_destroy(dgc); 205 } 206 207 /** Calling ui_menu_bar_select() with the same menu twice deselects it */ 208 PCUT_TEST(select_same) 209 { 210 dummy_gc_t *dgc; 211 gfx_context_t *gc; 212 ui_t *ui = NULL; 207 213 ui_resource_t *resource = NULL; 208 214 ui_menu_bar_t *mbar = NULL; 209 215 ui_menu_t *menu = NULL; 210 ui_evclaim_t claimed;211 pos_event_t event;212 gfx_coord2_t pos;213 216 gfx_rect_t rect; 214 217 errno_t rc; … … 219 222 gc = dummygc_get_ctx(dgc); 220 223 221 rc = ui_resource_create(gc, false, &resource); 222 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 223 PCUT_ASSERT_NOT_NULL(resource); 224 225 rc = ui_menu_bar_create(resource, &mbar); 226 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 227 PCUT_ASSERT_NOT_NULL(mbar); 224 rc = ui_create_disp(NULL, &ui); 225 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 226 227 rc = ui_resource_create(gc, false, &resource); 228 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 229 PCUT_ASSERT_NOT_NULL(resource); 230 231 rc = ui_menu_bar_create(ui, resource, &mbar); 232 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 233 PCUT_ASSERT_NOT_NULL(mbar); 234 235 rc = ui_menu_create(mbar, "Test", &menu); 236 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 237 PCUT_ASSERT_NOT_NULL(menu); 228 238 229 239 rect.p0.x = 0; 230 240 rect.p0.y = 0; 231 rect.p1.x = 50; 232 rect.p1.y = 25; 233 ui_menu_bar_set_rect(mbar, &rect); 234 235 rc = ui_menu_create(mbar, "Test", &menu); 236 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 237 PCUT_ASSERT_NOT_NULL(menu); 238 239 pos.x = 0; 240 pos.y = 0; 241 ui_menu_bar_select(mbar, &pos, menu); 241 rect.p1.x = 0; 242 rect.p1.y = 0; 243 ui_menu_bar_select(mbar, &rect, menu); 242 244 PCUT_ASSERT_EQUALS(menu, mbar->selected); 243 245 244 event.type = POS_PRESS; 245 event.hpos = 4; 246 event.vpos = 30; 247 claimed = ui_menu_bar_pos_event(mbar, &event); 248 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 249 PCUT_ASSERT_EQUALS(ui_claimed, claimed); 250 251 ui_menu_bar_destroy(mbar); 252 ui_resource_destroy(resource); 253 dummygc_destroy(dgc); 254 } 255 256 /* Unfocusing window closes open menu */ 257 PCUT_TEST(unfocus) 258 { 259 dummy_gc_t *dgc; 260 gfx_context_t *gc; 261 ui_resource_t *resource = NULL; 262 ui_menu_bar_t *mbar = NULL; 263 ui_menu_t *menu = NULL; 264 gfx_coord2_t pos; 265 errno_t rc; 266 267 rc = dummygc_create(&dgc); 268 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 269 270 gc = dummygc_get_ctx(dgc); 271 272 rc = ui_resource_create(gc, false, &resource); 273 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 274 PCUT_ASSERT_NOT_NULL(resource); 275 276 rc = ui_menu_bar_create(resource, &mbar); 277 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 278 PCUT_ASSERT_NOT_NULL(mbar); 279 280 rc = ui_menu_create(mbar, "Test", &menu); 281 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 282 PCUT_ASSERT_NOT_NULL(menu); 283 284 /* 285 * Position does not matter here. Probably should get rid of this 286 * argument, storing the position in the menu itself. 287 */ 288 pos.x = 0; 289 pos.y = 0; 290 ui_menu_bar_select(mbar, &pos, menu); 291 PCUT_ASSERT_EQUALS(menu, mbar->selected); 292 293 /* This should unselect the menu */ 294 ui_menu_bar_unfocus(mbar); 246 /* Selecting again should unselect the menu */ 247 ui_menu_bar_select(mbar, &rect, menu); 295 248 PCUT_ASSERT_NULL(mbar->selected); 296 249 297 250 ui_menu_bar_destroy(mbar); 298 251 ui_resource_destroy(resource); 299 dummygc_destroy(dgc); 300 } 301 302 /** Calling ui_menu_bar_select() with the same menu twice deselects it */ 303 PCUT_TEST(select_same) 304 { 305 dummy_gc_t *dgc; 306 gfx_context_t *gc; 307 ui_resource_t *resource = NULL; 308 ui_menu_bar_t *mbar = NULL; 309 ui_menu_t *menu = NULL; 310 gfx_coord2_t pos; 311 errno_t rc; 312 313 rc = dummygc_create(&dgc); 314 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 315 316 gc = dummygc_get_ctx(dgc); 317 318 rc = ui_resource_create(gc, false, &resource); 319 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 320 PCUT_ASSERT_NOT_NULL(resource); 321 322 rc = ui_menu_bar_create(resource, &mbar); 323 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 324 PCUT_ASSERT_NOT_NULL(mbar); 325 326 rc = ui_menu_create(mbar, "Test", &menu); 327 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 328 PCUT_ASSERT_NOT_NULL(menu); 329 330 pos.x = 0; 331 pos.y = 0; 332 ui_menu_bar_select(mbar, &pos, menu); 333 PCUT_ASSERT_EQUALS(menu, mbar->selected); 334 335 /* Selecting again should unselect the menu */ 336 ui_menu_bar_select(mbar, &pos, menu); 337 PCUT_ASSERT_NULL(mbar->selected); 338 339 ui_menu_bar_destroy(mbar); 340 ui_resource_destroy(resource); 252 ui_destroy(ui); 341 253 dummygc_destroy(dgc); 342 254 } … … 347 259 dummy_gc_t *dgc; 348 260 gfx_context_t *gc; 261 ui_t *ui = NULL; 349 262 ui_resource_t *resource = NULL; 350 263 ui_menu_bar_t *mbar = NULL; 351 264 ui_menu_t *menu1 = NULL; 352 265 ui_menu_t *menu2 = NULL; 353 gfx_coord2_t pos; 354 errno_t rc; 355 356 rc = dummygc_create(&dgc); 357 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 358 359 gc = dummygc_get_ctx(dgc); 360 361 rc = ui_resource_create(gc, false, &resource); 362 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 363 PCUT_ASSERT_NOT_NULL(resource); 364 365 rc = ui_menu_bar_create(resource, &mbar); 266 gfx_rect_t rect; 267 errno_t rc; 268 269 rc = dummygc_create(&dgc); 270 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 271 272 gc = dummygc_get_ctx(dgc); 273 274 rc = ui_create_disp(NULL, &ui); 275 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 276 277 rc = ui_resource_create(gc, false, &resource); 278 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 279 PCUT_ASSERT_NOT_NULL(resource); 280 281 rc = ui_menu_bar_create(ui, resource, &mbar); 366 282 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 367 283 PCUT_ASSERT_NOT_NULL(mbar); … … 375 291 PCUT_ASSERT_NOT_NULL(menu2); 376 292 377 pos.x = 0; 378 pos.y = 0; 379 ui_menu_bar_select(mbar, &pos, menu1); 293 rect.p0.x = 0; 294 rect.p0.y = 0; 295 rect.p1.x = 0; 296 rect.p1.y = 0; 297 ui_menu_bar_select(mbar, &rect, menu1); 380 298 PCUT_ASSERT_EQUALS(menu1, mbar->selected); 381 299 382 300 /* Selecting different menu should select it */ 383 ui_menu_bar_select(mbar, & pos, menu2);301 ui_menu_bar_select(mbar, &rect, menu2); 384 302 PCUT_ASSERT_EQUALS(menu2, mbar->selected); 385 303 386 304 ui_menu_bar_destroy(mbar); 387 305 ui_resource_destroy(resource); 306 ui_destroy(ui); 388 307 dummygc_destroy(dgc); 389 308 } -
uspace/lib/ui/test/menuentry.c
rda15002 r344f8b9 71 71 PCUT_ASSERT_NOT_NULL(resource); 72 72 73 rc = ui_menu_bar_create( resource, &mbar);73 rc = ui_menu_bar_create(NULL, resource, &mbar); 74 74 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 75 75 PCUT_ASSERT_NOT_NULL(mbar); … … 110 110 PCUT_ASSERT_NOT_NULL(resource); 111 111 112 rc = ui_menu_bar_create( resource, &mbar);112 rc = ui_menu_bar_create(NULL, resource, &mbar); 113 113 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 114 114 PCUT_ASSERT_NOT_NULL(mbar); … … 156 156 PCUT_ASSERT_NOT_NULL(resource); 157 157 158 rc = ui_menu_bar_create( resource, &mbar);158 rc = ui_menu_bar_create(NULL, resource, &mbar); 159 159 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 160 160 PCUT_ASSERT_NOT_NULL(mbar); … … 201 201 PCUT_ASSERT_NOT_NULL(resource); 202 202 203 rc = ui_menu_bar_create( resource, &mbar);203 rc = ui_menu_bar_create(NULL, resource, &mbar); 204 204 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 205 205 PCUT_ASSERT_NOT_NULL(mbar); … … 255 255 PCUT_ASSERT_NOT_NULL(resource); 256 256 257 rc = ui_menu_bar_create( resource, &mbar);257 rc = ui_menu_bar_create(NULL, resource, &mbar); 258 258 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 259 259 PCUT_ASSERT_NOT_NULL(mbar); … … 287 287 dummy_gc_t *dgc; 288 288 gfx_context_t *gc; 289 ui_t *ui = NULL; 289 290 ui_resource_t *resource = NULL; 290 291 ui_menu_bar_t *mbar = NULL; … … 292 293 ui_menu_entry_t *mentry = NULL; 293 294 gfx_coord2_t pos; 294 errno_t rc; 295 296 rc = dummygc_create(&dgc); 297 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 298 299 gc = dummygc_get_ctx(dgc); 300 301 rc = ui_resource_create(gc, false, &resource); 302 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 303 PCUT_ASSERT_NOT_NULL(resource); 304 305 rc = ui_menu_bar_create(resource, &mbar); 295 gfx_rect_t prect; 296 errno_t rc; 297 298 rc = dummygc_create(&dgc); 299 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 300 301 gc = dummygc_get_ctx(dgc); 302 303 rc = ui_create_disp(NULL, &ui); 304 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 305 306 rc = ui_resource_create(gc, false, &resource); 307 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 308 PCUT_ASSERT_NOT_NULL(resource); 309 310 rc = ui_menu_bar_create(ui, resource, &mbar); 306 311 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 307 312 PCUT_ASSERT_NOT_NULL(mbar); … … 314 319 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 315 320 PCUT_ASSERT_NOT_NULL(mentry); 321 322 prect.p0.x = 0; 323 prect.p0.y = 0; 324 prect.p1.x = 0; 325 prect.p1.y = 0; 326 327 rc = ui_menu_open(menu, &prect); 328 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 316 329 317 330 pos.x = 0; … … 322 335 ui_menu_bar_destroy(mbar); 323 336 ui_resource_destroy(resource); 337 ui_destroy(ui); 324 338 dummygc_destroy(dgc); 325 339 } … … 330 344 dummy_gc_t *dgc; 331 345 gfx_context_t *gc; 346 ui_t *ui = NULL; 332 347 ui_resource_t *resource = NULL; 333 348 ui_menu_bar_t *mbar = NULL; … … 335 350 ui_menu_entry_t *mentry = NULL; 336 351 gfx_coord2_t pos; 352 gfx_rect_t prect; 337 353 test_resp_t resp; 338 354 errno_t rc; … … 343 359 gc = dummygc_get_ctx(dgc); 344 360 345 rc = ui_resource_create(gc, false, &resource); 346 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 347 PCUT_ASSERT_NOT_NULL(resource); 348 349 rc = ui_menu_bar_create(resource, &mbar); 361 rc = ui_create_disp(NULL, &ui); 362 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 363 364 rc = ui_resource_create(gc, false, &resource); 365 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 366 PCUT_ASSERT_NOT_NULL(resource); 367 368 rc = ui_menu_bar_create(ui, resource, &mbar); 350 369 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 351 370 PCUT_ASSERT_NOT_NULL(mbar); … … 361 380 ui_menu_entry_set_cb(mentry, test_entry_cb, &resp); 362 381 resp.activated = false; 382 383 prect.p0.x = 0; 384 prect.p0.y = 0; 385 prect.p1.x = 0; 386 prect.p1.y = 0; 387 388 rc = ui_menu_open(menu, &prect); 389 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 363 390 364 391 pos.x = 0; … … 375 402 ui_menu_bar_destroy(mbar); 376 403 ui_resource_destroy(resource); 404 ui_destroy(ui); 377 405 dummygc_destroy(dgc); 378 406 } … … 383 411 dummy_gc_t *dgc; 384 412 gfx_context_t *gc; 413 ui_t *ui = NULL; 385 414 ui_resource_t *resource = NULL; 386 415 ui_menu_bar_t *mbar = NULL; … … 388 417 ui_menu_entry_t *mentry = NULL; 389 418 gfx_coord2_t pos; 419 gfx_rect_t prect; 390 420 test_resp_t resp; 391 421 errno_t rc; … … 396 426 gc = dummygc_get_ctx(dgc); 397 427 398 rc = ui_resource_create(gc, false, &resource); 399 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 400 PCUT_ASSERT_NOT_NULL(resource); 401 402 rc = ui_menu_bar_create(resource, &mbar); 428 rc = ui_create_disp(NULL, &ui); 429 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 430 431 rc = ui_resource_create(gc, false, &resource); 432 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 433 PCUT_ASSERT_NOT_NULL(resource); 434 435 rc = ui_menu_bar_create(ui, resource, &mbar); 403 436 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 404 437 PCUT_ASSERT_NOT_NULL(mbar); … … 414 447 ui_menu_entry_set_cb(mentry, test_entry_cb, &resp); 415 448 resp.activated = false; 449 450 prect.p0.x = 0; 451 prect.p0.y = 0; 452 prect.p1.x = 0; 453 prect.p1.y = 0; 454 455 rc = ui_menu_open(menu, &prect); 456 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 416 457 417 458 pos.x = 0; … … 433 474 ui_menu_bar_destroy(mbar); 434 475 ui_resource_destroy(resource); 476 ui_destroy(ui); 435 477 dummygc_destroy(dgc); 436 478 } … … 441 483 dummy_gc_t *dgc; 442 484 gfx_context_t *gc; 485 ui_t *ui = NULL; 443 486 ui_resource_t *resource = NULL; 444 487 ui_menu_bar_t *mbar = NULL; … … 446 489 ui_menu_entry_t *mentry = NULL; 447 490 gfx_coord2_t pos; 491 gfx_rect_t prect; 448 492 test_resp_t resp; 449 493 errno_t rc; … … 454 498 gc = dummygc_get_ctx(dgc); 455 499 456 rc = ui_resource_create(gc, false, &resource); 457 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 458 PCUT_ASSERT_NOT_NULL(resource); 459 460 rc = ui_menu_bar_create(resource, &mbar); 500 rc = ui_create_disp(NULL, &ui); 501 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 502 503 rc = ui_resource_create(gc, false, &resource); 504 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 505 PCUT_ASSERT_NOT_NULL(resource); 506 507 rc = ui_menu_bar_create(ui, resource, &mbar); 461 508 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 462 509 PCUT_ASSERT_NOT_NULL(mbar); … … 472 519 ui_menu_entry_set_cb(mentry, test_entry_cb, &resp); 473 520 resp.activated = false; 521 522 prect.p0.x = 0; 523 prect.p0.y = 0; 524 prect.p1.x = 0; 525 prect.p1.y = 0; 526 527 rc = ui_menu_open(menu, &prect); 528 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 474 529 475 530 pos.x = 0; … … 496 551 ui_menu_bar_destroy(mbar); 497 552 ui_resource_destroy(resource); 553 ui_destroy(ui); 498 554 dummygc_destroy(dgc); 499 555 } … … 504 560 dummy_gc_t *dgc; 505 561 gfx_context_t *gc; 562 ui_t *ui = NULL; 506 563 ui_resource_t *resource = NULL; 507 564 ui_menu_bar_t *mbar = NULL; … … 509 566 ui_menu_entry_t *mentry = NULL; 510 567 gfx_coord2_t pos; 568 gfx_rect_t prect; 511 569 pos_event_t event; 512 570 errno_t rc; … … 517 575 gc = dummygc_get_ctx(dgc); 518 576 519 rc = ui_resource_create(gc, false, &resource); 520 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 521 PCUT_ASSERT_NOT_NULL(resource); 522 523 rc = ui_menu_bar_create(resource, &mbar); 577 rc = ui_create_disp(NULL, &ui); 578 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 579 580 rc = ui_resource_create(gc, false, &resource); 581 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 582 PCUT_ASSERT_NOT_NULL(resource); 583 584 rc = ui_menu_bar_create(ui, resource, &mbar); 524 585 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 525 586 PCUT_ASSERT_NOT_NULL(mbar); … … 532 593 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 533 594 PCUT_ASSERT_NOT_NULL(mentry); 595 596 prect.p0.x = 0; 597 prect.p0.y = 0; 598 prect.p1.x = 0; 599 prect.p1.y = 0; 600 601 rc = ui_menu_open(menu, &prect); 602 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 534 603 535 604 pos.x = 0; … … 546 615 ui_menu_bar_destroy(mbar); 547 616 ui_resource_destroy(resource); 617 ui_destroy(ui); 548 618 dummygc_destroy(dgc); 549 619 } … … 554 624 dummy_gc_t *dgc; 555 625 gfx_context_t *gc; 626 ui_t *ui = NULL; 556 627 ui_resource_t *resource = NULL; 557 628 ui_menu_bar_t *mbar = NULL; … … 559 630 ui_menu_entry_t *mentry = NULL; 560 631 gfx_coord2_t pos; 632 gfx_rect_t prect; 561 633 pos_event_t event; 562 634 errno_t rc; … … 567 639 gc = dummygc_get_ctx(dgc); 568 640 569 rc = ui_resource_create(gc, false, &resource); 570 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 571 PCUT_ASSERT_NOT_NULL(resource); 572 573 rc = ui_menu_bar_create(resource, &mbar); 641 rc = ui_create_disp(NULL, &ui); 642 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 643 644 rc = ui_resource_create(gc, false, &resource); 645 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 646 PCUT_ASSERT_NOT_NULL(resource); 647 648 rc = ui_menu_bar_create(ui, resource, &mbar); 574 649 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 575 650 PCUT_ASSERT_NOT_NULL(mbar); … … 582 657 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 583 658 PCUT_ASSERT_NOT_NULL(mentry); 659 660 prect.p0.x = 0; 661 prect.p0.y = 0; 662 prect.p1.x = 0; 663 prect.p1.y = 0; 664 665 rc = ui_menu_open(menu, &prect); 666 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 584 667 585 668 pos.x = 0; … … 596 679 ui_menu_bar_destroy(mbar); 597 680 ui_resource_destroy(resource); 681 ui_destroy(ui); 598 682 dummygc_destroy(dgc); 599 683 } … … 604 688 dummy_gc_t *dgc; 605 689 gfx_context_t *gc; 690 ui_t *ui = NULL; 606 691 ui_resource_t *resource = NULL; 607 692 ui_menu_bar_t *mbar = NULL; … … 609 694 ui_menu_entry_t *mentry = NULL; 610 695 gfx_coord2_t pos; 696 gfx_rect_t prect; 611 697 pos_event_t event; 612 698 errno_t rc; … … 617 703 gc = dummygc_get_ctx(dgc); 618 704 619 rc = ui_resource_create(gc, false, &resource); 620 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 621 PCUT_ASSERT_NOT_NULL(resource); 622 623 rc = ui_menu_bar_create(resource, &mbar); 705 rc = ui_create_disp(NULL, &ui); 706 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 707 708 rc = ui_resource_create(gc, false, &resource); 709 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 710 PCUT_ASSERT_NOT_NULL(resource); 711 712 rc = ui_menu_bar_create(ui, resource, &mbar); 624 713 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 625 714 PCUT_ASSERT_NOT_NULL(mbar); … … 632 721 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 633 722 PCUT_ASSERT_NOT_NULL(mentry); 723 724 prect.p0.x = 0; 725 prect.p0.y = 0; 726 prect.p1.x = 0; 727 prect.p1.y = 0; 728 729 rc = ui_menu_open(menu, &prect); 730 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 634 731 635 732 pos.x = 0; … … 649 746 ui_menu_bar_destroy(mbar); 650 747 ui_resource_destroy(resource); 748 ui_destroy(ui); 651 749 dummygc_destroy(dgc); 652 750 } … … 657 755 dummy_gc_t *dgc; 658 756 gfx_context_t *gc; 757 ui_t *ui = NULL; 659 758 ui_resource_t *resource = NULL; 660 759 ui_menu_bar_t *mbar = NULL; … … 662 761 ui_menu_entry_t *mentry = NULL; 663 762 gfx_coord2_t pos; 763 gfx_rect_t prect; 664 764 pos_event_t event; 665 765 errno_t rc; … … 670 770 gc = dummygc_get_ctx(dgc); 671 771 672 rc = ui_resource_create(gc, false, &resource); 673 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 674 PCUT_ASSERT_NOT_NULL(resource); 675 676 rc = ui_menu_bar_create(resource, &mbar); 772 rc = ui_create_disp(NULL, &ui); 773 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 774 775 rc = ui_resource_create(gc, false, &resource); 776 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 777 PCUT_ASSERT_NOT_NULL(resource); 778 779 rc = ui_menu_bar_create(ui, resource, &mbar); 677 780 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 678 781 PCUT_ASSERT_NOT_NULL(mbar); … … 685 788 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 686 789 PCUT_ASSERT_NOT_NULL(mentry); 790 791 prect.p0.x = 0; 792 prect.p0.y = 0; 793 prect.p1.x = 0; 794 prect.p1.y = 0; 795 796 rc = ui_menu_open(menu, &prect); 797 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 687 798 688 799 event.type = POS_UPDATE; … … 699 810 ui_menu_bar_destroy(mbar); 700 811 ui_resource_destroy(resource); 812 ui_destroy(ui); 701 813 dummygc_destroy(dgc); 702 814 }
Note:
See TracChangeset
for help on using the changeset viewer.