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

#1501
Help requests / Re: Internal Button Events
13 March 2014, 10:14:39
I wouldn't know any good way either, I guess you'll just have to keep differentiating the classes with 'Button' and 'tgui::Button'.

But what you are doing looks really interesting.
#1502
Help requests / Re: Internal Button Events
12 March 2014, 22:12:00
QuoteAs for the Observer Pattern, that's essentially what I'm doing right?
Yes, but it was hard to tell with seeing little code.

QuoteAlso, any recommendations for how to name my stuff? Because I plan to do this with all the types: Buttons, Sliders, ect. And I thought I should put some sort of differentiation between my Buttons and the tgui buttons. The namespace solves it, but still.
I don't really see why you would need all these classes.
What is it that you have to add to all my widgets? If it is only the send function then you can just as well bind the receive function of the target immediately.

Depending on what you are planning to do with the widgets, you can write one class for all widgets instead of one for button, one for edit box, ...
class MyWidget : public IOBase
{
    MyWidget(tgui::Widget::Ptr widget) :
        m_widget(widget)
    {
    }

    tgui::Widget::Ptr m_widget;
}

MyWidget myWidget{ tgui::Button::Ptr(gui) };


A class like above could take any widget, depending on what you pass in the constructor. But it is of course only usefull if you don't need different behavior for every different widget.
#1503
Help requests / Re: String/letters label
12 March 2014, 17:44:51
QuoteWhy does label cut letters underline like in the picture in attachment?
I've fixed this bug a couple of times, but it seems like it always comes back. Are you using TGUI v0.6.1 or the version from github? I actually can't reproduce it with either version.

QuoteAnd how to place a picture as a button?
Just use tgui::Picture::Ptr. You can also bind a click callback to it.

QuoteIs it possible, and if it is, how to, place an url as a label?
Do you just mean a clickable text? You can just let it send a callback when you click on the label and then handle the click yourself.
#1504
Help requests / Re: Internal Button Events
12 March 2014, 10:35:39
QuoteIs this the BEST way for my button to accomplish that? I know I can do it using callBackId() but I think that's worse.
First of all, there is no best way. But binding callback is indeed much better than polling from the gui.

Quoteclass myButton :  public IOBase, public tgui::Button //<---should that be tgui::Button::Ptr????
I don't even think that inheriting from tgui::Button::Ptr is an option. Although it might compile, it probably won't do what you expect.
If you choose to inherit from tgui::Button, then you should also add the following line in your class:
typedef SharedWidgetPtr<myButton> Ptr;
This will allow you to later create the object with
myButton::Ptr button(gui);

But I don't think you should inherit from tgui::Button. You should only inherit from it when you want to extend its functionality, and that isn't really what you are doing. Composition is probably a better solution.

But of course I don't know the full situation so I can't really tell you which design you should use. I would just go with a design that you find good and learn from the mistakes. If you later find out that you had certain limitations due to your design then next time you will think about these cases when you write another program.

It will probably be different in your real code, but from the small code you showed you can put the contents of the send function in IOBase and you don't need to override it.

And if you haven't already, take a look at the Observer Pattern. It is used a lot for message systems.

Btw, I would recommend making your class names start with a capital letter, to avoid confusion.


I know that my post contained mainly bad critics but that doesn't mean that what you have come up with is that bad. Inheriting from a base class like your IOBase is probably the way to go, its just the way you do this that could possibly still be improved.


QuoteI would also like to say that this https://github.com/texus/TGUI/blob/master/examples/FullExample/FullExample.cpp, or something like it should be linked in the tutorials. Examples are the most useful thing in the world, and the tutorial only goes over a few things.
I'll add a link at the bottom of the tutorial to both the documentation and the example code.
But my site already contains the example code btw (https://tgui.eu/example-code/v06/).
#1505
It seems like these are just warnings. And they are in a apple library that the form builder uses, so I can't do much about them.

But the form builder won't start, it doesn't even give an error, so I might have to look into this.
I forgot that the form builder doesn't work on mac when the install target isn't build.
#1506
I got my hands on XCode 5.1 Developer Preview 2. The bug indeed seems to be fixed.
So I guess I just have to wait until XCode 5.1 gets released.

The compilation now also seems to fail because I am missing "#include <cmath>" in two files, but I've fixed that on github so you download the latest sources from there.

I also tried installing gcc, but I didn't get it to work.
#1507
This indeed seems to be the same problem as in the other topic.

As far as I know, this is a regression bug in clang.
It works fine on OS X Mountain Lion (llvm 3.2), it works fine on Linux with clang 3.4, it just doesn't work on OS X Mavericks (llvm 3.3).

I'm not even sure where to report the bug. I have no idea whether the bug is in official clang 3.3 or in the apple 5.0 version. And I don't really have the time to figure that out.

I've been hoping that the bug would be fixed automatically with an XCode update, but I'm starting to lose hope for that.
#1508
You should bind a callback to the slider to get notified about changed.
This can be done in different ways so make sure to read the callback tutorial.

Here is an (untested) example.
#include <TGUI/TGUI.hpp>

void sliderValueChanged(const tgui::Callback& callback)
{
    std::cout << "Value is: " << callback.value << std::endl;
}

int main()
{
    sf::RenderWindow window{sf::VideoMode{800, 600}, "TGUI window"};
    tgui::Gui gui(window);
    gui.setGlobalFont("TGUI/fonts/DejaVuSans.ttf");

    tgui::Slider::Ptr slider(gui);
    slider->load("TGUI/widgets/Black.conf");
    slider->setVerticalScroll(false);
    slider->setPosition(50, 50);
    slider->setSize(250, 25);

    std::cout << "Value is: " << slider->getValue() << std::endl;

    // Call the sliderValueChanged function when the value of the slider is changed
    slider->bindCallbackEx(sliderValueChanged, tgui::Slider::ValueChanged);

    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();
    }

    return 0;
}
#1509
I didn't entirely understood the question.
Are you asking for a way to get notified when the value changed, or are you saying that getValue always returns the same value even when moving the thumb of the slider?

