Open and Close DockBarTab

Hi, in my PlugIn I’m writing a code that shows/hides the Rhinoceros dock bar tabs.
For example the tabs are invisible when the user click with left mouse button on a point on screen and otherwise the are shown when the user moves the mouse to the right side of the desktop.
The function that do this job is this:

/*!
\brief Toggle the visibily of the Rhinoceros dock bar tabs
\param in_visible Visibility input
*/
void DockTreeSliding::ToggleDockTreeVisibility(const bool in_visible)
{

         if (!in_visible)
	{	
		// Clear the array of the actual visible tabs ID 
		m_uuidVisibleDockBarArray.clear();

		ON_SimpleArray<ON_UUID> tabIds;
		CRhinoTabbedDockBarDialog::GetOpenTabIds(tabIds);

		for (int i = 0; i < tabIds.Count(); i++)
		{
			ON_UUID tabId = tabIds[i];
                        
                        // Fill the array and close the visible tabs
			if (CRhinoTabbedDockBarDialog::IsTabVisible(*RhinoApp().ActiveDoc(), tabId))
			{
				m_uuidVisibleDockBarArray.push_back(tabId);
				CRhinoTabbedDockBarDialog::CloseDockbarTab(*RhinoApp().ActiveDoc(), tabId, nullptr);
			}
		}
		
		m_state = COLLAPSED;
	}
	else
	{
                // Iterate the previous visible tabs and put visible
		for (int i = 0; i < m_uuidVisibleDockBarArray.size(); i++)
		{
			ON_UUID tabID = m_uuidVisibleDockBarArray[i];
			CRhinoTabbedDockBarDialog::OpenDockbarTab(*RhinoApp().ActiveDoc(), tabID, false);
		}
		

		m_state = EXPANDED;
	}

}

The code hides/shows the right dock bar tabs correctly but if I change the tab order when I re-put visible the tabs the order is different.
Maybe this isn’t the correct way to do this job.
thank you very much for your help.

You might consider building a list of dock bars that contain the tabs you care about and hide/show the dock bar instead of removing and adding tabs.

Hi John, thank you for your answer. I didn’t think about it,
I found the function ShowDockBar that coul be helpfull for me.
For example if I would like to hide/show the Rhinoceros dock bar this method is corrrect?

int m_size = RhinoApp().RhinoUiDockBarManager().DockBarCount();

for (int i = 0; i < m_size; i++)
{
	CRhinoUiDockBar* curr_bar = RhinoApp().RhinoUiDockBarManager().DockBar(i);

	ON_wString dock_bar_name = curr_bar->DockBarName();

	if ( curr_bar->IsVisible()  && dock_bar_name == L"Rhinoceros" )
	{
		ON_UUID barID = curr_bar->DockBarID();
		m_uuidVisibleDockBarArray.push_back(barID);
		RhinoUiDockBarManager().ShowDockBar(barID, in_visible, false);
		qDebug() << QtUtility::FromOnWStringToQString(dock_bar_name);
	}
}
.
.
.

Thank you for you help.