Skip to content

Commit

Permalink
Routing info tooltip on REAPER <v7 (DS plugin)
Browse files Browse the repository at this point in the history
  • Loading branch information
firthm01 committed Oct 11, 2023
1 parent d031971 commit 4099b4e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "JuceHeader.h"

#include "components/look_and_feel/tooltips.hpp"
#include "components/ear_combo_box.hpp"
#include "components/onboarding.hpp"
#include "components/overlay.hpp"
Expand Down Expand Up @@ -42,6 +43,10 @@ class DirectSpeakersComponent : public Component,
propertiesFileLock(
std::make_unique<InterProcessLock>("EPS_preferences")),
propertiesFile(getPropertiesFile(propertiesFileLock.get())) {

tooltipWindow.setLookAndFeel(&tooltipLookAndFeel);
tooltipWindow.setOpaque(false);

header->setText(" Direct Speakers");

onBoardingButton->setButtonText("?");
Expand All @@ -68,6 +73,7 @@ class DirectSpeakersComponent : public Component,
addChildComponent(onBoardingOverlay.get());

//addAndMakeVisible(metadataValueBox.get());
mainValueBox->showRoutingTooltip(p->getNumDawChannels() < 128);
addAndMakeVisible(mainValueBox.get());
addAndMakeVisible(channelMetersBox.get());

Expand Down Expand Up @@ -110,8 +116,10 @@ class DirectSpeakersComponent : public Component,
headingArea.removeFromRight(39).removeFromBottom(39));
header->setBounds(headingArea);

auto leftColumn = area.withTrimmedRight(area.getWidth() / 2);
auto rightColumn = area.withTrimmedLeft(area.getWidth() / 2);
auto leftColumnWidth = area.getWidth() / 2;
if (leftColumnWidth < 385) leftColumnWidth = 385;
auto leftColumn = area.removeFromLeft(leftColumnWidth);
auto rightColumn = area;

// left column
mainValueBox->setBounds(leftColumn.removeFromTop(223).reduced(5, 5));
Expand Down Expand Up @@ -161,6 +169,10 @@ class DirectSpeakersComponent : public Component,

private:
DirectSpeakersAudioProcessor* p_;

TooltipWindow tooltipWindow{this};
TooltipLookAndFeel tooltipLookAndFeel;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(DirectSpeakersComponent)
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class ValueBoxMain : public Component {
speakerSetupLabel_(std::make_unique<Label>()),
speakerSetupsComboBox_(std::make_shared<EarComboBox>()),
routingLabel_(std::make_unique<Label>()),
routingInfoIcon_(std::make_unique<ImageComponent>()),
routingComboBox_(std::make_shared<EarComboBox>()) {
name_->setLabelText("Object Name");
name_->setText("Object_1");
Expand All @@ -38,6 +39,16 @@ class ValueBoxMain : public Component {
routingLabel_->setJustificationType(Justification::right);
addAndMakeVisible(routingLabel_.get());

routingInfoIcon_->setImage(ImageFileFormat::loadFrom(
binary_data::infologo_png, binary_data::infologo_pngSize));
routingInfoIcon_->setImagePlacement(RectanglePlacement::centred +
RectanglePlacement::doNotResize);
routingInfoIcon_->setAlpha(0.8);
routingInfoIcon_->setMouseCursor(MouseCursor::PointingHandCursor);
routingInfoIcon_->setTooltip(
"128 channel support requires REAPER v7 or later.");
addChildComponent(routingInfoIcon_.get());

routingComboBox_->setDefaultText("Select Scene channel range");
addAndMakeVisible(routingComboBox_.get());

Expand Down Expand Up @@ -92,13 +103,25 @@ class ValueBoxMain : public Component {

auto routingArea = area.removeFromTop(rowHeight_);
auto routingLabelArea = routingArea.withWidth(labelWidth_);
routingLabel_->setBounds(routingLabelArea);
if (routingInfoIcon_->isVisible()) {
auto routingInfoArea = routingArea.removeFromRight(13).withTrimmedTop(
1); // Trimming 1 to get an odd height. Icon is odd height too, so
// ensures an integer number of pixels padding top and bottom to
// avoid blurring through anti-aliasing.
routingInfoIcon_->setBounds(routingInfoArea);
routingArea.removeFromRight(marginSmall_);
}
auto routingComboBoxArea =
routingArea.withTrimmedLeft(labelWidth_ + marginBig_)
.reduced(0, marginSmall_);
routingLabel_->setBounds(routingLabelArea);
routingComboBox_->setBounds(routingComboBoxArea);
}

void showRoutingTooltip(bool visible) {
routingInfoIcon_->setVisible(visible);
}

std::shared_ptr<EarNameTextEditor> getNameTextEditor() { return name_; }
std::shared_ptr<ToggleButton> getUseTrackNameCheckbox() { return useTrackNameCheckbox_; }
std::shared_ptr<EarComboBox> getRoutingComboBox() { return routingComboBox_; }
Expand All @@ -119,6 +142,7 @@ class ValueBoxMain : public Component {
std::shared_ptr<EarComboBox> speakerSetupsComboBox_;
std::unique_ptr<Label> routingLabel_;
std::shared_ptr<EarComboBox> routingComboBox_;
std::shared_ptr<ImageComponent> routingInfoIcon_;
std::shared_ptr<ToggleButton> useTrackNameCheckbox_;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ValueBoxMain)
Expand Down

0 comments on commit 4099b4e

Please sign in to comment.