Skip to content

Commit

Permalink
Update PopupChannelSelector title look and feel
Browse files Browse the repository at this point in the history
  • Loading branch information
anjaldoshi committed Oct 18, 2024
1 parent 17f102f commit 469bc34
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 17 deletions.
25 changes: 13 additions & 12 deletions Source/Processors/Editors/PopupChannelSelector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ RangeEditor::RangeEditor (const String& name, const Font& font) : TextEditor (na
setFont (font);
}

PopupChannelSelector::PopupChannelSelector (Component* parent, PopupChannelSelector::Listener* listener_, std::vector<bool> channelStates, Array<String> 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)
PopupChannelSelector::PopupChannelSelector (Component* parent, PopupChannelSelector::Listener* listener_, std::vector<bool> channelStates, Array<String> 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), title (title_)
{
int nColumns;

Expand Down Expand Up @@ -154,14 +154,16 @@ PopupChannelSelector::PopupChannelSelector (Component* parent, PopupChannelSelec

auto contentComponent = std::make_unique<Component>();

if (channelNames.isEmpty())
if (channelNames.isEmpty() || channelNames.size() != nChannels)
{
channelNames.clear();
for (int i = 0; i < nChannels; i++)
{
channelNames.add ("CH" + String (i + 1));
}
}

// Create buttons for each channel. Use actual channel names as tooltips.
for (int i = 0; i < nRows; i++)
{
for (int j = 0; j < nColumns; j++)
Expand Down Expand Up @@ -212,6 +214,7 @@ PopupChannelSelector::PopupChannelSelector (Component* parent, PopupChannelSelec

// Add Range Editor
rangeEditor = std::make_unique<RangeEditor> ("Range", FontOptions (12.0f));
rangeEditor->setInputRestrictions (0, "0123456789:");
rangeEditor->setBounds (0.75 * width, height, 0.25 * width, width / nColumns);
rangeEditor->addListener (this);
contentComponent->addAndMakeVisible (rangeEditor.get());
Expand Down Expand Up @@ -240,13 +243,7 @@ PopupChannelSelector::PopupChannelSelector (Component* parent, PopupChannelSelec

if (title.isNotEmpty())
{
titleLabel = std::make_unique<Label> ("Title", title);
titleLabel->setBounds (0, 0, viewport->getWidth(), 20);
titleLabel->setJustificationType (Justification::centredLeft);
titleLabel->setFont (FontOptions ("Inter", "Regular", 16.0f));
addAndMakeVisible (titleLabel.get());

setSize (viewport->getWidth(), viewport->getHeight() + 20);
setSize (viewport->getWidth(), viewport->getHeight() + 24);
}
else
{
Expand All @@ -263,8 +260,12 @@ void PopupChannelSelector::resized()

void PopupChannelSelector::paint (Graphics& g)
{
g.setColour (findColour (ThemeColours::widgetBackground));
g.fillRoundedRectangle (getLocalBounds().toFloat().reduced (1.0f), 5.0f);
if (title.isNotEmpty())
{
g.setFont (FontOptions ("Inter", "Regular", 15.0f));
g.setColour (findColour (ThemeColours::controlPanelText));
g.drawFittedText (title, 5, 0, getWidth() - 10, 20, Justification::centredLeft, 1.0f);
}
}

void PopupChannelSelector::updatePopup()
Expand Down
2 changes: 1 addition & 1 deletion Source/Processors/Editors/PopupChannelSelector.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class PLUGIN_API PopupChannelSelector : public PopupComponent,
void updateRangeString();
void parseRangeString();

std::unique_ptr<Label> titleLabel;
String title;

OwnedArray<SelectButton> selectButtons;
std::unique_ptr<RangeEditor> rangeEditor;
Expand Down
4 changes: 2 additions & 2 deletions Source/Processors/Parameter/ParameterEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ void SelectedChannelsParameterEditor::buttonClicked (Button* button_)
if (p->getOwner()->getType() == ParameterOwner::DATASTREAM)
{
DataStream* stream = (DataStream*) p->getOwner();
popupTitle = String (stream->getSourceNodeId()) + " - " + stream->getName();
popupTitle = String (stream->getSourceNodeId()) + " " + stream->getSourceNodeName() + " - " + stream->getName();

for (auto channel : stream->getContinuousChannels())
channelNames.add (channel->getName());
Expand Down Expand Up @@ -718,7 +718,7 @@ void MaskChannelsParameterEditor::buttonClicked (Button* button_)
if (p->getOwner()->getType() == ParameterOwner::DATASTREAM)
{
DataStream* stream = (DataStream*) p->getOwner();
popupTitle = String (stream->getSourceNodeId()) + " - " + stream->getName();
popupTitle = String (stream->getSourceNodeId()) + " " + stream->getSourceNodeName() + " - " + stream->getName();

for (auto channel : stream->getContinuousChannels())
channelNames.add (channel->getName());
Expand Down
2 changes: 1 addition & 1 deletion Source/Processors/RecordNode/RecordNodeEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ void RecordChannelsParameterEditor::buttonClicked (Button* label)
if (p->getOwner()->getType() == ParameterOwner::DATASTREAM)
{
DataStream* stream = (DataStream*) p->getOwner();
popupTitle = String (stream->getSourceNodeId()) + " - " + stream->getName();
popupTitle = String (stream->getSourceNodeId()) + " " + stream->getSourceNodeName() + " - " + stream->getName();

for (auto channel : stream->getContinuousChannels())
channelNames.add (channel->getName());
Expand Down
2 changes: 1 addition & 1 deletion Source/UI/LookAndFeel/CustomLookAndFeel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ void CustomLookAndFeel::setTheme (ColourTheme theme)
setColour (Slider::rotarySliderOutlineColourId, currentThemeColours[ThemeColours::widgetBackground]);
setColour (Slider::textBoxTextColourId, currentThemeColours[ThemeColours::defaultText]);
setColour (Slider::textBoxBackgroundColourId, transparent);
setColour (Slider::textBoxHighlightColourId, currentThemeColours[ThemeColours::defaultFill].withAlpha (0.4f));
setColour (Slider::textBoxHighlightColourId, currentThemeColours[ThemeColours::menuHighlightBackground].withAlpha (0.4f));
setColour (Slider::textBoxOutlineColourId, currentThemeColours[ThemeColours::outline]);

setColour (ResizableWindow::backgroundColourId, currentThemeColours[ThemeColours::componentBackground]);
Expand Down

0 comments on commit 469bc34

Please sign in to comment.