Skip to main content
Associate II
November 15, 2023
Solved

Incorrect behavior when adding an item to ScrollableContainer.

  • November 15, 2023
  • 1 reply
  • 935 views

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.

This topic has been closed for replies.
Best answer by skvotcher

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

1 reply

skvotcherAuthorBest answer
Associate II
November 15, 2023

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