Up to date

This page is up to date for Godot 4.3. If you still find outdated information, please open an issue.

SplitContainer

Inherits: Container < Control < CanvasItem < Node < Object

Inherited By: HSplitContainer, VSplitContainer

A container that splits two child controls horizontally or vertically and provides a grabber for adjusting the split ratio.

Description

A container that accepts only two child controls, then arranges them horizontally or vertically and creates a divisor between them. The divisor can be dragged around to change the size relation between the child controls.

Children can be collapsed/expanded at runtime if you drag against their half minimum size. See collapse_mode for more info.

Tutorials

Properties

CollapseMode

collapse_mode

0

bool

collapsed

false

bool

drag_area_highlight_in_editor

false

DraggerVisibility

dragger_visibility

0

bool

dragging_enabled

true

int

split_offset

0

bool

vertical

false

Methods

void

clamp_split_offset()

Control

get_drag_area_control() const

Theme Properties

Color

grabber_icon_normal

Color(0.875, 0.875, 0.875, 0.6)

Color

grabber_icon_pressed

Color(0.226, 0.478, 0.921, 1)

int

autohide

1

int

autohide_split_bar

1

int

draw_grabber_icon

1

int

draw_split_bar

0

int

minimum_grab_thickness

6

int

separation

6

Texture2D

grabber

Texture2D

h_grabber

Texture2D

v_grabber

StyleBox

h_split_bar_background

StyleBox

split_bar_background

StyleBox

v_split_bar_background


Signals

drag_ended() 🔗

Emitted when the user ends dragging.


drag_started() 🔗

Emitted when the user starts dragging.


dragged(offset: int) 🔗

Emitted when the dragger is dragged by user.


Enumerations

enum DraggerVisibility: 🔗

DraggerVisibility DRAGGER_VISIBLE = 0

The split dragger is visible when the cursor hovers it.

DraggerVisibility DRAGGER_HIDDEN = 1

The split dragger is never visible.

DraggerVisibility DRAGGER_HIDDEN_COLLAPSED = 2

The split dragger is never visible and its space collapsed.


enum CollapseMode: 🔗

CollapseMode COLLAPSE_NONE = 0

Hiding the first or second sortable control child will result in hiding the dragger and the other control child will fill the visible area.

CollapseMode COLLAPSE_FIRST = 1

Hiding the first sortable control child will keep the dragger visible and you will be able to drag again to show it.

Note: hiding the second sortable control will also hide the dragger.

CollapseMode COLLAPSE_SECOND = 2

Hiding the second sortable control child will keep the dragger visible and you will be able to drag again to show it.

Note: hiding the first sortable control will also hide the dragger.

CollapseMode COLLAPSE_ALL = 3

Hiding the first or second sortable control child will keep the dragger visible and you will be able to drag again to show them.

Note: only one sortable control can be collapsed at time.


Property Descriptions

CollapseMode collapse_mode = 0 🔗

Can allow the first child or second child or both of them to be collapsed when they are not visible. See CollapseMode for details.

Children can be visible/hidden while dragging, if the mouse position becomes greater than their half size, they will hide otherwise they will show if they are hidden.


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.


DraggerVisibility dragger_visibility = 0 🔗

Determines the dragger's visibility. See DraggerVisibility for details.


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()

The initial offset of the splitting between the two Controls, with 0 being at the end of the first Control.


bool vertical = false 🔗

  • void set_vertical(value: bool)

  • bool is_vertical()

If true, the SplitContainer will arrange its children vertically, rather than horizontally.

Can't be changed when using HSplitContainer and VSplitContainer.


Method Descriptions

void clamp_split_offset() 🔗

Clamps the split_offset value to not go outside the currently possible minimal and maximum values.


Control get_drag_area_control() const 🔗

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.


Theme Property Descriptions

Color grabber_icon_normal = Color(0.875, 0.875, 0.875, 0.6) 🔗

The grabber icon normal color.


Color grabber_icon_pressed = Color(0.226, 0.478, 0.921, 1) 🔗

The grabber icon pressed color.


int autohide = 1 🔗

Boolean value. If 1 (true), the grabber icon will hide automatically when it isn't under the cursor. If 0 (false), it's always visible.


int autohide_split_bar = 1 🔗

Boolean value. If 1 (true), the split bar background will hide automatically when it isn't under the cursor. If 0 (false), it's always visible.


int draw_grabber_icon = 1 🔗

If 1 (true), the grabber icon will be visible. If 0 (false), it will be hidden.


int draw_split_bar = 0 🔗

If 1 (true), the split bar background will be visible. If 0 (false), it will be hidden.


int minimum_grab_thickness = 6 🔗

The minimum thickness of the area users can click on to grab the splitting line. If separation or h_grabber / v_grabber's thickness are too small, this ensure that the splitting line can still be dragged.


int separation = 6 🔗

The space between sides of the container.


Texture2D grabber 🔗

The icon used for the grabber drawn in the middle area.


Texture2D h_grabber 🔗

The icon used for the grabber drawn in the middle area when vertical is false.


Texture2D v_grabber 🔗

The icon used for the grabber drawn in the middle area when vertical is true.


StyleBox h_split_bar_background 🔗

Determines the background of the split bar when vertical is false.


StyleBox split_bar_background 🔗

Determines the background of the split bar. Can have expand margins to draw outside the bounds.


StyleBox v_split_bar_background 🔗

Determines the background of the split bar when vertical is true.