cancel
Showing results for 
Search instead for 
Did you mean: 

Incorrect behavior when adding an item to ScrollableContainer.

skvotcher
Associate II

Hello. I apologize in advance for any mistakes, as English is not my native language. I've encountered a problem: I have a custom container named ContainerAddTab, which contains a ScrollableContainer element, named scrollableContainer1. Into this element, I insert ProgramTab tabs named programTab. A problem occurs when adding more than 5 tabs. The spacing between the tabs begins to increase and reaches the width of the screen. This behavior is always the same and does not change. What could be the problem?

 

ProgramTab::ParamsTab& params = ProgramTab::getStruct();
tab.setWidth(params.tabWidth);
tab.setHeight(params.tabHeight);

if (programTabs.size() - 1 > 0)
{
    tab.setCoords(__TAB_START_X + params.tabWidth * (programTabs.size() - 1) + params.spacing * (programTabs.size() - 1), __TAB_START_Y);
}
else
{
    tab.setCoords(__TAB_START_X, __TAB_START_Y);
}

tab.setTabClickedCallback(tabClickedCallback);
tab.setActive(true);
screen->loadProgram(tab.getId());
scrollableContainer1.add(tab);
tab.setTabColor();
addProg.setX(__TAB_START_X + params.tabWidth * programTabs.size() + params.spacing * programTabs.size());

 

image.png

 

image.png

A bit about the code. In the ContainerAddTab class, I store an array of ProgramTab tabs, as well as a vector of pointers to these tabs.

I am trying to implement addition, deletion, and achieve correct behavior in their display. I would be grateful for any help.

Regards.

1 ACCEPTED SOLUTION

Accepted Solutions
skvotcher
Associate II

It was resolved that for dynamic addition it is necessary to use scrollableContainer1.reset();

View solution in original post

1 REPLY 1
skvotcher
Associate II

It was resolved that for dynamic addition it is necessary to use scrollableContainer1.reset();