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

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

0 Members and 1 Guest are viewing this topic.

pighead10

  • Jr. Member
  • **
  • Posts: 56
    • View Profile
    • Hog Pog
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #90 on: August 02, 2012, 08:27:29 pm »
At the moment, the game is created in a window, and the view is immediately set. Then the GUI buttons are created and displayed, but the click positioning is off (exactly like before you fixed it the first time) until I set the view again, after the objects have been created.
Immortui - Zombie puzzle game: http://immortui.hogpog.co.uk

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #91 on: August 02, 2012, 08:43:03 pm »
It's strange. If I debug my program (in linux), a resize event is send when the window is created and thus my gui will get the chance to make the needed calculations. You aren't receiving any resize events until you manually resize the window?

Does it help if you put the following code after you change the view in the beginning of your program?
sf::Event event;
event.type = sf::Event::Resized;
event.size.width = 800; // The width of the window, not the width of the view
event.size.height = 600; // The height of the window, not the height of the view
window.handleEvent(event);

I will try to debug it on my windows tomorrow.

TGUI: C++ SFML GUI

pighead10

  • Jr. Member
  • **
  • Posts: 56
    • View Profile
    • Hog Pog
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #92 on: August 02, 2012, 09:27:16 pm »
Nope, that doesn't have any effect. Also, is there any way to make callback activate when the object is underneath another object? I have a "selection box" object, which is a square with an outline and transparent centre positioned exactly on top of the object , but no callback is fired when I click on the object underneath.
Immortui - Zombie puzzle game: http://immortui.hogpog.co.uk

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #93 on: August 02, 2012, 09:58:22 pm »
I might have an idea on how to solve the view problem, I'll try it tomorrow.
For your other problem, it is not yet possible but it was on my todo list. As it shouldn't be to hard to implement I will give it a higher priority.

If I make a change it will be in v0.5, so I am afraid that even if I make those fixes you will still have to upgrade if you are still using v0.4.
TGUI: C++ SFML GUI

pighead10

  • Jr. Member
  • **
  • Posts: 56
    • View Profile
    • Hog Pog
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #94 on: August 02, 2012, 10:14:57 pm »
That's not a problem, upgrading SFML and tgui was on my todo list too. Thanks!
Immortui - Zombie puzzle game: http://immortui.hogpog.co.uk

Senzin

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #95 on: August 03, 2012, 12:14:07 am »
The formbuilder.exe I downloaded works fine. I wonder what could have caused such a strange bug with my build.

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #96 on: August 03, 2012, 12:36:38 am »
I wonder what could have caused such a strange bug with my build.
I made a small fix in my uploaded version. Before, the three windows were rendered together. I don't know why, but apparently it gave some strange results. If I had known that it caused that kind of behaviour I would have uploaded it earlier (I already made the fix a few days ago, I just didn't put it online yet).
TGUI: C++ SFML GUI

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #97 on: August 03, 2012, 08:44:08 pm »
@pighead10
I made some changes with the way the view is used in v0.5, so hopefully this solves your problem.
If your selection box is a Picture then you should now be able to click through it. Other objects will allow this in the future, but for now only a Picture will allow you to click through it.
TGUI: C++ SFML GUI

Beernutts

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #98 on: August 04, 2012, 04:33:11 pm »
Hi Texus,

I just DL'd you v 0.5 and am building it for Code::Blocks, but I'm getting errors.  I've fixed most of them, from this:
    const sf::Font* EditBox::getTextFont()
    {
        return m_TextBeforeSelection.getFont();
    }
 
to
    const sf::Font& EditBox::getTextFont()
    {
        return m_TextBeforeSelection.getFont();
    }
 
Changing * to &, as getFont() returns a reference, not a pointer.
(I had to do that for multiple .cpp's, and I modified where it was calling those functions.

But, then I ran into a bigger issue, which I can guess a fix, but I'm not sure.  Calling this:
unsigned int Builder::getClickedObjectID(sf::Event& event)
{
    // Check if the left mouse was pressed
    if (event.mouseButton.button == sf::Mouse::Left)
    {
        float mouseX = event.mouseButton.x / (mainWindow.getSize().x / mainWindow.getView().getSize().x);
        float mouseY = event.mouseButton.y / (mainWindow.getSize().y / mainWindow.getView().getSize().y);

        unsigned int highestID = 0;
        unsigned int objectID = 1;

        #define FindObjectNr(Object, objects) \
        for (unsigned int i=0; i<objects.size(); ++i) \
        { \
            tgui::Object* object = mainWindow.get<tgui::Object>(tgui::to_string(objects[i].id)); \
         \
            if (object->mouseOnObject(mouseX, mouseY)) \
            { \
                if (highestID < object->getObjectID()) \
                { \
                    if (highestID > 0) \
                        object->mouseNotOnObject(); \
                 \
                    highestID = object->getObjectID(); \
                    objectID = objects[i].id; \
                } \
            } \
        }


        FindObjectNr(Picture, pictures)
...
 

Gives me an error because getObjectID() is not defined anywhere.  I searched all through the code, and it's not there.  I can modify Objects.hpp, add the funciton, add an id, and just, in the constructor, increment a global ID and assign it that way, but I'm not sure what it is supposed to be used for.

Any ideas?

Thanks!  Looking forward to using this.

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #99 on: August 04, 2012, 04:42:43 pm »
The first problem, the one with the font is because you aren't using the latest sfml version.
I made the change from reference to pointer this morning because it was changed in sfml last night.

I forgot to update my form builder code after my rewrite from two days ago. I'll fix it as soon as possible.
(You might be able to use the executable from here until then).
TGUI: C++ SFML GUI

Beernutts

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #100 on: August 04, 2012, 04:53:11 pm »
WOW!  I downloaded the latest SFML snapshot two days ago, he updates sfml yesterday, and you update TGUI between now and then too!  Just my bad luck I guess :)

I've made the change to supply a unique ID from getObjectId() and it builds, and I can run Form Builder, but I'm not 100% sure it's right.  BTW, running the executable formbuilder.exe you linked just closes immediately with no errors.

Thanks.

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #101 on: August 04, 2012, 05:58:39 pm »
I should really do something about the error handling in my form builder. It closes immediately because it can't find its recources. If you execute it next to the images folder and the FormObjectsWindow.txt file then it should run.

Edit: The form builder should now work again.
« Last Edit: August 04, 2012, 08:52:25 pm by texus »
TGUI: C++ SFML GUI

Beernutts

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #102 on: August 05, 2012, 05:55:38 pm »
A simple request.  Would it be possible to make the button be able to also just load am Image as the button?  So, whenever anyone clicks the image, the button callback kicks off? 

I'm looking for something simple like that, so i figured you could overload tgui::Button::load() to take an image name (or maybe an sf::Image or sf::Texture).

Thanks for the work!

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #103 on: August 05, 2012, 08:20:08 pm »
I am not sure what you mean exactly. Do you just want a single image, so no hover and down images?
If this is what you want then you can just use the Picture struct. It will also send a callback when you click on it.
TGUI: C++ SFML GUI

Beernutts

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #104 on: August 06, 2012, 03:27:24 am »
I am not sure what you mean exactly. Do you just want a single image, so no hover and down images?
If this is what you want then you can just use the Picture struct. It will also send a callback when you click on it.

Oh, yes, that's what I want.  I didn't realize it would send a callback, so never mind.  Thanks again!

 

anything