Skip to content

Improve SplitContainer grab area by adding margin properties and exposing the Control to scripting #6231

Description

@Koyper

Describe the project you are working on

GUI elements for handling large collections of items, and GUI elements for organizing related containers of text, lists and collections - common GUI utility used frequently.

Describe the problem or limitation you are having in your project

Because you can't access the grab area Control, and there is no way to modify the span of the split bar accross the SplitContainer, a lot of ungainly scripting code is required to implement a few highly useful variations of SplitContainers.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

  • A common gui implementation includes buttons on the split bar dividing two container areas. This is typically used to move assets back and forth between related collections. Exposing the Control used by the new grab area in SplitContainer, makes adding buttons to the split bar a matter of a few lines of code.
  • The span of the split bar is currently fixed to the entire width of the SplitContainer. By simply providing drag_area_margin_begin and drag_area_margin_end properties, useful combinations of SplitContainers can be created with a few lines of code, such as "drawers" that collapse against at the top, bottom or side of a parent container.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

The code is complete per PR #72680

The PR combines this proposal with proposal #6230, with fixes various issues with SplitContainer that make scripting difficult.

Screen.Recording.2023-02-03.at.12.29.31.PM.mov

This is all the GDScript neccessary for the buttons:

func _ready():
	var button := $Button
	var button_right := $ButtonRight
	remove_child(button)
	remove_child(button_right)
	hsplit.get_drag_area_control().add_child(button)
	hsplit.get_drag_area_control().add_child(button_right)
	button.position.y = -150 
	button_right.position.y = -50
Screen.Recording.2023-02-03.at.12.40.10.PM.mov

If this enhancement will not be used often, can it be worked around with a few lines of script?

Extremely difficult to implement in script - all of the visual split bar elements have to be drawn over a split container with dragging disabled, and the script has to set the offset when the overlaid control is dragged.

Is there a reason why this should be core and not an add-on in the asset library?

These two enhancements are small modifications to split_container.cpp, but greatly improve it's utility.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions