Changeset 0563982 in mainline
- Timestamp:
- 2021-04-01T21:31:24Z (4 years ago)
- Children:
- 2e1dbf7d
- Parents:
- 379cd75f
- Location:
- uspace/lib/ui
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/private/menu.h
r379cd75f r0563982 56 56 /** Selected menu entry or @c NULL */ 57 57 struct ui_menu_entry *selected; 58 /** Maximum entry width */ 59 gfx_coord_t max_w; 60 /** Total entry height */ 61 gfx_coord_t total_h; 58 62 /** Menu entries (ui_menu_entry_t) */ 59 63 list_t entries; -
uspace/lib/ui/src/menu.c
r379cd75f r0563982 163 163 ui_menu_geom_t *geom) 164 164 { 165 ui_menu_entry_t *mentry;166 165 gfx_coord2_t edim; 167 166 gfx_coord_t frame_w; 168 167 gfx_coord_t frame_h; 169 gfx_coord_t w;170 gfx_coord_t h;171 168 172 169 if (menu->mbar->res->textmode) { … … 178 175 } 179 176 180 edim.x = 0; 181 edim.y = 0; 182 183 mentry = ui_menu_entry_first(menu); 184 while (mentry != NULL) { 185 w = ui_menu_entry_width(mentry); 186 h = ui_menu_entry_height(mentry); 187 188 if (w > edim.x) 189 edim.x = w; 190 edim.y += h; 191 192 mentry = ui_menu_entry_next(mentry); 193 } 177 edim.x = menu->max_w; 178 edim.y = menu->total_h; 194 179 195 180 geom->outer_rect.p0 = *spos; -
uspace/lib/ui/src/menuentry.c
r379cd75f r0563982 69 69 { 70 70 ui_menu_entry_t *mentry; 71 gfx_coord_t width; 71 72 72 73 mentry = calloc(1, sizeof(ui_menu_entry_t)); … … 82 83 mentry->menu = menu; 83 84 list_append(&mentry->lentries, &menu->entries); 85 86 /* Update accumulated menu entry dimensions */ 87 width = ui_menu_entry_width(mentry); 88 if (width > menu->max_w) 89 menu->max_w = width; 90 menu->total_h += ui_menu_entry_height(mentry); 84 91 85 92 *rmentry = mentry; … … 372 379 gfx_coord_t hpad; 373 380 gfx_coord_t vpad; 374 const char *caption;375 381 gfx_coord_t width; 376 382 … … 385 391 } 386 392 387 caption = mentry->caption; 388 width = gfx_text_width(res->font, caption) + 2 * hpad; 393 width = mentry->menu->max_w; 389 394 geom->text_pos.x = pos->x + hpad; 390 395 geom->text_pos.y = pos->y + vpad;
Note:
See TracChangeset
for help on using the changeset viewer.