FoldableContainer

继承: Container < Control < CanvasItem < Node < Object

能够展开、折叠的容器。

描述

A container that can be expanded/collapsed, with a title that can be filled with controls, such as buttons. This is also called an accordion.

The title can be positioned at the top or bottom of the container. The container can be expanded or collapsed by clicking the title or by pressing ui_accept when focused. Child control nodes are hidden when the container is collapsed. Ignores non-control children.

A FoldableContainer can be grouped with other FoldableContainers so that only one of them can be opened at a time; see foldable_group and FoldableGroup.

属性

FocusMode

focus_mode

2 (overrides Control)

FoldableGroup

foldable_group

bool

folded

false

String

language

""

MouseFilter

mouse_filter

0 (overrides Control)

String

title

""

HorizontalAlignment

title_alignment

0

TitlePosition

title_position

0

TextDirection

title_text_direction

0

OverrunBehavior

title_text_overrun_behavior

0

方法

void

add_title_bar_control(control: Control)

void

expand()

void

fold()

void

remove_title_bar_control(control: Control)

主题属性

Color

collapsed_font_color

Color(1, 1, 1, 1)

Color

font_color

Color(0.875, 0.875, 0.875, 1)

Color

font_outline_color

Color(1, 1, 1, 1)

Color

hover_font_color

Color(0.95, 0.95, 0.95, 1)

int

h_separation

2

int

outline_size

0

Font

font

int

font_size

Texture2D

expanded_arrow

Texture2D

expanded_arrow_mirrored

Texture2D

folded_arrow

Texture2D

folded_arrow_mirrored

StyleBox

focus

StyleBox

panel

StyleBox

title_collapsed_hover_panel

StyleBox

title_collapsed_panel

StyleBox

title_hover_panel

StyleBox

title_panel


信号

folding_changed(is_folded: bool) 🔗

容器折叠/展开时发出。


枚举

enum TitlePosition: 🔗

TitlePosition POSITION_TOP = 0

标题出现在容器顶部。

TitlePosition POSITION_BOTTOM = 1

标题出现在容器底部。同时会让所有 StyleBox 垂直翻转。


属性说明

FoldableGroup foldable_group 🔗

与容器关联的 FoldableGroup。多个 FoldableContainer 节点具有相同的分组时,只允许有一个处于展开状态。


bool folded = false 🔗

  • void set_folded(value: bool)

  • bool is_folded()

如果为 true,则会折叠容器折叠,隐藏所有子节点。


String language = "" 🔗

Language code used for text shaping algorithms. If left empty, the current locale is used instead.


String title = "" 🔗

容器的标题文本。


HorizontalAlignment title_alignment = 0 🔗

标题的水平文本对齐方式。


TitlePosition title_position = 0 🔗

标题的位置。


TextDirection title_text_direction = 0 🔗

标题的文本书写方向。


OverrunBehavior title_text_overrun_behavior = 0 🔗

定义标题在文本比可用空间更长时的行为。


方法说明

void add_title_bar_control(control: Control) 🔗

添加放置在容器标题旁的 Control,遮挡可点击区域。主要用途是添加 Button 节点,但可以是任何 Control

控件会被添加为该容器的子节点,必要时会从之前的父节点中移除。这些控件是右对齐的,最先添加的控件位于最左侧。


void expand() 🔗

展开容器,发出 folding_changed


void fold() 🔗

折叠容器,发出 folding_changed


void remove_title_bar_control(control: Control) 🔗

移除使用 add_title_bar_control() 添加的 Control。该节点不会自动释放,你需要使用 Node.queue_free()


主题属性说明

Color collapsed_font_color = Color(1, 1, 1, 1) 🔗

折叠时的标题字体颜色。


Color font_color = Color(0.875, 0.875, 0.875, 1) 🔗

展开时的标题字体颜色。


Color font_outline_color = Color(1, 1, 1, 1) 🔗

标题字体轮廓颜色。


Color hover_font_color = Color(0.95, 0.95, 0.95, 1) 🔗

标题字体悬停颜色。


int h_separation = 2 🔗

标题的图标和文本之间以及标题栏控件之间的水平间距。


int outline_size = 0 🔗

标题字体轮廓大小。


Font font 🔗

标题字体。


int font_size 🔗

标题字体大小。


Texture2D expanded_arrow 🔗

展开时使用的标题图标。


Texture2D expanded_arrow_mirrored 🔗

展开时使用的标题图标(用于底部标题)。


Texture2D folded_arrow 🔗

折叠时使用的标题图标(用于从左至右布局)。


Texture2D folded_arrow_mirrored 🔗

展开时使用的标题图标(用于从右至左布局)。


StyleBox focus 🔗

FoldableContainer 拥有 GUI 焦点时使用的背景。focus StyleBox 显示在基础 StyleBox 之上,所以应该使用部分透明的 StyleBox,确保基础 StyleBox 仍然可见。代表轮廓或下划线的 StyleBox 可以很好地实现这个目的。要禁用聚焦的视觉效果,请指定 StyleBoxEmpty 资源。请注意,禁用聚焦的视觉效果会影响使用键盘/手柄进行导航的可用性,所以出于可访问性的原因,不建议这样做。


StyleBox panel 🔗

FoldableContainer 的默认背景。


StyleBox title_collapsed_hover_panel 🔗

处于折叠状态下,鼠标光标进入标题区域时使用的背景。


StyleBox title_collapsed_panel 🔗

处于折叠状态下,FoldableContainer 标题的默认背景。


StyleBox title_hover_panel 🔗

处于展开状态下,鼠标光标进入标题区域时使用的背景。


StyleBox title_panel 🔗

处于展开状态下,FoldableContainer 标题的默认背景。