Changeset f2416ec3 in mainline for uspace/lib/ui/src/menubar.c
- Timestamp:
- 2021-05-26T07:40:59Z (4 years ago)
- Children:
- 6baab83
- Parents:
- 344f8b9
- git-author:
- Jiri Svoboda <jiri@…> (2021-05-25 18:40:50)
- git-committer:
- Jiri Svoboda <jiri@…> (2021-05-26 07:40:59)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/src/menubar.c
r344f8b9 rf2416ec3 47 47 #include <ui/menu.h> 48 48 #include <ui/menubar.h> 49 #include <ui/window.h> 49 50 #include "../private/menubar.h" 50 51 #include "../private/resource.h" … … 73 74 * 74 75 * @param ui UI 75 * @param res UI resource76 * @param window Window that will contain the menu bar 76 77 * @param rmbar Place to store pointer to new menu bar 77 78 * @return EOK on success, ENOMEM if out of memory 78 79 */ 79 errno_t ui_menu_bar_create(ui_t *ui, ui_resource_t *res, 80 ui_menu_bar_t **rmbar) 80 errno_t ui_menu_bar_create(ui_t *ui, ui_window_t *window, ui_menu_bar_t **rmbar) 81 81 { 82 82 ui_menu_bar_t *mbar; … … 94 94 95 95 mbar->ui = ui; 96 mbar-> res = res;96 mbar->window = window; 97 97 list_initialize(&mbar->menus); 98 98 *rmbar = mbar; … … 149 149 errno_t ui_menu_bar_paint(ui_menu_bar_t *mbar) 150 150 { 151 ui_resource_t *res; 151 152 gfx_text_fmt_t fmt; 152 153 gfx_coord2_t pos; … … 161 162 errno_t rc; 162 163 164 res = ui_window_get_res(mbar->window); 165 163 166 /* Paint menu bar background */ 164 167 165 rc = gfx_set_color( mbar->res->gc, mbar->res->wnd_face_color);168 rc = gfx_set_color(res->gc, res->wnd_face_color); 166 169 if (rc != EOK) 167 170 goto error; 168 171 169 rc = gfx_fill_rect( mbar->res->gc, &mbar->rect);172 rc = gfx_fill_rect(res->gc, &mbar->rect); 170 173 if (rc != EOK) 171 174 goto error; 172 175 173 if ( mbar->res->textmode) {176 if (res->textmode) { 174 177 hpad = menubar_hpad_text; 175 178 vpad = menubar_vpad_text; … … 188 191 while (menu != NULL) { 189 192 caption = ui_menu_caption(menu); 190 width = gfx_text_width( mbar->res->font, caption) + 2 * hpad;193 width = gfx_text_width(res->font, caption) + 2 * hpad; 191 194 tpos.x = pos.x + hpad; 192 195 tpos.y = pos.y + vpad; … … 197 200 198 201 if (menu == mbar->selected) { 199 fmt.color = mbar->res->wnd_sel_text_color;200 bg_color = mbar->res->wnd_sel_text_bg_color;202 fmt.color = res->wnd_sel_text_color; 203 bg_color = res->wnd_sel_text_bg_color; 201 204 } else { 202 fmt.color = mbar->res->wnd_text_color;203 bg_color = mbar->res->wnd_face_color;205 fmt.color = res->wnd_text_color; 206 bg_color = res->wnd_face_color; 204 207 } 205 208 206 rc = gfx_set_color( mbar->res->gc, bg_color);209 rc = gfx_set_color(res->gc, bg_color); 207 210 if (rc != EOK) 208 211 goto error; 209 212 210 rc = gfx_fill_rect( mbar->res->gc, &rect);213 rc = gfx_fill_rect(res->gc, &rect); 211 214 if (rc != EOK) 212 215 goto error; 213 216 214 rc = gfx_puttext( mbar->res->font, &tpos, &fmt, caption);217 rc = gfx_puttext(res->font, &tpos, &fmt, caption); 215 218 if (rc != EOK) 216 219 goto error; … … 220 223 } 221 224 222 rc = gfx_update( mbar->res->gc);225 rc = gfx_update(res->gc); 223 226 if (rc != EOK) 224 227 goto error; … … 269 272 ui_evclaim_t ui_menu_bar_pos_event(ui_menu_bar_t *mbar, pos_event_t *event) 270 273 { 274 ui_resource_t *res; 271 275 gfx_coord2_t pos; 272 276 gfx_rect_t rect; … … 277 281 gfx_coord2_t ppos; 278 282 283 res = ui_window_get_res(mbar->window); 284 279 285 ppos.x = event->hpos; 280 286 ppos.y = event->vpos; 281 287 282 if ( mbar->res->textmode) {288 if (res->textmode) { 283 289 hpad = menubar_hpad_text; 284 290 } else { … … 291 297 while (menu != NULL) { 292 298 caption = ui_menu_caption(menu); 293 width = gfx_text_width( mbar->res->font, caption) + 2 * hpad;299 width = gfx_text_width(res->font, caption) + 2 * hpad; 294 300 295 301 rect.p0 = pos;
Note:
See TracChangeset
for help on using the changeset viewer.