Quoteside question: which one should i use as slider for music volume? slider2d or slider?
The normal slider. The 2d version is more for something like a color palette.
#1510
One possibility would be that you are mixing SJLJ and DW2 versions of your compiler.
Do you have a MinGW version installed on your pc, other than the one that came with codeblocks?

QuoteI have coped the libstdc++6 lib to the project folder from the mingw bin and this error appears.
I'm not sure what you are trying to accomplish with this.
If the program isn't running on your own pc without copying this dll then your compiler may be corrupted.
You are talking about the mingw bin folder, this is "C:\Program Files (x86)\CodeBlocks\MinGW\bin\" right?
What error do you get if you do not copy this file?

Quotesfml 2.1 is working fine by its own
The precompiled TGUI download also contains SFML libraries. When using TGUI, make sure you use these libraries.
#1511
The one on the download page should work.
Download TGUI v0.6.1 with precompiled MinGW 4.7 TDM (SJLJ) 32-bit libraries

If its not working then you should let me know what goes wrong. It should work for the MinGW 4.7 that comes with CodeBlocks.
But make sure to use the included sfml libraries instead of sfml 2.1.
#1512
QuoteCMake Error at cmake/Config.cmake:13 (message):
  Unsupported architecture
This config file is directly copied from sfml, so I doubt it is going to contain any mistakes.
Maybe you should check if you can build sfml?

Is there a reason why you need to build tgui yourself? Because there is a precompiled version available for your compiler.
#1513
Installation help / Re: Missing MSVCP120D.dll
17 February 2014, 09:44:53
QuoteThe tutorial from the site says the path is:
TGUI/widgets/Button/Black
Which page on my site says that?
Is it possible that you are looking at a tutorial for TGUI v0.5 instead of v0.6? A lot has changed between these versions.

QuoteIn my console prompt it reads:
TGUI error: Failed to parse TGUI/widgets/Black.png
It took my a moment to realize what is wrong with this. You need to load a config file, not an image. The config file will tell tgui which images to load and which parts of the images should be shown. So you have to load "TGUI/widgets/Black.conf" instead.

Make sure to follow these introduction tutorials: https://tgui.eu/tutorials/v06/.
#1514
Installation help / Re: Missing MSVCP120D.dll
16 February 2014, 12:10:46
QuoteI am using Visual Studio 2012
QuoteThe program can't start because MSVCP120D.dll is missing
This looks strange to me, because MSVCP120D.dll is from Visual Studio 2013.

So are you perhaps using the tgui libraries for VS2013 instead of these for VS2012?
#1515
Quoteit doesn't effect the program
Then we are talking about a different issue.
I could only reproduce the errors when the file passed to the load function of EditBox wasn't found, which means that the edit box doesn't get drawn. If everything works (when you see the image, two labels, two edit boxes and the button) then I don't get these errors.

If it doesn't affect anything then it can be ignored, although I would prefer to fix such issue. But as I can't reproduce this, it might just as well be a driver issue. And whatever the issue is, if I can't reproduce it then I can't fix it.
#1516
You should put "return 0;" before your main loop, that will show you the first few errors that are being printed instead of seeing the error that is printed every frame.

Because you say that the image isn't being displayed, I assume that it isn't loaded. The reason for this is probably because you are placing the image in the wrong folder (not in the working directory).

