summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2022-10-16 03:44:43 -0400
committerWilliam Wilgus <me.theuser@yahoo.com>2022-10-16 04:30:22 -0400
commitb16bae6fe624d30631bf83290e204197ab136c12 (patch)
tree2a23b1b6eeda10698c10609bebc6150a08337d01
parent5e7c34f5b3e67fb5cd380be70e02d9e73651a686 (diff)
downloadrockbox-b16bae6fe624d30631bf83290e204197ab136c12.tar.gz
rockbox-b16bae6fe624d30631bf83290e204197ab136c12.zip
skin_display.c cleanup - No functional changes
Change-Id: Ib8ce47d9cf33ba6b02d799862f322e481a712dfb
-rw-r--r--apps/gui/skin_engine/skin_display.c132
1 files changed, 68 insertions, 64 deletions
diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c
index 4a3dcc2177..2285a20b59 100644
--- a/apps/gui/skin_engine/skin_display.c
+++ b/apps/gui/skin_engine/skin_display.c
@@ -499,78 +499,82 @@ void write_line(struct screen *display, struct align_pos *format_align,
499 499
500 /* CASE 1: left and centered string overlap */ 500 /* CASE 1: left and centered string overlap */
501 /* there is a left string, need to merge left and center */ 501 /* there is a left string, need to merge left and center */
502 if ((left_width != 0 && center_width != 0) && 502 if (center_width != 0)
503 (left_width + space_width > center_xpos)) { 503 {
504 /* replace the former separator '\0' of left and 504 if (left_width != 0 && left_width + space_width > center_xpos) {
505 center string with a space */ 505 /* replace the former separator '\0' of left and
506 *(--format_align->center) = ' '; 506 center string with a space */
507 /* calculate the new width and position of the merged string */ 507 *(--format_align->center) = ' ';
508 left_width = left_width + space_width + center_width; 508 /* calculate the new width and position of the merged string */
509 /* there is no centered string anymore */ 509 left_width = left_width + space_width + center_width;
510 center_width = 0; 510 /* there is no centered string anymore */
511 } 511 center_width = 0;
512 /* there is no left string, move center to left */ 512 }
513 if ((left_width == 0 && center_width != 0) && 513 /* there is no left string, move center to left */
514 (left_width > center_xpos)) { 514 else if (left_width == 0 && center_xpos < 0) {
515 /* move the center string to the left string */ 515 /* move the center string to the left string */
516 format_align->left = format_align->center; 516 format_align->left = format_align->center;
517 /* calculate the new width and position of the string */ 517 /* calculate the new width and position of the string */
518 left_width = center_width; 518 left_width = center_width;
519 /* there is no centered string anymore */ 519 /* there is no centered string anymore */
520 center_width = 0; 520 center_width = 0;
521 } 521 }
522 } /*(center_width != 0)*/
522 523
523 /* CASE 2: centered and right string overlap */ 524 /* CASE 2: centered and right string overlap */
524 /* there is a right string, need to merge center and right */ 525 /* there is a right string, need to merge center and right */
525 if ((center_width != 0 && right_width != 0) && 526 if (center_width != 0)
526 (center_xpos + center_width + space_width > right_xpos)) { 527 {
527 /* replace the former separator '\0' of center and 528 int center_left_x = center_xpos + center_width;
528 right string with a space */ 529 if (right_width != 0 && center_left_x + space_width > right_xpos) {
529 *(--format_align->right) = ' '; 530 /* replace the former separator '\0' of center and
530 /* move the center string to the right after merge */ 531 right string with a space */
531 format_align->right = format_align->center; 532 *(--format_align->right) = ' ';
532 /* calculate the new width and position of the merged string */ 533 /* move the center string to the right after merge */
533 right_width = center_width + space_width + right_width; 534 format_align->right = format_align->center;
534 right_xpos = (viewport_width - right_width); 535 /* calculate the new width and position of the merged string */
535 /* there is no centered string anymore */ 536 right_width = center_width + space_width + right_width;
536 center_width = 0; 537 right_xpos = (viewport_width - right_width);
537 } 538 /* there is no centered string anymore */
538 /* there is no right string, move center to right */ 539 center_width = 0;
539 if ((center_width != 0 && right_width == 0) && 540 }
540 (center_xpos + center_width > right_xpos)) { 541 /* there is no right string, move center to right */
541 /* move the center string to the right string */ 542 else if (right_width == 0 && center_left_x > right_xpos) {
542 format_align->right = format_align->center; 543 /* move the center string to the right string */
543 /* calculate the new width and position of the string */ 544 format_align->right = format_align->center;
544 right_width = center_width; 545 /* calculate the new width and position of the string */
545 right_xpos = (viewport_width - right_width); 546 right_width = center_width;
546 /* there is no centered string anymore */ 547 right_xpos = (viewport_width - right_width);
547 center_width = 0; 548 /* there is no centered string anymore */
548 } 549 center_width = 0;
550 }
551 } /*(center_width != 0)*/
549 552
550 /* CASE 3: left and right overlap 553 /* CASE 3: left and right overlap
551 There is no center string anymore, either there never 554 There is no center string anymore, either there never
552 was one or it has been merged in case 1 or 2 */ 555 was one or it has been merged in case 1 or 2 */
553 /* there is a left string, need to merge left and right */ 556 /* there is a left string, need to merge left and right */
554 if ((left_width != 0 && center_width == 0 && right_width != 0) && 557 if (center_width == 0 && right_width != 0)
555 (left_width + space_width > right_xpos)) { 558 {
556 /* replace the former separator '\0' of left and 559 if (left_width != 0 && left_width + space_width > right_xpos) {
557 right string with a space */ 560 /* replace the former separator '\0' of left and
558 *(--format_align->right) = ' '; 561 right string with a space */
559 /* calculate the new width and position of the string */ 562 *(--format_align->right) = ' ';
560 left_width = left_width + space_width + right_width; 563 /* calculate the new width and position of the string */
561 /* there is no right string anymore */ 564 left_width = left_width + space_width + right_width;
562 right_width = 0; 565 /* there is no right string anymore */
563 } 566 right_width = 0;
564 /* there is no left string, move right to left */ 567 }
565 if ((left_width == 0 && center_width == 0 && right_width != 0) && 568 /* there is no left string, move right to left */
566 (left_width > right_xpos)) { 569 else if (left_width == 0 && right_xpos < 0) {
567 /* move the right string to the left string */ 570 /* move the right string to the left string */
568 format_align->left = format_align->right; 571 format_align->left = format_align->right;
569 /* calculate the new width and position of the string */ 572 /* calculate the new width and position of the string */
570 left_width = right_width; 573 left_width = right_width;
571 /* there is no right string anymore */ 574 /* there is no right string anymore */
572 right_width = 0; 575 right_width = 0;
573 } 576 }
577 } /* (center_width == 0 && right_width != 0)*/
574 578
575 if (scroll && ((left_width > scroll_width) || 579 if (scroll && ((left_width > scroll_width) ||
576 (center_width > scroll_width) || 580 (center_width > scroll_width) ||