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

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

0 Members and 2 Guests are viewing this topic.

Haikarainen

  • Guest
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #225 on: September 20, 2012, 03:14:03 pm »
The master branch is still v0.4 which only works with the RC version of sfml.
You must download the v0.5-dev branch.

Allright. 2 issues with formbuilder:

1. I'm having issues with creating an ArchLinux PKGBUILD for TGUI (basically a package so users can install TGUI without having to compile it themselves etc), Everything seems really messy, when doing 'make install', the lib-file is gently placed where I want it (/usr/lib), but the formbuilder is placed in whatever directory I built it in, + /src/TGUI/FormBuilder. Also it is placed there with just the binary(not fonts and txt-files needed). I suggest you create a data-directory (something like "/opt/tgui/" or "/etc/tgui/" or whatever) to make it more linux friendly. Fonts  should be placed in /usr/share/fonts so their cache can be easily updated etc. Is this something planned or am I on my own here? Maybe I should exclude the formbuilder from the package?

2. Placing a button and entering a "!" in the Text-attribute segfaults the application.
Code: [Select]
(gdb) backtrace
#0  0x00007ffff7b943ad in tgui::EventManager::handleEvent(sf::Event&) () from /usr/lib/libtgui.so
#1  0x00007ffff7bbeff5 in tgui::Window::handleEvent(sf::Event) () from /usr/lib/libtgui.so
#2  0x00000000004111d9 in main ()

this MIGHT be sfml though

texus

  • Sr. Member
  • ****
  • Posts: 499
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #226 on: September 20, 2012, 03:33:57 pm »
1. I use ubuntu, so I can't really help you much with ArchLinux.
But if you use 'make install' then the form builder should be copied to the 'Form Builder' directory automatically. This directory does contain all needed resources.

The font is just something I distribute so that you can directly start programming without having to look for a font on your pc to use.
I don't think it is really necessary to install it, unless there would be an advantage in placing it in the /usr/share/fonts folder.

2. I will look into this. I have been able to reproduce this when using the library, however I didn't have it when using the source code directly.
TGUI: C++ SFML GUI

Haikarainen

  • Guest
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #227 on: September 20, 2012, 04:02:33 pm »
1. I use ubuntu, so I can't really help you much with ArchLinux.
But if you use 'make install' then the form builder should be copied to the 'Form Builder' directory automatically. This directory does contain all needed resources.

The font is just something I distribute so that you can directly start programming without having to look for a font on your pc to use.
I don't think it is really necessary to install it, unless there would be an advantage in placing it in the /usr/share/fonts folder.

2. I will look into this. I have been able to reproduce this when using the library, however I didn't have it when using the source code directly.

The advantage of having the font in the /usr/share/fonts and having a data directory is that you can place the executable ( or symlink to it ) in /usr/bin, and creating a streamlined package that just goes with the linux system and philosophy etc. I think you will come to the same conclusion if you try and create a deb-package for ubuntu. My point is you simply dont do the windows-way of multiple-storing files in every folder it is needed when creating a linux-package. /usr/bin, /etc, /usr/share and so forth is the standard in linux.

texus

  • Sr. Member
  • ****
  • Posts: 499
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #228 on: September 20, 2012, 05:38:19 pm »
I have fixed the problem with typing a '!' in the edit box, together with some other small bugs that I noticed.

So the font should be in /usr/share/fonts, but where exactly?
The font that I am using can be found in the truetype/ttf-dejavu folder, so should I put it there if it wasn't found there already?
I don't know about other linux distros, is it always installed in that folder?
The form builder will be installed in /etc/tgui and a link to the executable will be created in /usr/bin.
Is that the correct way to do it, or did I still miss something?

If you can answer these questions then I'll make the changes today or tomorrow.
TGUI: C++ SFML GUI

Haikarainen

  • Guest
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #229 on: September 21, 2012, 04:37:46 pm »
I have fixed the problem with typing a '!' in the edit box, together with some other small bugs that I noticed.

So the font should be in /usr/share/fonts, but where exactly?
The font that I am using can be found in the truetype/ttf-dejavu folder, so should I put it there if it wasn't found there already?
I don't know about other linux distros, is it always installed in that folder?
The form builder will be installed in /etc/tgui and a link to the executable will be created in /usr/bin.
Is that the correct way to do it, or did I still miss something?

If you can answer these questions then I'll make the changes today or tomorrow.

Thats great effort!

Well I've been thinking it through, the font-deal really should be up to the distribution to provide, regarding arch: I found a package called ttf-dejavu, ill just make that a dependency and that problem is solved(if the code doesnt load a specific file).

