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

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

0 Members and 2 Guests are viewing this topic.

texus

  • Sr. Member
  • ****
  • Posts: 499
    • View Profile
    • TGUI
    • Email
TGUI: a c++ GUI for SFML
« Reply #15 on: March 09, 2012, 07:01:02 pm »
Except for the library file, you can put the folders anywhere you want.
Just make sure that the path is in the include directory of your IDE, just like you configured your IDE to find sfml.
Don't forget to link to tgui. This is also done in the same way as sfml, by adding -ltgui to your linking options.
The place of your object folder doesn't matter either, as you must pass a pathname whenever you load an object.

I don't really know how to decently distribute my project. I don't know how to use makefiles or cmake, so you will have to copy the lib file to the correct place by yourself.

I would think you need to put the libtgui.so file in the /usr/lib folder.
If it doesn't work then you might need to call ldconfig (in the terminal, as root).

I am happy to see that people are starting to test my library, at least I finally know which things I must improve.
TGUI: C++ SFML GUI

Alejandro

  • Newbie
  • *
  • Posts: 27
    • View Profile
TGUI: a c++ GUI for SFML
« Reply #16 on: March 09, 2012, 07:55:28 pm »
Thank you for the quick reply, didn't expect to get an answer so soon  :D

I'm not using Linux, I have a Windows 7 64-bit with an ATI card, which for the most part of my problems doesn't matter.

Anyway thanks for clearing up the problems with scale and deleting objects :) /because I read in the example code about the things that could be caused by it and borders, but didn't relate that the problem with the text could originate from here/

About the skinning, I realize that I have to make the images by myself, I just wanted to note that the way it is implemented in this GUI library is far easier than the ones I've tried before on other languages as well.

Sorry about clogging your TODO list, I hope you get to do the things YOU want for this project and that more people will find it useful and contribute to its development :)

texus

  • Sr. Member
  • ****
  • Posts: 499
    • View Profile
    • TGUI
    • Email
TGUI: a c++ GUI for SFML
« Reply #17 on: March 09, 2012, 08:15:34 pm »
Quote
I'm not using Linux, I have a Windows 7
I guess I should test it on my windows then. I always assumed that it didn't work because I was using linux.

Quote
Sorry about clogging your TODO list, I hope you get to do the things YOU want for this project
Usually I just try to do whatever I think that other people might need, so it's not a problem. I just meant to say that there are so many things to add and so many small bugs to remove that you shouldn't expect it soon.
TGUI: C++ SFML GUI

Alejandro

  • Newbie
  • *
  • Posts: 27
    • View Profile
TGUI: a c++ GUI for SFML
« Reply #18 on: March 10, 2012, 10:45:21 am »
After fiddling around with the format of the text which enables you to use forms I found out that I don't how whether there is a way to set a callback to a widget. I know that I can get the widget by name in code and set its callback there, but can I write a line in the form text for each widget, which specifies its callback ID ?

Anyway, even without a form editor everything is pretty straightforward, so that you won't get frustrated or confused while trying to configure your GUI :)

texus

  • Sr. Member
  • ****
  • Posts: 499
    • View Profile
    • TGUI
    • Email
TGUI: a c++ GUI for SFML
« Reply #19 on: March 10, 2012, 11:25:17 am »
Setting thr callback id inside the text file is something I overlooked, I will add it in the next release.
Thanks for reporting this.
TGUI: C++ SFML GUI

Alejandro

  • Newbie
  • *
  • Posts: 27
    • View Profile
TGUI: a c++ GUI for SFML
« Reply #20 on: March 10, 2012, 12:44:08 pm »
Sorry for spamming the thread, but I had another problem while trying to do screen transitions.

I know that I can delete multiple elements by name, or all by calling a single function, but when I do call removeAllObjects, the application crashes and I don't think that deleting every single object is a good idea, when your loading from text files.

I tried something like:
Code: [Select]

Window:
{
Panel: "Main"
{
    Picture: "Pic1"
    {
        Filename = "Data/Images/GUI/Backgrounds/Main.png"
    }
}
}

and eventually delete the panel "Main" by code and later load another form text file, but to start, nothing renders at all, which leads me to the conclusion that I am not using panels properly, or they aren't meant to hold other objects /which I doubt since window is derived from panel/.

The possible solutions I can think of are:
- Learning how to use a panel properly.
- Having a function removeObjectsFromFile, which takes a form text file and searches for the names.
- After the call of removeAllObjects with the fact that there is a window object in the text file, something could be messing up the GUI window.

texus

  • Sr. Member
  • ****
  • Posts: 499
    • View Profile
    • TGUI
    • Email
TGUI: a c++ GUI for SFML
« Reply #21 on: March 10, 2012, 01:34:49 pm »
Panel was never fully tested so it might still contains some mistakes (like e.g. objects from different panels can both be focused).
Unless you really need them for e.g. creating multiple radio button groups (radio buttons have to be in different panels to check both radio buttons), you shouldn't use them.

Quote
Having a function removeObjectsFromFile, which takes a form text file and searches for the names.
This might be something for later, when I will allow placing multiple forms in one file.
Then I will add the functionality to load or remove a complete form.

Quote
Panel: "Main"
{
    Picture: "Pic1"
    {
        Filename = "Data/Images/GUI/Backgrounds/Main.png"
    }
}
This isn't possible yet. I shouldn't have added the possibility to create panels from a file.
Panels can already be loaded from a file, but you can't add objects to it yet (at least not in the text file itself).

The current loadObjectFromFile function isn't capable of loading objects within a panel.
I am thinking on a way to fix it, but whatever I will find as a solution, the function will have to be completely rewritten.

Quote
when I do call removeAllObjects, the application crashes
Although this is probably because the loading from the file failed, this is something that is not allowed to happen.
I will try to find out why it crashes when I get the time.
TGUI: C++ SFML GUI

Alejandro

  • Newbie
  • *
  • Posts: 27
    • View Profile
TGUI: a c++ GUI for SFML
« Reply #22 on: March 10, 2012, 02:28:30 pm »
Just for reference, the panel file doesn't get loaded, but the one that does get loaded has window and a picture and 5 buttons, but if I call removeAllObjects it crashes, so that you know the problem isn't in file loading :)

Edit1: If I try to set text to an edit box in a form text file, the app crashes.

Edit2: Sometimes the text on a button gets blurry, which is probably because of floating point math for centering it on the button. A simple cast to int should fix it :)

texus

  • Sr. Member
  • ****
  • Posts: 499
    • View Profile
    • TGUI
    • Email
TGUI: a c++ GUI for SFML
« Reply #23 on: March 10, 2012, 06:24:07 pm »
The next release has arrived.

The important changes in v0.3.4 are:
- setSize function added to all gui objects. Note that it may not be called before the load function.
- The setGlobalFont function was added to the window.
- Objects loaded from a file can have a callback id.
- You can use a horizontal scrollbar
- removeAllObjects no longer crashes the program


Quote
If I try to set text to an edit box in a form text file, the app crashes.
I don't have this problem, but this would mean that the example code would crash too.

Quote
Sometimes the text on a button gets blurry
I'll investigate this problem later, but I don't think that a blurry text has anything to do with my code for centering the text.
It can only get blurry when it is scaled instead of just changing it's text size.
Anyway, this problem should only appear when no text size was set, which you don't want to do in most situations (the text size will be different in every button).
Edit: What did you pass to the SetScale function?
TGUI: C++ SFML GUI

Alejandro

  • Newbie
  • *
  • Posts: 27
    • View Profile
TGUI: a c++ GUI for SFML
« Reply #24 on: March 10, 2012, 07:24:35 pm »
Thanks a lot for the bug fixes and new features, everything works like a charm now.

After trying to find the root of my crash problem with edit box, I decided to copy everything from the sample form text file and it seems that my problems might derive from encoding or character issues, which were fixed by copying text from the original form file.

And something to say, so that this post would be more useful:

Is it a bug or feature that when an edit box loses focus, if it had text selected it is still selected, while another edit box has some other text selected and so on ...?

Edit: I don't use the setScale function as all the GUI elements I make are match and if something doesn't match, I make a new image. Also I always set the size, because otherwise the text seems too big for me /in this case I set size to 17, which doesn't really matter that much/.

If you want I can send you and image of what happens and the images and files for you to test as well.

texus

  • Sr. Member
  • ****
  • Posts: 499
    • View Profile
    • TGUI
    • Email
gfgbcvsbvxc
« Reply #25 on: March 10, 2012, 07:39:03 pm »
Quote from: "Alejandro"
Is it a bug or feature that when an edit box loses focus, if it had text selected it is still selected, while another edit box has some other text selected and so on ...?
It is not a bug, but it might be better if the colors changed when the focus is lost.
The problem is that this would require four extra colors and I think it will get harder to understand what every color does.

Quote
If you want I can send you and image of what happens and the images and files for you to test as well.
You can do that if you want, although I only need the size of the image and the scale factors to reproduce the problem.
TGUI: C++ SFML GUI

texus

  • Sr. Member
  • ****
  • Posts: 499
    • View Profile
    • TGUI
    • Email
TGUI: a c++ GUI for SFML
« Reply #26 on: March 12, 2012, 06:58:35 pm »
I had to make another release as the naming convention in sfml just changed.

I did however make some changes since the last release:
- The 'm_' prefix was dropped on public members.
- Picture now sends a callback when you click on it.
- EditBox now also sends a callback when you press the return key.

The full list of changes can still be found here.
TGUI: C++ SFML GUI

texus

  • Sr. Member
  • ****
  • Posts: 499
    • View Profile
    • TGUI
    • Email
TGUI: a c++ GUI for SFML
« Reply #27 on: March 13, 2012, 07:16:38 pm »
Apparently my draw function overrides the one from sfml, so this had to be fixed.
The only other thing that has changed in v0.3.6 is that I have added a Label object.
TGUI: C++ SFML GUI

TechRogue

  • Jr. Member
  • **
  • Posts: 63
    • View Profile
TGUI: a c++ GUI for SFML
« Reply #28 on: March 17, 2012, 08:21:35 pm »
What's the rationale for marking a method const and then using const_cast(this)? Doesn't that defeat the purpose of const member methods in the first place?

texus

  • Sr. Member
  • ****
  • Posts: 499
    • View Profile
    • TGUI
    • Email
TGUI: a c++ GUI for SFML
« Reply #29 on: March 17, 2012, 08:42:57 pm »
I guess you are referring to my drawGUI method.

It is something I overlooked. Originally this was the draw function from sfml, I just changed the parameters and later even the name. I just forgot to remove the const.
I was getting errors about 'this' being constant, so I wrote that const_cast, forgetting that this was just because the function was made constant.
It was a stupid mistake. I should have known that I didn't need a const_cast.

Anyway thanks for pointing it out, it will be changed in my next release.
TGUI: C++ SFML GUI

 

anything