Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: TGUI: a c++ GUI for SFML (with Form Builder)  (Read 286765 times)

0 Members and 3 Guests are viewing this topic.

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #240 on: October 21, 2012, 11:33:24 am »
1. Texts inside progressbars (either centered, left or rightaligned).
2. Z-ordering or being able to have panels inside panels (containers etc)
3. Smaller fonts and controls in the formbuilder. Unusable on 1366x768 with textboxes
I'll make sure that all those things will be fully supported in v0.6.

1. Centered text is already possible with loadingBar.setText. I will add left and right alignment later.
2. Panels inside panels is already possible (even child windows inside child windows is possible).
3. The Form Builder will be completely rewritten. It will be a lot more useful when I am finished with it.
TGUI: C++ SFML GUI

Haikarainen

  • Guest
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #241 on: October 21, 2012, 01:48:58 pm »
1. Texts inside progressbars (either centered, left or rightaligned).
2. Z-ordering or being able to have panels inside panels (containers etc)
3. Smaller fonts and controls in the formbuilder. Unusable on 1366x768 with textboxes
I'll make sure that all those things will be fully supported in v0.6.

1. Centered text is already possible with loadingBar.setText. I will add left and right alignment later.
2. Panels inside panels is already possible (even child windows inside child windows is possible).
3. The Form Builder will be completely rewritten. It will be a lot more useful when I am finished with it.


Ohh, fancy news :D

StormWingDelta

  • Sr. Member
  • ****
  • Posts: 365
    • View Profile
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #242 on: October 26, 2012, 08:27:46 pm »
lol no matter what I don't CMake keeps giving me the error mentioned in the tutorial for setting this up. I know for a fact that I have the right locations and even sectioned off an area with the directories it wanted with no such luck.

I have many ideas but need the help of others to find way to make use of them.

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #243 on: October 26, 2012, 09:29:08 pm »
What does your SFMLHeaders folder contain?
As stated in the error, it has to contain an include AND a lib folder (which contains the libraries).

It would be easier if you didn't create your own folders, as SFML2-RC already contains these folders in its root directory.
TGUI: C++ SFML GUI

StormWingDelta

  • Sr. Member
  • ****
  • Posts: 365
    • View Profile
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #244 on: October 26, 2012, 10:36:41 pm »
the SFMLHeaders folder is where the include and lib files are so the only things I can think of being the issue is the root folder name itself. Other than that I have no clue since all the files are where they should be.
I have many ideas but need the help of others to find way to make use of them.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #245 on: October 26, 2012, 10:47:18 pm »
Apparently it can find the headers, but not the libraries. What's inside the "lib" folder?
Laurent Gomila - SFML developer

StormWingDelta

  • Sr. Member
  • ****
  • Posts: 365
    • View Profile
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #246 on: October 26, 2012, 11:01:59 pm »
Apparently it can find the headers, but not the libraries. What's inside the "lib" folder?

lol it was the way the lib folder was setup causing the issues since I just copied it from the build file. When I copied the lib folder from the build of SFML I have I forgot to remove the two sub folders in it and move the files within into the lib folder itself.  Strange thing is I have a differently named copy of the folder it was wanting setup with all the lib files in one folder and it doesn't seem to see it.  :o ???
« Last Edit: October 26, 2012, 11:05:02 pm by StormWingDelta »
I have many ideas but need the help of others to find way to make use of them.

Midleiro F

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #247 on: October 27, 2012, 12:29:27 pm »
Hello Texus,

I want to congratulate and also thank you for making this great GUI. I find it very simple and intuitive to use, just like SFML, which is just perfect. I'm looking forward to be using it in a game I'm making for a college project.

This is maybe an old topic, but I have a suggestion on the new callback system. It would be interesting to be able to connect a function to a certain event that is triggered on the widget. For instance:

editBox->addCallback( [&]() { cout << editBox->getText() }, tgui::EditBox::Focus | tgui::EditBox::Unfocus );


Keep up the good work!

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #248 on: October 27, 2012, 01:08:16 pm »
Quote
I find it very simple and intuitive to use, just like SFML, which is just perfect. I'm looking forward to be using it in a game I'm making for a college project.
Nice to hear that you find it useful.

Quote
This is maybe an old topic, but I have a suggestion on the new callback system.
It isn't an old topic. After this rewrite I hope that I won't have to change the callback system again, so all suggestions to make it better are welcome right now.

Quote
It would be interesting to be able to connect a function to a certain event that is triggered on the widget. For instance:

editBox->addCallback( [&]() { cout << editBox->getText() }, tgui::EditBox::Focus | tgui::EditBox::Unfocus );
I am not sure what you are trying to do. Could you explain what you expect with passing that first parameter?
TGUI: C++ SFML GUI

Midleiro F

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #249 on: October 27, 2012, 01:35:21 pm »
Well, say I have a function that I would like to be called every time a button is clicked. A function like
void MyCallbackFunc()
{  
    cout << "The button was clicked!";
}
, or any other appropriate reaction to the button click.

