Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rect_clip_content of Control node does not clip children in all cases #37683

Closed
Sauermann opened this issue Apr 8, 2020 · 9 comments · Fixed by #37718
Closed

rect_clip_content of Control node does not clip children in all cases #37683

Sauermann opened this issue Apr 8, 2020 · 9 comments · Fixed by #37718

Comments

@Sauermann
Copy link
Contributor

Godot version: 3.2.1

OS/device including version: Windows 10

Issue description:
In some cases children and their children get displayed outside of the rect of the parent, even though rect_clip_content is set to true on the parent.

According to the documentation of the control class https://docs.godotengine.org/en/stable/classes/class_control.html#class-control-property-rect-clip-content I would expect, that all children get clipped within the bounds of the clipping parent.

This happens in the following setup:

- Control
  - Node
    - TileMap

Thank you for having a look at this issue.

Steps to reproduce:
Create a scene according to the described setup.
Add Tiles to the TileMap that are outside of the rect of the Control node.
Set rect_clip_content on the node Control to true.
The issue is visible in the editor and when the scene is run.

Workaround:
Change the type of Node to Control or Node2D.

Alternative solution:
Change the documentation of rect_clip_content and describe this behavior.

Minimal reproduction project:
ClipTileMapBug.zip

@Zireael07
Copy link
Contributor

Probably happens because Node isn't a CanvasItem, right?

@Sauermann
Copy link
Contributor Author

Thanks for the reply. In regard to this information, am I right to assume, that this is intended behavior?

@Zireael07
Copy link
Contributor

Most likely yes, though I'm not a core contributor :)

@groud
Copy link
Member

groud commented Apr 8, 2020

I would say this is an expected behavior. When you put an intermediate basic node in your hierarchy, this does reset the "transform inheritance" too. By that I mean that, in your example, the Tilemap node wont be positioned relatively to the Control node.

So I guess it is kind of expected that the rect clipping works the same way.

@Sauermann
Copy link
Contributor Author

Thank you for confirming that this works as intended. Closing this issue accordingly.

@Sauermann
Copy link
Contributor Author

I would like to reopen this issue and suggest to resolve this by clarifying the documentation of rect_clip_content:

Enables whether rendering of children should be clipped to this control’s rectangle.
should be changed to
Enables whether rendering of CanvasItem based children should be clipped to this control's rectangle.

If approvable, I would like to create a pull request for this.

@Calinou
Copy link
Member

Calinou commented Apr 9, 2020

@Sauermann Feel free to open a pull request for this 🙂

@Sauermann
Copy link
Contributor Author

Will do.
I assume that

Enables whether rendering of children should be clipped to this control's rectangle. If [code]true[/code], parts of a child which would be visibly outside of this control's rectangle will not be rendered.
is the correct place for such a PR and that https://github.com/godotengine/godot-docs/blob/master/classes/class_control.rst is automatically generated?

@Calinou
Copy link
Member

Calinou commented Apr 9, 2020

@Sauermann Yes, that's correct 🙂

Sauermann added a commit to Sauermann/godot that referenced this issue Apr 9, 2020
@akien-mga akien-mga added this to the 4.0 milestone Apr 9, 2020
akien-mga pushed a commit to akien-mga/godot that referenced this issue Apr 16, 2020
…y CanvasItem based nodes.

Resolves godotengine#37683

(cherry picked from commit 3f19b5e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment