class_name SheetDetailPanel extends PanelContainer ## The side panel that opens when you click a list entry's ⓘ or a chip: the ## box's name as a caps label, the entry's name, its other columns as small ## tags, and its full details text (editable). An in-app panel, not a window. const WIDTH := 340.0 var ed: SheetEditor var box_id := "" var index := -1 var _col: VBoxContainer func setup(p_editor: SheetEditor) -> void: ed = p_editor custom_minimum_size.x = WIDTH var sb := Style.box(Style.CARD_SOFT, 0, [18, 18, 18, 18]) sb.border_color = Style.DASH sb.border_width_left = 1 add_theme_stylebox_override("panel", sb) _col = VBoxContainer.new() _col.add_theme_constant_override("separation", 12) add_child(_col) visible = false func open(p_box_id: String, p_index: int) -> void: box_id = p_box_id index = p_index rebuild() func close() -> void: box_id = "" index = -1 visible = false func rebuild() -> void: for c in _col.get_children(): _col.remove_child(c) c.queue_free() var box := ed.doc.find_box(box_id) if ed.doc and box_id != "" else null var rows: Array = box.value if box and box.value is Array else [] if box == null or index < 0 or index >= rows.size(): visible = false return visible = true var entry: Dictionary = rows[index] var cols := SheetFieldsList.columns(box) var head := HBoxContainer.new() var names := VBoxContainer.new() names.size_flags_horizontal = SIZE_EXPAND_FILL names.add_theme_constant_override("separation", 2) names.add_child(Style.make_label(box.title.to_upper(), Style.caps(), 11, Style.TRIM)) var title := Style.make_label(str(entry.get(str(cols[0]["name"]), "")), Style.display(), 26, Style.INK) title.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART names.add_child(title) head.add_child(names) var close_button := ModalCard.make_button("×", "plain") close_button.name = "Close" close_button.tooltip_text = "Close the details" close_button.pressed.connect(close) head.add_child(close_button) _col.add_child(head) var tags := HFlowContainer.new() tags.add_theme_constant_override("h_separation", 6) for k in range(1, cols.size()): var key := str(cols[k]["name"]) if str(entry.get(key, "")) != "": tags.add_child(_tag("%s %s" % [key, SheetValues.show(entry[key])])) if tags.get_child_count() > 0: _col.add_child(tags) _col.add_child(Style.make_label("Details", Style.body_bold(), 14, Style.INK)) var text := TextEdit.new() text.name = "DetailsText" text.text = str(entry.get("details", "")) text.placeholder_text = "What it does, in full. Hovering the entry shows the start of this." text.wrap_mode = TextEdit.LINE_WRAPPING_BOUNDARY text.custom_minimum_size.y = 220 text.size_flags_vertical = SIZE_EXPAND_FILL ModalCard.style_text_edit(text) var key_box := box var at := index text.text_changed.connect(func() -> void: var next := SheetFieldsList.entries(key_box) if at < next.size(): next[at]["details"] = text.text ed.edit_value(key_box, next, "")) _col.add_child(text) func _tag(text: String) -> PanelContainer: var p := PanelContainer.new() p.add_theme_stylebox_override("panel", Style.box(Style.VALUE_BG, 5, [8, 2, 8, 2])) p.add_child(Style.make_label(text, Style.body_bold(), 13, Style.VALUE_INK)) return p