From 17f102f34e636166f7667144c3be8290e15529e9 Mon Sep 17 00:00:00 2001 From: anjaldoshi Date: Thu, 17 Oct 2024 17:16:53 -0700 Subject: [PATCH] Update PopupChannelSelector to include channel names and title --- .../Editors/PopupChannelSelector.cpp | 36 +++++++++++++++++-- .../Processors/Editors/PopupChannelSelector.h | 6 +++- .../Processors/Parameter/ParameterEditor.cpp | 28 +++++++++++++-- .../RecordNode/RecordNodeEditor.cpp | 16 +++++++-- 4 files changed, 78 insertions(+), 8 deletions(-) diff --git a/Source/Processors/Editors/PopupChannelSelector.cpp b/Source/Processors/Editors/PopupChannelSelector.cpp index 5e2b5d805..ce7c6ed87 100644 --- a/Source/Processors/Editors/PopupChannelSelector.cpp +++ b/Source/Processors/Editors/PopupChannelSelector.cpp @@ -116,7 +116,7 @@ RangeEditor::RangeEditor (const String& name, const Font& font) : TextEditor (na setFont (font); } -PopupChannelSelector::PopupChannelSelector (Component* parent, PopupChannelSelector::Listener* listener_, std::vector channelStates) +PopupChannelSelector::PopupChannelSelector (Component* parent, PopupChannelSelector::Listener* listener_, std::vector channelStates, Array channelNames, const String& title) : PopupComponent (parent), listener (listener_), nChannels (int (channelStates.size())), mouseDragged (false), startDragCoords (0, 0), shiftKeyDown (false), firstButtonSelectedState (false), isDragging (false), editable (true), maxSelectable (-1) { int nColumns; @@ -153,6 +153,15 @@ PopupChannelSelector::PopupChannelSelector (Component* parent, PopupChannelSelec buttonColour = Colours::azure; auto contentComponent = std::make_unique(); + + if (channelNames.isEmpty()) + { + for (int i = 0; i < nChannels; i++) + { + channelNames.add ("CH" + String (i + 1)); + } + } + for (int i = 0; i < nRows; i++) { for (int j = 0; j < nColumns; j++) @@ -162,6 +171,7 @@ PopupChannelSelector::PopupChannelSelector (Component* parent, PopupChannelSelec auto* button = new ChannelButton (nColumns * i + j, this); button->setBounds (width / nColumns * j, height / nRows * i, buttonSize, buttonSize); button->setToggleState (channelStates[nColumns * i + j], NotificationType::dontSendNotification); + button->setTooltip (channelNames[nColumns * i + j]); button->addListener (this); contentComponent->addAndMakeVisible (button); @@ -228,13 +238,33 @@ PopupChannelSelector::PopupChannelSelector (Component* parent, PopupChannelSelec viewport->setSize (width, height + (editable ? buttonSize : 0)); } - setSize (viewport->getWidth(), viewport->getHeight()); + if (title.isNotEmpty()) + { + titleLabel = std::make_unique