by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Bruno Van de Velde
@texus
@DJuego Did you set the minimum or maximum for that knob somewhere?
Does getValue() return the value that you passed to setValue()?
Did you try it with another value as well?
DJuego
@DJuego
Hi @texus. No . I don't set programatically the minimum/maximum. I use the TGUI editor with values minimun -180 and maximun +181. It works. The knob is responsive to events. I can move the dial as i expect.
No. getValue() returns the previous value. The setValue() is ignored.
Bruno Van de Velde
@texus
What are the values returned by getMinimum() and getMaximum()?
DJuego
@DJuego
tgui::Knob::Ptr knob_orientacion = m_gui.get<tgui::Knob>("Knob1");
knob_orientacion->setValue(33);
auto valor = knob_orientacion->getValue();
auto minimum = knob_orientacion->getMinimum();
auto maximum = knob_orientacion->getMaximum();
valor = -53
minimum = -180
maximum = 181
They are the expected values of maximum and minimum.
"valor" should be 33.
Bruno Van de Velde
@texus
Is there a callback function connected on value change? Is the value still wrong when executing knob_orientation->disconnectAll(); before setting the value?
DJuego
@DJuego
I have another knobs in the same program. It works perfectly with setValue(). The only difference is the size of the problematic knob. It is "big". Height/Width is 400. The parameters maximum and minimum are the same.
A second please.
Yes! I have debugged the callback function. That's probably the problem.
DJuego
@DJuego
Of course, that was the problem. Next time I will investigate deeply before I issue an alert around here. ;-) A series of fortuitous coincidences meant that in the other knobs the problem did not manifest itself. That's why I was perplexed.
Thank you very much, @texus.
Nikita
@GoverLabs
Hi Texus! Just want to say that tgui::Signals namespace is awesome! Finding correct signal name was a bit tricky and distracting.
DJuego
@DJuego
Hi again to all!!
I try to develop an application that uses TGUI for the graphical interface, and QtBluetooth.
Unfortunately it seems that there is some incompatibility.
DJuego
@DJuego
I am working in Windows 10 x64, Visual Studio 2017, Qt 5.13.1, TGUI from master.
DJuego
@DJuego
When i add: #include <QtBluetooth/qbluetoothsocket.h>
I get:
w:\archivos_de_programa\msvc2017\x64\tgui\include\tgui\signal.hpp(312): error C2059: syntax error: 'const'
1>w:\archivos_de_programa\msvc2017\x64\tgui\include\tgui\signal.hpp(313): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
1>w:\archivos_de_programa\msvc2017\x64\tgui\include\tgui\signal.hpp(452): error C2059: syntax error: 'const'
1>w:\archivos_de_programa\msvc2017\x64\tgui\include\tgui\signal.hpp(452): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
1>w:\archivos_de_programa\msvc2017\x64\tgui\include\tgui\signal.hpp(453): error C2059: syntax error: 'const'
1>w:\archivos_de_programa\msvc2017\x64\tgui\include\tgui\signal.hpp(453): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
1>w:\archivos_de_programa\msvc2017\x64\tgui\include\tgui\signal.hpp(454): error C2059: syntax error: 'const'
[...]
Bruno Van de Velde
@texus
@DJuego Does it work when you put the qbluetoothsocket include behind the TGUI include instead of infront of it?
DJuego
@DJuego
Yes, @texus
The problem seems to be that Qt defines a macro "emit".
Bruno Van de Velde
@texus
Yeah, you will either have to undefine emit before including TGUI or make sure Qt isn't included before TGUI
DJuego
@DJuego
I see. It would be interesting to document it, if it cannot be resolved.
In any case, this fix works for me for this program.
Bruno Van de Velde
@texus
Any macro from any external library will break code with the same names, I'm not sure if it is the job of TGUI to list these conflicts.
For the issue with windows.h I have code in TGUI that prevents the conflict, but I don't think I can solve this case with Qt in TGUI that way as it will prevent the user from actually using the emit from Qt if I undefine it
DJuego
@DJuego
I get it. Let's hope the solution is always that simple.
Thank you for your attention, @texus .
Bruno Van de Velde
@texus
The safest way to prevent issues with multiple libraries is always to put code that uses them in separate cpp files
In conflicts where swapping the include order doesn't work, that would be the solution
DJuego
@DJuego
I know what you mean. But I don't know if that's always feasible.
Tom Niget
@zdimension
Good afternoon, I'm using the .NET bindings for a C# program and I'm encountering some garbage collection problems; I'm trying to initialize all the GUI components in a separate method and for some reason this causes problems at runtime
It seems that the .NET GC is collecting some of the delegates used internally by some widgets, so I'm getting CallbackOnCollectedDelegate errors
Storing all the widgets in a list to take ownership of them or even GC.KeepAlive'ing them doesn't seem to make any change at all
Bruno Van de Velde
@texus
In case someone finds this issue later, the CallbackOnCollectedDelegate issue has been fixed in TGUI.Net 0.8.3.11
Bryan Triana
@BryanTriana
Anyone know how to use mouseOnWidget using SFML? Right now I am trying to check if the mouse is hovering a certain button but it seems the coordinates between SFML and TGUI are not the same. Here is some code showing what I am doing:
void States::SettingsState::handleEvent(const sf::Event& event)
{
    if (event.type == sf::Event::KeyPressed)
    {
        auto& keyBindingSettings = App::KeyBindingSettings::getInstance();

        auto mousePosition = window.mapPixelToCoords({ sf::Mouse::getPosition(window) });

        if (moveUpButton->mouseOnWidget(mousePosition))
        {
            std::cout << "UPP\n";
        }
        else if (moveDownButton->mouseOnWidget(mousePosition))
        {
            std::cout << "Down\n";
        }
        else if (moveRightButton->mouseOnWidget(mousePosition))
        {
            std::cout << "Right\n";
        }
        else if (moveLeftButton->mouseOnWidget(mousePosition))
        {
            std::cout << "Left\n";
        }
    }
}
Bruno Van de Velde
@texus

