Skip to content
Open
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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ target_sources(${PROJECT_NAME}
src/media/AudioDisplayComponent.cpp
src/media/MidiDisplayComponent.cpp
src/media/FileDisplayComponent.cpp
src/media/TextDisplayComponent.cpp
src/media/OutputLabelComponent.cpp

src/media/pianoroll/KeyboardComponent.cpp
Expand Down
2 changes: 1 addition & 1 deletion pyharp
Submodule pyharp updated 5 files
+1 −1 LICENSE
+60 −196 README.md
+7 −24 examples/ui_tester/app.py
+19 −19 pyharp/core.py
+2 −2 setup.py
21 changes: 21 additions & 0 deletions src/Model.h
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,17 @@ class Model
DBG_AND_LOG("Model::extractInputs: MIDI track input \"" + midiTrack->label
+ "\" extracted.");
}
else if (type == "text_track")
{
std::shared_ptr<ModelComponentInfo> textFile =
std::make_shared<TextTrackComponentInfo>(controlsDict);

newInputs.push_back(textFile);
tempComponentIDs.push_back(textFile->id);

DBG_AND_LOG("Model::extractInputs: Text file input \"" + textFile->label
+ "\" extracted.");
}
else if (type == "generic_file")
{
std::shared_ptr<ModelComponentInfo> fileChooser =
Expand Down Expand Up @@ -618,6 +629,16 @@ class Model
DBG_AND_LOG("Model::extractOutputs: MIDI track output \"" + midiTrack->label
+ "\" extracted.");
}
else if (type == "text_track")
{
std::shared_ptr<ModelComponentInfo> textFile =
std::make_shared<TextTrackComponentInfo>(controlsDict);

newOutputs.push_back(textFile);

DBG_AND_LOG("Model::extractOutputs: Text file output \"" + textFile->label
+ "\" extracted.");
}
else if (type == "generic_file")
{
std::shared_ptr<ModelComponentInfo> fileOutput =
Expand Down
3 changes: 3 additions & 0 deletions src/media/MediaDisplayComponent.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "MediaDisplayComponent.h"
#include "AudioDisplayComponent.h"
#include "MidiDisplayComponent.h"
#include "TextDisplayComponent.h"

#include "../utils/Interface.h"

Expand Down Expand Up @@ -295,9 +296,11 @@ StringArray MediaDisplayComponent::getSupportedExtensions()
{
StringArray audioExtensions = AudioDisplayComponent::getSupportedExtensions();
StringArray midiExtensions = MidiDisplayComponent::getSupportedExtensions();
StringArray textExtensions = TextDisplayComponent::getSupportedExtensions();

StringArray allExtensions = StringArray(audioExtensions);
allExtensions.mergeArray(midiExtensions);
allExtensions.mergeArray(textExtensions);

return allExtensions;
}
Expand Down
43 changes: 43 additions & 0 deletions src/media/TextDisplayComponent.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include "TextDisplayComponent.h"

TextDisplayComponent::TextDisplayComponent() : TextDisplayComponent("Text Track") {}

TextDisplayComponent::TextDisplayComponent(String name, bool req, bool fromDAW, DisplayMode mode)
: MediaDisplayComponent(name, req, fromDAW, mode)
{
textEditor.setMultiLine(true);
textEditor.setReadOnly(true);
textEditor.setScrollbarsShown(true);
textEditor.setCaretVisible(false);
textEditor.setPopupMenuEnabled(false);
textEditor.setText("No text file loaded.");
contentComponent.addAndMakeVisible(textEditor);
}

StringArray TextDisplayComponent::getSupportedExtensions()
{
StringArray extensions;

extensions.add(".txt");

return extensions;
}

void TextDisplayComponent::resized()
{
MediaDisplayComponent::resized();
textEditor.setBounds(contentComponent.getLocalBounds());
}

void TextDisplayComponent::loadMediaFile(const URL& filePath)
{
File file = filePath.getLocalFile();
textEditor.setText(file.loadFileAsString());
}

void TextDisplayComponent::resetMedia()
{
textEditor.setText("No text file loaded.");
}

void TextDisplayComponent::postLoadActions(const URL& /*filePath*/) {}
38 changes: 38 additions & 0 deletions src/media/TextDisplayComponent.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#pragma once

#include "MediaDisplayComponent.h"

class TextDisplayComponent : public MediaDisplayComponent
{
public:
TextDisplayComponent();
TextDisplayComponent(String name,
bool req = true,
bool fromDAW = false,
DisplayMode mode = DisplayMode::Hybrid);
~TextDisplayComponent() override = default;

static StringArray getSupportedExtensions();

StringArray getInstanceExtensions() override
{
return TextDisplayComponent::getSupportedExtensions();
}

int getFixedHeight() const override { return fixedHeight; }

double getTotalLengthInSecs() override { return 0.0; }

void resized() override;

void loadMediaFile(const URL& filePath) override;

private:
void resetMedia() override;

void postLoadActions(const URL& filePath) override;

TextEditor textEditor;

static constexpr int fixedHeight = 150;
};
5 changes: 5 additions & 0 deletions src/utils/Controls.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ struct MidiTrackComponentInfo : public TrackComponentInfo
using TrackComponentInfo::TrackComponentInfo;
};

struct TextTrackComponentInfo : public TrackComponentInfo
{
using TrackComponentInfo::TrackComponentInfo;
};

struct FileComponentInfo : public ModelComponentInfo // TODO - Listener?
{
bool required = true;
Expand Down
15 changes: 15 additions & 0 deletions src/widgets/TrackAreaWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "../media/FileDisplayComponent.h"
#include "../media/MediaDisplayComponent.h"
#include "../media/MidiDisplayComponent.h"
#include "../media/TextDisplayComponent.h"

#include "../utils/Controls.h"
#include "../utils/Interface.h"
Expand Down Expand Up @@ -376,6 +377,11 @@ class TrackAreaWidget : public Component,
m = std::make_unique<MidiDisplayComponent>(
label, midiTrackInfo->required, fromDAW, displayMode);
}
else if (auto textTrackInfo = dynamic_cast<TextTrackComponentInfo*>(trackInfo))
{
m = std::make_unique<TextDisplayComponent>(
label, textTrackInfo->required, fromDAW, displayMode);
}
else
{
DBG_AND_LOG(
Expand Down Expand Up @@ -491,6 +497,15 @@ class TrackAreaWidget : public Component,

trackInfo = std::move(midiTrackInfo);
}
else if (TextDisplayComponent::getSupportedExtensions().contains(ext))
{
auto textTrackInfo = std::make_unique<TextTrackComponentInfo>();

textTrackInfo->required = false;
textTrackInfo->label = label.toStdString();

trackInfo = std::move(textTrackInfo);
}
else
{
DBG_AND_LOG("TrackAreaWidget::addTrackFromFilePath: Tried to add file "
Expand Down
Loading