Skip to content

Allow ScrollBar to watch ScrollContainer in tree #5012

Open
godotengine/godot
#63626
@Rindbee

Description

@Rindbee

Describe the project you are working on

Want to customize the ScrollBar related to the ScrollContainer in the editor.

Describe the problem or limitation you are having in your project

The ScrollBar associated with the ScrollContainer is implemented as internal node for out-of-the-box purposes. This is good.

However, due to the limitation of internal nodes, we cannot customize its theme properties and layout properties in the editor very well.

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

The existing designs, the Range::share function, and SCROLL_MODE_SHOW_NEVER, have given us a good foundation. Only by making good use of these, the purpose of replacing internal ScrollBar with external ScrollBar can be simply achieved.

  1. SCROLL_MODE_SHOW_NEVER just hides the ScrollBar, but doesn't disable scrolling. This is exactly what we need.
  2. The data required for scrolling is completely recorded by the internal ScrollBar.
  3. Range::share makes it easy to share this data.

All the prerequisites are complete, we just need to let the ScrollBar say hello to the ScrollContainer.

Regarding watch, the main point is that the sharing is one-way, from internal nodes to external nodes, which allows multiple watchers. It's a bit like watching TV, whether TV controls people or people control TV, this is a question. It is definitely not a question of the amount of English vocabulary.

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

  1. Mark the ScrollContainer's position in the tree using the watch_target_path property of type NodePath to remind who the ScrollBar is serving for.
  2. When setting a new watch_target_path, and when entering the tree, try to find the corresponding internal ScrollBar from the watch_target_path according to the direction. And then try to share the internal data.
  3. Attempts may or may not succeed. We use watching to indicate whether it was successful or not.

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

Not easy and requires more complex operations.

I'm sure a lot of people will be happy with the change from internal nodes to external nodes.

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

This is about improving the ScrollContainer/ScrollBar usability out of box.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions