Text offset in Tabs

Started by Myster, 30 September 2015, 21:14:23

Myster

Hello again)

In the last version of TGUI v0.7-alpha2 in my app strange problem appeared:
text on the tabs displaying above the tabs (see the screenshot: texts "View" and "Export" now between buttons and checkbox)

In prev. TGUI versions all was good.
Where my mistake? may be I overlooked something from new docs about tabs? :-\

My code:
Code (cpp) Select
winEditConfigTabs = theme->load("tab");
winEditConfigTabs->setTextSize(text_size);
winEditConfigTabs->setPosition(8, 60);
winEditConfigTabs->add(txt_tab_view);
winEditConfigTabs->add(txt_tab_export,false);
winEditConfigTabs->connect("TabSelected", [&](){ ConfigWinUpdate(); } );
winEditConfig->add(winEditConfigTabs);

texus

Apparently Tab was not tested with a custom text size. It should work when you remove the setTextSize call.
I'll see if I can find where it goes wrong in my code.

texus

The problem was that Tab.setFont (which gets called during winEditConfig->add) did not reposition the text.

To work around the issue with your tgui version you can just move that line before all the others:
Code (cpp) Select
winEditConfigTabs = theme->load("tab");
winEditConfig->add(winEditConfigTabs);
winEditConfigTabs->setTextSize(text_size);
...


Or you could download the latest tgui version and compile it with CMake.

Myster

Sorry for delay, I was ill.
It works) Thanks, texus)

But there was a difference (which gives programmers to choose between the stretchable/unstretchable tabs)

1st is:
Code (cpp) Select
winEditConfigTabs = theme->load("tab");
winEditConfigTabs->setTextSize(text_size);
winEditConfigTabs->setPosition(8, 60);
winEditConfigTabs->add(txt_tab_view);
winEditConfigTabs->add(txt_tab_export,false);
winEditConfigTabs->connect("TabSelected", [&](){ ConfigWinUpdate(); } );
winEditConfig->add(winEditConfigTabs); // <==


2nd is:
Code (cpp) Select
winEditConfigTabs = theme->load("tab");
winEditConfig->add(winEditConfigTabs); // <==
winEditConfigTabs->setTextSize(text_size);
winEditConfigTabs->setPosition(8, 60);
winEditConfigTabs->add(txt_tab_view);
winEditConfigTabs->add(txt_tab_export,false);
winEditConfigTabs->connect("TabSelected", [&](){ ConfigWinUpdate(); } );


But I don't know whether to give programmers a choice (?) because stretchable tabs are most commonly used ::)

texus

The first one is another bug, the second one is the only correct outcome. I want to make fixed sizes possible in the future but it is not supported yet.

texus

The bug has been fixed, the latest tgui version will now always give the second result.