It seems like EditBox is missing a check in draw which causes it to be drawn even when it isn't loaded (which probably causes those opengl errors). I'll solve it in the next release, but the real problem which you have is that it isn't loaded correctly.
#1517
If it works fine in debug mode then its probably some incompatibility. Make sure that when compiling in release mode, you are also using the release libraries from sfml and the release library of tgui.

Also check if you have other options that you perhaps set in debug mode and not in release mode.

If you can't figure it out then you can try sending me the project files and sfml and tgui libraries (preferably the whole build folder from tgui, including all these files that cmake generated), e.g. via dropbox.
#1518
Help requests / Re: check if a widget is already
10 February 2014, 18:05:24
Here is a tutorial about the callbacks: https://tgui.eu/tutorials/v06/callback-system/.

To go a little more into detail:
A function pointer doesn't accept pointers to member functions, because these function actually have another parameter behind the scenes (a pointer to the object). This is the reason I went to c++11 to use std::function. But even here you have to do something extra, you have to bind that extra parameter.
editBox->bindCallback(std::bind(&MyClass::function, &myObj), tgui::EditBox::ReturnKeyPressed);

And to make that line a little shorter I added another bindCallback function that you can just call like this:
editBox->bindCallback(&MyClass::function, &myObj, tgui::EditBox::ReturnKeyPressed);

So your line should become:
widget.fenĂȘtre->bindCallbackEx(&cVanne::fermerWidget, this, tgui::ChildWindow::Closed);
#1519
Help requests / Re: check if a widget is already
10 February 2014, 17:08:51
If there is a window then the Gui::get function will return a pointer to it, otherwise it will return a nullptr.

So you only need to add the following check:
if (gui.get("fenetre") == nullptr) {
    // The window doesn't exist yet, create it now
}
#1520
Installation help / Re: Where is the lib folder?
08 February 2014, 13:05:47
It seems that my tutorials are a bit outdated (the precompiled v0.6.0 libs are different than the earlier ones for which the tutorials were originally written). Normally I shouldn't be including SFML myself but SFML 2.1 just isn't as stable as the github version. Once SFML 2.2 comes out my tutorials will be correct again.

The precompiled libraries that you downloaded contains a lib folder with two folders in it: SFML and TGUI.
So the additional library directories should be "TGUI_Path/lib/TGUI" and "TGUI_Path/lib/SFML".

You just made me realize that I didn't include the SFML headers in the download. So I have reuploaded the files which now contain the missing headers.
The additional include directory should be "TGUI_Path/include". That will include both sfml and tgui now.

When you compile yourself with CMake then you create a build folder in which all files are created. So there should be a lib folder in that build folder.
#1521
Feature requests / Re: Handle a ressource path
06 February 2014, 00:41:11
The change didn't make it into the v0.6.0 release after all, but it will be included in v0.6.1.
It is already available in the latest version on github.

I had already forgotten that you had implemented part of it so I implemented it myself. But its good that you provided the changed code because I had implemented everything except loading from a widgets file :).

Thanks for suggestion this feature.

Blog post on resource paths
#1522
I've added a setLineSpacing function which allows you to set the line spacings of all lines, no matter what font or text size it uses.

In the meantime I've also updated the addLine function so that you don't have to pass the color every time. You can now choose to make it use the default values (changeable with setTextSize, setTextColor and setTextFont) or to pass the values directly to the addLine function.
#1523
QuoteFeature request: It would be nice if we could set the spacing between each line manually too.
I've been thinking about it and I don't think I will do this, it would hardly ever get used and I would have to add several functions to support setting a different line spacing for every line and for reusing the default spacing. Setting one line spacing for the whole chatbox is something that I would do, but it doesn't fit with the fact that you can set a different font and text size for every line.

There are other things that are hardcoded (e.g. the distance between the text and the side of the chatbox), so maybe if I ever allow customizing these small details then I will also allow the line spacing to be changed.
#1524
Quote~15% of the fonts i tested (around 20) didn't work, would be interessting to know why
The problem of these fonts are that their line spacing is too small. The sf::Font::getLineSpacing function returns a value smaller than the character size. Due to badly placed brackets and the use of unsigned ints, subtracting the character size from the line spacing ended up being a really huge number :).

The fix is easy, but another problem remains: the line spacing is too small. So with the current implementation the lines will overlap instead of being displayed below each other. I'll just put the lines below each other with an offset of e.g. 1/10th of its size, instead of using the line spacing returned by sfml.

Edit: Fixed in latest version on github.
#1525
Help requests / Re: Render frame resize issue
23 January 2014, 13:49:15
You should use a different view for sfml and tgui if you want to render them differently. Because you want the gui view to change with the resolution, you can't just pass true to the draw function (which is for changing sfml view while keeping the gui view).

So you will have to do something like this:
    set sfml view
    render with sfml

    set view for tgui
    render the gui

How to change the view is something that is explained in the sfml tutorials.