So I would call
button->addCallback(MyCallbackFunc, tgui::Button::Clicked)
, or something like that. I think that would make things very easy.

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #250 on: October 27, 2012, 02:05:15 pm »
The current idea is to implement it like this: (might still be changed though)
button->callbacks = tgui::Button::LeftMouseClick; // This can be set to multiple callbacks by using '|'
button->callbackFunction = myCallbackFunc;

You will even be able put the callback function in a class.
class myClass: public tgui::CallbackManager
{
    bool callbackFunction(const tgui::Callback& callback);
}

button->callbackClass = myClass;

Of course in the above way, it isn't possible to have a callback function for every event (e.g. send unfocus and focus events to different functions). You can only have one callback function per object.
Also every class can only hold one callback function, as it has to be named 'callbackFunction'.
The last disadvantage is that the function has to be very strict: bool as return type and tgui::Callback as parameter.

However, the above code has been tested and I am thus sure that I could implement this.

I will of course see if it is possible to do something like you suggested, but I fear that I won't get very far.
In bigger projects you will probably use classes and the above implementation is the only one that I found so far that can send callbacks to a non-static member function.
But as your suggestion with the addCallback method seems easier to use than what I have implemented so far, I will definately keep looking to get something like that to work (whenever I find the time for it).
TGUI: C++ SFML GUI

StormWingDelta

  • Sr. Member
  • ****
  • Posts: 365
    • View Profile
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #251 on: October 27, 2012, 05:09:01 pm »
You could also do an array(or some other kind of list) of callbacks along with the addcallback if you can figure it out. :)  That would wipe out  a few issues people are mentioning and add some more functionality in the process. 
I have many ideas but need the help of others to find way to make use of them.

cire

  • Full Member
  • ***
  • Posts: 138
    • View Profile
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #252 on: October 27, 2012, 07:09:48 pm »
Maybe making use of some C++11 features (or boost, previously) would make things a little easier?

#include <iostream>
#include <functional>
#include <map>
#include <vector>

class Button
{
public:
    typedef std::function<void()> callbackfunc ;
    enum Clicked { LeftMouseClick } ;

    void addCallback( callbackfunc cbf, Clicked click )
        { callbacks[click].push_back(cbf) ;}

    void doCallbacks(Clicked c)
    {
        switch ( c )
        {
        case LeftMouseClick:
            for ( auto cb : callbacks[c] )
                cb() ;
            break ;
        }
    }

private:
    std::map<Clicked, std::vector<callbackfunc>> callbacks ;
};


class myClass
{
public:
    myClass ( Button & b )
    {
        // onMouse = std::bind(&myClass::onMouseClick, *this) ;  Don't need this!
        b.addCallback(std::bind(&myClass::onMouseClick, *this), Button::LeftMouseClick) ;
    }

private:
    void onMouseClick()
        { std::cout << "onMouseClick()\n" ;}

    // Button::callbackfunc onMouse ;  Don't need this!
};

void myCallbackFunc()
    { std::cout << "myCallbackFunc()\n"; }

int main()
{
    Button b ;
    b.addCallback(myCallbackFunc, Button::LeftMouseClick) ;    
    myClass mc(b) ;

    b.doCallbacks(Button::LeftMouseClick) ;
}

Edit:  myClass doesn't need to keep a copy of the std::function object.  Commented it out.
« Last Edit: October 27, 2012, 07:19:33 pm by cire »

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #253 on: October 27, 2012, 07:46:10 pm »
I don't want to use C++11 (I am trying to keep the same compiler support as sfml, so I don't want to force anyone to the latest compiler just to use my gui), but I was just considering using boost. I have been trying to avoid it for some time because I don't want another dependency, but I am starting to realize that I will have to use it eventually.

Thanks for the code example. I will take a better look at it when I find some more time.
TGUI: C++ SFML GUI

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #254 on: October 28, 2012, 10:04:20 pm »
Thanks to the code that cire posted, I have been able to get the callback system to work like this:
void function1();
void function2(const tgui::Callback& callback);

class myClass
{
    void function3();
    void function4(const tgui::Callback& callback);
}


button->bindCallback(function1, tgui::Button::Focus);
button->bindCallbackEx(function2, tgui::Button::Focus);

myClass app;
button->bindCallback(boost::bind(&myClass::function3, &app), tgui::Button::Focus);
button->bindCallbackEx(boost::bind(&myClass::function4, &app, _1), tgui::Button::Focus);

The function passed to bindCallback takes no parameters while the function passed to bindCallbackEx takes a tgui::Callback parameter (so that you can send multiple callbacks to a single function and still distinguish the callbacks from each other.

I wish I could make the last two lines easier, but I guess it will have to stay like that.
It would also be nice if the bindCallback and bindCallbackEx were merged, but I haven't found a way to do that yet.

PS: A part of boost will be included with tgui so you won't have to install it yourself. You can just use boost::bind without including anything extra.
TGUI: C++ SFML GUI