Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - texus

Pages: 1 2 [3] 4 5 ... 109
31
Help requests / Re: How to build tgui on android
« on: 05 February 2021, 22:48:56 »
I did some tests and some reading, you can't really use Visual Studio for this.

If you have MinGW installed then you can use that, otherwise you can download Ninja (which is a single executable that you can place anywhere you want, so it is a lot less than having to install the entire MinGW package just to use a small part of it). To download ninja, get "ninja-win.zip" from https://github.com/ninja-build/ninja/releases

I had to make the following changes to the cmake step:
- Delete the contents of the build directory that you already created, you need to start a fresh build.
- I had to use CMake 3.19, when using CMake 3.18 it would look for android stuff in the wrong directory
- Pass "Ninja" as parameter to the "-G" flag (use "MinGW Makefiles" when using MinGW)
- When using ninja, set CMAKE_MAKE_PROGRAM to the executable location. The same applies for MinGW and mingw32-make.exe, but MinGW is probably installed in the PATH which makes this step unnecessary.
- I had to use slashes in the android NDK path, it didn't like the backslashes (it was interpreting them as escape characters, so using "\\" instead of "/" would probably work as well).

This is the command I used:
Code: [Select]
cmake -G Ninja -DCMAKE_MAKE_PROGRAM="D:\Downloads\ninja.exe" -DCMAKE_SYSTEM_NAME=Android -DCMAKE_ANDROID_NDK="C:/Users/texus/AppData/Local/Android/Sdk/ndk/22.0.7026061" -DCMAKE_ANDROID_ARCH_ABI=x86 -DCMAKE_BUILD_TYPE=Debug ..
At this point for me it complained about not finding SFML because I currently don't have the SFML android libraries installed. If you have SFML installed in your NDK then it should find them automatically (at least it does on linux).
I will try building SFML tomorrow and see if there are any more difficulties to solve in getting TGUI's android build working on windows.

Assuming it find the SFML libraries for you and the cmake step completes, you would probably have to run "ninja" and "ninja install" to create the libraries and installing them to the NDK (you will likely need the entire file path to the ninja executable instead of just writing "ninja").

32
Help requests / Re: How to build tgui on android
« on: 04 February 2021, 18:42:11 »
I have no idea about that.

Does it give you the same error if you remove the "-A Win32" from the command?

If that doesn't work then you could try installing MinGW-w64 (https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/installer/mingw-w64-install.exe/download).
You would then need to change the "-G" parameter in the cmake command from "Visual Studio 16 2019" to "MinGW Makefiles".
If the cmake step would finish with MinGW then you probably have to run "mingw32-make" and "mingw32-make install" afterwards (this is the equivalent step to building the project with Visual Studio and also building the INSTALL target in visual studio).

I don't have android tools installed on my windows, so I currently can't do any tests. I will probably be able to try building on Windows myself this weekend.

33
Help requests / Re: How to build tgui on android
« on: 04 February 2021, 09:38:54 »
Was there a .sln file in the build folder? I think you just opened the wrong file.

Check if there is a .sln file next to the .vcxproj file and open that one with Visual Studio.

34
Help requests / Re: How to build tgui on android
« on: 04 February 2021, 08:34:57 »
I wouldn't use the graphical interface actually, unless you already know how to use it. For building TGUI for windows it is fine because all properties exist, but for Android you need to start manually creating properties, so I find using the command line easier.

On linux you have the "make" command, but on Windows you will need some kind of build system installed. Do you have either Visual Studio or MinGW installed? The guide below will assume you have Visual Studio 2019, if you have a different version then have a look at https://cmake.org/cmake/help/v3.19/manual/cmake-generators.7.html#id13 for what you need to pass behind the "-G" in the cmake command.

I haven't tried the follow the following instructions, so there may be errors in it, but you should do something like this:

- Create a new "build-android" folder inside the TGUI folder you downloaded.

- Open a command prompt. (Press Win+R and type "cmd.exe" without the quotes to start one)

- Navigate to your TGUI folder in the command prompty.  (e.g. if TGUI is located in C:\TGUI then type "cd C:\TGUI\build-android" without the quotes and hit enter)

- Run the following cmake command in the terminal. Make sure to replace "/path/to/ndk" with the path to the NDK (which is probably part of your Android Studio installation).
Code: [Select]
cmake -G "Visual Studio 16 2019" -DCMAKE_SYSTEM_NAME=Android -DCMAKE_ANDROID_NDK=/path/to/ndk -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a -DCMAKE_BUILD_TYPE=Debug ..
If it all goes well then there should be a Visual Studio project in the build-android folder which you can open and build. That will produce the libraries.

35
Help requests / Re: How to build tgui on android
« on: 03 February 2021, 22:15:40 »
I'm not sure where you are stuck.
How did you build SFML? The instructions are very similar. I could try to explain in more detail how to run cmake, but didn't you already have to do that for SFML as well?

36
Help requests / Re: How to build tgui on android
« on: 03 February 2021, 18:32:26 »
What OS are you using? The commands that are given have to be run on the command line and might be slightly different on platforms other than linux.

I can't give you a better guide than what the tutorial contains, but if you get stuck on specific things or don't understand some of the instructions then I might be able to clarify that part.
The first step if just running cmake. You can use the graphical cmake interface if you prefer, "-DCMAKE_SYSTEM_NAME=Android" in the command would mean to create a CMAKE_SYSTEM_NAME property and set its value to "Android".

