Skip to content

Commit

Permalink
Ensure tabbed components are resized properly when one is closed
Browse files Browse the repository at this point in the history
  • Loading branch information
anjaldoshi committed Dec 24, 2024
1 parent 4d666c6 commit b10b793
Showing 1 changed file with 21 additions and 22 deletions.
43 changes: 21 additions & 22 deletions Source/UI/DataViewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -610,23 +610,8 @@ void DataViewport::removeTab (int nodeId, bool sendNotification)

if (foundTab)
{
if (draggableTabComponent->getNumTabs() == 0 && draggableTabComponents.size() > 1)
{
draggableTabComponents.removeObject (draggableTabComponent);
activeTabbedComponent--;

tabbedComponentLayout.clearAllItems();

tabbedComponentResizer->setVisible (draggableTabComponents.size() == 2);

resized();

if (draggableTabComponents[activeTabbedComponent]->getNumTabs() > 1)
addTabbedComponentButton->setVisible (true);
else
addTabbedComponentButton->setVisible (false);
}

// remove the tabbed component if it's empty
removeTabbedComponent (draggableTabComponent);
return;
}
}
Expand All @@ -641,11 +626,14 @@ void DataViewport::buttonClicked (Button* button)
addAndMakeVisible (d);
draggableTabComponents.add (d);

tabbedComponentResizer->setVisible (true);
if (draggableTabComponents.size() == 2)
{
tabbedComponentResizer->setVisible (true);

tabbedComponentLayout.setItemLayout (0, -0.25, -0.75, -0.5);
tabbedComponentLayout.setItemLayout (1, 12, 12, 12);
tabbedComponentLayout.setItemLayout (2, -0.25, -0.75, -0.5);
tabbedComponentLayout.setItemLayout (0, -0.25, -0.75, -0.5);
tabbedComponentLayout.setItemLayout (1, 12, 12, 12);
tabbedComponentLayout.setItemLayout (2, -0.25, -0.75, -0.5);
}

resized();

Expand Down Expand Up @@ -684,7 +672,18 @@ void DataViewport::removeTabbedComponent (DraggableTabComponent* draggableTabCom

tabbedComponentLayout.clearAllItems();

tabbedComponentResizer->setVisible (draggableTabComponents.size() == 2);
if (draggableTabComponents.size() == 2)
{
tabbedComponentResizer->setVisible (true);

tabbedComponentLayout.setItemLayout (0, -0.25, -0.75, -0.5);
tabbedComponentLayout.setItemLayout (1, 12, 12, 12);
tabbedComponentLayout.setItemLayout (2, -0.25, -0.75, -0.5);
}
else
{
tabbedComponentResizer->setVisible (false);
}

resized();
}
Expand Down

0 comments on commit b10b793

Please sign in to comment.