Skip to content

Commit

Permalink
Routing info tooltip on REAPER <v7 (HOA plugin)
Browse files Browse the repository at this point in the history
  • Loading branch information
firthm01 committed Oct 11, 2023
1 parent 4f2dd24 commit d031971
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
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/onboarding.hpp"
#include "components/overlay.hpp"
#include "helper/properties_file.hpp"
Expand Down Expand Up @@ -32,6 +33,9 @@ class HoaComponent : public Component,
std::make_unique<InterProcessLock>("EPS_preferences")),
propertiesFile(getPropertiesFile(propertiesFileLock.get())) {

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

header->setName("EarHeader (HoaComponent::header)");
onBoardingButton->setName("EarButton (HoaComponent::onBoardingButton)");
onBoardingOverlay->setName("Overlay (HoaComponent::onBoardingOverlay)");
Expand Down Expand Up @@ -65,6 +69,7 @@ class HoaComponent : public Component,
addAndMakeVisible(onBoardingButton.get());
addChildComponent(onBoardingOverlay.get());

mainValueBox->showRoutingTooltip(p->getNumDawChannels() < 128);
addAndMakeVisible(mainValueBox.get());
addAndMakeVisible(orderDisplayValueBox.get());

Expand Down Expand Up @@ -128,6 +133,10 @@ class HoaComponent : public Component,

private:
HoaAudioProcessor* p_;

TooltipWindow tooltipWindow{this};
TooltipLookAndFeel tooltipLookAndFeel;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(HoaComponent)
};

Expand Down
23 changes: 22 additions & 1 deletion ear-production-suite-plugins/plugins/hoa/src/value_box_main.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class ValueBoxMain : public Component {
hoaTypeLabel_(std::make_unique<Label>()),
hoaTypeComboBox_(std::make_shared<EarComboBox>()),
routingLabel_(std::make_unique<Label>()),
routingInfoIcon_(std::make_unique<ImageComponent>()),
routingComboBox_(std::make_shared<EarComboBox>()) {

colourComboBox_->setName("EarComboBox (ValueBoxMain::colourComboBox_)");
Expand All @@ -45,6 +46,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 @@ -108,13 +119,22 @@ 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<EarComboBox> getRoutingComboBox() { return routingComboBox_; }
std::shared_ptr<EarComboBox> getColourComboBox() { return colourComboBox_; }
Expand All @@ -136,6 +156,7 @@ class ValueBoxMain : public Component {

std::unique_ptr<Label> routingLabel_;
std::shared_ptr<EarComboBox> routingComboBox_;
std::shared_ptr<ImageComponent> routingInfoIcon_;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ValueBoxMain)
};
Expand Down
1 change: 1 addition & 0 deletions shared/components/look_and_feel/tooltips.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "JuceHeader.h"
#include "colours.hpp"

namespace ear {
namespace plugin {
Expand Down

0 comments on commit d031971

Please sign in to comment.