Changeset 112f70a in mainline
- Timestamp:
- 2023-09-14T09:53:27Z (15 months ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8a6ebbb
- Parents:
- 61643c8
- git-author:
- Jiri Svoboda <jiri@…> (2023-09-13 18:53:09)
- git-committer:
- Jiri Svoboda <jiri@…> (2023-09-14 09:53:27)
- Location:
- uspace
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/uidemo/uidemo.c
r61643c8 r112f70a 805 805 } 806 806 807 ui_menu_entry_set_disabled(mfoobar, true); 808 807 809 rc = ui_menu_entry_sep_create(demo.mfile, &msep); 808 810 if (rc != EOK) { -
uspace/lib/ui/include/ui/menuentry.h
r61643c8 r112f70a 1 1 /* 2 * Copyright (c) 202 2Jiri Svoboda2 * Copyright (c) 2023 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 51 51 extern void ui_menu_entry_set_cb(ui_menu_entry_t *, ui_menu_entry_cb_t, 52 52 void *); 53 extern void ui_menu_entry_set_disabled(ui_menu_entry_t *, bool); 54 extern bool ui_menu_entry_is_disabled(ui_menu_entry_t *); 53 55 extern ui_menu_entry_t *ui_menu_entry_first(ui_menu_t *); 54 56 extern ui_menu_entry_t *ui_menu_entry_last(ui_menu_t *); -
uspace/lib/ui/private/menuentry.h
r61643c8 r112f70a 1 1 /* 2 * Copyright (c) 202 1Jiri Svoboda2 * Copyright (c) 2023 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 53 53 /** Callbacks */ 54 54 ui_menu_entry_cb_t cb; 55 /** This entry is disabled */ 56 bool disabled; 55 57 /** This entry is a separator entry */ 56 58 bool separator; -
uspace/lib/ui/private/resource.h
r61643c8 r112f70a 79 79 /** Window text color */ 80 80 gfx_color_t *wnd_text_color; 81 /** Disabled text color */ 82 gfx_color_t *wnd_dis_text_color; 81 83 /** Window text highlight color */ 82 84 gfx_color_t *wnd_text_hgl_color; -
uspace/lib/ui/src/menu.c
r61643c8 r112f70a 534 534 break; 535 535 case KC_ENTER: 536 if (menu->selected != NULL) 536 if (menu->selected != NULL && 537 !ui_menu_entry_is_disabled(menu->selected)) 537 538 ui_menu_entry_activate(menu->selected); 538 539 break; … … 543 544 c = ui_menu_entry_get_accel(mentry); 544 545 if (c == (char32_t)tolower(event->c) && 545 menu->selected != NULL) {546 !ui_menu_entry_is_disabled(mentry)) { 546 547 ui_menu_entry_activate(mentry); 547 548 break; -
uspace/lib/ui/src/menuentry.c
r61643c8 r112f70a 163 163 } 164 164 165 /** Set menu entry disabled flag. 166 * 167 * @param mentry Menu entry 168 * @param disabled @c true iff entry is to be disabled, @c false otherwise 169 */ 170 void ui_menu_entry_set_disabled(ui_menu_entry_t *mentry, bool disabled) 171 { 172 mentry->disabled = disabled; 173 } 174 175 /** Get menu entry disabled flag. 176 * 177 * @param mentry Menu entry 178 * @return disabled @c true iff entry is disabled, @c false otherwise 179 */ 180 bool ui_menu_entry_is_disabled(ui_menu_entry_t *mentry) 181 { 182 return mentry->disabled; 183 } 184 165 185 /** Get first menu entry in menu. 166 186 * … … 372 392 fmt.hgl_color = res->wnd_sel_text_hgl_color; 373 393 bg_color = res->wnd_sel_text_bg_color; 394 } else if (mentry->disabled) { 395 fmt.color = res->wnd_dis_text_color; 396 fmt.hgl_color = res->wnd_dis_text_color; 397 bg_color = res->wnd_face_color; 374 398 } else { 375 399 fmt.color = res->wnd_text_color; -
uspace/lib/ui/src/resource.c
r61643c8 r112f70a 68 68 gfx_color_t *wnd_face_color = NULL; 69 69 gfx_color_t *wnd_text_color = NULL; 70 gfx_color_t *wnd_dis_text_color = NULL; 70 71 gfx_color_t *wnd_text_hgl_color = NULL; 71 72 gfx_color_t *wnd_sel_text_color = NULL; … … 140 141 goto error; 141 142 143 rc = gfx_color_new_rgb_i16(0x9696, 0x9696, 0x9696, &wnd_dis_text_color); 144 if (rc != EOK) 145 goto error; 146 142 147 rc = gfx_color_new_rgb_i16(0, 0, 0, &wnd_text_hgl_color); 143 148 if (rc != EOK) … … 239 244 resource->wnd_face_color = wnd_face_color; 240 245 resource->wnd_text_color = wnd_text_color; 246 resource->wnd_dis_text_color = wnd_dis_text_color; 241 247 resource->wnd_text_hgl_color = wnd_text_hgl_color; 242 248 resource->wnd_sel_text_color = wnd_sel_text_color; … … 282 288 if (wnd_text_color != NULL) 283 289 gfx_color_delete(wnd_text_color); 290 if (wnd_dis_text_color != NULL) 291 gfx_color_delete(wnd_dis_text_color); 284 292 if (wnd_text_hgl_color != NULL) 285 293 gfx_color_delete(wnd_text_hgl_color); … … 350 358 gfx_color_t *wnd_face_color = NULL; 351 359 gfx_color_t *wnd_text_color = NULL; 360 gfx_color_t *wnd_dis_text_color = NULL; 352 361 gfx_color_t *wnd_text_hgl_color = NULL; 353 362 gfx_color_t *wnd_sel_text_color = NULL; … … 416 425 goto error; 417 426 427 rc = gfx_color_new_ega(0x78, &wnd_dis_text_color); 428 if (rc != EOK) 429 goto error; 430 418 431 rc = gfx_color_new_ega(0x74, &wnd_text_hgl_color); 419 432 if (rc != EOK) … … 506 519 resource->wnd_face_color = wnd_face_color; 507 520 resource->wnd_text_color = wnd_text_color; 521 resource->wnd_dis_text_color = wnd_dis_text_color; 508 522 resource->wnd_text_hgl_color = wnd_text_hgl_color; 509 523 resource->wnd_sel_text_color = wnd_sel_text_color; … … 549 563 if (wnd_text_color != NULL) 550 564 gfx_color_delete(wnd_text_color); 565 if (wnd_dis_text_color != NULL) 566 gfx_color_delete(wnd_dis_text_color); 551 567 if (wnd_text_hgl_color != NULL) 552 568 gfx_color_delete(wnd_text_hgl_color); … … 630 646 gfx_color_delete(resource->wnd_face_color); 631 647 gfx_color_delete(resource->wnd_text_color); 648 gfx_color_delete(resource->wnd_dis_text_color); 632 649 gfx_color_delete(resource->wnd_sel_text_color); 633 650 gfx_color_delete(resource->wnd_sel_text_bg_color);
Note:
See TracChangeset
for help on using the changeset viewer.