Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
FoldableContainer
继承: Container < Control < CanvasItem < Node < Object
能够展开、折叠的容器。
描述
能够展开、折叠的容器,标题中可以添加按钮等控件。这也叫做手风琴。
标题可以放在容器的顶部或底部。点击标题或在聚焦时按下 ui_accept 可以将容器展开或折叠。容器折叠时子控件节点隐藏。忽略非控件子节点。
可折叠容器可以与其他可折叠容器分组,这样一次只能打开其中一个;见 foldable_group 和 FoldableGroup。
属性
focus_mode |
|
|
|
||
|
||
mouse_filter |
|
|
|
||
|
||
|
||
|
||
|
方法
void |
add_title_bar_control(control: Control) |
void |
expand() |
void |
fold() |
void |
remove_title_bar_control(control: Control) |
主题属性
|
||
|
||
|
||
|
||
|
||
|
||
信号
folding_changed(is_folded: bool) 🔗
容器折叠/展开时发出。
枚举
enum TitlePosition: 🔗
TitlePosition POSITION_TOP = 0
标题出现在容器顶部。
TitlePosition POSITION_BOTTOM = 1
标题出现在容器底部。同时会让所有 StyleBox 垂直翻转。
属性说明
FoldableGroup foldable_group 🔗
void set_foldable_group(value: FoldableGroup)
FoldableGroup get_foldable_group()
与容器关联的 FoldableGroup。多个 FoldableContainer 节点具有相同的分组时,只允许有一个处于展开状态。
如果设为 true,该容器将会被折叠,并隐藏其所有子节点。
语言代码,用于文本塑形算法。如果留空则使用当前区域设置。
容器的标题文本。
HorizontalAlignment title_alignment = 0 🔗
void set_title_alignment(value: HorizontalAlignment)
HorizontalAlignment get_title_alignment()
标题的水平文本对齐方式。
TitlePosition title_position = 0 🔗
void set_title_position(value: TitlePosition)
TitlePosition get_title_position()
标题的位置。
TextDirection title_text_direction = 0 🔗
void set_title_text_direction(value: TextDirection)
TextDirection get_title_text_direction()
标题的文本书写方向。
OverrunBehavior title_text_overrun_behavior = 0 🔗
void set_title_text_overrun_behavior(value: OverrunBehavior)
OverrunBehavior get_title_text_overrun_behavior()
定义标题在文本比可用空间更长时的行为。
方法说明
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) 🔗
标题字体悬停颜色。
标题的图标和文本之间以及标题栏控件之间的水平间距。
标题字体轮廓大小。
标题字体。
标题字体大小。
展开时使用的标题图标。
Texture2D expanded_arrow_mirrored 🔗
展开时使用的标题图标(用于底部标题)。
折叠时使用的标题图标(用于从左至右布局)。
Texture2D folded_arrow_mirrored 🔗
展开时使用的标题图标(用于从右至左布局)。
FoldableContainer 拥有 GUI 焦点时使用的背景。focus StyleBox 显示在基础 StyleBox 之上,所以应该使用部分透明的 StyleBox,确保基础 StyleBox 仍然可见。代表轮廓或下划线的 StyleBox 可以很好地实现这个目的。要禁用聚焦的视觉效果,请指定 StyleBoxEmpty 资源。请注意,禁用聚焦的视觉效果会影响使用键盘/手柄进行导航的可用性,所以出于无障碍访问的原因,不建议这样做。
FoldableContainer 的默认背景。
StyleBox title_collapsed_hover_panel 🔗
处于折叠状态下,鼠标光标进入标题区域时使用的背景。
StyleBox title_collapsed_panel 🔗
处于折叠状态下,FoldableContainer 标题的默认背景。
处于展开状态下,鼠标光标进入标题区域时使用的背景。
处于展开状态下,FoldableContainer 标题的默认背景。