Main Menu

Recent posts

#21
Help requests / Segmentation fault during copy...
Last post by GetterSetter - 06 April 2024, 22:02:00
Hello, the following line of code gives me a segmentation fault during execution and I don't know why:
texture.loadFromPixelData(smg.getSize(), smg.getPixelsPtr());
//smg - sf::Image;
//texture - tgui::Texture;
I definitely know that sf::Image is loaded correctly and is not empty.
The call stack:
tgui::Backend::createTexture() (Unknown:0)
tgui::Texture::loadFromPixelData(tgui::Vector2<unsigned int>, unsigned char const*, tgui::Rect<unsigned int> const&, tgui::Rect<unsigned int> const&, bool) (Unknown:0)
Backend::GetTextureFromClipboard() (Backend.hpp:37)
main() (test.cpp:41)
UPD: I've rebuilt tgui with debug flag and I have the following message from tgui::getBackend():
TGUI assertion: getBackend() was called while there is no backend
test: /.../LIBS/TGUI-1.2.0/src/Backend/Window/Backend.cpp:77: std::shared_ptr<tgui::Backend> tgui::getBackend(): Assertion `globalBackend != nullptr' failed.

Okay, I've got the idea. I must have some backend (i.e. tgui::Gui), but why?
#22
Help requests / Re: Changing SpinControl value...
Last post by GetterSetter - 05 April 2024, 20:45:23
Okay, thank you a lot!
#23
Help requests / Re: Changing SpinControl value...
Last post by texus - 05 April 2024, 18:21:04
You can temporarily disable the onValueChange signal:
Code (cpp) Select
SpindleControl2->onValueChange.setEnabled(false);
SpindleControl2->setValue(BalancedValue);
SpindleControl2->onValueChange.setEnabled(true);
#24
Help requests / Changing SpinControl value wit...
Last post by GetterSetter - 05 April 2024, 17:55:07
Hello, I want to change SpinControl value without calling onValueChange(), is it possible?
Let me describe what I intend to do and possibly you will give some idea how to implement this.
I have 2 SpinControl widgets (the width and the height of the picture) which are linked/bound (idk which word is more correct here), so changing one should affect another, e.g. if I double height, the width should also be doubled. Let's call the function which is responsible for that BalanceRatio():
//Briefly
BalanceRatio()
{
SpindleControl2->setValue(BalancedValue);
}

When I call it inside onValueChange() it creates a recursion and it's quite logical.
Then I've made the next trick (looks ugly but it actually helped):
SpindleControl1->onValueChange([](){
//Some code here
SpindleControl1->setFocused(0);
});

SpindleControl1->onUnfocus(BalanceRatio);
And it worked pretty nice until I noticed that if I press the arrow continuously, onUnfocus will be never called.
And the question is: how to set the new value without calling onValueChange() to avoid the recursion?
P.S. I'm sorry if there are some grammar mistakes but I feel really fatigued and have neither time nor the desire to use the translator to check my writing   :-\ .
#25
Help requests / Re: How to fit a Picture insid...
Last post by GetterSetter - 05 April 2024, 13:14:27
Much obliged, Texus!
#26
Help requests / Re: How to fit a Picture insid...
Last post by texus - 04 April 2024, 19:58:50
The most efficient way is to calculate it yourself on a resize event, but you can actually let TGUI do this automatically.

If you know the ratio is 4/3, you can use this code:
pic->setPosition("(&.size - size) / 2");
pic->setSize({"min(&.w, &.h * 4/3)", "min(&.h, &.w * 3/4)"});

Or if you don't know the ratio you can calculate it on runtime and change the above setSize call to the following (this code assumes the picture is added to the gui directly, but just replace "gui" with the parent of the picture if not):
pic->setSize({bindMin(bindWidth(gui), bindHeight(gui) * (pic->getSize().x / pic->getSize().y)),
              bindMin(bindHeight(gui), bindWidth(gui) * (pic->getSize().y / pic->getSize().x))});
#27
Help requests / How to fit a Picture inside a ...
Last post by GetterSetter - 04 April 2024, 19:48:27
Hello, I would like to ask if there are any ways to fully fit the picture with the constant w/h-ratio inside the panel (see attachment: the purple border is the panel and the green rectangle is the picture) that are already implemented inside the library, or should I implement such things by myself? The main idea is to fit it dynamically (while the panel is being resized from (w0;h0) to (w1; h1)).
#28
Installation help / Re: CMake cannot find SFML
Last post by texus - 31 March 2024, 16:02:24
Quotebut I couldn't find anything. Is it possible that the file is not in the folder and CMake creates it?
The file has to be created by CMake somewhere in your build directory. Deleting the entire build directory should cause it to be recreated from scratch instead of from cached files.

The most important thing is that you got it working now though.
#29
Installation help / Re: CMake cannot find SFML
Last post by luka - 30 March 2024, 17:29:36
QuoteEDIT: Your dll file isn't even recognized as a valid DLL by the tools that I have to dump dll information.
EDIT 2: The first 1536 bytes (= exactly 3 * 512 bytes) in your DLL are all 0-bytes, so the file looks corrupted. Have you tried deleting the file and letting your cmake project generate it again?

I tried deleting it and copying it with the CMake script, but I still encountered the same error. So, I attempted to locate the file where it's being copied from, but I couldn't find anything. Is it possible that the file is not in the folder and CMake creates it?

Copying the tgui-d.dll from TGUI 1.2.0 works in VS Code and directly from the directory. Thank you very much.
#30
Installation help / Re: CMake cannot find SFML
Last post by texus - 30 March 2024, 08:59:34
I have no idea how it's even possible, but something looks wrong with that TGUI dll. The size of your dll is smaller than the ones I have. Even the 32bit dlls that I have are still larger than the tgui-d.dll that was generated on your pc.

I've downloaded the "MinGW-w64 13.1.0 - x86_64‑posix‑seh (64bit)" version of TGUI 1.2.0 from https://tgui.eu/download/ and copied the tgui-d.dll from the bin folder of the zip file into your build_directory and afterwards I could run your exe just fine (after also copying xubuntu_bg_aluminium.jpg into the build_directory).

EDIT: Your dll file isn't even recognized as a valid DLL by the tools that I have to dump dll information.
EDIT 2: The first 1536 bytes (= exactly 3 * 512 bytes) in your DLL are all 0-bytes, so the file looks corrupted. Have you tried deleting the file and letting your cmake project generate it again?