|
46 | 46 | ' Date added label - positioned at bottom right |
47 | 47 | m.dateCreatedLabel = m.top.findNode("dateCreatedLabel") |
48 | 48 |
|
| 49 | + ' Re-anchor date label (and logo, if loaded) after the button group layout settles. |
| 50 | + ' setDateAdded() runs before setupButtons(), so its boundingRect() call would see an |
| 51 | + ' empty group. This observer fires after the render thread computes the real height. |
| 52 | + m.buttonGrp.observeField("renderTracking", "onButtonGrpRendered") |
| 53 | + |
49 | 54 | ' Gradient overlay - dynamically sized to span from itemDetails to extrasSlider |
50 | 55 | m.itemTextGradient = m.top.findNode("itemTextGradient") |
51 | 56 | m.itemDetails = m.top.findNode("itemDetails") |
|
1762 | 1767 | dateAdded.toLocalTime() |
1763 | 1768 | m.dateCreatedLabel.text = tr("Added") + " " + dateAdded.AsDateString("short-month-no-weekday") + " " + formatTime(dateAdded) |
1764 | 1769 |
|
1765 | | - ' Position at bottom right: screen is 1920x1080, with 96px padding |
| 1770 | + ' Set X position only — Y is deferred to anchorDateLabel() which runs after the |
| 1771 | + ' button group layout settles (via renderTracking observer). |
| 1772 | + m.dateCreatedLabel.translation = [1920 - 96 - 450, 0] |
| 1773 | + m.dateCreatedLabel.visible = true |
| 1774 | +end sub |
| 1775 | + |
| 1776 | +' anchorDateLabel: Derive the date label's Y position from the button group's rendered rect. |
| 1777 | +' Returns dateLabelY so callers (e.g. logo positioning) can use it without duplicating the math. |
| 1778 | +' Safe to call multiple times — idempotent. |
| 1779 | +' @return {float} dateLabelY — the Y coordinate used for the date label |
| 1780 | +function anchorDateLabel() as float |
1766 | 1781 | buttonRect = m.buttonGrp.boundingRect() |
1767 | 1782 | buttonBottom = buttonRect.y + buttonRect.height |
1768 | | - m.dateCreatedLabel.translation = [1920 - 96 - 450, buttonBottom - 30] |
1769 | | - m.dateCreatedLabel.visible = true |
| 1783 | + dateLabelY = buttonBottom - 30 |
| 1784 | + |
| 1785 | + if isValid(m.dateCreatedLabel) and m.dateCreatedLabel.visible |
| 1786 | + m.dateCreatedLabel.translation = [m.dateCreatedLabel.translation[0], dateLabelY] |
| 1787 | + end if |
| 1788 | + |
| 1789 | + return dateLabelY |
| 1790 | +end function |
| 1791 | + |
| 1792 | +' onButtonGrpRendered: Fires after the render thread settles the button group layout. |
| 1793 | +' Re-anchors the date label and repositions the logo (if already loaded) so both |
| 1794 | +' elements reflect the true button group height. |
| 1795 | +sub onButtonGrpRendered() |
| 1796 | + if m.buttonGrp.renderTracking = "none" then return |
| 1797 | + |
| 1798 | + dateLabelY = anchorDateLabel() |
| 1799 | + |
| 1800 | + ' If the logo is already loaded and visible, reposition it relative to the new dateLabelY. |
| 1801 | + if isValid(m.itemLogo) and m.itemLogo.visible |
| 1802 | + logoY = dateLabelY - m.itemLogo.height - 18 |
| 1803 | + m.itemLogo.translation = [m.itemLogo.translation[0], logoY] |
| 1804 | + end if |
1770 | 1805 | end sub |
1771 | 1806 |
|
1772 | 1807 | ' onLogoLoadStatusChanged: Position logo to the right, with its bottom just above the date label. |
|
1817 | 1852 | rightEdge = 1920 * 0.95 |
1818 | 1853 | logoX = rightEdge - displayWidth |
1819 | 1854 |
|
1820 | | - if isValid(m.dateCreatedLabel) and m.dateCreatedLabel.visible |
1821 | | - ' Anchor logo bottom 18px above the date label |
1822 | | - dateLabelY = m.dateCreatedLabel.translation[1] |
1823 | | - else |
1824 | | - ' Date label hidden — use the same position it would occupy |
1825 | | - buttonRect = m.buttonGrp.boundingRect() |
1826 | | - buttonBottom = buttonRect.y + buttonRect.height |
1827 | | - dateLabelY = buttonBottom - 30 |
1828 | | - end if |
| 1855 | + dateLabelY = anchorDateLabel() |
1829 | 1856 | logoY = dateLabelY - displayHeight - 18 |
1830 | 1857 |
|
1831 | 1858 | m.itemLogo.translation = [logoX, logoY] |
|
0 commit comments