SplitContainer

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

被繼承: HSplitContainer, VSplitContainer

將兩個子控制項垂直或水平分隔的容器,提供了用於調整分隔比例的抓取器。

說明

僅接受兩個子控制項的容器,會將它們垂直或水平排列,在中間建立一個分隔條。分隔條可以拖拽,從而改變兩個控制項的大小關係。

教學

屬性

bool

collapsed

false

bool

drag_area_highlight_in_editor

false

int

drag_area_margin_begin

0

int

drag_area_margin_end

0

int

drag_area_offset

0

DraggerVisibility

dragger_visibility

0

bool

dragging_enabled

true

int

split_offset

0

bool

touch_dragger_enabled

false

bool

vertical

false

方法

void

clamp_split_offset()

Control

get_drag_area_control()

主題屬性

Color

touch_dragger_color

Color(1, 1, 1, 0.3)

Color

touch_dragger_hover_color

Color(1, 1, 1, 0.6)

Color

touch_dragger_pressed_color

Color(1, 1, 1, 1)

int

autohide

1

int

minimum_grab_thickness

6

int

separation

12

Texture2D

grabber

Texture2D

h_grabber

Texture2D

h_touch_dragger

Texture2D

touch_dragger

Texture2D

v_grabber

Texture2D

v_touch_dragger

StyleBox

split_bar_background


訊號

drag_ended() 🔗

Emitted when the user ends dragging.


drag_started() 🔗

Emitted when the user starts dragging.


dragged(offset: int) 🔗

當使用者拖動拖動器時發出。


列舉

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.

DraggerVisibility DRAGGER_HIDDEN = 1

The split dragger icon is never visible regardless of the value of autohide.

The size of the grabber icon determines the minimum separation.

DraggerVisibility DRAGGER_HIDDEN_COLLAPSED = 2

The split dragger icon is not visible, and the split bar is collapsed to zero thickness.


屬性說明

bool collapsed = false 🔗

  • void set_collapsed(value: bool)

  • bool is_collapsed()

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 🔗

  • void set_drag_area_highlight_in_editor(value: bool)

  • bool is_drag_area_highlight_in_editor_enabled()

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 🔗

  • void set_drag_area_margin_begin(value: int)

  • int get_drag_area_margin_begin()

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 🔗

  • void set_drag_area_margin_end(value: int)

  • int get_drag_area_margin_end()

Reduces the size of the drag area and split bar split_bar_background at the end of the container.


int drag_area_offset = 0 🔗

  • void set_drag_area_offset(value: int)

  • int get_drag_area_offset()

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 🔗

Determines the dragger's visibility. This property does not determine whether dragging is enabled or not. Use dragging_enabled for that.


bool dragging_enabled = true 🔗

  • void set_dragging_enabled(value: bool)

  • bool is_dragging_enabled()

Enables or disables split dragging.


int split_offset = 0 🔗

  • void set_split_offset(value: int)

  • int get_split_offset()

兩個 Control 之間拆分的初始偏移量,0 位於第一個 Control 的末尾。


bool touch_dragger_enabled = false 🔗

  • void set_touch_dragger_enabled(value: bool)

  • bool is_touch_dragger_enabled()

If true, a touch-friendly drag handle will be enabled for better usability on smaller screens. Unlike the standard grabber, this drag handle overlaps the SplitContainer's children and does not affect their minimum separation. The standard grabber will no longer be drawn when this option is enabled.


bool vertical = false 🔗

  • void set_vertical(value: bool)

  • bool is_vertical()

如果為 true,則該 SplitContainer 會垂直排列其子代,而不是水平排列。

在使用 HSplitContainerVSplitContainer 時無法改變。


方法說明

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.


主題屬性說明

Color touch_dragger_color = Color(1, 1, 1, 0.3) 🔗

The color of the touch dragger.


Color touch_dragger_hover_color = Color(1, 1, 1, 0.6) 🔗

The color of the touch dragger when hovered.


Color touch_dragger_pressed_color = Color(1, 1, 1, 1) 🔗

The color of the touch dragger when pressed.


int autohide = 1 🔗

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.


int separation = 12 🔗

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.


Texture2D grabber 🔗

The icon used for the grabber drawn in the middle area. This is only used in HSplitContainer and VSplitContainer. For SplitContainer, see h_grabber and v_grabber instead.


Texture2D h_grabber 🔗

verticalfalse 時繪製在中間區域的抓取器圖示。


Texture2D h_touch_dragger 🔗

The icon used for the drag handle when touch_dragger_enabled is true and vertical is false.


Texture2D touch_dragger 🔗

The icon used for the drag handle when touch_dragger_enabled is true. This is only used in HSplitContainer and VSplitContainer. For SplitContainer, see h_touch_dragger and v_touch_dragger instead.


Texture2D v_grabber 🔗

verticaltrue 時繪製在中間區域的抓取器圖示。


Texture2D v_touch_dragger 🔗

The icon used for the drag handle when touch_dragger_enabled is true and vertical is true.


StyleBox split_bar_background 🔗

Determines the background of the split bar if its thickness is greater than zero.