Hello,
I have a custom Widget:
For example:
That's the beginning of the method
So it's seems to be ok, but my application crashes sometimes when I resize window, sometimes the behavior is what I expect it to be.
Even my VScode debug mode can't find the function that's crashing.
I didn't find any crash pattern, it seems to be totally random for me.
In the above example, I want the height of itemContainerW to be proportional to another widget's height, so I use bindHeight, and the width auto set by setSide.
Then setSide just change the size according to AlignementSide variable before send it to parent Widget.
Did I miss somehting with this layout utilisation ?
update: It seems to crash more often if I resize the window smaller at first
If I resize it larger, it seems to be working as long as I do not go with a window too small...
Thank you
I have a custom Widget:
Code Select
class ItemContainerWidget : public tgui::WidgetI want to have this widget auto resize one of its edge when the user call setSize.For example:
Code Select
auto itemContainerW = ItemContainerWidget::create(ItemContainerWidget::AlignmentSide::VERTICAL, 2, m_listItemStack);
itemContainerW->setSize(800, tgui::bindHeight(m_scrollPanel)-m_scrollPanel->getScrollbarWidth());
800 here is no relevant as I want the x size to be auto detect in setSize method of ItemContainerWidgetThat's the beginning of the method
Code Select
void ItemContainerWidget::setSize(const tgui::Layout2d& size){
cout << "before" << endl;
cout << "size.getValue(): " << size.getValue() << endl;
if(m_alignmentSide == AlignmentSide::HORIZONTAL){
m_sizeItemRect = size.getValue().x/m_nbItemPerAlignmentSide;
}else if(m_alignmentSide == AlignmentSide::VERTICAL){
m_sizeItemRect = size.getValue().y/m_nbItemPerAlignmentSide;
}
cout << "m_sizeItemRect: " << m_sizeItemRect << endl;
unsigned nbItemPerNonAlignmentSide = std::ceil(m_listIS.size()/(float)m_nbItemPerAlignmentSide);
cout << "nbItemPerNonAlignmentSide: " << nbItemPerNonAlignmentSide << endl;
//update size accordingly to m_nbItemPerAlignmentSide
tgui::Layout2d newSize = size;
if(m_alignmentSide == AlignmentSide::HORIZONTAL){
newSize.y = nbItemPerNonAlignmentSide*m_sizeItemRect;
}else if(m_alignmentSide == AlignmentSide::VERTICAL){
newSize.x = nbItemPerNonAlignmentSide*m_sizeItemRect;
}
cout << "newSize: " << newSize.toString() << endl;
Widget::setSize(newSize);
.... change pos and size of some stuff ....
So it's seems to be ok, but my application crashes sometimes when I resize window, sometimes the behavior is what I expect it to be.
Even my VScode debug mode can't find the function that's crashing.
I didn't find any crash pattern, it seems to be totally random for me.
In the above example, I want the height of itemContainerW to be proportional to another widget's height, so I use bindHeight, and the width auto set by setSide.
Then setSide just change the size according to AlignementSide variable before send it to parent Widget.
Did I miss somehting with this layout utilisation ?
update: It seems to crash more often if I resize the window smaller at first
If I resize it larger, it seems to be working as long as I do not go with a window too small...
Thank you