Text offset in Tabs
« on: 30 September 2015, 21:14:23 »
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:
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);
« Last Edit: 30 September 2015, 21:16:34 by Myster »

*

texus

  • *****
  • 1161
    • View Profile
    • Texus's Blog
Re: Text offset in Tabs
« Reply #1 on: 01 October 2015, 10:56:15 »
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

  • *****
  • 1161
    • View Profile
    • Texus's Blog
Re: Text offset in Tabs
« Reply #2 on: 01 October 2015, 11:19:03 »
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:
winEditConfigTabs = theme->load("tab");
winEditConfig->add(winEditConfigTabs);
winEditConfigTabs->setTextSize(text_size);
...

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

Re: Text offset in Tabs
« Reply #3 on: 03 October 2015, 14:08:05 »
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:
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:
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

  • *****
  • 1161
    • View Profile
    • Texus's Blog
Re: Text offset in Tabs
« Reply #4 on: 03 October 2015, 14:35:35 »
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

  • *****
  • 1161
    • View Profile
    • Texus's Blog
Re: Text offset in Tabs
« Reply #5 on: 05 October 2015, 16:02:59 »
The bug has been fixed, the latest tgui version will now always give the second result.