Changeset a130983 in mainline
- Timestamp:
- 2022-11-17T19:56:07Z (22 months ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 901b302
- Parents:
- 5d62130
- Location:
- uspace
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/barber/barber.c
r5d62130 ra130983 361 361 362 362 ui_wnd_params_init(¶ms); 363 params.caption = " ";363 params.caption = "Barber Pole"; 364 364 params.placement = ui_wnd_place_bottom_right; 365 365 /* -
uspace/lib/gfxfont/include/types/gfx/text.h
r5d62130 ra130983 73 73 /** Horizontal alignment */ 74 74 gfx_halign_t halign; 75 /** Justification width (for gfx_halign_justify)*/76 gfx_coord_t justify_width;75 /** Width available for the text */ 76 gfx_coord_t width; 77 77 /** Vertical alignment */ 78 78 gfx_valign_t valign; 79 /** Abbreviate the text with ellipsis if it does not fit @c width */ 80 bool abbreviate; 79 81 /** Underline */ 80 82 bool underline; -
uspace/lib/gfxfont/src/text.c
r5d62130 ra130983 183 183 /* Adjust position for horizontal alignment */ 184 184 if (fmt->halign != gfx_halign_left) { 185 /* Compute text width */ 185 186 width = gfx_text_width(fmt->font, str); 187 if (fmt->abbreviate && width > fmt->width) 188 width = fmt->width; 189 186 190 switch (fmt->halign) { 187 191 case gfx_halign_center: … … 233 237 gfx_coord2_t spos; 234 238 gfx_rect_t rect; 239 gfx_coord_t width; 240 gfx_coord_t rmargin; 241 bool ellipsis; 235 242 errno_t rc; 236 243 … … 244 251 if (rc != EOK) 245 252 return rc; 253 254 width = gfx_text_width(fmt->font, str); 255 256 if (fmt->abbreviate && width > fmt->width) { 257 /* Need to append ellipsis */ 258 ellipsis = true; 259 rmargin = spos.x + fmt->width - gfx_text_width(fmt->font, "..."); 260 } else { 261 ellipsis = false; 262 rmargin = spos.x + width; 263 } 246 264 247 265 cpos = spos; … … 256 274 gfx_glyph_get_metrics(glyph, &gmetrics); 257 275 276 /* Stop if we would run over the right margin */ 277 if (fmt->abbreviate && cpos.x + gmetrics.advance > rmargin) 278 break; 279 258 280 rc = gfx_glyph_render(glyph, &cpos); 259 281 if (rc != EOK) … … 274 296 275 297 rc = gfx_fill_rect(fmt->font->typeface->gc, &rect); 298 if (rc != EOK) 299 return rc; 300 } 301 302 /* Render ellipsis, if required */ 303 if (ellipsis) { 304 rc = gfx_font_search_glyph(fmt->font, ".", &glyph, &stradv); 305 if (rc != EOK) 306 return EOK; 307 308 gfx_glyph_get_metrics(glyph, &gmetrics); 309 310 rc = gfx_glyph_render(glyph, &cpos); 311 if (rc != EOK) 312 return rc; 313 314 cpos.x += gmetrics.advance; 315 316 rc = gfx_glyph_render(glyph, &cpos); 317 if (rc != EOK) 318 return rc; 319 320 cpos.x += gmetrics.advance; 321 322 rc = gfx_glyph_render(glyph, &cpos); 276 323 if (rc != EOK) 277 324 return rc; … … 376 423 tfmt.valign = gfx_valign_baseline; 377 424 425 /* Remaining available width */ 426 tfmt.width = fmt->width - (cpos->x - spos.x); 427 378 428 *cfmt = tfmt; 379 429 } … … 390 440 { 391 441 gfx_coord2_t spos; 442 gfx_coord_t width; 392 443 393 444 gfx_text_start_pos(pos, fmt, str, &spos); 445 width = gfx_text_width(fmt->font, str); 446 if (fmt->abbreviate && width > fmt->width) 447 width = fmt->width; 394 448 395 449 rect->p0.x = spos.x; 396 450 rect->p0.y = spos.y - fmt->font->metrics.ascent; 397 rect->p1.x = spos.x + gfx_text_width(fmt->font, str);451 rect->p1.x = spos.x + width; 398 452 rect->p1.y = spos.y + fmt->font->metrics.descent + 1; 399 453 } -
uspace/lib/ui/include/types/ui/paint.h
r5d62130 ra130983 94 94 /** Horizontal alignment */ 95 95 gfx_halign_t halign; 96 /** Justification width (for gfx_halign_justify)*/97 gfx_coord_t justify_width;96 /** Width available for the text */ 97 gfx_coord_t width; 98 98 /** Vertical alignment */ 99 99 gfx_valign_t valign; -
uspace/lib/ui/private/wdecor.h
r5d62130 ra130983 80 80 /** Title bar rectangle */ 81 81 gfx_rect_t title_bar_rect; 82 /** Window caption rectangle */ 83 gfx_rect_t caption_rect; 82 84 /** Maximize button rectangle */ 83 85 gfx_rect_t btn_max_rect; -
uspace/lib/ui/src/paint.c
r5d62130 ra130983 922 922 tfmt.color = fmt->color; 923 923 tfmt.halign = fmt->halign; 924 tfmt. justify_width = fmt->justify_width;924 tfmt.width = fmt->width; 925 925 tfmt.valign = fmt->valign; 926 926 tfmt.underline = false; -
uspace/lib/ui/src/wdecor.c
r5d62130 ra130983 88 88 /** Window frame width in text mode */ 89 89 wdecor_frame_w_text = 1, 90 /** Window caption horizontal margin */ 91 wdecor_cap_hmargin = 4, 92 /** Window caption horizontal margin in text mode */ 93 wdecor_cap_hmargin_text = 1, 90 94 /** Close button cross leg length */ 91 95 wdecor_close_cross_n = 5, … … 326 330 fmt.halign = gfx_halign_center; 327 331 fmt.valign = gfx_valign_center; 328 329 pos.x = (trect.p0.x + trect.p1.x) / 2; 330 pos.y = (trect.p0.y + trect.p1.y) / 2; 332 fmt.abbreviate = true; 333 fmt.width = geom.caption_rect.p1.x - 334 geom.caption_rect.p0.x; 335 336 pos.x = (geom.caption_rect.p0.x + geom.caption_rect.p1.x) / 2; 337 pos.y = (geom.caption_rect.p0.y + geom.caption_rect.p1.y) / 2; 331 338 332 339 if (wdecor->res->textmode) { … … 450 457 gfx_coord_t btn_x; 451 458 gfx_coord_t btn_y; 459 gfx_coord_t cap_hmargin; 452 460 453 461 /* Does window have a frame? */ … … 529 537 geom->btn_max_rect.p1.x = btn_x; 530 538 geom->btn_max_rect.p1.y = btn_y + 20; 539 540 btn_x -= 20; 531 541 } else { 532 542 geom->btn_max_rect.p0.x = btn_x - 3; … … 534 544 geom->btn_max_rect.p1.x = btn_x; 535 545 geom->btn_max_rect.p1.y = btn_y + 1; 546 547 btn_x -= 3; 536 548 } 537 549 } else { … … 541 553 geom->btn_max_rect.p1.y = 0; 542 554 } 555 556 if (wdecor->res->textmode == false) 557 cap_hmargin = wdecor_cap_hmargin; 558 else 559 cap_hmargin = wdecor_cap_hmargin_text; 560 561 geom->caption_rect.p0.x = geom->title_bar_rect.p0.x + 562 cap_hmargin; 563 geom->caption_rect.p0.y = geom->title_bar_rect.p0.y; 564 geom->caption_rect.p1.x = btn_x - cap_hmargin; 565 geom->caption_rect.p1.y = geom->title_bar_rect.p1.y; 543 566 } 544 567
Note:
See TracChangeset
for help on using the changeset viewer.