Changeset 266ec54 in mainline for uspace/lib/ui/src/wdecor.c
- Timestamp:
- 2020-11-28T23:06:31Z (3 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- db3c6795
- Parents:
- 554a5f1
- git-author:
- Jiri Svoboda <jiri@…> (2020-11-27 22:30:28)
- git-committer:
- Jiri Svoboda <jiri@…> (2020-11-28 23:06:31)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/src/wdecor.c
r554a5f1 r266ec54 173 173 ui_wdecor_get_geom(wdecor, &geom); 174 174 175 rc = ui_paint_bevel(wdecor->res->gc, &rect, 176 wdecor->res->wnd_frame_hi_color, 177 wdecor->res->wnd_frame_sh_color, 1, &rect); 178 if (rc != EOK) 179 return rc; 180 181 rc = ui_paint_bevel(wdecor->res->gc, &rect, 182 wdecor->res->wnd_highlight_color, 183 wdecor->res->wnd_shadow_color, 1, &rect); 184 if (rc != EOK) 185 return rc; 186 187 rc = ui_paint_bevel(wdecor->res->gc, &rect, 188 wdecor->res->wnd_face_color, 189 wdecor->res->wnd_face_color, 2, &rect); 190 if (rc != EOK) 191 return rc; 192 193 trect = geom.title_bar_rect; 194 195 rc = ui_paint_bevel(wdecor->res->gc, &trect, 196 wdecor->res->wnd_shadow_color, 197 wdecor->res->wnd_highlight_color, 1, &trect); 198 if (rc != EOK) 199 return rc; 200 201 rc = gfx_set_color(wdecor->res->gc, wdecor->active ? 202 wdecor->res->tbar_act_bg_color : 203 wdecor->res->tbar_inact_bg_color); 204 if (rc != EOK) 205 return rc; 206 207 rc = gfx_fill_rect(wdecor->res->gc, &trect); 208 if (rc != EOK) 209 return rc; 210 211 gfx_text_fmt_init(&fmt); 212 fmt.halign = gfx_halign_center; 213 fmt.valign = gfx_valign_center; 214 215 pos.x = (trect.p0.x + trect.p1.x) / 2; 216 pos.y = (trect.p0.y + trect.p1.y) / 2; 217 218 rc = gfx_set_color(wdecor->res->gc, wdecor->active ? 219 wdecor->res->tbar_act_text_color : 220 wdecor->res->tbar_inact_text_color); 221 if (rc != EOK) 222 return rc; 223 224 rc = gfx_puttext(wdecor->res->font, &pos, &fmt, wdecor->caption); 225 if (rc != EOK) 226 return rc; 227 228 rc = ui_pbutton_paint(wdecor->btn_close); 229 if (rc != EOK) 230 return rc; 175 if ((wdecor->style & ui_wds_frame) != 0) { 176 rc = ui_paint_bevel(wdecor->res->gc, &rect, 177 wdecor->res->wnd_frame_hi_color, 178 wdecor->res->wnd_frame_sh_color, 1, &rect); 179 if (rc != EOK) 180 return rc; 181 182 rc = ui_paint_bevel(wdecor->res->gc, &rect, 183 wdecor->res->wnd_highlight_color, 184 wdecor->res->wnd_shadow_color, 1, &rect); 185 if (rc != EOK) 186 return rc; 187 188 rc = ui_paint_bevel(wdecor->res->gc, &rect, 189 wdecor->res->wnd_face_color, 190 wdecor->res->wnd_face_color, 2, &rect); 191 if (rc != EOK) 192 return rc; 193 } 194 195 if ((wdecor->style & ui_wds_titlebar) != 0) { 196 trect = geom.title_bar_rect; 197 198 rc = ui_paint_bevel(wdecor->res->gc, &trect, 199 wdecor->res->wnd_shadow_color, 200 wdecor->res->wnd_highlight_color, 1, &trect); 201 if (rc != EOK) 202 return rc; 203 204 rc = gfx_set_color(wdecor->res->gc, wdecor->active ? 205 wdecor->res->tbar_act_bg_color : 206 wdecor->res->tbar_inact_bg_color); 207 if (rc != EOK) 208 return rc; 209 210 rc = gfx_fill_rect(wdecor->res->gc, &trect); 211 if (rc != EOK) 212 return rc; 213 214 gfx_text_fmt_init(&fmt); 215 fmt.halign = gfx_halign_center; 216 fmt.valign = gfx_valign_center; 217 218 pos.x = (trect.p0.x + trect.p1.x) / 2; 219 pos.y = (trect.p0.y + trect.p1.y) / 2; 220 221 rc = gfx_set_color(wdecor->res->gc, wdecor->active ? 222 wdecor->res->tbar_act_text_color : 223 wdecor->res->tbar_inact_text_color); 224 if (rc != EOK) 225 return rc; 226 227 rc = gfx_puttext(wdecor->res->font, &pos, &fmt, wdecor->caption); 228 if (rc != EOK) 229 return rc; 230 231 if ((wdecor->style & ui_wds_close_btn) != 0) { 232 rc = ui_pbutton_paint(wdecor->btn_close); 233 if (rc != EOK) 234 return rc; 235 } 236 } 231 237 232 238 return EOK; … … 285 291 void ui_wdecor_get_geom(ui_wdecor_t *wdecor, ui_wdecor_geom_t *geom) 286 292 { 287 geom->interior_rect.p0.x = wdecor->rect.p0.x + 4; 288 geom->interior_rect.p0.y = wdecor->rect.p0.y + 4; 289 geom->interior_rect.p1.x = wdecor->rect.p1.x - 4; 290 geom->interior_rect.p1.y = wdecor->rect.p1.y - 4; 291 292 geom->title_bar_rect.p0 = geom->interior_rect.p0; 293 geom->title_bar_rect.p1.x = geom->interior_rect.p1.x; 294 geom->title_bar_rect.p1.y = geom->interior_rect.p0.y + 22; 295 296 geom->btn_close_rect.p0.x = geom->title_bar_rect.p1.x - 1 - 20; 297 geom->btn_close_rect.p0.y = geom->title_bar_rect.p0.y + 1; 298 geom->btn_close_rect.p1.x = geom->title_bar_rect.p1.x - 1; 299 geom->btn_close_rect.p1.y = geom->title_bar_rect.p0.y + 1 + 20; 300 301 geom->app_area_rect.p0.x = geom->interior_rect.p0.x; 302 geom->app_area_rect.p0.y = geom->title_bar_rect.p1.y; 303 geom->app_area_rect.p1 = geom->interior_rect.p1; 293 /* Does window have a frame? */ 294 if ((wdecor->style & ui_wds_frame) != 0) { 295 geom->interior_rect.p0.x = wdecor->rect.p0.x + 4; 296 geom->interior_rect.p0.y = wdecor->rect.p0.y + 4; 297 geom->interior_rect.p1.x = wdecor->rect.p1.x - 4; 298 geom->interior_rect.p1.y = wdecor->rect.p1.y - 4; 299 } else { 300 geom->interior_rect = wdecor->rect; 301 } 302 303 /* Does window have a title bar? */ 304 if ((wdecor->style & ui_wds_titlebar) != 0) { 305 geom->title_bar_rect.p0 = geom->interior_rect.p0; 306 geom->title_bar_rect.p1.x = geom->interior_rect.p1.x; 307 geom->title_bar_rect.p1.y = geom->interior_rect.p0.y + 22; 308 309 geom->app_area_rect.p0.x = geom->interior_rect.p0.x; 310 geom->app_area_rect.p0.y = geom->title_bar_rect.p1.y; 311 geom->app_area_rect.p1 = geom->interior_rect.p1; 312 } else { 313 geom->title_bar_rect.p0.x = 0; 314 geom->title_bar_rect.p0.y = 0; 315 geom->title_bar_rect.p1.x = 0; 316 geom->title_bar_rect.p1.y = 0; 317 318 geom->app_area_rect = geom->interior_rect; 319 } 320 321 /* Does window have a close button? */ 322 if ((wdecor->style & ui_wds_close_btn) != 0) { 323 geom->btn_close_rect.p0.x = geom->title_bar_rect.p1.x - 1 - 20; 324 geom->btn_close_rect.p0.y = geom->title_bar_rect.p0.y + 1; 325 geom->btn_close_rect.p1.x = geom->title_bar_rect.p1.x - 1; 326 geom->btn_close_rect.p1.y = geom->title_bar_rect.p0.y + 1 + 20; 327 } else { 328 geom->btn_close_rect.p0.x = 0; 329 geom->btn_close_rect.p0.y = 0; 330 geom->btn_close_rect.p1.x = 0; 331 geom->btn_close_rect.p1.y = 0; 332 } 304 333 } 305 334 … … 310 339 * and its decoration. 311 340 * 341 * @param style Decoration style 312 342 * @param app Application area rectangle 313 343 * @param rect Place to store (outer) window decoration rectangle 314 344 */ 315 void ui_wdecor_rect_from_app(gfx_rect_t *app, gfx_rect_t *rect) 316 { 317 rect->p0.x = app->p0.x - 4; 318 rect->p0.y = app->p0.y - 22 - 4; 319 rect->p1.x = app->p1.x + 4; 320 rect->p1.y = app->p1.y + 4; 345 void ui_wdecor_rect_from_app(ui_wdecor_style_t style, gfx_rect_t *app, 346 gfx_rect_t *rect) 347 { 348 *rect = *app; 349 350 if ((style & ui_wds_frame) != 0) { 351 rect->p0.x -= wdecor_edge_w; 352 rect->p0.y -= wdecor_edge_h; 353 rect->p1.x += wdecor_edge_w; 354 rect->p1.y += wdecor_edge_h; 355 } 356 357 if ((style & ui_wds_titlebar) != 0) 358 rect->p0.y -= 22; 321 359 } 322 360 … … 471 509 ui_wdecor_get_geom(wdecor, &geom); 472 510 473 claim = ui_pbutton_pos_event(wdecor->btn_close, event); 474 if (claim == ui_claimed) 475 return; 511 if ((wdecor->style & ui_wds_close_btn) != 0) { 512 claim = ui_pbutton_pos_event(wdecor->btn_close, event); 513 if (claim == ui_claimed) 514 return; 515 } 476 516 477 517 ui_wdecor_frame_pos_event(wdecor, event); 478 518 479 if (event->type == POS_PRESS && 480 gfx_pix_inside_rect(&pos, &geom.title_bar_rect)) 481 ui_wdecor_move(wdecor, &pos); 519 if ((wdecor->style & ui_wds_titlebar) != 0) { 520 if (event->type == POS_PRESS && 521 gfx_pix_inside_rect(&pos, &geom.title_bar_rect)) 522 ui_wdecor_move(wdecor, &pos); 523 } 482 524 } 483 525
Note:
See TracChangeset
for help on using the changeset viewer.