Main Menu
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - texus

#1476
Then you might have the dll from the wrong MinGW version.

You should check which compiler is being used to compile tgui and your project.
In CMake check the 'Advanced' option and have a look at which compiler is being used.
Also have a look at you codeblocks settings and look at which compiler it uses.
These should be the same folder, and it has to be the folder from where you copied the libstdc++-6.dll from.

Also, what happens if you don't put that dll next to the exe?
#1477
Did you by any chance copy libstdc++-6.dll next to your executable? (I think I've seen this problem before when someone copied the wrong libstdc++-6.dll next to its program)

Do you have multiple MinGW compilers on your pc?
#1478
Help requests / Re: MenuBar Item bindCallback
29 March 2014, 15:42:30
Quote from: Strikerklm96 on 29 March 2014, 15:22:36
menu->bindCallbackEx(std::bind(&MyClass::function, &mc), tgui::MenuBar::MenuItemClicked);
Doesn't work. Gives errors in "functional" file.
I changed the code a few times while writing the post, I must have overlooked that line. The function that bindCallbackEx needs has the Callback parameter, so it should have been
menu->bindCallbackEx(std::bind(&MyClass::function, std::placeholders::_1, &mc), tgui::MenuBar::MenuItemClicked);

Quote from: Strikerklm96 on 29 March 2014, 15:22:36
I looked at the documentation of TGUI though, and realized this:
menu->bindCallbackEx(&MyClass::function, &mc, tgui::MenuBar::MenuItemClicked);
does work
This function was added to just call the other one with the std::bind as parameter. Its just a shortcut so that you don't need to use std::bind and std::placeholders yourself.

Quote from: Strikerklm96 on 29 March 2014, 15:22:36I don't really understand what bind does though, and I have never learned this lambda stuff (is it something I should know?)
Bind is less important. It just binds a parameter to a function, so that where the function is stored it has no idea about the extra parameters, but they will be there when the function is called. Due to the way c++ works behind the scenes you need this for member functions as they actually have 'this' as argument.

But lambda functions are more important, they allow you to write nameless functions.
Here is a simple use case: the button will hide itself when it is clicked.
button->bindCallback([=](){ button->hide(); }, tgui::Button::LeftMouseClicked);

It replaces the following code:

void function()
{
    // Assuming that this function somehow manages to access the button,
    // which the lambda function could do without problems as it was in the correct scope
    button->hide();
}

button->bindCallback(function, tgui::Button::LeftMouseClicked);


Using lambda functions really starts to pay off when you need a simple functor (e.g. as last parameter in std::remove_if).

But in the end, you can perfectly work without them. But they may be interesting to look at someday.
#1479
Help requests / Re: MenuBar Item bindCallback
29 March 2014, 10:25:16
You will have to bind your own function that handles which item has been clicked.

The example becomes a little bit harder as the function needs to have access to the window, which is only possible if they are in the same class.
class MyClass
{
public:
    void function(const tgui::Callback& callback);
    sf::RenderWindow window;
}

void MyClass::function(const tgui::Callback& callback)
{
    if (callback.text == "Exit")
        window.close();
    /* else ... */
}

MyClass mc;
menu->bindCallbackEx(std::bind(&MyClass::function, &mc), tgui::MenuBar::MenuItemClicked);


You can also give the function the window as parameter, but then of course it will also have this window parameter even when you aren't handing the "Exit" callback.
void function(const tgui::Callback& callback, sf::RenderWindow& window)
{
    if (callback.text == "Exit")
        window.close();
}

menu->bindCallbackEx(std::bind(function, std::placeholders::_1, std::ref(window)), tgui::MenuBar::MenuItemClicked);


I guess the lambda function would perhaps be a little too long in this case:
menu->bindCallbackEx(std::bind([&](const tgui::Callback& callback, sf::RenderWindow& window) { if (callback.text == "Exit") window.close(); }, std::placeholders::_1, std::ref(window)), tgui::MenuBar::MenuItemClicked);

But I'm afraid that there is no bindCallback function to bind to a specific menu item being clicked. These bindCallback functions are inherited from a base class, and are not specific to the widget.

In the Callback struct, you will have the 'text' member as you can see in the above examples. You can also use the 'index'. This will be 0 for all the menu items in the "File" menu, but if you would also add an "Edit" menu then a callback from there would have index 1.

The callback system is complex, so make sure to read the tutorial and experiment a bit with it.
#1480
Help requests / Re: Troubles with callbacks
28 March 2014, 18:17:19
Neither of the 3 options are correct.
The compiler has to know which function (which is what you pass in your codes), but it also should know on which object it should call this function. So the correct line becomes:
myButton->bindCallbackEx(&MyClass::CallbackFunction, &myClassInstance, tgui::Button::LeftMouseClicked);

Actually that line is just shorthand for the following code:
myButton->bindCallbackEx(std::bind(&MyClass::CallbackFunction, &myClassInstance), tgui::Button::LeftMouseClicked);

When the code is called inside the class fom which you want to call the function, then "&myClassInstance" is just "this".
#1481
Help requests / Re: Troubles with callbacks
28 March 2014, 17:35:58
You can give the buttons an id to identify them.

void callbackFunction(const Callback& callback)
{
   // callback.id will be either 0 or 1 or ... or _worlds.size()-1
}

for(int i=0;i<_worlds.size();i++)
{
    /* ... */
    button->setCallbackId(i);
    button->bindCallbackEx(callbackFunction, tgui::Button::LeftMouseClicked);
    /* ... */
}


The std::bind method is for when you want you callback function to have a parameter other than the Callback struct.

QuoteI don't even know if my way to is good.
It looks good to me.
#1482
I've looked into it, but there doesn't seem to be an easy way to add this.
Loading widgets from a file is still something that is far from being perfect, but I can't immediately do much about it.

I'm afraid you will have to solve it in your c++ code. (GridName, ButtonName1 and ButtonName2 are the names of the widgets in the file)

tgui::Grid::Ptr grid = gui.get("GridName");
grid->addWidget(grid.get("ButtonName1"), 1, 2);
grid->addWidget(grid.get("ButtonName2"), 2, 0);


But of course doing that for all widgets might be a bit long and requires a bit too much hardcoding. So maybe you can do it in another way, using the knowledge that the widgets in the grid are in the same order as they are defined in the file. When you e.g. have a 3x4 grid you can do this:

tgui::Grid::Ptr grid = gui.get("GridName");
auto& widgets = grid.getWidgets();
for (unsigned int row = 0; row < 3; ++row) {
    for (unsigned int col = 0; col < 4; ++col) {
        grid->addWidget(widgets[row*4 + col], row, col);
    }
}


(Codes were written without testing)
#1483
It seems to work fine here.
If you can't solve the problem then you can send me the .cbp file and maybe I can find a mistake in it.
#1484
Thats really strange.

Are you sure that you are using the sfml libraries included in the tgui download?
Are you linking statically or dynamically, in debug or release mode?
You are using MinGW 4.7.1, right?

I'll try it on my windows as well and see if I can reproduce the problem.
#1485
QuoteI actually don't see any of the "extlibs" "mingw" "x68" or "freetype.a" keywords that you used as an example.
It is included with the SFML download, but maybe it isn't installed.

QuoteI thought the precompiled tgui libraries wouldn't include a static version like I needed.
Not only does it include the static versions, it also includes a copy of the sfml extlibs folder (since v0.6.2).
#1486
When linking statically, sfml now forces you to link to its dependencies yourself.

You can solve your problem by changing the FREETYPE_LIBRARY property to "H:/Program Files/SFML/extlibs/mingw/x68/freetype.a" (or something like that). Same for GLEW_LIBRARY and FREETYPE_LIBRARY.

But what tgui version are u using? I tried to make tgui automatically find these extlibs in v0.6.1. Maybe my fix is no longer working?

Also make sure not to change any properties after pressing 'configure'. Otherwise it might find the dynamic sfml libraries first and no longer look for the static ones when changing TGUI_SHARED_LIB. Always have the options correct before you press configure. And then when it gives you errors and more properties to fill in, only adjust the new ones and don't touch the old ones.
Try deleting the cache if you mess up somewhere.

Any reason why you are not using the precompiled tgui libraries? (if you are using mingw 4.8 then you would have a valid reason).
#1487
Help requests / Re: Loading Options
24 March 2014, 08:50:17
To place files and images inside your exe you can use 'resources', but this is not supported yet in tgui. This is also a windows-only thing, which is not cross-platform at all.
#1488
QuoteOn a side note, can I ask you if you plan on implementing a cross-plattform clipboard support that let's you paste text into tgui from the OS' clipboard ? (Copying text from another program and pasting it into tgui)
I originally wanted to implement the clipboard like that, but it was too hard on linux. It works with events, which are handled by sfml and would thus be hard to intercept.
It would be doable on windows, and I am considering adding this feature and make it windows only (even though I kindof hate windows). I haven't looked at mac yet, so maybe I can support it on mac too, but most likely it will involve objective-c code.

Basically I'm not really thrilled to start working on it, there are other features that currently have priority.
#1489
If you don't need to copy & paste then you can use the ChatBox widget (which allows different text colors). In the future it is even the goal to allow you to select text inside it and allow copy & pasting. So once this is done, what you are requesting would no longer be needed.

But I will have a look later today if the TextBox can be made read-only easily. If it isn't too hard to do then I'll make the change, as having a selectable ChatBox is something you won't see in the near future.
#1490
Help requests / Re: String/letters label
17 March 2014, 18:54:50
I can reproduce the problem with SFML 2.1, but not with the github version.

Something must have changed in sf::Text since sfml 2.1 I guess, because sfml 2.1 seems to mess up the clipping calculations in TGUI.

Edit: according to this commit, the problem was introduced in sfml 2.1, and fixed afterwards.
#1491
Help requests / Re: String/letters label
17 March 2014, 16:58:59
I don't even think anything changed in Label between v0.6.1 and v0.6.2.

I can't reproduce it (on linux). Could you show some small program for which it doesn't work for you?
#1492
Help requests / Re: window flickering in macOs
16 March 2014, 12:44:40
Quotei checked shared_libs and build frameworks in cmake and compiled it
I don't even think that I compiled sfml myself. I just downloaded sfml 2.1 and used the install.sh script. (after running the install script you should install the correct template for xcode 5, because it installs the old template).

Edit: Ignore this post, I hadn't seen your edit yet
#1493
Help requests / Re: window flickering in macOs
16 March 2014, 12:34:12
Its been a while since I installed sfml on my mac.

Did you download the "Templates for Xcode 5" from the sfml download page?

Quoteclang: error: unknown argument: '-frameworksfml-system' [-Wunused-command-line-argument-hard-error-in-future]
I think the mistake is just that there should be a space, so it should be  '-framework sfml-system'.
#1494
Help requests / Re: window flickering in macOs
15 March 2014, 14:42:24
Ok, I get the flickering too now.

So for some reason you will have to use the sfml framework with tgui, not the dylibs. This might be because the tgui libraries are compiled against the sfml framework.

But I don't have time to look into this in detail right now, so I'll just add a notice in the tutorial about this.
#1495
Help requests / Re: window flickering in macOs
15 March 2014, 14:35:52
I just let it use frameworks and then only add -ltgui myself.

I'll have a look at what happens when I use dylibs.
#1496
Help requests / Re: window flickering in macOs
15 March 2014, 14:21:36
What exactly do you mean with "window flickering"?

I just tested and I didn't have any problems. I didn't even get that terminal output.

I only changed a few things, as your code didn't work out-of-the-box.
picture->load("Data/Backgrounds/loginBackground.tex");
First of all, I used the cute_image.jpg as image instead (as you didn't provide that tex file).
But I had to write the following, becuase otherwise it wouldn't search for it in the correct directory:
picture->load(resourcePath() + "cute_image.jpg");
Same thing for the other load functions.

Did you use the sfml template for your xcode project?


Edit:
I didn't really look close enough at the console output when writing the post.
It looks like you are linking to both the dylibs and the framework of sfml.
#1497
Help requests / Re: Renderwindow Exceptions
14 March 2014, 14:56:50
I was afraid you were going to answer that.

Could you send me your visual studio project so that I can test it here? (upload it or dropbox or some similar place)
#1498
Help requests / Re: Renderwindow Exceptions
14 March 2014, 14:26:34
A few things to check:
Are you sure you are using the SFML libraries that are included with the TGUI download?
Are you sure that you are linking to the correct libraries (debug libs in debug mode, release libs in release mode)?
Are you sure you downloaded the VS2012 version?
#1499
Help requests / Re: Internal Button Events
13 March 2014, 18:26:31
QuoteIs there anywhere else I could have known that's the purpose of a Panel class? The documentation just says its a container for widgets.
Well, "a container for widgets" is exactly what you need. In the end, the Gui class itself is not much more than a container. But I understand that when you are looking to implement different screens that this isn't what you think about.

Quoteyou should put it in the doc maybe?
My biggest limitation is always the lack of time. There was a tutorial for v0.5 (https://tgui.weebly.com/v05---panel.html), but just like many tutorials it hasn't been ported to v0.6 yet. But I might add a tutorial for panel to the site when I find some more time.

Edit: I managed to find some time: https://tgui.eu/tutorials/v06/panel/

QuoteAnd how should tabs be utilized? Enabling and disabling panels?
I actually have some example code of how to use tabs and panels together: https://tgui.eu/tutorials/v06/tabs/

QuoteSorry if these are stupid questions, but for someone like me who has never really dealt with GUI before, I tend to try and solve problems that already have a designated solution, like the Panel,  and or I don't understand how the design is intended to work.
There not stupid questions, most things are just underdocumented. And its always harder to use code that someone else wrote, because if you would write it yourself then you would probably do it differently in a way that makes more sense to you.
#1500
Help requests / Re: Internal Button Events
13 March 2014, 14:19:11
QuoteWhat is the intended way to have multiple GUI's in existence at the same time?
I dont have much time to give a detailed answer right now, but you should have a look at the Panel.
You can create multiple panels and then just hide the once that you don't want to show. Using multiple Gui objects is not a good idea because you will have to pass the events to the right one and draw the right one. With panels you just use the show and hide functions and you don't need to change anything about the handleEvent or draw functions.