-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
Add z_index
property for Control nodes (like in Node2D)
#839
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I don't think this is a good idea. Control nodes receive input depending on tree order. Tree order determines draw order. Z-index would make input counterintuitive. Rather than using a z-index the following API should be used: Node.move_child() and Node.raise(). |
I had an equipment panel made of vbox and hbox containers that I had to scrap and do line by line because of draw order issues (a submenu child of a button would be drawn over by other buttons in the container). This proposal would have allowed me to keep the original, much more intuitive scene design instead of having to have a control per row (and bottom-up by hardcoding margins)... |
I think this i a good idea and CanvasLayers are unnecessary then. |
This comment has been minimized.
This comment has been minimized.
@Gerarama Please don't bump issues without contributing significant new information. Use the 👍 reaction button on the first post instead. |
One would certainly expect a popup - in my case a fileDialog - to be drawn on top of everything else. Yet, it's drawn behind any of my sprites with +ve z-indices. Almost a year into my project I don't suddenly want to have to go in and start re-ordering everything else. It could take days. Actually, I did find a workaround but only because most of the world I needed my dialog to be on top of was on the same script. I basically hid everything when the fileDialog came up then showed it again once the selection was made. If they were in different scripts you could easily run into the problem of circular references func _on_OpenFileButton_pressed(): func _on_SavedHandFileDialog_file_selected(path): |
Does set_as_toplevel help your case? |
No, it didn't. I applied it to FileDialog, then to it's parent and then to it's parent( hostPanel), and none of them had any effect. The hostPanel which is being hidden and then shown is a sprite with z-level of 5 to make sure it appears on top of the world (in this case tableTop). My workaround however works beautifully for me. |
@Thebas Good use case for z-index. You can use the following to apply z-index to a control: var item = control.get_canvas_item()
VisualServer.canvas_item_set_z_index(item, rect_scale.length() * 10.0) Hope that helps. |
VisualServer.canvas_item_set_z_index(get_canvas_item(), rect_scale.length() * 10.0) /\/\/\ |
z_index
property for Control nodes (like in Node2D)
I am currently working on this (godotengine/godot#68070) and would like to ask for some feedback. z_index related properties are moved to |
Describe the project you are working on: I am working on a PC Simulator with WindowDialogs in it.
Describe the problem or limitation you are having in your project: For all Control nodes you can't set a z order. That's especially problematic with Dialogs. (I've tried it with putting a Node2D as a parent of a dialog and then trying to z order but that didn't work probably because it orders the z axis in the order of the Nodetree).
Describe the feature / enhancement and how it helps to overcome the problem or limitation: Adding z ordering into Control nodes or at least for the Dialogs like with Node2D (And maybe a CheckButton class if you want to disable the ordering with the Nodetree).
Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams: I don't know how it could be done because I am not familiar with the Engine, but I think that it could be built like the Node2D.
(I don't know if this is a good reference)
https://github.com/godotengine/godot/blob/master/scene/2d/node_2d.cpp
If this enhancement will not be used often, can it be worked around with a few lines of script?: I don't think so because it would be an enhancement to the core of control nodes and/or dialogs.
Is there a reason why this should be core and not an add-on in the asset library?: Because I think that adding z ordering for Control Nodes can be helpful in many ways (not only in dialogs) and many people seem to have problems with it.
Here is a discussion about it. I've tried it with those possible solutions but it didn't work either way.
godotengine/godot#7692
The text was updated successfully, but these errors were encountered: