class_name ListRow extends PanelContainer ## One item in a list of names, such as the inspiration list or a sync result column. ## ## Every row has its own background, alternating between the theme's [code]ListRowEven[/code] ## and [code]ListRowOdd[/code] styles, so it is clear where an item starts even when its ## text wraps over several lines. ## The label showing the item's text. var label: Label ## The item's text. var text: String: get: return label.text ## Creates the row for item number [param row] (counting from 0) in a list. The text uses ## the theme's [param label_style], e.g. [code]TextLarge[/code]. static func create( item_text: String, row: int, label_style: StringName, alignment: HorizontalAlignment = HORIZONTAL_ALIGNMENT_LEFT, ) -> ListRow: var list_row: ListRow = ListRow.new() list_row.theme_type_variation = &"ListRowOdd" if row % 2 != 0 else &"ListRowEven" list_row.label = Label.new() list_row.label.theme_type_variation = label_style list_row.label.text = item_text list_row.label.horizontal_alignment = alignment list_row.label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART list_row.add_child(list_row.label) return list_row