Regarding where to place the binary: Most people nowadays seem to just place the binary in /usr/bin, but since it is a library, you should really just place the binary in /usr/lib/tgui/formbuilder/ or something, and make a symlink from there.

There still is 1 problem to make this optimal: Dataloading. since we now run the program from /usr/bin (does not matter if it is a symlink or not), we need a specific place to load data. This needs 2 things:

1. Create a configuration file in /etc/tgui/formbuilder.conf or something, with a string, lets name it "DataDirectory".
2. Create a folder /usr/share/tgui/data/ or something, where we place all the solid, readonly data(textures, the formdata for the formbuilder etc)

Then, in your program, do something like:
#ifdef LINUX
LoadConfiguration("/etc/tgui/formbuilder.conf");
#elifdef WINDOWS
LoadConfiguration("./formbuilder.conf");
#endif
LoadData(Configuration->DataDirectory);

It feels like im telling against what I've said before, You'll have to excuse me but I hadnt done enough research then to come with solid answers.

texus

  • Sr. Member
  • ****
  • Posts: 499
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #230 on: September 21, 2012, 05:28:56 pm »
Quote
if the code doesnt load a specific file
The code does load a specific file. I wouldn't know how to do it otherwise.

I don't think the config file is really necessary, I guess I could just skip it and load the data directly from /usr/share/tgui/data/.
Maybe I'll add a conf file later when I allow to change some settings, but right now it would only contain the data directory.

TGUI: C++ SFML GUI

texus

  • Sr. Member
  • ****
  • Posts: 499
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #231 on: September 23, 2012, 05:59:28 pm »
I have create a new branch on github: install-test.
You should see if this is better to create the package with.
TGUI: C++ SFML GUI

texus

  • Sr. Member
  • ****
  • Posts: 499
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #232 on: October 14, 2012, 02:55:42 pm »
I have started planning the new callback system for v0.6 and I could use some opinions.
Note that v0.6 probably won't be released this year, so you won't see this new callback system soon.

Right now, callbacks are send after changing the callbackID of the object. All callbacks are polled later in the main loop (so no immediate callbacks). This also means that all callbacks come together in one place, where you have to distinct them from each other with the callbackID.

In v0.6 you will be able to intercept callbacks on 3 different levels:
- You can tell a single object to send callback to a specific function (so the callbacks can be spread over multiple functions).
- You can set a global callback function which receives the callback from all objects (unlike with polling, you get callbacks immediately).
- Or you can keep using the current way, by polling them from the window.

Objects will also send callbacks for more reasons. Until now callbacks were limited and were either on or off.
In v0.6 you will be able to choose exactly which callback you want.
If you e.g. want to make a button react on mouse down instead of on mouse click then you can simply do this:
button->callbacks = tgui::Button::LeftMouseDown;
(Right now, a button will send both mouse down and mouse click events, so you must filter it when you receive the callback)

Callbacks can be combined, so if you want to know when your edit box get focused or unfocused then just set both triggers:
editBox->callbacks = tgui::EditBox::Focus | tgui::EditBox::Unfocus;

The following four triggers will be added to all objects: Focus, Unfocus, MouseEnter, MouseLeave. And even more may be added in the future. They couldn't be added before because you would be overwhelmed by callbacks, but when you can choose the needed callbacks, I can easily add them.

Let me know what you think about this new way of handling callbacks.
Any ideas, comments or critics are welcome.
TGUI: C++ SFML GUI

lejar

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #233 on: October 15, 2012, 08:10:02 pm »
I just upgraded from V0.4 to V0.5 (and SFML 1.6 -> 2.0) and after changing the broken methods I've been noticing some segfaults that weren't there before.

A backtrace shows it happening when the window handles events.
Code: [Select]
#0  0x00000000682e7473 in ?? ()
#1  0x000000000042e2e8 in tgui::EventManager::unfocusAllObjects (this=0x9920a8)
    at /home/*****/Desktop/WarBound/src/TGUI/EventManager.cpp:346
#2  0x000000000042d984 in tgui::EventManager::handleEvent (this=0x9920a8,
    event=...) at /home/*****/Desktop/WarBound/src/TGUI/EventManager.cpp:122
#3  0x0000000000511980 in tgui::Window::handleEvent (this=0x992020, event=...)
    at /home/*****/Desktop/WarBound/src/TGUI/Window.cpp:93
#4  0x000000000051c902 in ClientGame::gameLoop (this=0x7faee0)
    at /home/*****/Desktop/WarBound/src/client.cpp:181
#5  0x000000000051fe87 in main (argc=1, argv=0x7fffffffe1f8)
    at /home/*****/Desktop/WarBound/src/client.cpp:563

I thought it would be from me handling my callbacks incorrectly but in this section of code there are no callbacks being processed. i.e. my code for the callbacks in that section is:

Code: [Select]
tgui::Callback callback;
while(window->getCallback(callback))
{
  continue;
}

It might also be good to mention that I don't have any active objects attached to the window at the point of the segfault.

Let me know what you think about this new way of handling callbacks.
Any ideas, comments or critics are welcome.

I think that is a wonderful idea. I was just thinking that callbacks should have this functionality.

texus

  • Sr. Member
  • ****
  • Posts: 499
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #234 on: October 15, 2012, 11:24:01 pm »
I never had crashes there before.
According to what I see in the backtrace, this happens when you press the mouse button, right?

unfocusAllObjects can't crash if no objects were created. The only thing I can think of is that somehow the m_FocusedObject variable is messed up, but it is changed in many places.

Could you show a minimal example of how to reproduce this crash?
Some other info might also help (OS, compiler, static/dynamic linking).
TGUI: C++ SFML GUI

lejar

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #235 on: October 16, 2012, 12:46:28 pm »
Could you show a minimal example of how to reproduce this crash?
Some other info might also help (OS, compiler, static/dynamic linking).

It turns out there were objects attached to the window at the time of the crash. I removed all objects from the window before the crash point and the crash stopped happening. At that point I decided to simplify my code to make it easier to make a minimal example. After simplifying the code, the crash is no longer there. (yes I removed the remove all objects part)

I was displaying an alert window in the form of a button and every time I wanted to show another alert I would create another button. At the point of the crash, all alert buttons should have been deleted; which apparently was not the case. In my simplified code, I use one button and just change the text for each new alert. (Which is much more elegant for my implementation.) I assume it was just bad code on my part. Thanks for your help.

texus

  • Sr. Member
  • ****
  • Posts: 499
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #236 on: October 16, 2012, 01:29:16 pm »
Considering the contents of the unfocusAllObjects function, I think a crash in that function can only be caused by a bug in tgui.

If you have the time and you don't mind then you should add all tgui source files in your project and link to opengl.
In debug mode, you should be able to find out in which situation the crash ocurred. If m_FocusedObject turns out to be corrupted (higher than the amount of objects) then it is indeed a bug in tgui and it should be fixed.

Whether you test the thing above or not, if you don't mind then I would like to see the code you were using so that I can do some debugging and hopefully find out why it crashed.
TGUI: C++ SFML GUI

lejar

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #237 on: October 16, 2012, 09:38:53 pm »
I never had crashes there before.
According to what I see in the backtrace, this happens when you press the mouse button, right?

unfocusAllObjects can't crash if no objects were created. The only thing I can think of is that somehow the m_FocusedObject variable is messed up, but it is changed in many places.

Could you show a minimal example of how to reproduce this crash?
Some other info might also help (OS, compiler, static/dynamic linking).

I don't know what you meant with linking to openGL so I made a code::blocks project which links to SFML 2.0 and has the TGUI source in it. There is some very minimal code in the main file which reproduces the crash. You might have to change the location of your SFML lib files in the project settings to get it to compile.

For some extra info: I'm using Ubuntu 12.04 x64 with gcc 4.6.3. Let me know if you find anything interesting or need anything else!

(The project was too large to attach to the post so I sent you a PM with a link.)

texus

  • Sr. Member
  • ****
  • Posts: 499
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #238 on: October 16, 2012, 10:37:24 pm »
Quote
I don't know what you meant with linking to openGL
I didn't want to give too much details, because I didn't know your os yet. What I meant was add -lGL to the linker flags in case an undefined reference error would show up.

Quote
There is some very minimal code in the main file which reproduces the crash.
Thanks, the code lead me to the bug immediately.
I once made a change in one of the remove function (the one that takes a pointer to the object), but I forgot to add it to the other remove function (the one that takes a string, which you were using).
It has been fixed now. Thanks for your help.
TGUI: C++ SFML GUI

Haikarainen

  • Guest
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #239 on: October 21, 2012, 12:49:32 am »
Feature requests:

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

Btw, haven't forgotten about the archpackage, just havent had the time yet.
« Last Edit: October 21, 2012, 12:53:54 am by Haikarainen »

 

anything