Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/media/MediaDisplayComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,27 @@

#include <cmath>

void OptionalBannerComponent::paint(Graphics& g)
{
const float cx = static_cast<float>(getWidth()) / 2.0f;
const float cy = static_cast<float>(getHeight()) / 2.0f;

g.setColour(Colour::fromRGB(90, 105, 105));
g.fillAll();

g.setColour(Colours::white);
g.setFont(12.0f);

Graphics::ScopedSaveState state(g);
g.addTransform(AffineTransform::rotation(-MathConstants<float>::halfPi, cx, cy));

Rectangle<float> textBounds(
0, 0, static_cast<float>(getHeight()), static_cast<float>(getWidth()));
textBounds.setCentre(cx, cy);

g.drawText("OPTIONAL", textBounds, Justification::centred, false);
}

namespace
{
struct TickScheme
Expand Down Expand Up @@ -164,6 +185,8 @@ MediaDisplayComponent::MediaDisplayComponent(String name, bool req, bool fromDAW
horizontalScrollBar.setAutoHide(false);
horizontalScrollBar.addListener(this);

addAndMakeVisible(optionalBanner);

timeAxisStrip = std::make_unique<TimeAxisStrip>(this);

mediaAreaContainer.addAndMakeVisible(overheadPanel);
Expand Down Expand Up @@ -335,6 +358,16 @@ void MediaDisplayComponent::resized()
{
// Place header beside media
mainFlexBox.flexDirection = FlexBox::Direction::row;

if (! isRequired() && isInputTrack() && ! isThumbnailTrack())
{
mainFlexBox.items.add(FlexItem(optionalBanner).withWidth(24));
}
else
{
optionalBanner.setBounds(0, 0, 0, 0);
}

// Fixed area for track label and buttons
mainFlexBox.items.add(FlexItem(headerComponent).withFlex(1).withMaxWidth(40).withMargin(4));
}
Expand Down
31 changes: 20 additions & 11 deletions src/media/MediaDisplayComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,23 @@ enum class DisplayMode
Thumbnail // Reduced functionality
};

class OptionalBannerComponent : public Component
{
public:
void paint(Graphics& g) override;
};

class TimeAxisStrip : public Component
{
public:
explicit TimeAxisStrip(MediaDisplayComponent* ownerIn) : owner(ownerIn) {}

void paint(Graphics& g) override;

private:
MediaDisplayComponent* owner = nullptr;
};

class ColorablePanel : public Component
{
public:
Expand All @@ -48,17 +65,6 @@ class ColorablePanel : public Component
Colour backgroundColor;
};

class TimeAxisStrip : public Component
{
public:
explicit TimeAxisStrip(MediaDisplayComponent* ownerIn) : owner(ownerIn) {}

void paint(Graphics& g) override;

private:
MediaDisplayComponent* owner = nullptr;
};

class MediaDisplayComponent : public Component,
public ChangeListener,
public ChangeBroadcaster,
Expand Down Expand Up @@ -272,6 +278,9 @@ class MediaDisplayComponent : public Component,
MultiButton::Mode copyFileButtonActiveInfo;
MultiButton::Mode copyFileButtonInactiveInfo;

// Banner shown on left edge of optional input tracks
OptionalBannerComponent optionalBanner;

// Panel displaying overhead labels
ColorablePanel overheadPanel { overheadPanelColor };

Expand Down
Loading