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

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

0 Members and 5 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 #495 on: April 29, 2013, 12:12:13 pm »
setOrigin does indeed do some harm in objects where clipping is aplied. The inheritance will be removed in the future so that this will be solved. But this means that you can't use the setOrigin function for now.

TGUI v0.6 is far from being ready so it might still take a while before it gets released. But the latest development version is already available you can make use of the changes that I already made.

Quote
But it doesn't work right now.
Did you download the latest development snapshot from my site? The code can only be compiled if your version is less than 5 days old.

Quote
Also, in the loading bar, when you use setText method it works well, but when you move loading bar (setPostition method), it does not move the text, but only the loading bar, and the text is not show when it's out of bounds.
The following code works fine for me (with both v0.5 and v0.6)
loadingBar->load("TGUI/objects/LoadingBar/Black");
loadingBar->setText("Hello");
loadingBar->setPosition(100, 100);
TGUI: C++ SFML GUI

china92

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #496 on: April 29, 2013, 12:56:54 pm »
Thanks for fast reply.  Ok, I don't need setOrigin that much, because there is a simple workaround for this method.

You're right, my version is about 1month old, I'll download the latest one. ;-)

Hm, that's weird, it works fine for me too... Then I don't know how I provoked this issue. And since I already fix that by changing the code I can't take it back.  :-\
I'll try to find what was the problem and if I found it, I'll notice you.

I have another question. How to make loading like this work?
loadingBar->load("TGUI/objects/LoadingBar/Black");
I mean the path, because right now it gives me an error:
Quote
TGUI error: Failed to open TGUI/objects/LoadingBar/Black/info.txt
and I have to give the direct path to the folder with object. I work with VS2012 on Win7.

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #497 on: April 29, 2013, 01:26:52 pm »
I'm not sure where the working directory is in visual studio (I haven't been on windows for some time). I think it is the folder that contains your project file, so if you put the TGUI folder there then it should work. Otherwise just experiment a little, place the folder next to your executable and see if it works then.
TGUI: C++ SFML GUI

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #498 on: April 29, 2013, 01:45:47 pm »
Project settings -> Debugging -> Working directory -> set "$(TargetDir)" if you want the working directory to be the one containing the executable (like when you launch it from the file explorer).
Laurent Gomila - SFML developer

china92

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #499 on: April 29, 2013, 02:53:22 pm »
Thank you for your answers. I thought VS somehow includes the main TGUI dir, when I do everything like in the tutorial. Yet, the example code didn't work, because of the wrong paths, and I had to manually change them to direct paths. Thanks! :)
(maybe you (texus) should add this information in tutorial, for future newbies like me ? ; )

I'm not sure where the working directory is in visual studio (I haven't been on windows for some time). I think it is the folder that contains your project file
Yes it is by default (..\Visual Studio 2012\Projects\[project name]\[project name]), when you run your app via Debugger, but when you run via explorer, it's the executable dir.
« Last Edit: April 29, 2013, 03:07:38 pm by china92 »

china92

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #500 on: April 30, 2013, 02:39:49 pm »
Sorry for the second reply, but I have another problem. I need a button with background image/texture.

AFAIK there is nothing like this in tgui, but maybe there is a workaround for it? Or maybe it is a good idea to make my own ImageButton class? I assume inheritance from tgui::Button/tgui::Button::Ptr is a bad idea (?).

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #501 on: April 30, 2013, 03:57:29 pm »
I'm not sure what you are asking for.
tgui::Button IS an image button, it draws a backround image with text in front of it.

Quote
inheritance from tgui::Button/tgui::Button::Ptr is a bad idea (?).
If you ever decide to inherit something, don't inherit from the Ptr (it won't even compile).
But in the future there will be a turorial about writing custom objects in v0.6 and there it will be explained.
TGUI: C++ SFML GUI

china92

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #502 on: April 30, 2013, 05:12:16 pm »
I want to add the button, with the icon, something like this:


Then the button should have method like setImage/setIcon. Maybe it could be done by pushing callback from image downward to the button?

If you ever decide to inherit something, don't inherit from the Ptr (it won't even compile).
That's strange, because I'm using this in my TD. :)
I made my own class Statusbar, which inherits from tgui::Panel::Ptr. Inside id has its own objects, it seems to work pretty well. I had a problem when I set inheritance from tgui::Panel, because I didn't know know do add it (Suatusbar) later to the tgui window. I can show you my code to make it more clear. ;)

But in the future there will be a turorial about writing custom objects in v0.6 and there it will be explained.
Ok, great, I'm looking forward to it. :)
« Last Edit: April 30, 2013, 05:21:35 pm by china92 »

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #503 on: April 30, 2013, 06:12:00 pm »
Quote
I want to add the button, with the icon, something like this
If it is just a static picture (no different image when it is held down) then you can use tgui::Picture. It is capable of sending callbacks when you click on it. Otherwise just change the images inside the path that you pass to the button in the load function.

Quote
That's strange, because I'm using this in my TD.
Your right, it does compile.
However the correct way to do the inheritance it this:
struct myObj : public tgui::Object
{
    typedef SharedObjectPtr<myObj> Ptr;
};

I expect that there will be only a minor difference with inheriting from tgui::Object::Ptr directly, namely the use of the dot or the arrow operator.
TGUI: C++ SFML GUI

china92

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #504 on: April 30, 2013, 09:14:41 pm »
Thank you for your reply, I'll try to cope with simple pictures.

However the correct way to do the inheritance it this:
struct myObj : public tgui::Object
{
    typedef SharedObjectPtr<myObj> Ptr;
};

I expect that there will be only a minor difference with inheriting from tgui::Object::Ptr directly, namely the use of the dot or the arrow operator.
You are right, but with inheritance from tgui::Object::Ptr I can simply make an object in this way:
MyObj nameofobject(tguiWindow);
(I have to call init method inside constructor to do it)

I'm sure your version is "more correct", but I have some problems with setting text into the label inside my statusbar, so I'll leave it as it is right now (inherited from Ptr).

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #505 on: May 01, 2013, 12:05:17 pm »
This topic has more than 500 posts now, so I think it's time to open my own forum to keep the questions organized.

You can find it here.
TGUI: C++ SFML GUI

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #506 on: May 01, 2013, 12:56:06 pm »
Good idea ;)

I lock this topic to "force" people to switch to your forum, let me know if you prefer to keep it open instead.
Laurent Gomila - SFML developer