Is is possible to set the text style in a Label ?
« on: 25 January 2015, 01:02:52 »
I've set the text to a label, but I'd like to say add an underline or make it bold, i.e. the stuff can be set with sf::Text test.setStyle();
I've tried the below but obviously it says that m_text isn't accessible.

LabelList->m_Text.setStyle(sf::Text::Underlined);
 

So I tried the below, where i define the sf::Text string and style. However I get a cannot convert parameter error.

        tgui::Label::Ptr LabelList;
        sf::Text str;

        str.setString("Global Nation Treasury");
        str.setStyle(sf::Text::Underlined);
        LabelList->setText(str);

Error   17      error C2664: 'tgui::Label::setText' : cannot convert parameter 1 from 'sf::Text' to 'const sf::String &'
 

PS. Sorry for all of the posts recently - I really hope that I'm not asking obvious things here. I did try to search the forums beforehand.
« Last Edit: 25 January 2015, 01:05:05 by starkhorn »

*

texus

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: Is is possible to set the text style in a Label ?
« Reply #1 on: 25 January 2015, 01:06:12 »
It is not possible. You should draw an sf::Text yourself to have more advanced features like bold and underline.

Or you can cheat, put the following before including tgui and use m_Text anyway :). But that's probably not what you want.
#define private public
#define protected public

Edit: I'll think about adding a setStyle function in the future. But I would have to test what the effect would be (since it might break stuff like word-wrap).
« Last Edit: 25 January 2015, 01:08:50 by texus »

*

texus

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: Is is possible to set the text style in a Label ?
« Reply #2 on: 27 January 2015, 15:08:58 »
I just realized that word-wrap was only added in v0.7-dev, so there is actually nothing that stops me from adding such style in v0.6 right away.

The latest version on the master branch now has setTextStyle and getTextStyle functions.