tgui::Picture::Ptrs In ToolTips

Started by MoLAoS, 06 September 2015, 20:24:06

MoLAoS

How possible do you think it would be to spawn a tooltip that can have other images in it with their own tooltips? Basically recursive tooltips. A currently functional workaround may be having a function that spawns a panel or something on mouseover that stays up but it would probably be pretty complicated.

This feature is probably more relevant for games than other kinds of applications. The Glest Advanced Engine GUI could show picture widgets in tooltips and do some other stuff but I don't think those widgets could spawn their own tooltips.

texus

#1
Making the tooltip something different than a Label has been requested before.
The problem is currently the design of such functionality, the tooltip should be allowed to be a panel but it should still be as simple as it is now so that you can just set a string without hassle.

If the tooltip can be a panel then recursive tooltips are immediately supported as well.

Maybe I can make two functions: setToolTipText which works like the current one and setToolTip which takes a widget as parameter, any widget whether it is a picture or a panel.

Edit: I have been thinking about a few different ways of implementing it but all of them make using a tooltip more complex. I also realized that the recursive tooltips won't work because the tooltip goes away when you move the mouse.

MoLAoS

Quote from: texus on 06 September 2015, 21:12:20
Making the tooltip something different than a Label has been requested before.
The problem is currently the design of such functionality, the tooltip should be allowed to be a panel but it should still be as simple as it is now so that you can just set a string without hassle.

If the tooltip can be a panel then recursive tooltips are immediately supported as well.

Maybe I can make two functions: setToolTipText which works like the current one and setToolTip which takes a widget as parameter, any widget whether it is a picture or a panel.

Edit: I have been thinking about a few different ways of implementing it but all of them make using a tooltip more complex. I also realized that the recursive tooltips won't work because the tooltip goes away when you move the mouse.


Well yes, in the current implementation that would happen. But you could probably do something like check if it hovers over any child widget. Alternatively I suppose I could just try to fiddle with panels myself somehow. Probably wouldn't use mouseover in that case.

texus

Panels as tooltips is something that will happen, but recursive tooltips are out of the question. In order to have them I would have to keep the tool tip visible even after the mouse moves until it move off the tooltip (which is not that easy to detect since the mouse starts outside of it or on the top left corner, it would easily disappear when trying to move the mouse on it). And I don't like it when tooltips act that way.

So if you want such behavior you will indeed have to implement it in your own code.

texus

Pictures (or any other widget) are now supported as tool tips in TGUI 0.7-dev.

Normal tool tip:
Code (cpp) Select
tgui::Label::Ptr toolTip = theme->load("ToolTip");
toolTip->setText("Don't read this!");
button->setToolTip(toolTip);


Setting a picture as tool tip:
Code (cpp) Select
tgui::Picture::Ptr pic = std::make_shared<tgui::Picture>("Image.png");
pic->setSize(100, 100);
button->setToolTip(pic);


Changing the time to display and the distance between the mouse and the tool tip can be changed through the static functions from the ToolTip class:
Code (cpp) Select
tgui::ToolTip::setTimeToDisplay(sf::milliseconds(400));
tgui::ToolTip::setDistanceToMouse({10, 10});

MoLAoS

Quote from: texus on 08 September 2015, 16:26:11
Pictures (or any other widget) are now supported as tool tips in TGUI 0.7-dev.

Normal tool tip:
Code (cpp) Select
tgui::Label::Ptr toolTip = theme->load("ToolTip");
toolTip->setText("Don't read this!");
button->setToolTip(toolTip);


Setting a picture as tool tip:
Code (cpp) Select
tgui::Picture::Ptr pic = std::make_shared<tgui::Picture>("Image.png");
pic->setSize(100, 100);
button->setToolTip(pic);


Changing the time to display and the distance between the mouse and the tool tip can be changed through the static functions from the ToolTip class:
Code (cpp) Select
tgui::ToolTip::setTimeToDisplay(sf::milliseconds(400));
tgui::ToolTip::setDistanceToMouse({10, 10});


cool, that was fast.