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

Topics - SurvRabbit

#1
Help requests / Widget Offset
13 May 2018, 16:01:01
How can I set the offset between widgets in a grid?
auto grid = tgui::Grid::create();
grid->setPosition(400, 200);
for (int i = 0; i < 5; ++i)
{
for (int j = 0; j < 5; ++j) {
auto button = tgui::Button::create("Hi");
button->setRenderer(theme.getRenderer("ButtonInv"));
button->setSize(40, 40);
grid->addWidget(button, i, j);
}
}
grid->setSize(200, 200); // I have to make sure that there is free space between the buttons
gui.add(grid);

I can get the offset values for the widget from grid->getWidgetOffset(); But how do I change them?
I need to achieve an offset of 2 pixels between the buttons and each time it is inconvenient to select the grid size.