Skip to content

Fix various issues with SplitContainer that make scripting it difficult. #6230

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

  • SplitContainer has no reliable method or signal for notification of when initialization of child controls is ready. _ready() is called earlier than the child containers are resized for the split offset.
  • There is no background color or StyleBox for the background of the split bar, so clunky scripting has to follow the split_offset to keep a line centered in the split bar; If you wanted the background behind the grabber icon, you would have to draw it behind the entire SplitContainer.
  • There is no signal for when the split drag is released or started, so a very common use of saving and restoring the user's split offsets in a resource has to be timed off when the dragged signal stops.
  • The new drag area that can be wider than the split bar has no facility to offset it to avoid it overlaying an adjacent scroll bar, so themes that have a scrollbar hard up against the right side of their container will be blocked by the grab area. This means that themes with a hairline split bar or a collapsed split bar can't take advantage of the purpose of the separate grab area.
  • While developing a script with the wider grab area, you can't easily visualize the area for testing purposes, without more inconvenient draw code to track the split offset and grab area Control, which is not exposed for scripting.

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

  • A new split_bar_background StyleBox allows solid color, gradients or textures to fill in the split bar behind or in place of the grabber icon.
  • An essential new property drag_area_scrollbar_offset is required if one of the child controls has a scrollbar or other selectable control up against the split bar, in order to prevent the drag area from blocking mouse selection of the scroll bar or control.
  • New signals drag_started and drag_released make it easier to script saving and restoring the split_offset
  • A new property dragging_enabled separates dragging from dragger_visibility so the appearance of the drag bar is independent from whether dragging is enabled or not.
  • A new drag_area_show_drag_area property allows you to see the drag area during development.
  • A new virtual method _splits_ready() with a corresponding signal so a script knows when the split container children have been resized after the initial sort. This was a big problem because formerly, SplitContainer._ready() was called before the children had been fit to the container, and there was no easy way to get that information.

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 #6231 for two enhancements that add begin and end margins to the drag area, and exposes the drag area Control to scripting.

Screen.Recording.2023-02-03.at.12.36.25.PM.mov
Screen.Recording.2023-02-03.at.12.58.21.PM.mov

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

No. The script required to work around these difficiencies runs to hundreds of lines of unreliable script. The _ready notification issue can't be worked around at all, yields and awaits are required to try and guess when the children will be ready.

The new SplitContainer per the PR does the same thing better with just a few lines of script that anyone can understand.

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

The improvements can't be added via an add-on.

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