Changeset f2416ec3 in mainline for uspace/lib/ui/src
- 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)
- Location:
- uspace/lib/ui/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/src/menu.c
r344f8b9 rf2416ec3 49 49 #include <ui/menuentry.h> 50 50 #include <ui/resource.h> 51 #include <ui/window.h> 51 52 #include "../private/menubar.h" 52 53 #include "../private/menu.h" … … 170 171 ui_menu_geom_t *geom) 171 172 { 173 ui_resource_t *res; 172 174 gfx_coord2_t edim; 173 175 gfx_coord_t frame_w; 174 176 gfx_coord_t frame_h; 175 177 176 if (menu->mbar->res->textmode) { 178 res = ui_window_get_res(menu->mbar->window); 179 180 if (res->textmode) { 177 181 frame_w = menu_frame_w_text; 178 182 frame_h = menu_frame_h_text; … … 242 246 params.rect = geom.outer_rect; 243 247 244 rc = ui_popup_create(menu->mbar->ui, ¶ms, &popup); 248 rc = ui_popup_create(menu->mbar->ui, menu->mbar->window, ¶ms, 249 &popup); 245 250 if (rc != EOK) 246 251 return rc; -
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; -
uspace/lib/ui/src/menuentry.c
r344f8b9 rf2416ec3 46 46 #include <ui/paint.h> 47 47 #include <ui/menuentry.h> 48 #include <ui/window.h> 48 49 #include "../private/menubar.h" 49 50 #include "../private/menuentry.h" … … 209 210 * resource instead. 210 211 */ 211 res = mentry->menu->mbar->res;212 res = ui_window_get_res(mentry->menu->mbar->window); 212 213 213 214 *caption_w = gfx_text_width(res->font, mentry->caption); … … 235 236 * resource instead. 236 237 */ 237 res = menu->mbar->res;238 res = ui_window_get_res(menu->mbar->window); 238 239 239 240 if (res->textmode) … … 274 275 * resource instead. 275 276 */ 276 res = mentry->menu->mbar->res;277 res = ui_window_get_res(mentry->menu->mbar->window); 277 278 278 279 if (res->textmode) { -
uspace/lib/ui/src/popup.c
r344f8b9 rf2416ec3 67 67 * 68 68 * @param ui User interface 69 * @param parent Parent window 69 70 * @param params Popup parameters 70 71 * @param rpopup Place to store pointer to new popup window 71 72 * @return EOK on success or an error code 72 73 */ 73 errno_t ui_popup_create(ui_t *ui, ui_ popup_params_t *params,74 ui_popup_ t **rpopup)74 errno_t ui_popup_create(ui_t *ui, ui_window_t *parent, 75 ui_popup_params_t *params, ui_popup_t **rpopup) 75 76 { 76 77 ui_popup_t *popup; … … 93 94 94 95 popup->ui = ui; 96 popup->parent = parent; 95 97 popup->window = window; 96 98
Note:
See TracChangeset
for help on using the changeset viewer.