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

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

0 Members and 1 Guest are viewing this topic.

texus

  • Sr. Member
  • ****
  • Posts: 499
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #435 on: February 19, 2013, 09:26:48 pm »
These errors mean that you have to link to opengl (by adding "-lGL" to your linker options.

I guess I should update the tutorial. Last time I tested the libraries I didn't have any problems, but it might have been before I started using opengl code.
TGUI: C++ SFML GUI

Gan

  • Jr. Member
  • **
  • Posts: 98
    • View Profile
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #436 on: February 20, 2013, 01:48:56 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>();
I can't create a panel in 1.5. Your 1.5 example works but adding panel creation causes a crash. (I tested with a clean version of your library)

Edit:
1.6 doesn't crash, but no panel shows on screen. This code:
Code: [Select]
tgui::Panel* panel = window.add<tgui::Panel>();
panel->setPosition(100, 100);
panel->setSize(100, 100);
panel->setBackgroundColor(sf::Color::Red);

Edit 2:
Got the panel to show with this code:
Code: [Select]
tgui::Panel* panel = window.add<tgui::Panel>();
panel->load(500, 500);
panel->setPosition(100, 100);
panel->setBackgroundColor(sf::Color::Red);

Edit 3:
I just skewered the 1.6 code. Tossed the background code and added the setBackgroundTexture function. Also ruined the ChildWindow cause apparently that uses a lot of the panel code. Good thing I won't need that yet...

Edit 4:
Strangest thing, I can create a panel using the altered 1.6 code in an example program. But it crashes when I do the same code in my other application. Hmmmm. Crash line:
m_EventManager.m_Objects.push_back(newObject);
With and exc_bad_access. Maybe I deleted something that shouldn't have been deleted.

Edit 5:
It may not be my changes that are making it crash. I decided to add a label instead of a panel, this code causes it to crash:
Code: [Select]
tgui::Label* labelUsername = window->add<tgui::Label>();
    labelUsername->setText("Username:");
    labelUsername->setPosition(200, 100);

Edit 6:
 ;D Nevermind. I was using the window object before I set it.
« Last Edit: February 20, 2013, 08:17:33 pm by Gan »

Gan

  • Jr. Member
  • **
  • Posts: 98
    • View Profile
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #437 on: February 20, 2013, 08:17:40 pm »
How do I use 1.6 callbacks?
I noticed this code:
Code: [Select]
panel->bindCallback(<#boost::function<void ()> func#>, <#unsigned int trigger#>);But where are the triggers defined?

texus

  • Sr. Member
  • ****
  • Posts: 499
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #438 on: February 20, 2013, 08:37:36 pm »
I'm glad that the panel problems are solved then.

The triggers are defined inside the objects, so they are spread over multiple places.

Every layer has it's own triggers. An example:
- Object has Focused, Unfocused, MouseLeft, MouseEntered triggers.
- ClickableObject has LeftMouseDown, LeftMousePressed and LeftMouseClicked.
- Button adds SpaceKeyPressed and EnterKeyPressed.
So when using a button, you can use all of the above callback triggers. You don't need to know where they are exactly to use them. Just use tgui::Button::LeftMouseClicked to access the trigger.

Be aware that the triggers I gave above are not correct. The triggers are named slightly different in the current downloadable version so you will have to take a look in the header files for now.

Hopefully this will get easier once I finish the documentation.

And it's version 0.6 by the way, not 1.6 :)
TGUI: C++ SFML GUI

Gan

  • Jr. Member
  • **
  • Posts: 98
    • View Profile
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #439 on: February 20, 2013, 09:16:00 pm »
Sweet, got the callback working.
Though how do I get the mouseX and mouseY in the panel?

Code: [Select]
panel->bindCallback(boost::bind(&DesignerGrid::mouseDown, this), tgui::Panel::MouseLeft);
...
void DesignerGrid::mouseDown() {
//int x, int y ?
}

Edit:
Actually even though it is binded, mouseDown isn't being called.

Edit 2:
I might not have the latest 0.6, I'll download it

Edit 3:
Had the feb 3rd version, downloading the Feb 8 version now.

Edit 4:
Is the TGUI master branch 0.6?
I can't seem to find any of the callback functions in the Panel header file.
« Last Edit: February 20, 2013, 09:24:15 pm by Gan »

texus

  • Sr. Member
  • ****
  • Posts: 499
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #440 on: February 20, 2013, 11:08:14 pm »
Currently the downloads are a bit of a mess.
The master branch is still v0.5, the v0.6 is not on github yet.
So the version from 3 february on my site was the latest version.

For your problem: MouseLeft is not LeftMouseClick. Your callback function is going to be called when the mouse leaves the panel, not when you click it. In fact there isn't any way to check if the panel was clicked yet, you'll have to make the objects inside of the panel tell you that they were clicked.

I am going to try to get everything online this weekend, including the fixes to your problems.
I'll make Panel and ChildWindow work with background textures and add a callback to the panel when it is clicked.

If you have a callback and you want to find out the mouse position then you'll need to add a parameter to your callback function.
void mouseDown(const Callback& callback) {
    // Only do the following when the callback has something to do with the mouse (check callback.trigger).
    // On e.g. a key press, these values will contain nonsense.
    int x = callback.mouse.x;
    int y = callback.mouse.y;
}
TGUI: C++ SFML GUI

Gan

  • Jr. Member
  • **
  • Posts: 98
    • View Profile
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #441 on: February 21, 2013, 01:06:27 am »
 ;D So excited.

I'll route click and mouse events from the window for now, until you release the next version of awesomeness.

netrick

  • Full Member
  • ***
  • Posts: 174
    • View Profile
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #442 on: February 22, 2013, 07:31:11 pm »
What are changes between 0.5 and 0.5.1?

texus

  • Sr. Member
  • ****
  • Posts: 499
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #443 on: February 22, 2013, 07:34:39 pm »
- Added support for changing the title alignment in ChildWindow.
- Fixed a minor bug with unfocusing objects.
- Fixed a small bug in the CMake script.
TGUI: C++ SFML GUI

texus

  • Sr. Member
  • ****
  • Posts: 499
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #444 on: February 23, 2013, 06:43:20 pm »
The next development version of v0.6 has arrived (with the smart pointers and other improvements).

This will be the last time I'll announce a new snapshot as from now on you can find the latest version on github.
So the master branch is now v0.6 (and v0.5 has been moved to it's own branch).

I haven't had enough time to really test all those changes, but it compiles and the simple example codes work so there shouldn't be too much problems. If you do find bugs then let me know and I'll try to fix them asap.

There still aren't many tutorials for this version, but I have already finished the installation and introduction tutorials.
For the rest you can look at the documentation and changelog.
The download also includes a few example codes to get the basics working.
TGUI: C++ SFML GUI

Cpl.Bator

  • Hero Member
  • *****
  • Posts: 540
    • View Profile
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #445 on: February 24, 2013, 12:40:20 pm »
if i want use the tgui source directly in my code , i must add definition in cmake for no error :
Quote
add_definitions(-DSFML_STATIC)
but, is not true. i use sfml with dynamic link.

texus

  • Sr. Member
  • ****
  • Posts: 499
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #446 on: February 24, 2013, 01:24:37 pm »
What error are you talking about exactly?

Just a wild guess, but try to add -Dtgui_EXPORTS instead.
TGUI: C++ SFML GUI

Cpl.Bator

  • Hero Member
  • *****
  • Posts: 540
    • View Profile
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #447 on: February 24, 2013, 01:43:33 pm »
Quote
C:\Users\JEROME\Desktop\Paint\src\TGUI\AnimatedButton.cpp:38:5: attention : 'tgu
i::AnimatedButton::AnimatedButton()' redeclared without dllimport attribute: pre
vious dllimport ignored [-Wattributes]
C:\Users\JEROME\Desktop\Paint\src\TGUI\AnimatedButton.cpp:52:5: attention : 'tgu
i::AnimatedButton::AnimatedButton(const tgui::AnimatedButton&)' redeclared witho
ut dllimport attribute: previous dllimport ignored [-Wattributes]
C:\Users\JEROME\Desktop\Paint\src\TGUI\AnimatedButton.cpp:101:5: attention : 'vi
rtual tgui::AnimatedButton::~AnimatedButton()' redeclared without dllimport attr
ibute: previous dllimport ignored [-Wattributes]
C:\Users\JEROME\Desktop\Paint\src\TGUI\AnimatedButton.cpp:132:21: attention : 't
gui::AnimatedButton& tgui::AnimatedButton::operator=(const tgui::AnimatedButton&
)' redeclared without dllimport attribute: previous dllimport ignored [-Wattribu
tes]
C:\Users\JEROME\Desktop\Paint\src\TGUI\AnimatedButton.cpp:164:21: attention : 'v
irtual tgui::AnimatedButton* tgui::AnimatedButton::clone()' redeclared without d
llimport attribute: previous dllimport ignored [-Wattributes]
C:\Users\JEROME\Desktop\Paint\src\TGUI\AnimatedButton.cpp:171:10: attention : 'v
irtual bool tgui::AnimatedButton::load(const string&)' redeclared without dllimp
ort attribute: previous dllimport ignored [-Wattributes]
C:\Users\JEROME\Desktop\Paint\src\TGUI\AnimatedButton.cpp:518:10: attention : 'v
irtual void tgui::AnimatedButton::setSize(float, float)' redeclared without dlli
mport attribute: previous dllimport ignored [-Wattributes]
C:\Users\JEROME\Desktop\Paint\src\TGUI\AnimatedButton.cpp:535:17: attention : 'v
irtual std::string tgui::AnimatedButton::getLoadedPathname() const' redeclared w
ithout dllimport attribute: previous dllimport ignored [-Wattributes]
C:\Users\JEROME\Desktop\Paint\src\TGUI\AnimatedButton.cpp:542:10: attention : 'v
irtual void tgui::AnimatedButton::setText(const sf::String&)' redeclared without
 dllimport attribute after being referenced with dll linkage [enabled by default
]

Work fine with -Dtgui_EXPORTS
Very great job ! i waiting for single bitmap for customize the gui  :P

Cpl.Bator

  • Hero Member
  • *****
  • Posts: 540
    • View Profile
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #448 on: February 24, 2013, 02:09:01 pm »
there is a mistake on the doxygen for childWindow :
Quote
virtual bool    load (float width, float height, const sf::Color &backgroundColor, const std::string &pathname)

The std::string is the first parameter , not the last.

texus

  • Sr. Member
  • ****
  • Posts: 499
    • View Profile
    • TGUI
    • Email
Re: TGUI: a c++ GUI for SFML (with Form Builder)
« Reply #449 on: February 24, 2013, 02:23:21 pm »
Those errors are indeed what you get with the combination of windows + dynamic linking + using source code directly.
Change any of those three things (or define tgui_EXPORTS) and you won't have any problems.

If you are waiting for me to add the feature of customizing with a single bitmap then you're going to wait for a long time. It's not planned anywhere soon.

The documentation is indeed wrong, I guess I uploaded a slightly outdated documentation (the parameter changed yesterday). I'll fix that in a few minutes.
TGUI: C++ SFML GUI

 

anything