Skip to content

Commit

Permalink
Restore ScrubberInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
medengineer committed Aug 3, 2023
1 parent 5856842 commit 42fb696
Show file tree
Hide file tree
Showing 6 changed files with 194 additions and 43 deletions.
27 changes: 23 additions & 4 deletions Source/Processors/FileReader/FileReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ FileReader::~FileReader()

void FileReader::registerParameters()
{
addPathParameter(Parameter::PROCESSOR_SCOPE, "selected_file", "Selected File", "File to load data from", defaultFile.getFullPathName(), getSupportedExtensions(), false);
addPathParameter(Parameter::PROCESSOR_SCOPE, "selected_file", "Selected File", "File to load data from", "default", getSupportedExtensions(), false);
addSelectedStreamParameter(Parameter::PROCESSOR_SCOPE, "active_stream", "Active Stream", "Currently active stream", {}, 0);
addTimeParameter(Parameter::PROCESSOR_SCOPE, "start_time", "Start Time", "Time to start playback");
addTimeParameter(Parameter::PROCESSOR_SCOPE, "end_time", "End Time", "Time to end playback");
Expand All @@ -117,16 +117,20 @@ void FileReader::parameterValueChanged(Parameter* p)
else if (p->getName() == "active_stream")
{
setActiveStream(p->getValue());
static_cast<FileReaderEditor*> (getEditor())->getScrubberInterface()->update();
CoreServices::updateSignalChain (this->getEditor());
}
else if (p->getName() == "start_time")
{
TimeParameter* tp = static_cast<TimeParameter*>(p);
startSample = millisecondsToSamples(tp->getTimeValue()->getTimeInMilliseconds());
static_cast<FileReaderEditor*> (getEditor())->getScrubberInterface()->update();
}
else if (p->getName() == "end_time")
{
TimeParameter* tp = static_cast<TimeParameter*>(p);
stopSample = millisecondsToSamples(tp->getTimeValue()->getTimeInMilliseconds());
static_cast<FileReaderEditor*> (getEditor())->getScrubberInterface()->update();
}
}

Expand Down Expand Up @@ -238,13 +242,25 @@ bool FileReader::setFile (String fullpath)
return false;
}

if (!headlessMode)
static_cast<FileReaderEditor*> (getEditor())->populateRecordings (input);

setActiveStream (0);

if (!headlessMode)
{

FileReaderEditor* ed = (FileReaderEditor*)editor.get();

ed->populateRecordings (input);

ed->showScrubInterface(false);

ed->enableScrubDrawer(getCurrentNumTotalSamples() / getCurrentSampleRate() > 30.0f);

}

gotNewFile = true;

CoreServices::updateSignalChain (this->getEditor());

return true;
}

Expand Down Expand Up @@ -523,7 +539,9 @@ Array<EventInfo> FileReader::getActiveEventInfo()

String FileReader::handleConfigMessage(String msg)
{
//TODO: Needs update to use new parameters

/*
const MessageManagerLock mml;
StringArray tokens;
Expand All @@ -541,6 +559,7 @@ String FileReader::handleConfigMessage(String msg)
static_cast<FileReaderEditor*> (getEditor())->setPlaybackStartTime(std::stoi(tokens[1].toStdString()));
else
LOGD("Invalid key");
*/

return "File Reader received config: " + msg;
}
Expand Down
56 changes: 39 additions & 17 deletions Source/Processors/FileReader/FileReaderEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,25 @@ FileReaderEditor::FileReaderEditor (GenericProcessor* parentNode)
{

scrubberInterface = new ScrubberInterface(fileReader);
scrubberInterface->setBounds(0, 0, 200, 200);
scrubberInterface->setBounds(0, 0, 420, 140);
addChildComponent(scrubberInterface);

scrubDrawerButton = new ScrubDrawerButton(getNameAndId() + " Scrub Drawer Button");
scrubDrawerButton->setBounds(4, 40, 10, 78);
scrubDrawerButton->setToggleState(false, dontSendNotification);
scrubDrawerButton->addListener(this);
addChildComponent(scrubDrawerButton);
scrubDrawerButton->setEnabled(false);
addAndMakeVisible(scrubDrawerButton);

lastFilePath = CoreServices::getDefaultUserSaveDirectory();

addPathParameterEditor (Parameter::PROCESSOR_SCOPE, "selected_file", 10, 29);
addSelectedStreamParameterEditor (Parameter::PROCESSOR_SCOPE, "active_stream", 10, 54);
addTimeParameterEditor (Parameter::PROCESSOR_SCOPE, "start_time", 10, 79);
addTimeParameterEditor (Parameter::PROCESSOR_SCOPE, "end_time", 10, 104);
addPathParameterEditor (Parameter::PROCESSOR_SCOPE, "selected_file", 24, 29);
addSelectedStreamParameterEditor (Parameter::PROCESSOR_SCOPE, "active_stream", 24, 54);
addTimeParameterEditor (Parameter::PROCESSOR_SCOPE, "start_time", 24, 79);
addTimeParameterEditor (Parameter::PROCESSOR_SCOPE, "end_time", 24, 104);

for (auto& p : {"selected_file", "active_stream", "start_time", "end_time"})
{
auto* ed = getParameterEditor(p);
if (ed != nullptr)
ed->setBounds(ed->getX(), ed->getY(), 3*ed->getWidth() / 2, ed->getHeight());
ed->setBounds(ed->getX(), ed->getY(), 2*ed->getWidth(), ed->getHeight());
}

/*
Expand All @@ -98,14 +97,17 @@ FileReaderEditor::FileReaderEditor (GenericProcessor* parentNode)
addAndMakeVisible (timeLimits);
*/

desiredWidth = 240;
desiredWidth = 280;

lastFilePath = CoreServices::getDefaultUserSaveDirectory();

}

