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

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

0 Members and 3 Guests are viewing this topic.

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Back to C++ gamedev with SFML in May 2023

netrick

  • Full Member
  • ***
  • Posts: 174
    • View Profile
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #361 on: January 07, 2013, 07:37:54 pm »
I often see that feature on checkboxes as well. Also I need checkboxes for look.

But I think I can just copy the images, so that is no problem. But I still have 3 questions:

1) Is there a way to disallow user to click on checkbox? I mean I controll if it's checked/unchecked and the user can only see it and can't click on it.

2) I found a bug. Using check() on the radio button doesn't send callback. Why? It should send callbacks, there is no difference whether user or the code checked it, because there are some actions to do after its checked. Any fix?

3) Why there is no checked/unchecked callback trigger for checkbox? I really need it.
« Last Edit: January 07, 2013, 07:58:01 pm by netrick »

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #362 on: January 08, 2013, 12:05:23 pm »
Only one radio button with the same parent can be checked at a time.
If you want to group them then you should take a look at the tutorial of Panel.

1) Call object->disable(). This will block all events from going to the object.

2) It seems like I placed the callback when you clicked on the checkbox instead of in the check function. I think I probably did this so that no callbacks would be triggered when you manually check the checkbox.
You can always adjust the source code to your needs and remove the callback code from leftMouseReleased and keyPressed and place it in the check and uncheck functions (in both CheckBox and RadioButton).

3) Any callback coming from the checkbox means that the state was changed in some way. So when you receive a callback you should just look at callback.checked. If it is true then it just got checked and if it is false then it just got unchecked.
v0.6 works with checked/unchecked triggers by the way. Too bad that the version is currently not stable enough.
TGUI: C++ SFML GUI

netrick

  • Full Member
  • ***
  • Posts: 174
    • View Profile
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #363 on: January 08, 2013, 05:36:54 pm »
Thanks for answers.

2) It seems like I placed the callback when you clicked on the checkbox instead of in the check function. I think I probably did this so that no callbacks would be triggered when you manually check the checkbox.
You can always adjust the source code to your needs and remove the callback code from leftMouseReleased and keyPressed and place it in the check and uncheck functions (in both CheckBox and RadioButton).

But I think that callback shouldn't be done that way by default. Callback isn't reaction for mouse movement done by user, rather it is reaction for checked/unchecked. From my experience with gui systems (not game ones), it doesn't matter if the user or the code uses it - the onWhatever() functiong gets called in both cases. I really think you should change it by default. There aren't many reason why you should separate code and user checks, it makes the code MUCH uglier. See, sometimes you check one chekbox and it automatically checks another checkbox - and why in this point the functions related to that checkboxes shouldn't be called?

From the callback handling code point of view it really shouldn't matter what is the reason why the checkbox is checked, when it's checked the callback handler should always be called.

The very simple example from wxWidgets - when you close the application from code, the onExit() function gets called even though the user didn't press the close button. The same applies to other callbacks as well.

I really think that the current way is counter-intuitive and you should change it. And if someone really needs to do it the other way (checking in code doesn't send callback), you can always have a default argument in check function (send callback = true). But to be honest, I'm yet to see an use for that in any well designed gui application (i've done some wxwidgets gui programming before).

It's not only my point of view - as I said other guis send callbacks even when it is triggered by code. I hope that I explained it well and you can see the point.

The another example is not related to gui but shows the idea too - for example when you have networking code and you have callbacks when receiving packets (ie enet library), it sends the callback even though the user of application doesn't have any control on it. The callbacks should be related to code, not to the user.
« Last Edit: January 08, 2013, 05:45:24 pm by netrick »

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #364 on: January 08, 2013, 05:51:14 pm »
I fully agree with you. That's why v0.6 already does it in the exact way that you expect it.

But I am not really planning on changing v0.5 anymore unless it is to fix a real bug.
TGUI: C++ SFML GUI

netrick

  • Full Member
  • ***
  • Posts: 174
    • View Profile
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #365 on: January 08, 2013, 06:03:00 pm »
Oh, I didn't realise that in 0.6 it's fixed! That's great to hear!

Anyway, do you plan to include clickable object in 0.6 by default? It would be nice.

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #366 on: January 08, 2013, 06:15:38 pm »
I'll do that (when I have more time).
TGUI: C++ SFML GUI

netrick

  • Full Member
  • ***
  • Posts: 174
    • View Profile
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #367 on: January 11, 2013, 07:41:56 pm »
How do you do communication between widgets in tgui? Do you use observer or publish-subscripe pattern? Or do it less fancy way?

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #368 on: January 11, 2013, 08:03:56 pm »
There is an EventManager which holds a list of all objects. When you call the handleEvent function from the window then a function from all these objects is called (which function depends on the event).
So something like the observer pattern.

Objects themselves cannot communicate with each other directly because they don't know about each other.
They can only talk to their parent object.
TGUI: C++ SFML GUI

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML
« Reply #369 on: January 11, 2013, 09:07:22 pm »
For those who are interested, I have added precompiled libraries for MinGW 4.7 to the download page.

If you downloaded CodeBlocks 12.11 with MingGW, then you can use these libraries instead of having to compile them yourself.

Precompiled libraries for other compilers and versions will be added in the future.

Edit: Libraries for Visual Studio 2010 are also online now (untested).
« Last Edit: January 20, 2013, 11:08:35 am by texus »
TGUI: C++ SFML GUI

netrick

  • Full Member
  • ***
  • Posts: 174
    • View Profile
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #370 on: January 28, 2013, 04:20:55 pm »
I have a suggestion, but I think it would be rather long-term. Do you plan to add open and save file dialogs? Something like irrlicht's gui has. It doesn't have to be fancy, just basic features.

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #371 on: January 28, 2013, 04:47:45 pm »
That is indeed on a long-term, but the FileTreeDialog is planned to be written eventually. But probably not in v0.6.
TGUI: C++ SFML GUI

netrick

  • Full Member
  • ***
  • Posts: 174
    • View Profile
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #372 on: January 28, 2013, 08:37:28 pm »
How can you make child window's title to be centered?
« Last Edit: January 28, 2013, 08:48:53 pm by netrick »

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #373 on: January 28, 2013, 08:53:49 pm »
Currently, you can't.

But it's not such a bad idea to be able to do that.

EDIT: I will add it to v0.5.1, which will come in a week or two.
« Last Edit: January 29, 2013, 03:53:34 pm by texus »
TGUI: C++ SFML GUI

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #374 on: February 03, 2013, 04:19:55 pm »
A new development snapshot is now available for v0.6.

Next to the new callback system it also includes the MenuBar object.

There still aren't tutorials for this version, but the documentation might be enough for some.
In the previous snapshot the form builder was left out (it didn't compile anymore). This has been solved by now.
I have also included precompiled libraries for those working with CodeBlocks 12.11 or Visual Studio 2010.

An example code for the menu bar:
tgui::MenuBar* menuBar = window.add<tgui::MenuBar>("myMenuBar");
menuBar->addMenu("File");
menuBar->addMenuItem("File", "Save");
menuBar->addMenuItem("File", "Load");
menuBar->addMenuItem("File", "Exit");
menuBar->addMenu("Edit");
menuBar->addMenuItem("Edit", "Undo");
menuBar->addMenuItem("Edit", "Redo");
menuBar->addMenu("View");
« Last Edit: February 03, 2013, 04:28:53 pm by texus »
TGUI: C++ SFML GUI

 

anything