commit 998278cb6a93248c7ad56c0e68397d870645da15
parent 5590de8162646348cadd689e1fc7a50d5fe88fff
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date: Mon, 18 Nov 2024 23:37:16 +0100
add functionality to activate tab page via code from component / bringToFront() for patch manager
Diffstat:
6 files changed, 36 insertions(+), 0 deletions(-)
diff --git a/source/jucePluginEditorLib/patchmanager/patchmanager.cpp b/source/jucePluginEditorLib/patchmanager/patchmanager.cpp
@@ -290,6 +290,12 @@ namespace jucePluginEditorLib::patchManager
return true;
}
+
+ void PatchManager::bringToFront() const
+ {
+ m_editor.selectTabWithComponent(this);
+ }
+
bool PatchManager::selectPatch(const uint32_t _part, const int _offset)
{
auto [patch, _] = m_state.getNeighbourPreset(_part, _offset);
diff --git a/source/jucePluginEditorLib/patchmanager/patchmanager.h b/source/jucePluginEditorLib/patchmanager/patchmanager.h
@@ -113,6 +113,8 @@ namespace jucePluginEditorLib::patchManager
bool setGridLayout128();
+ void bringToFront() const;
+
private:
bool selectPatch(uint32_t _part, int _offset);
diff --git a/source/juceUiLib/editor.cpp b/source/juceUiLib/editor.cpp
@@ -334,4 +334,15 @@ namespace genericUI
#endif
Component::paint(g);
}
+
+ bool Editor::selectTabWithComponent(const juce::Component* _component) const
+ {
+ for (const auto& it : m_tabGroupsByName)
+ {
+ auto* tabGroup = it.second;
+ if (tabGroup->selectTabWithComponent(_component))
+ return true;
+ }
+ return false;
+ }
}
diff --git a/source/juceUiLib/editor.h b/source/juceUiLib/editor.h
@@ -114,6 +114,8 @@ namespace genericUI
static bool resizeDrawableImage(juce::DrawableImage& _drawable, uint32_t _percent);
void paint(juce::Graphics& g) override;
+
+ bool selectTabWithComponent(const juce::Component* _component) const;
private:
EditorInterface& m_interface;
diff --git a/source/juceUiLib/tabgroup.cpp b/source/juceUiLib/tabgroup.cpp
@@ -25,6 +25,19 @@ namespace genericUI
setPage(0);
}
+ bool TabGroup::selectTabWithComponent(const juce::Component* _component) const
+ {
+ for (size_t i=0; i<m_tabs.size(); ++i)
+ {
+ if (m_tabs[i] == _component || m_tabs[i]->isParentOf(_component))
+ {
+ setPage(i);
+ return true;
+ }
+ }
+ return false;
+ }
+
void TabGroup::setPage(const size_t _page) const
{
for(size_t i=0; i<m_tabs.size(); ++i)
diff --git a/source/juceUiLib/tabgroup.h b/source/juceUiLib/tabgroup.h
@@ -28,6 +28,8 @@ namespace genericUI
const std::string& getName() const { return m_name; }
+ bool selectTabWithComponent(const juce::Component* _component) const;
+
private:
void setPage(const size_t _page) const;