@BryanTriana TGUI widgets aren't really supposed to be queried directly. You would normally just pass the sf::Event to TGUI and connect the MouseEntered and MouseLeft signals on the buttons so that you get a callback when the mouse gets on top or leaves the buttons.

The code you showed might fail in 2 cases:

  • If the buttons are not directly added to the gui. If they are part of a child window then the position in the button is relative to the child window. You would then have to use mousePosition - childWindow->getPosition() - childWindow->getChildWidgetsOffset() to mouseOnWidget.
  • If the SFML and TGUI view is configured differently. Both your sf::RenderWindow and tgui::Gui can be given a view, the mapPixelToCoords will use the SFML view by default. You can tell it to use the TGUI view by passing the view as second parameter: window.mapPixelToCoords({ sf::Mouse::getPosition(window) }, gui.getView())
Olle Samuelsson
@kroyee
Using getAbsolutePosition could also be an option I'm guessing?
Something like sf::Rect<float>(button->getAbsolutePosition(), button->getSize()).contains(mousePosition)
Bruno Van de Velde
@texus
That would probably work for most widgets. If there is a difference between getSize and getFullSize then it might be wrong (e.g. that code will return false when hovering over the text of a checkbox)
But instead of manually having to care about the parents of the buttons and subtracting their position and offset, you could use getAbsolutePosition to just pass mousePosition - (button->getAbsolutePosition() - button->getPosition()) to mouseOnWidget. That should work no matter how many layers deep the button is placed.
Olle Samuelsson
@kroyee
Right, that seems like the better approach.
Bryan Triana
@BryanTriana
@texus Thanks, I think I will approach this using the MouseEntered and MouseLeft signals as it seems like it is the cleanest solution.