Recent Posts

Pages: 1 [2] 3 4 ... 10
11
Help requests / Re: listView and symbols
« Last post by che2a on 29 May 2020, 09:03:23 »
Yes, now it work
You teach me a good thing today :)

Thank you
12
Help requests / Re: listView and symbols
« Last post by texus on 28 May 2020, 18:34:58 »
Using widestrings will require you to store the value in a std::wstring or sf::String immediately, so your code where you add it to the return of std::to_string won't compile.
You could use u8"\u20AC" if you want to store it in an std::string (but your code wouldn't work when compiling with c++20 or higher because that would return an std::u8string instead).
So the best option would probably be to put it in an sf::String immediately:
sf::String str_annual_wages = std::to_string(drivers_vector[i]->contract->getAnnualWages()) + sf::String(L"\u20AC");
13
Help requests / Re: listView and symbols
« Last post by texus on 28 May 2020, 18:27:49 »
Unless you are an organization with more than 5 users, Visual Studio has a free community version.

Maybe you should try L"\u20AC".
Having unicode characters in your code can be tricky, because it will require the cpp files to have the right encoding (and your code thus won't compile if someone uses a different file encoding), so it might be better just to use the hex code instead.
14
Help requests / Re: listView and symbols
« Last post by che2a on 28 May 2020, 18:05:12 »
I use Codeblocks , it never worked for me to use wide strings with L"€"

I tried to change editor encoding settings but impossible i always have an error during the compilation

I would like to use visual studio but is not free...

15
Help requests / Re: listView and symbols
« Last post by Kvaz1r on 28 May 2020, 17:50:08 »
Do you use unicode character set in your project?
About the “Character set” option in Visual Studio
16
Help requests / Re: listView and symbols
« Last post by che2a on 28 May 2020, 17:18:22 »
Thank you but when i use L"€"
I have error : converting to execution character set : Illegal byte sequence

When i use this symbol in sf::Text it is displayed correctly
17
Help requests / Re: listView and symbols
« Last post by Kvaz1r on 28 May 2020, 16:59:34 »
It has nothing to do with ListView.
Use wide string for any non-Ascii symbols:

Code: [Select]
#include <TGUI/TGUI.hpp>

class MyFrame
{
public:
    MyFrame()
    {
        window.create(sf::VideoMode(800, 600), "MCVE");
        gui.setTarget(window);

        auto listView = tgui::ListView::create();
        listView->setSize(window.getSize().x, window.getSize().y);

        listView->addColumn(L"Key");
        listView->addColumn(L"Value");
        sf::String test = "test";
        test += L"€";
        listView->addItem({"0" ,test});

        gui.add(listView);
    }
    void main()
    {
        while (window.isOpen())
        {
            sf::Event event;
            while (window.pollEvent(event))
            {
                if (event.type == sf::Event::Closed)
                    window.close();
                gui.handleEvent(event);
            }
            window.clear();
            gui.draw();
            window.display();
        }
    }
    sf::RenderWindow window;
    tgui::Gui gui;
};

int main()
{
    MyFrame().main();
}
18
Help requests / [solved] listView and symbols
« Last post by che2a on 28 May 2020, 16:01:11 »
Hello, the ListView widget does not display the € symbol

I tried with sf::String::FromUtf8 and utf16 but it not works

How i can display symbols ?

Thank you

str_annual_wages = std::to_string(drivers_vector[i]->contract->getAnnualWages()) + "€";

vect.push_back(sf::String::fromUtf8(str_annual_wages.begin(), str_annual_wages.end()));

// This is a part of my code, i use vectors to fill the listview columns

 
19
Help requests / Re: SFML drawing into a child window
« Last post by texus on 27 May 2020, 18:31:03 »
I would just treat the Canvas as you previously treated the RenderWindow: change your draw_channel function to
void Channel::draw_channel(tgui::Canvas::Ptr &canvas,uint16_t x,uint16_t y)
and replace "window.draw" with "canvas->draw" inside the function.

Pre-rendering to a RenderTexture first is going to be marginally slower since you would be doing an extra draw call. If you would use a RenderTexture then you would also have to create it somewhere. Creating it is a "slow" operation, so you wouldn't want to use a single RenderTexture for each Channel object. You would end up with a single RenderTexture that you create once and pass around everywhere in your code, but that is exactly what you would do when you just pass the Canvas everywhere (Canvas is nothing more than a widget containing a RenderTexture).

Making a sprite in the class is the same option as creating a RenderTexture. You can't draw things to a sprite and you can't draw a RenderTexture to the canvas, you need both the RenderTexture and Sprite to make a drawing buffer. The only way to use RenderTexture and Sprite is to create a RenderTexture, draw on that render texture, create a sprite from the texture and drawing the sprite to the canvas. But again, that is just doubling the effort as this is what Canvas already does (it creates a RenderTexture, lets you draw on it with the clear(), draw() and display() function, creates a sprite from the texture and later draws that sprite to the window).

Whether your object should contain a draw function so that it can draw itself, or whether you have the rendering code outside the object is a design decision that might depend on how the code is used. But you actually already made this design decision. When drawing to the RenderWindow, you chose to keep the drawing code inside the Channel object, so there is no reason why you would suddenly do it another way just because you need to render to a canvas.
20
Help requests / Re: SFML drawing into a child window
« Last post by Kvaz1r on 27 May 2020, 15:09:41 »
Yes, it exactly the reason, thank you.
Pages: 1 [2] 3 4 ... 10