Skip to content

Commit

Permalink
NamedPanel has a public method to change tab selection (#87)
Browse files Browse the repository at this point in the history
rather than just mukcing with internals
  • Loading branch information
baconpaul authored May 28, 2024
1 parent c119883 commit f49ff30
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions include/sst/jucegui/components/NamedPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ struct NamedPanel : public juce::Component,
std::vector<juce::Rectangle<int>> tabPositions;
juce::Rectangle<int> totalTabArea;
void resetTabState();
void selectTab(int tab);

bool hasHamburger{false};
static constexpr int hamburgerSize = 22;
Expand Down
12 changes: 9 additions & 3 deletions src/sst/jucegui/components/NamedPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,7 @@ void NamedPanel::mouseDown(const juce::MouseEvent &event)
{
if (tabPositions[i].toFloat().contains(event.position))
{
selectedTab = i;
if (onTabSelected)
onTabSelected(i);
selectTab(i);
}
}
if (pst != selectedTab)
Expand Down Expand Up @@ -257,6 +255,14 @@ void NamedPanel::resetTabState()
totalTabArea = ht.withWidth(totalTabSize);
}

void NamedPanel::selectTab(int tab)
{
selectedTab = tab;
if (onTabSelected)
onTabSelected(tab);
repaint();
}

void NamedPanel::setTogglable(bool b)
{
if (b == isTogglable)
Expand Down

0 comments on commit f49ff30

Please sign in to comment.