FileReaderEditor::~FileReaderEditor()
{
}

/*
void FileReaderEditor::setFile (String file, bool shouldUpdateSignalChain)
{
if (file.equalsIgnoreCase("default"))
Expand Down Expand Up @@ -139,7 +141,6 @@ void FileReaderEditor::setFile (String file, bool shouldUpdateSignalChain)
{
fileNameLabel->setText (fileToRead.getFileName(), dontSendNotification);
/* Only show scrubber interface if recording > 30s */
scrubDrawerButton->setVisible(false);
if ( scrubInterfaceVisible )
showScrubInterface(false);
Expand All @@ -155,12 +156,12 @@ void FileReaderEditor::setFile (String file, bool shouldUpdateSignalChain)
{
clearEditor();
}

if (shouldUpdateSignalChain)
CoreServices::updateSignalChain (this);
repaint();
}
*/

void FileReaderEditor::paintOverChildren (Graphics& g)
{
Expand All @@ -177,7 +178,7 @@ void FileReaderEditor::paintOverChildren (Graphics& g)

void FileReaderEditor::buttonClicked (Button* button)
{

/*
if (! acquisitionIsActive)
{
if (button == fileButton)
Expand All @@ -203,6 +204,7 @@ void FileReaderEditor::buttonClicked (Button* button)
}
}
}
*/

if (button == scrubDrawerButton) {

Expand All @@ -214,11 +216,13 @@ void FileReaderEditor::buttonClicked (Button* button)

void FileReaderEditor::collapsedStateChanged()
{
/*
if (!getCollapsedState())
{
scrubberInterface->setVisible(scrubInterfaceAvailable);
scrubDrawerButton->setVisible(scrubInterfaceAvailable);
}
*/

}

Expand All @@ -230,10 +234,15 @@ ScrubberInterface* FileReaderEditor::getScrubberInterface()
void FileReaderEditor::showScrubInterface(bool show)
{

scrubInterfaceVisible = show;
scrubberInterface->setVisible(show);

int dX = scrubberInterface->getWidth();
dX = show ? dX : -dX;

if (scrubInterfaceVisible && !show)
dX = -dX;
else if (!scrubInterfaceVisible && !show)
return;

desiredWidth += dX;

/* Move all editor components to the right */
Expand All @@ -242,6 +251,13 @@ void FileReaderEditor::showScrubInterface(bool show)
scrubDrawerButton->getWidth(), scrubDrawerButton->getHeight()
);

for (auto& p : {"selected_file", "active_stream", "start_time", "end_time"})
{
auto* ed = getParameterEditor(p);
ed->setBounds(ed->getX() + dX, ed->getY(), ed->getWidth(), ed->getHeight());
}

/*
fileButton->setBounds(
fileButton->getX() + dX, fileButton->getY(),
fileButton->getWidth(), fileButton->getHeight()
Expand All @@ -266,6 +282,7 @@ void FileReaderEditor::showScrubInterface(bool show)
timeLimits->getX() + dX, timeLimits->getY(),
timeLimits->getWidth(), timeLimits->getHeight()
);
*/

/* Show all scrubber interface components */
// TOFIX: Don't think this is needed anymore...
Expand All @@ -283,6 +300,8 @@ void FileReaderEditor::showScrubInterface(bool show)
CoreServices::highlightEditor(this);
deselect();

scrubInterfaceVisible = show;

}

bool FileReaderEditor::setPlaybackStartTime (unsigned int ms)
Expand Down Expand Up @@ -426,6 +445,7 @@ void FileReaderEditor::populateRecordings (FileSource* source)

void FileReaderEditor::clearEditor()
{
/*
fileNameLabel->setText ("No file selected.", dontSendNotification);
recordSelector->clear (dontSendNotification);
Expand All @@ -435,6 +455,7 @@ void FileReaderEditor::clearEditor()
currentTime->setTimeMilliseconds (1, 0);
CoreServices::updateSignalChain(this);
*/

}

Expand Down Expand Up @@ -511,7 +532,8 @@ void FileReaderEditor::fileDragEnter (const StringArray& files, int x, int y)

void FileReaderEditor::filesDropped (const StringArray& files, int x, int y)
{
setFile (files[0]);
//TODO: Use parameter
//setFile (files[0]);

m_isFileDragAndDropActive = false;
repaint();
Expand Down
7 changes: 6 additions & 1 deletion Source/Processors/FileReader/FileReaderEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include "../Editors/GenericEditor.h"
#include "../../Utils/Utils.h"

#include "ScrubberInterface.h"

class FileReader;
class FileReaderEditor;
class DualTimeComponent;
Expand Down Expand Up @@ -99,7 +101,7 @@ class FileReaderEditor : public GenericEditor
void stopAcquisition() override;

/** Sets the active file */
void setFile (String file, bool shouldUpdateSignalChain = true);
// void setFile (String file, bool shouldUpdateSignalChain = true);

/** Responds to combo box selections */
void comboBoxChanged (ComboBox* combo);
Expand All @@ -113,6 +115,9 @@ class FileReaderEditor : public GenericEditor
/** Returns a pointer to the ScrubberInterface */
ScrubberInterface* getScrubberInterface();

/** Enables/disables the ScrubDrawerButton */
void enableScrubDrawer(bool enabled) { scrubDrawerButton->setEnabled(enabled); }

/** Controls whether or not to show the file scrubbing interface */
void showScrubInterface(bool show);

Expand Down
Loading

0 comments on commit 42fb696

Please sign in to comment.