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

Tabs' set_min_width() doesn't seem to be effective #31238

Closed
Calinou opened this issue Aug 9, 2019 · 5 comments · Fixed by #47491
Closed

Tabs' set_min_width() doesn't seem to be effective #31238

Calinou opened this issue Aug 9, 2019 · 5 comments · Fixed by #47491

Comments

@Calinou
Copy link
Member

Calinou commented Aug 9, 2019

Godot version: 7bb2215

OS/device including version: Fedora 30

Issue description: Changing a Tabs node's minimum width using set_min_width doesn't seem to do anything, at least in the context of the editor scene tabs. I could confirm that the value is being changed internally by printing it, so the issue must be elsewhere.

I also noticed that the setter/getter isn't exposed to GDScript. I tried exposing them out of curiosity, but that didn't solve the issue.

Steps to reproduce: Go to the Editor Settings, change Interface > Scene Tabs > Minimum Width to a value like 200 then restart the editor.

@codecustard
Copy link
Contributor

codecustard commented Aug 10, 2019

After looking at the source and doing some tests, it seems the way that it was implemented, the minimum width is misleading. The tabs are basically sized big enough to fit the entire text of the tab. Minimum width only starts to take effect when you have so many tabs open. Basically it's the width of the minimized (non-current) tabs when you have a large number of tabs open.

This is the code I was looking at:

godot/scene/gui/tabs.cpp

Lines 577 to 596 in 02319dc

if (min_width > 0 && mw > limit && i != current) {
if (lsize > m_width) {
slen = m_width - (sb->get_margin(MARGIN_LEFT) + sb->get_margin(MARGIN_RIGHT));
if (tabs[i].icon.is_valid()) {
slen -= tabs[i].icon->get_width();
slen -= get_constant("hseparation");
}
if (cb_displaypolicy == CLOSE_BUTTON_SHOW_ALWAYS || (cb_displaypolicy == CLOSE_BUTTON_SHOW_ACTIVE_ONLY && i == current)) {
Ref<Texture> cb = get_icon("close");
slen -= cb->get_width();
slen -= get_constant("hseparation");
}
slen = MAX(slen, 1);
lsize = m_width;
}
}
tabs.write[i].ofs_cache = w;
tabs.write[i].size_cache = lsize;
tabs.write[i].size_text = slen;
w += lsize;

I've also noticed that the "Resize if many tabs" option doesn't seem to do anything as it will always resize the tabs regardless of this option.

I'm not sure which is better, perhaps renaming the setting to get the point across better? Something like: "Minimized Width w/ Many Tabs" Or maybe change the functionality so that you can adjust the minimum size of the tab the way this issue suggests, which I think would kinda introduce more problems because in the context of few tabs, it is useful... but when you have alot of tabs... the way that it works at the moment seems to be more useful because with few tabs, it's a pretty pointless setting when the editor already adjusts the tab size to fit the full text and a minimum size for a tab with few text takes up screen real estate.

@Calinou
Copy link
Member Author

Calinou commented Aug 10, 2019

Or maybe change the functionality so that you can adjust the minimum size of the tab the way this issue suggests, which I think would kinda introduce more problems because in the context of few tabs, it is useful... but when you have alot of tabs... the way that it works at the moment seems to be more useful because with few tabs, it's a pretty pointless setting when the editor already adjusts the tab size to fit the full text and a minimum size for a tab with few text takes up screen real estate.

I think having wider tabs makes for better usability when you only have a few of them, as they're easier to click 🙂

This would make the behavior similar to Web browsers: tabs start fairly wide and become more narrow as you open more of them.

@Anutrix
Copy link
Contributor

Anutrix commented Aug 11, 2019

Or maybe change the functionality so that you can adjust the minimum size of the tab the way this issue suggests, which I think would kinda introduce more problems because in the context of few tabs, it is useful... but when you have alot of tabs... the way that it works at the moment seems to be more useful because with few tabs, it's a pretty pointless setting when the editor already adjusts the tab size to fit the full text and a minimum size for a tab with few text takes up screen real estate.

I think having wider tabs makes for better usability when you only have a few of them, as they're easier to click 🙂

This would make the behavior similar to Web browsers: tabs start fairly wide and become more narrow as you open more of them.

How much is fairly wide? 15% or 20% of total row width?

@Calinou
Copy link
Member Author

Calinou commented Aug 11, 2019

How much is fairly wide? 15% or 20% of total row width?

That seems to be roughly it, judging by how Chromium and Firefox do it.

@KoBeWi
Copy link
Member

KoBeWi commented Nov 18, 2020

Looks still valid in 3.2.4 beta2

Maybe we should just remove it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants