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

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

0 Members and 2 Guests are viewing this topic.

Gan

  • Jr. Member
  • **
  • Posts: 98
    • View Profile
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #405 on: February 14, 2013, 09:53:14 pm »
Is there a canvas object so for example I could have multiple canvases with their own relative positions, mouse events relative inside the canvas and have it clip drawing in the canvas?

I'm working on a game and I think a GUI library would be very beneficial.

netrick

  • Full Member
  • ***
  • Posts: 174
    • View Profile
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #406 on: February 14, 2013, 10:10:39 pm »
Imagine a situaton.

Code: [Select]
class a
{
void foo()
{}
}

a obj;

tguiObj widget->bind(&obj.foo()) //the syntax is wrong but you get the point, I bind the obj function to callback

//obj gets deleted here

//here is the callback function called, undefined behaviour (segfault mostly and/or memory corruption)

Qt signals check if the slots exist. How will tgui deal with it?

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #407 on: February 14, 2013, 11:20:29 pm »
Quote
Is there any possibility of adding an outline around text?
Label is just a simple wrapper around sf::Text. Except for a background color it doesn't add anything.

Quote
Is there a canvas object so for example I could have multiple canvases with their own relative positions, mouse events relative inside the canvas and have it clip drawing in the canvas?
Yes, the Panel object.

Quote
How will tgui deal with it?
It doesn't :).
Definately undefined behaviour.
I never though about this kind of situation before, so I'll see what I can come up with.
TGUI: C++ SFML GUI

Gan

  • Jr. Member
  • **
  • Posts: 98
    • View Profile
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #408 on: February 16, 2013, 05:25:06 am »
I'm really diggin' TGUI 0.5. I got it compiled and am playing with the example code.

But one caveat I've noticed is that when window.close() is called, the program crashes with an object memory error.

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #409 on: February 16, 2013, 09:23:33 am »
I never had any crashes with that version.
What code are u using exactly to make it crash?
Does the crash really occur on the window.close call, or somewhere later?

Could you try the following for me?
- Create less objects (maybe the crash only occured when creating one specific kind of object)
- Try putting the event loop at the end of the main loop, so that the draw function isn't called after closing the window.
TGUI: C++ SFML GUI

Gan

  • Jr. Member
  • **
  • Posts: 98
    • View Profile
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #410 on: February 16, 2013, 09:30:14 am »
This is the exact code that crashes on exit:
http://tgui.weebly.com/tgui-v05.html

I can post the exact error log when I get on my computer.

netrick

  • Full Member
  • ***
  • Posts: 174
    • View Profile
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #411 on: February 16, 2013, 12:21:26 pm »
1) What says your debugger call stack?
2) Do you use latest SFML 2 snapshot?
3) By any chance, maybe you use precompiled tgui/sfml for another version of mingw/g++/vc++? Try recompiling.
4) Are you sure that there is no additional code in your project? Or maybe you dynamically link other library which causes this problem? Some libs just doesn't like dynamic linking for various reasons. Try linking only sfml + tgui, both static. (however for sure SFML2 doesn't have any problem with dynamic linking. I don't know with tgui though)
« Last Edit: February 16, 2013, 12:23:55 pm by netrick »

Gan

  • Jr. Member
  • **
  • Posts: 98
    • View Profile
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #412 on: February 17, 2013, 08:11:03 am »
(1)
Quote
Test(8292,0xac56fa28) malloc: *** error for object 0x2ae988: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
(2) I believe it is.
(3) Compiled it myself for C++11 and 10.7+.
(4) No additional code.

Everything works fine. Just when I try to close the window, it gets mad.

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #413 on: February 17, 2013, 10:49:37 am »
It hasn't been tested on mac for a long time, but I see no reason why it would crash on a mac while it works on linux and windows. I'll try to test it on a mac somewhere this month though.

Quote
Compiled it myself for C++11 and 10.7+.
You probably did, but make sure that sfml and tgui are compiled in exactly the same way, with the same build flags.

But could you still try to move the event loop to the end of the main loop and to create less objects?
This might be stupid, but does it make a difference when using the BabyBlue style instead of the Black style?
TGUI: C++ SFML GUI

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #414 on: February 17, 2013, 08:37:20 pm »
I just finished with a new object: ChatBox.



It will be included with the next v0.6 preview.
But if you are using v0.5 then you can already start using it immediately if you want to. You can download the extention here.
TGUI: C++ SFML GUI

Cpl.Bator

  • Hero Member
  • *****
  • Posts: 540
    • View Profile
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #415 on: February 18, 2013, 01:10:51 am »
Great ! i use your lib when the doc & example of 0.6 was done ;)

Gan

  • Jr. Member
  • **
  • Posts: 98
    • View Profile
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #416 on: February 18, 2013, 06:39:46 am »
How do I draw to a panel?

Like, I'm making an app that has 3 views in the same window. Each view has it's own controller, I just made those controllers have a panel as the view and now I'm wondering...
How do you draw to the background of the panel?

panel->draw(myPolygon); doesn't work.

Edit:
panel = window->add<tgui::Panel>("DesignerGrid"); Throws a bad exec access error.
Perhaps I'm doing it wrong...
« Last Edit: February 18, 2013, 06:44:40 am by Gan »

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #417 on: February 18, 2013, 10:31:51 am »
You can't draw directly to a panel. Because every object has to be drawable (including Panel), they all have a draw function. If I remember correctly then adding another draw function to draw on top of the panel would give ambigious calls in some situations. I'll look at it again, but if what I remeber is correct then I can't add the possibility easily.

Creating the panel shouldn't be a problem.
The following code works fine for me.
tgui::Window window(sf::VideoMode(800, 600), "TGUI window");
tgui::Panel* panel = window.add<tgui::Panel>();
TGUI: C++ SFML GUI

Gan

  • Jr. Member
  • **
  • Posts: 98
    • View Profile
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #418 on: February 18, 2013, 03:17:02 pm »
Oh.
Is there a way to set the background texture of a panel? And just draw to the background texture?

It sure would be nice to not have to draw directly to the window.

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #419 on: February 18, 2013, 04:39:56 pm »
I didn't have much time this morning so I forgot to add that to my reply.

There is a setBackgroundImage function in Panel which takes a filename as parameter.
TGUI: C++ SFML GUI