Retrieve and modify the tab container of tabbed panes

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
User avatar
raiguard
Factorio Staff
Factorio Staff
Posts: 579
Joined: Wed Dec 13, 2017 8:29 pm
Contact:

Retrieve and modify the tab container of tabbed panes

Post by raiguard »

I would like to request a way to get the "tab container" (the flow that contains the actual tab buttons) of a tabbed pane, and modify it as any other LuaGuiElement (except for deleting it altogether, which would be disallowed). My usecase is so that I can add a drag handle and close button to the top-right of this GUI, similar to the new character GUI.

Thanks in advance!

I tried implementing this myself first, but it turned out be be too complex for my skill level and knowledge of C++...
2020-02-22 15_45_22-Factorio 0.18.8.png
2020-02-22 15_45_22-Factorio 0.18.8.png (118.19 KiB) Viewed 1735 times
Don't forget, you're here forever.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14311
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Retrieve and modify the tab container of tabbed panes

Post by Rseding91 »

That's... kind of not possible. The character GUI isn't even finished and the way it currently does that logic mods would never be able to do through the Lua API. You could try to do it yourself and see all the issues you'll run into.
If you want to get ahold of me I'm almost always on Discord.
User avatar
raiguard
Factorio Staff
Factorio Staff
Posts: 579
Joined: Wed Dec 13, 2017 8:29 pm
Contact:

Re: Retrieve and modify the tab container of tabbed panes

Post by raiguard »

Yeah, I actually tried doing this myself first, but ran into issues almost immediately that I didn't know how to solve. That's why I put it on here.

I have discovered a partial workaround: I found out recently that you can actually add elements to buttons and tabs, just like any other element. So I created a tab and put stuff in it:
2020-02-23 10_58_14-Window.png
2020-02-23 10_58_14-Window.png (69.19 KiB) Viewed 1667 times
However, as you can see, there are a few issues. First, only the active tab can draw "over" the pane. Second, the close button's shadow isn't drawn, or is probably hidden behind the tab itself.

Additionally, using horizontally_stretchable on the tab doesn't appear to work, so I had to hardcode the width.

If a method to force the tab to "draw over" even when inactive were implemented, and if the shadow layering could be fixed, then this could work!
Don't forget, you're here forever.
User avatar
raiguard
Factorio Staff
Factorio Staff
Posts: 579
Joined: Wed Dec 13, 2017 8:29 pm
Contact:

Re: Retrieve and modify the tab container of tabbed panes

Post by raiguard »

Well, after doing some really janky crap, I managed to make it work. And it actually doesn't look half bad!

2020-02-24 21_49_14-Window.png
2020-02-24 21_49_14-Window.png (91.97 KiB) Viewed 1609 times
What I did was remove the top border on the content pane so it seamlessly transitions into the top. Then I modified the inactive tab styles to draw the top of the frame as their glow, so it looks almost like it's an actual feature of the engine...

I still have to hardcode the width of the drag handle and the frame itself, because the tab doesn't expand when you use horizontally_stretchable on it. I'll probably make a PR to fix that.

This can be moved to "won't implement" now. :D
Don't forget, you're here forever.
Post Reply

Return to “Modding interface requests”