37
Help requests / Re: button->connect issues
« on: 31 January 2021, 14:00:28 »
Try "std::ref(gui)" instead of "gui", since your function takes a reference as parameter.

38
Help requests / Re: button->connect issues
« on: 30 January 2021, 19:51:47 »
I can't reproduce such error.
Can you post some minimal code that I can copy-paste so that I'm testing the exact same code?

39
Help requests / Re: button->connect issues
« on: 30 January 2021, 17:30:28 »
Your parameters are in the wrong order. The showPause function is declared with the window as second parameter but you are passing it as first parameter in the connect call.

40
Help requests / Re: How to use file form generated by GUI_BUILDER?
« on: 29 December 2020, 18:58:24 »
You can call gui.loadWidgetsFromFile(filename).
You can also call the function on a Container widget instead of on the Gui, in case you want the form to be loaded inside a child window.

The only place where this is currently mentioned is the tgui homepage. It doesn't belong there, but I placed it there to have it at least mentioned somewhere :)

41
Yes, I meant mouseDownEvent instead of event.

The getWidgetBelowMouseCursor was actually added to 0.8 as well, but its currently only in the 0.8 branch on github (which will become 0.8.9).

42
MouseReleased in ListBox wasn't made for this. It was added so that you could know when selecting an item end (since you can hold down the mouse button and move to select a different item).

Dragging an object on top of another is not really something supported in TGUI. You can drag things (e.g. the thumb of a slider), but until you drop it all events to other widgets are ignored. Since you need special code for dragging anyway, you might as well add some extra code to handle dropping it on the right item. I would just add the following code before the gui.handleEvent call to simulate a mouse down event before processing the mouse release:
Code: (cpp) [Select]
if (dragging && (event.type == sf::Event::MouseButtonReleased)
 && (gui.getWidgetBelowMouseCursor({event.mouseButton.x, event.mouseButton.y}) == listBox))
{
    sf::Event mouseDownEvent = event;
    event.type = sf::Event::MouseButtonPressed;
    gui.handleEvent(mouseDownEvent);
}

43
Thanks for reporting and providing a clear MCVE. This has now been fixed in the latest 0.9-dev version.

44
Help requests / Re: Tool Tip Functionning - 1 Tooltip for X buttons
« on: 25 October 2020, 13:09:26 »
The gui builder simply doesn't support tool tips yet.

Quote
This would mean I shouldn't put it in the same file as my main gui ?
You could technically still store it in the main gui, but directly after calling xgui.loadWidgetsFromFile you would have to remove it again:
Code: (cpp) [Select]
tgui::ChildWindow::Ptr toolTipChildWindow = xgui.get<tgui::ChildWindow>("child_game_city_construction_tooltip");
xgui.remove(toolTipChildWindow);
// Use the toolTipChildWindow variable directly when calling setToolTip and setTitle.

The loadWidgetsFromFile will always add all widgets to the parent (because otherwise there would be no way to access the widget after calling loadWidgetsFromFile), so if you use a second file then you can't put a ChildWindow widget in there either. The second file would have to contain the contents of the child window (e.g. just a label) and in your c++ code you would have to create the child window yourself, give it a title and size and call childWindow->loadWidgetsFromFile("tooltip_contents_form.txt").

If the contents of the child window doesn't change too much based on the the button you are on then you can use one of the above solutions, but otherwise you might want to create everything dynamically in c++. The gui builder was intended for static forms and even tool tips were designed to be static (one tool tip for each button instead of reusing the same child window). It is possible to reuse the same child window (with a hack such as changing the contents on the the MouseEntered signal), but what you are trying to do was never considered so there is no "correct" solution for it.

45
Help requests / Re: Tool Tip Functionning - 1 Tooltip for X buttons
« on: 23 October 2020, 18:31:23 »
Some parts of the tool tip are automatically handled by TGUI and you shouldn't change them yourself:
- the position (what you pass to setPosition is added as an offset for the tool tip relative to your mouse, it isn't an absolute position like with normal widgets)
- the visibility (you should never have to call setVisible on a tooltip widget, TGUI will show and hide them automatically)
- the parent (i.e. don't call gui.add on the tooltip)

The crash originates from the fact that you have made the child window a part of xgui instead of letting the buttons handle the tool tip.
In order for widgets to show up on the screen, they need to be added to the gui (either directly or indirectly via some container widget). So when the button wants to show the tool tip, it adds it to the gui (which does practically nothing since you already did that). But when the tool tip gets hidden, the button removes the tool tip child window from the gui. So when you hover over the next button, `xgui.get<tgui::ChildWindow>("child_game_city_construction_tooltip")` will return a nullptr and the code crashes as you attempt to call setTitle on a nullptr.

The solution is to not add the child window to the gui (i.e. don't call xgui.add(childWindow) and instead store the child window pointer somewhere so that you can call `button->setToolTip(childWindow)` and `childWindow->setTitle(...)`. This solves both the crash and the wrong behavior where the child window is visible before you hover over a button.

Btw, when you get another crash, you should check the call stack in your IDE, it tells you where the crash happened. This information can save time in searching what went wrong.

Pages: 1 2 [3] 4 5 ... 109