godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.07k stars 69 forks source link

Allow specifying icons for tabs in TabContainer #592

Open git2013vb opened 4 years ago

git2013vb commented 4 years ago

Describe the project you are working on: gui interface for client server game Describe the problem or limitation you are having in your project: Currently we have the possibility to set a text to identify a tab in TabContainer Describe the feature / enhancement and how it helps to overcome the problem or limitation: 1) I wold like to have a image and/or a text instead just a text in tabs.

image

2) The option to show them in sx/dx/bottom side not just in top side only as is now. Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams: I guess it is a editor job? If this enhancement will not be used often, can it be worked around with a few lines of script?: I'm not sure about it. Is there a reason why this should be core and not an add-on in the asset library?: It will be nice if will be a standard feature.

groud commented 4 years ago

I wold like to have a image and/or a text instead just a text in tabs.

This is possible via script, using the set_tab_icon() function.

KoBeWi commented 4 years ago

Well, TabContainer could allow to dynamically customize tabs, like GraphNode does it with sockets.

git2013vb commented 4 years ago

I wold like to have a image and/or a text instead just a text in tabs.

This is possible via script, using the set_tab_icon() function.

I checked but I don't see any Icon or similar field from inspector: image Is there something in documentation that can help me? Or is an undocumented feature?

edit: I use this structure: image So the label "Peers" come out from the "ScrollContainer" name that don't have either any "icon" or similar field in inspector..

Also for the point nr. 2?

KoBeWi commented 4 years ago

It's not in the inspector, you can do it in code: https://docs.godotengine.org/en/latest/classes/class_tabcontainer.html#class-tabcontainer-method-set-tab-icon I just said it could be in the inspector to improve usability, so the proposal is ok.

As for point 2 (you could edit the post to make it more visible btw), there's a PR that implements bottom tabs: https://github.com/godotengine/godot/pull/31909

git2013vb commented 4 years ago

Thank you :)

chucklepie commented 3 years ago

I don't know how far along this request is, but one good reason for having this as a 'custom constant' (or similar) is more than likely the texture will be a different size to the text. The net result is when you run the game your offsets for gui controls are probably shifted down and it looks a mess. But you cannot see what it looks like in design mode, so adjusting is difficult.

To be honest there are a load of properties that should be part of the editor, for example set_tab_title seems pretty basic requirement.

Maybe the problem is how TabContainer and Tabs are coupled and share common properties for some reason...

lucasshuan commented 2 years ago

@chucklepie I may be wrong, but I don't think the TabContainer and Tabs are supposed to be used together?

By all means, I also think it would be good if Godot's tabs had a text/icon property built-in. It's currently really strange how the text of the tab is the node's name.

YuriSizov commented 2 years ago

Indeed, TabContainer and Tabs are not to be used together, they are replacements for each other. But they do share a lot of APIs and that's a huge bother to keep in sync. So our current plan is to make TabContainer use Tabs internally for the actual tabbar, and only add the "convert children to tabs" logic on top of it.

This proposal will be solved in master, by the way, as we now have a way to edit arrays of data nicely in the Inspector, and some controls have already been ported to that system (like ItemList). See https://github.com/godotengine/godot/issues/52463. There is already a PR for the TabBar control (renamed from Tabs to give a better idea what that control does): https://github.com/godotengine/godot/pull/54560.

chucklepie commented 2 years ago

Ok, this doesn't really make sense to me, but if it's being fixed then fine, maybe the problem is almost complete lack of documentation (i.e. in the non-reference section, and very terse to the point of not being there in the reference section).

But when you see the word 'TabContainer' you presume it means container for tabs, which is how I coded it as 'Tabs' didn't give me obvious means of creating multiple tabs and even says it doesn't control children which makes you wonder why it's called 'tabs' in the first place ;-)

KoBeWi commented 2 years ago

Tabs were renamed to TabBar, so there is no more confusion. And the aforementioned PR was merged.

But the proposal isn't resolved yet. TabContainer can't use property array, because the list of properties depend on its children. As I said, this is closer to GraphNode's slots. Although we could maybe adapt the property array to support constant property lists.

false-fox commented 2 months ago

plus support, having it editable in the inspector makes it more accessible and better UX overall