Skip to content
Draft
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
2 changes: 1 addition & 1 deletion JUCE
Submodule JUCE updated 3874 files
15 changes: 14 additions & 1 deletion src/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ enum CommandIDs
// View
viewStatusArea = 0x2000,
viewMediaClipboard = 0x2001,
viewPreviewPane = 0x2002,

// Help
about = 0x3000,
Expand Down Expand Up @@ -71,6 +72,7 @@ PopupMenu MainComponent::getMenuForIndex([[maybe_unused]] int menuIndex, const S
{
menu.addCommandItem(&commandManager, CommandIDs::viewStatusArea);
menu.addCommandItem(&commandManager, CommandIDs::viewMediaClipboard);
menu.addCommandItem(&commandManager, CommandIDs::viewPreviewPane);
}
else if (menuName == "Help")
{
Expand Down Expand Up @@ -135,7 +137,7 @@ void MainComponent::getAllCommands(Array<CommandID>& commands)

commands.addArray(editIDs, numElementsInArray(editIDs));

const CommandID viewIDs[] = { CommandIDs::viewStatusArea, CommandIDs::viewMediaClipboard };
const CommandID viewIDs[] = { CommandIDs::viewStatusArea, CommandIDs::viewMediaClipboard, CommandIDs::viewPreviewPane };

commands.addArray(viewIDs, numElementsInArray(viewIDs));

Expand Down Expand Up @@ -207,6 +209,12 @@ void MainComponent::getCommandInfo(CommandID commandID, ApplicationCommandInfo&

break;

case CommandIDs::viewPreviewPane:
result.setInfo("Preview Pane", "Toggles display of track preview pane", "View", 0);
result.setTicked(mediaClipboardWidget.isPreviewPaneVisible());

break;

/* --Help-- */
case CommandIDs::about:
result.setInfo(
Expand Down Expand Up @@ -277,6 +285,11 @@ bool MainComponent::perform(const InvocationInfo& info)

break;

case CommandIDs::viewPreviewPane:
DBG_AND_LOG("MainComponent:: perform: \"ViewPreviewPane\" command invoked.");
mediaClipboardWidget.togglePreviewPane();
break;

/* --Help-- */
case CommandIDs::about:
DBG_AND_LOG("MainComponent::perform: \"about\" command invoked.");
Expand Down
10 changes: 0 additions & 10 deletions src/MainComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,16 +536,6 @@ Rectangle<int> MainComponent::getClipboardRemoveButtonBounds()
return {};
}

Rectangle<int> MainComponent::getClipboardPlayButtonBounds()
{
if (showMediaClipboard && mediaClipboardWidget.isVisible())
{
auto bounds = mediaClipboardWidget.getPlayButtonBounds();
return getLocalArea(&mediaClipboardWidget, bounds);
}
return {};
}

Rectangle<int> MainComponent::getClipboardSendToDAWButtonBounds()
{
if (showMediaClipboard && mediaClipboardWidget.isVisible())
Expand Down
133 changes: 121 additions & 12 deletions src/media/MediaDisplayComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,23 @@ MediaDisplayComponent::MediaDisplayComponent(String name, bool req, bool fromDAW
mediaAreaContainer.addAndMakeVisible(contentComponent);
mediaAreaContainer.addAndMakeVisible(*timeAxisStrip);
mediaAreaContainer.addAndMakeVisible(horizontalScrollBar);
addAndMakeVisible(mediaAreaContainer);
if (isPreviewTrack())
{
mediaRowComponent.addAndMakeVisible(mediaAreaContainer);
mediaRowComponent.addAndMakeVisible(previewControlsComponent);
addAndMakeVisible(mediaRowComponent);

mediaRowFlexBox.flexDirection = FlexBox::Direction::row;
mediaRowFlexBox.alignItems = FlexBox::AlignItems::stretch;

previewControlsFlexBox.flexDirection = FlexBox::Direction::column;
previewControlsFlexBox.alignItems = FlexBox::AlignItems::center;
previewControlsFlexBox.justifyContent = FlexBox::JustifyContent::center;
}
else
{
addAndMakeVisible(mediaAreaContainer);
}

mediaAreaFlexBox.flexDirection = FlexBox::Direction::column;

Expand Down Expand Up @@ -253,6 +269,42 @@ void MediaDisplayComponent::initializeButtons()
copyFileButton.addMode(copyFileButtonInactiveInfo);
headerComponent.addAndMakeVisible(copyFileButton);

// Modes for the preview pane
if (isPreviewTrack())
{
previewPlayButtonInfo = MultiButton::Mode {
"Preview-Play",
"Click to start playback.",
[this] { start(); },
MultiButton::DrawingMode::IconOnly,
Colours::limegreen,
fontaudio::Play
};
previewPauseButtonInfo = MultiButton::Mode {
"Preview-Pause",
"Click to pause playback.",
[this] { pause(); },
MultiButton::DrawingMode::IconOnly,
Colours::yellow,
fontaudio::Pause
};
previewStopButtonInfo = MultiButton::Mode {
"Preview-Stop",
"Click to stop playback.",
[this] { stop(); },
MultiButton::DrawingMode::IconOnly,
Colours::orangered,
fontaudio::Stop
};
previewPlayPauseButton.addMode(previewPlayButtonInfo);
previewPlayPauseButton.addMode(previewPauseButtonInfo);
previewStopButton.addMode(previewStopButtonInfo);
previewStopButton.setMode(previewStopButtonInfo.displayLabel);

previewControlsComponent.addAndMakeVisible(previewPlayPauseButton);
previewControlsComponent.addAndMakeVisible(previewStopButton);
}

resetButtonState();
}

Expand Down Expand Up @@ -331,6 +383,14 @@ void MediaDisplayComponent::resized()
.withHeight(trackNameLabel.getFont().getHeight())
.withMargin(1));
}
else if (isPreviewTrack())
{
// Place header over media
mainFlexBox.flexDirection = FlexBox::Direction::column;
mainFlexBox.items.add(FlexItem(headerComponent)
.withHeight(trackNameLabel.getFont().getHeight())
.withMargin(1));
}
else
{
// Place header beside media
Expand All @@ -339,18 +399,34 @@ void MediaDisplayComponent::resized()
mainFlexBox.items.add(FlexItem(headerComponent).withFlex(1).withMaxWidth(40).withMargin(4));
}

// Media area takes remaining space
mainFlexBox.items.add(FlexItem(mediaAreaContainer).withFlex(8));
// Media area takes remaining space unless preview pane is open
if (isPreviewTrack())
{
mainFlexBox.items.add(FlexItem(mediaRowComponent).withFlex(8));
}
else
{
mainFlexBox.items.add(FlexItem(mediaAreaContainer).withFlex(8));
}

mainFlexBox.performLayout(totalBounds);

if (isPreviewTrack())
{
mediaRowFlexBox.items.clear();
mediaRowFlexBox.items.add(FlexItem(mediaAreaContainer).withFlex(1));
mediaRowFlexBox.items.add(
FlexItem(previewControlsComponent).withWidth(25).withMargin({ 0, 2, 0, 2 }));
mediaRowFlexBox.performLayout(mediaRowComponent.getLocalBounds());
}

// Remove existing items in header flex
headerFlexBox.items.clear();

// Add track label to header flex
headerFlexBox.items.add(FlexItem(trackNameLabel).withFlex(1).withMargin({ 0, 2, 0, 0 }));

if (! isThumbnailTrack())
if (! isThumbnailTrack() && ! isPreviewTrack())
{
// Add buttons to header flex
headerFlexBox.items.add(FlexItem(buttonsComponent).withFlex(2).withMargin({ 0, 0, 0, 1 }));
Expand All @@ -363,7 +439,7 @@ void MediaDisplayComponent::resized()
float trackNameLabelWidth = labelBounds.getWidth();
float trackNameLabelHeight = labelBounds.getHeight();

if (! isThumbnailTrack())
if (! isThumbnailTrack() && ! isPreviewTrack())
{
Point<float> labelCenter = labelBounds.getCentre();
// Rotate track name label 90 degrees
Expand Down Expand Up @@ -454,6 +530,18 @@ void MediaDisplayComponent::resized()
// Perform layout in media area
mediaAreaFlexBox.performLayout(mediaAreaContainer.getLocalBounds());

// Performs layout in preview pane
if (isPreviewTrack())
{
previewControlsFlexBox.items.clear();
previewControlsFlexBox.items.add(
FlexItem(previewPlayPauseButton).withWidth(25).withHeight(25).withMargin({ 2, 0, 2, 0 }));
previewControlsFlexBox.items.add(
FlexItem(previewStopButton).withWidth(25).withHeight(25).withMargin({ 2, 0, 2, 0 }));
previewControlsFlexBox.performLayout(previewControlsComponent.getLocalBounds());
}


if (! isLabelRepositioningScheduled)
{
isLabelRepositioningScheduled = true;
Expand Down Expand Up @@ -605,6 +693,10 @@ void MediaDisplayComponent::resetButtonState()
chooseFileButton.setMode(chooseFileButtonActiveInfo.displayLabel);
saveFileButton.setMode(saveFileButtonInactiveInfo.displayLabel);
copyFileButton.setMode(copyFileButtonInactiveInfo.displayLabel);
if (isPreviewTrack())
{
previewPlayPauseButton.setMode(previewPlayButtonInfo.displayLabel);
}
}

void MediaDisplayComponent::initializeDisplay(const URL& filePath)
Expand Down Expand Up @@ -1191,6 +1283,11 @@ void MediaDisplayComponent::start()
startTimerHz(40);

playStopButton.setMode(stopButtonInfo.displayLabel);

if (isPreviewTrack())
{
previewPlayPauseButton.setMode(previewPauseButtonInfo.displayLabel);
}
}

void MediaDisplayComponent::stop()
Expand All @@ -1204,9 +1301,24 @@ void MediaDisplayComponent::stop()

playStopButton.setMode(playButtonActiveInfo.displayLabel);

if (isPreviewTrack())
{
previewPlayPauseButton.setMode(previewPlayButtonInfo.displayLabel);
}

sendChangeMessage();
}

void MediaDisplayComponent::pause()
{
stopPlaying();

stopTimer();

//currentPositionCursor.setVisible(true);
previewPlayPauseButton.setMode(previewPlayButtonInfo.displayLabel);
}

void MediaDisplayComponent::updateCursorPosition()
{
float mediaWidth = getMediaWidth();
Expand Down Expand Up @@ -1234,14 +1346,11 @@ void MediaDisplayComponent::updateCursorPosition()

cursorPositionX = jmin(maxCursorXPos, jmax(minCursorXPos, cursorPositionX));

Rectangle<int> mediaAreaBounds = mediaAreaContainer.getBounds();
Rectangle<int> mediaBounds = contentComponent.getBounds();

// Include offset(s) for track header
cursorPositionX += static_cast<float>(mediaAreaBounds.getX());
cursorPositionY += static_cast<float>(mediaAreaBounds.getY());
// Include offset for label overlay header
cursorPositionY += static_cast<float>(mediaBounds.getY());
// Get position of contentComponent in the correct coordinate space, accounting for nested parents
Point<int> mediaOrigin = getLocalPoint(&contentComponent, Point<int>(0, 0));
cursorPositionX += static_cast<float>(mediaOrigin.getX());
cursorPositionY += static_cast<float>(mediaOrigin.getY());
// Offset by half of width
cursorPositionX -= cursorWidth / 2.0f;

Expand Down
30 changes: 28 additions & 2 deletions src/media/MediaDisplayComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ enum class DisplayMode
Input,
Output,
Hybrid, // All functionality
Thumbnail // Reduced functionality
Thumbnail, // Reduced functionality
Preview // For preview pane
};

class ColorablePanel : public Component
Expand Down Expand Up @@ -95,6 +96,7 @@ class MediaDisplayComponent : public Component,
bool isOutputTrack() { return (displayMode == DisplayMode::Output) || isHybridTrack(); }
bool isHybridTrack() { return displayMode == DisplayMode::Hybrid; }
bool isThumbnailTrack() { return displayMode == DisplayMode::Thumbnail; }
bool isPreviewTrack() { return displayMode == DisplayMode::Preview; }

void setMediaInstructions(String instructions) { mediaInstructions = instructions; }

Expand Down Expand Up @@ -140,6 +142,7 @@ class MediaDisplayComponent : public Component,

void start();
void stop();
void pause();

virtual bool isPlaying() { return transportSource.isPlaying(); }

Expand Down Expand Up @@ -188,7 +191,15 @@ class MediaDisplayComponent : public Component,

void timerCallback() override;
virtual void visibleRangeCallback() { repaint(); }
virtual void changeListenerCallback(ChangeBroadcaster*) override { repaint(); }
virtual void changeListenerCallback(ChangeBroadcaster*) override
{
repaint();
Component::SafePointer<MediaDisplayComponent> safeThis(this);
MessageManager::callAsync([safeThis]() mutable {
if (safeThis != nullptr)
safeThis->sendChangeMessage();
});
}

virtual void resetMedia() = 0;
void resetPaths();
Expand Down Expand Up @@ -255,6 +266,10 @@ class MediaDisplayComponent : public Component,
Component buttonsComponent;
// Media + overhead panel (if any)
Component mediaAreaContainer;
// Preview pane controls
Component previewControlsComponent;
// Preview pane waveform and control row
Component mediaRowComponent;

// Header sub-components
Label trackNameLabel;
Expand All @@ -272,6 +287,13 @@ class MediaDisplayComponent : public Component,
MultiButton::Mode copyFileButtonActiveInfo;
MultiButton::Mode copyFileButtonInactiveInfo;

// Preview mode controls
MultiButton previewPlayPauseButton;
MultiButton::Mode previewPlayButtonInfo;
MultiButton::Mode previewPauseButtonInfo;
MultiButton previewStopButton;
MultiButton::Mode previewStopButtonInfo;

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

Expand All @@ -283,6 +305,10 @@ class MediaDisplayComponent : public Component,
FlexBox buttonsFlexBox;
// Flex for media / overhead panel (if any)
FlexBox mediaAreaFlexBox;
// Flex for preview pane buttons
FlexBox previewControlsFlexBox;
// Flex for preview pane waveform + control row
FlexBox mediaRowFlexBox;

Uuid trackID;
String trackName;
Expand Down
Loading
Loading