Changeset 172188a in mainline for uspace/lib/ui/src/wdecor.c
- Timestamp:
- 2020-10-21T21:26:56Z (4 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a2f173b
- Parents:
- 20d2c6c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/src/wdecor.c
r20d2c6c r172188a 126 126 void ui_wdecor_set_rect(ui_wdecor_t *wdecor, gfx_rect_t *rect) 127 127 { 128 gfx_rect_t crect;128 ui_wdecor_geom_t geom; 129 129 130 130 wdecor->rect = *rect; 131 crect.p0.x = rect->p1.x - 5 - 20; 132 crect.p0.y = rect->p0.y + 5; 133 crect.p1.x = rect->p1.x - 5; 134 crect.p1.y = rect->p0.y + 5 + 20; 135 136 ui_pbutton_set_rect(wdecor->btn_close, &crect); 131 132 ui_wdecor_get_geom(wdecor, &geom); 133 ui_pbutton_set_rect(wdecor->btn_close, &geom.btn_close_rect); 137 134 } 138 135 … … 161 158 gfx_text_fmt_t fmt; 162 159 gfx_coord2_t pos; 160 ui_wdecor_geom_t geom; 163 161 164 162 rect = wdecor->rect; 163 ui_wdecor_get_geom(wdecor, &geom); 165 164 166 165 rc = ui_paint_bevel(wdecor->res->gc, &rect, … … 182 181 return rc; 183 182 184 trect.p0 = rect.p0; 185 trect.p1.x = rect.p1.x; 186 trect.p1.y = rect.p0.y + 22; 183 trect = geom.title_bar_rect; 187 184 188 185 rc = ui_paint_bevel(wdecor->res->gc, &trect, … … 248 245 } 249 246 247 /** Get window decoration geometry. 248 * 249 * @param wdecor Window decoration 250 * @param geom Structure to fill in with computed geometry 251 */ 252 void ui_wdecor_get_geom(ui_wdecor_t *wdecor, ui_wdecor_geom_t *geom) 253 { 254 geom->interior_rect.p0.x = wdecor->rect.p0.x + 4; 255 geom->interior_rect.p0.y = wdecor->rect.p0.y + 4; 256 geom->interior_rect.p1.x = wdecor->rect.p1.x - 4; 257 geom->interior_rect.p1.y = wdecor->rect.p1.y - 4; 258 259 geom->title_bar_rect.p0 = geom->interior_rect.p0; 260 geom->title_bar_rect.p1.x = geom->interior_rect.p1.x; 261 geom->title_bar_rect.p1.y = geom->interior_rect.p0.y + 22; 262 263 geom->btn_close_rect.p0.x = geom->title_bar_rect.p1.x - 1 - 20; 264 geom->btn_close_rect.p0.y = geom->title_bar_rect.p0.y + 1; 265 geom->btn_close_rect.p1.x = geom->title_bar_rect.p1.x - 1; 266 geom->btn_close_rect.p1.y = geom->title_bar_rect.p0.y + 1 + 20; 267 268 geom->app_area_rect.p0.x = geom->interior_rect.p0.x; 269 geom->app_area_rect.p0.y = geom->title_bar_rect.p1.y; 270 geom->app_area_rect.p1 = geom->interior_rect.p1; 271 } 272 250 273 /** Handle window decoration position event. 251 274 * … … 255 278 void ui_wdecor_pos_event(ui_wdecor_t *wdecor, pos_event_t *event) 256 279 { 257 gfx_rect_t trect;258 gfx_rect_t cbrect;259 280 gfx_coord2_t pos; 260 261 trect.p0.x = wdecor->rect.p0.x + 3; 262 trect.p0.y = wdecor->rect.p0.y + 3; 263 trect.p1.x = wdecor->rect.p1.x - 3; 264 trect.p1.y = trect.p0.y + 22; 265 266 cbrect.p0.x = wdecor->rect.p1.x - 5 - 20; 267 cbrect.p0.y = wdecor->rect.p0.y + 5; 268 cbrect.p1.x = wdecor->rect.p1.x - 5; 269 cbrect.p1.y = wdecor->rect.p0.y + 5 + 20; 281 ui_wdecor_geom_t geom; 270 282 271 283 pos.x = event->hpos; 272 284 pos.y = event->vpos; 273 285 274 if (gfx_pix_inside_rect(&pos, &cbrect)) { 286 ui_wdecor_get_geom(wdecor, &geom); 287 288 if (gfx_pix_inside_rect(&pos, &geom.btn_close_rect)) { 275 289 ui_pbutton_pos_event(wdecor->btn_close, event); 276 290 return; 277 291 } 278 292 279 if (event->type == POS_PRESS && gfx_pix_inside_rect(&pos, &trect)) 293 if (event->type == POS_PRESS && 294 gfx_pix_inside_rect(&pos, &geom.title_bar_rect)) 280 295 ui_wdecor_move(wdecor, &pos); 281 296 }
Note:
See TracChangeset
for help on using the changeset viewer.