Methods

(static) fitTextRow(itemWidths, separatorWidth, budget, minCutWidth) → {object}

How much of a row of text items fits a width budget, and where to cut the rest.

ItemDetails' info rows are horizontal LayoutGroups of labels with a bullet divider between items, and a LayoutGroup never clips: whatever does not fit runs on past the budget. On the details screen that means into the logo, which sits at the right edge. This answers the fitting question ONCE, from widths, so the screen only has to apply the answer.

Pure on purpose: no node access, no m, no globals. The caller measures (a Label's boundingRect() is correct the instant its text is set, so this runs before the first paint) and the spec can drive every overflow shape without a device.

The cut keeps whole items in order and ends the row on the item that crosses the budget, narrowed to the space left so the Label can ellipsize it. Items after that one are dropped. If the space left is too small to read, that item is dropped too rather than rendered as a stub, EXCEPT the first item: a row is never emptied, so the first item always gets the whole budget.

ItemDetails: spacing + divider + spacing) or 0 when every kept item renders at its natural width }

Parameters:
NameTypeDescription
itemWidthsobject

array of each item's natural width, in row order

separatorWidthinteger

the full footprint BETWEEN two items (for

budgetinteger

the width the row may occupy

minCutWidthinteger

narrowest width worth showing a cut item at

Returns:

{ keep: items to keep, cutWidth: width for the last kept item,

Type: 
object

(static) textLineWidth(lineBottomY, textLeftX, logoBox, clearance, rightEdgeX) → {integer}

The width a line of text starting at textLeftX may use, given where the logo is.

A line that ends above the logo (with clearance to spare) runs to rightEdgeX; one beside the logo stops clearance short of the logo's left edge. With no logo on screen every line runs to rightEdgeX.

Parameters:
NameTypeDescription
lineBottomYinteger

the line's bottom edge, in screen space

textLeftXinteger

the line's left edge, in screen space

logoBoxobject

{ x, y } of the logo's top-left corner, or invalid for no logo

clearanceinteger

the gap kept between text and the logo, on both sides

rightEdgeXinteger

the right edge text never passes

Returns:

the line's width budget

Type: 
integer