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...
SplitContainer
继承: Container < Control < CanvasItem < Node < Object
派生: HSplitContainer, VSplitContainer
将两个子控件垂直或水平分隔的容器,提供了用于调整分隔比例的抓取器。
描述
仅接受两个子控件的容器,会将它们垂直或水平排列,在中间创建一个分隔条。分隔条可以拖拽,从而改变两个控件的大小关系。
教程
属性
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
方法
void |
|
主题属性
|
||
|
||
|
||
信号
drag_ended() 🔗
Emitted when the user ends dragging.
drag_started() 🔗
Emitted when the user starts dragging.
当用户拖动拖动器时发出。
枚举
enum DraggerVisibility: 🔗
DraggerVisibility DRAGGER_VISIBLE = 0
The split dragger icon is always visible when autohide is false
, otherwise visible only when the cursor hovers it.
The size of the grabber icon determines the minimum separation.
The dragger icon is automatically hidden if the length of the grabber icon is longer than the split bar.
The split dragger icon is never visible regardless of the value of autohide.
The size of the grabber icon determines the minimum separation.
The split dragger icon is not visible, and the split bar is collapsed to zero thickness.
属性说明
If true
, the dragger will be disabled and the children will be sized as if the split_offset was 0
.
bool drag_area_highlight_in_editor = false
🔗
Highlights the drag area Rect2 so you can see where it is during development. The drag area is gold if dragging_enabled is true
, and red if false
.
int drag_area_margin_begin = 0
🔗
Reduces the size of the drag area and split bar split_bar_background at the beginning of the container.
int drag_area_margin_end = 0
🔗
Reduces the size of the drag area and split bar split_bar_background at the end of the container.
Shifts the drag area in the axis of the container to prevent the drag area from overlapping the ScrollBar or other selectable Control of a child node.
DraggerVisibility dragger_visibility = 0
🔗
void set_dragger_visibility(value: DraggerVisibility)
DraggerVisibility get_dragger_visibility()
Determines the dragger's visibility. See DraggerVisibility for details. This property does not determine whether dragging is enabled or not. Use dragging_enabled for that.
bool dragging_enabled = true
🔗
Enables or disables split dragging.
两个 Control 之间拆分的初始偏移量,0
位于第一个 Control 的末尾。
如果为 true
,则该 SplitContainer 会垂直排列其子代,而不是水平排列。
在使用 HSplitContainer 和 VSplitContainer 时无法改变。
方法说明
void clamp_split_offset() 🔗
限制 split_offset 值不超出当前可能的最小值和最大值。
Control get_drag_area_control() 🔗
Returns the drag area Control. For example, you can move a pre-configured button into the drag area Control so that it rides along with the split bar. Try setting the Button anchors to center
prior to the reparent()
call.
$BarnacleButton.reparent($SplitContainer.get_drag_area_control())
Note: The drag area Control is drawn over the SplitContainer's children, so CanvasItem draw objects called from the Control and children added to the Control will also appear over the SplitContainer's children. Try setting Control.mouse_filter of custom children to Control.MOUSE_FILTER_IGNORE to prevent blocking the mouse from dragging if desired.
Warning: This is a required internal node, removing and freeing it may cause a crash.
主题属性说明
Boolean value. If 1
(true
), the grabber will hide automatically when it isn't under the cursor. If 0
(false
), it's always visible. The dragger_visibility must be DRAGGER_VISIBLE.
int minimum_grab_thickness = 6
🔗
The minimum thickness of the area users can click on to grab the split bar. This ensures that the split bar can still be dragged if separation or h_grabber / v_grabber's size is too narrow to easily select.
The split bar thickness, i.e., the gap between the two children of the container. This is overridden by the size of the grabber icon if dragger_visibility is set to DRAGGER_VISIBLE, or DRAGGER_HIDDEN, and separation is smaller than the size of the grabber icon in the same axis.
Note: To obtain separation values less than the size of the grabber icon, for example a 1 px
hairline, set h_grabber or v_grabber to a new ImageTexture, which effectively sets the grabber icon size to 0 px
.
在中间区域绘制的抓取图标。
vertical 为 false
时绘制在中间区域的抓取器图标。
vertical 为 true
时绘制在中间区域的抓取器图标。
StyleBox split_bar_background 🔗
Determines the background of the split bar if its thickness is greater than zero.