Main Menu
Menu

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.

Show posts Menu

Messages - texus

#276
Help requests / Re: How to build tgui on android
06 February 2021, 11:10:46
If you are still interested in trying SFML and TGUI on android then I've build some libraries that you should be able to use.

Download: https://www.dropbox.com/s/efsbs1ni5inzo1d/sfml-tgui-android-debug.zip?dl=1  (42.3 MB)

The zip file contains an "sfml" and a "tgui" folder. These folders need to be placed in "C:/Users/Alexhero/AppData/Local/Android/Sdk/ndk/22.0.7026061/sources/third_party".
They contain debug libraries for both x86 and armeabi-v7a.

(I only build the libraries, I didn't try to run a program with them)
#277
Help requests / Re: How to build tgui on android
06 February 2021, 10:36:56
I looked into building SFML, but it still has its issues.
SFML 2.5.1 had 2 issues that prevented me from using it on android in the past.

The first one caused a crash at runtime and has been solved recently (3 weeks ago), so the latest version from github should be able to run on android (but I haven't tested it yet).

The second issue, which still exists in the latest github version, is that it doesn't support NDK 22 (which you are using). There is a workaround to make it work, but it does raise the question: what NDK version were your SFML libraries compiled for?
The TGUI libraries must be compiled with the exact same version of the NDK. If someone just gave you SFML libraries and you are then going to build TGUI libraries yourself, then they may not match and your program will most likely just crash (if it doesn't already fail when linking).

There is also a third issue for some people: SFML has no support for 64-bit platforms, which means you can't publish your app in the App Store.
#278
Help requests / Re: How to build tgui on android
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:
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").
#279
Help requests / Re: How to build tgui on android
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.
#280
Help requests / Re: How to build tgui on android
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.
#281
Help requests / Re: How to build tgui on android
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).
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.
#282
Help requests / Re: How to build tgui on android
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?
#283
Help requests / Re: How to build tgui on android
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".
#284
Help requests / Re: button->connect issues
31 January 2021, 14:00:28
Try "std::ref(gui)" instead of "gui", since your function takes a reference as parameter.
#285
Help requests / Re: button->connect issues
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?
#286
Help requests / Re: button->connect issues
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.
#287
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 :)
#288
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).
#289
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);
}
#290
Thanks for reporting and providing a clear MCVE. This has now been fixed in the latest 0.9-dev version.
#291
The gui builder simply doesn't support tool tips yet.

QuoteThis 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.
#292
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.
#293
Help requests / Re: Texture for RangeSlider
13 October 2020, 08:29:50
I think I finally understood what you mean. When textures are loaded, nothing extra is shown inbetween the two thumbs.
I'll try to fix this soon (in TGUI 0.9-dev).

Edit: I've already fixed the SelectedTrackColor property, it should work now even when textures are loaded. I'll look into adding a new SelectedTrackTexture property later.

Edit2: TextureSelectedTrack and TextureSelectedTrackHover properties have been added to RangeSliderRenderer.
#294
Help requests / Re: Texture for RangeSlider
12 October 2020, 08:22:12
QuoteRangeSlider is inherited from Slider
It actually doesn't, it just contains mostly the same code.

QuoteI can not set the RangeSlider to display textures (available to Sliders)
What exactly doesn't work? Do you get an error or does is just not show the textures?

I just tried loading the black theme and using the Slider section to create the RangeSlider like below and it worked (it's not recommended to use a section of a wrong type, but it works here because they do support the same properties).
Code (cpp) Select
rangeSlider->setRenderer(theme.getRenderer("Slider"));

QuoteThere does not seem to be a way to load textures for the space between the two thumbs.
This indeed seems to be missing.
There are 2 ways this could be implemented though. You could have a texture that has the same size as the track and of which only a part is shows (similarly to how the front image in ProgressBar works), or you could have a small texture with the same height as the track which is stretched horizontally to fill the selected area. I guess the first one would be the better option because it can handle rounded corners on the track or other special cases.
#295
Could it be that C:/Strawberry/c/include/freetype2 is giving a conflict with the freetype that comes with SFML?
#296
I don't see anything wrong with those files, it says that it has freetype at T:/libraries/C++/SFML-2.5.1/extlibs/libs-msvc-universal/x86/freetype.lib

Did you download the SFML version from github?
You are setting TGUI_SHARED_LIBS to FALSE, right?
Could you send the CMakeCache.txt file from your TGUI build?
Could you send your entire SFML folder?

I'm not sure when I'll find enough time to look into this in detail, but if you send me those files then I'll try to find some explanation when I find the time.

By placing the old code back in TGUI's cmake you are changing the CMAKE_INCLUDE_PATH and CMAKE_LIBRARY_PATH variables and the issue is only solved as a side-effect of this (those lines existed in the cmake script for building the gui builder and tests, not for finding sfml). So although it works, it isn't really the solution (it only works by accident that way).
#297
Could you send the SFML*.cmake files to me that you have inside your build folder?
#298
Then were did the SFML folder come from?
SFML doesn't has a SFMLConfig.cmake in the root by default. If you e.g. download it from the SFML website then the file will be in lib/cmake/SFML.
Did you build SFML yourself with CMake? If so, did you create a build directory?
The only case that I can think of where the file would be located there is when you build SFML with CMake and set the build directory to the same as the source directory, but even then it should be able to find freetype.
#299
Did you manually copy the SFMLConfig.cmake to a different location, because it seems like SFMLConfig.cmake can't find FreeType? The SFMLConfig.cmake hardcodes relative paths, so you are supposed to keep the SFML folder structure.

The SFML_ROOT method hasn't been recommended for quite some time already (because SFML changed the way you are supposed to find it with CMake), and I don't recommend adding back the code that uses it.

It might work when you put the hardcoded paths back into TGUI's CMake file, but the whole idea of using SFMLConfig.cmake (compared to the old FindSFML.cmake) was that I wouldn't have to hardcode these extlib paths anymore.
#300
Help requests / Re: Menu item clicks
14 September 2020, 17:03:17
The connectMenuItem function is still the correct way to do this (and it just calls onMenuItemClick internally). Although it is a bit weird that all other connects are handled by onXxx, it has always been a bit of a weird function (since every other signal used the normal "connect" function while here you needed "connectMenuItem"). I don't immediately see a better way to do it, so connectMenuItem is likely going to remain unchanged.