Skip to content

Commit 3edfc5c

Browse files
committed
Clean up ControlPanel class
1 parent 83f5f23 commit 3edfc5c

File tree

2 files changed

+39
-60
lines changed

2 files changed

+39
-60
lines changed

Source/UI/ControlPanel.cpp

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,9 @@ void Clock::mouseDown (const MouseEvent& e)
340340
}
341341

342342
ControlPanel::ControlPanel (ProcessorGraph* graph_, AudioComponent* audio_, bool isConsoleApp_)
343-
: graph (graph_), audio (audio_), isConsoleApp (isConsoleApp_), initialize (true), open (false), lastEngineIndex (-1), forceRecording (false), hasRecorded (false)
343+
: graph (graph_),
344+
audio (audio_),
345+
isConsoleApp (isConsoleApp_)
344346
{
345347
AccessClass::setControlPanel (this);
346348

@@ -638,10 +640,6 @@ bool ControlPanel::setSelectedRecordEngineId (String id)
638640

639641
void ControlPanel::createPaths()
640642
{
641-
/* int w = getWidth() - 325;
642-
if (w > 150)
643-
w = 150;*/
644-
645643
int w = getWidth() - 435;
646644
if (w > 22)
647645
w = 22;
@@ -717,12 +715,10 @@ void ControlPanel::resized()
717715
{
718716
case 2:
719717
meterComponentsY += offset1;
720-
//meterComponentsWidth = w / 2 - meterComponentsMargin * 2 - 12;
721718
break;
722719

723720
case 3:
724721
meterComponentsY += offset1 + offset2;
725-
//meterComponentsWidth = w / 2 - meterComponentsMargin * 2 - 12;
726722
break;
727723

728724
default:
@@ -800,12 +796,6 @@ void ControlPanel::resized()
800796
recordSelector->setBounds ((w - 435) > 40 ? 35 : w - 450, topBound, 125, h - 10);
801797
recordSelector->setVisible (true);
802798

803-
/* Record options no longer used */
804-
/*
805-
recordOptionsButton->setBounds ((w - 435) > 40 ? 140 : w - 350, topBound, h - 10, h - 10);
806-
recordOptionsButton->setVisible (false);
807-
*/
808-
809799
/* Shows the default root recording directory for new RecordNodes */
810800
filenameComponent->setBounds (165, topBound, w - 510, h - 10);
811801
filenameComponent->setVisible (true);
@@ -851,10 +841,8 @@ void ControlPanel::labelTextChanged (Label* label)
851841
{
852842
node->newDirectoryNeeded = true;
853843
}
854-
//newDirectoryButton->setEnabledState (true);
855-
clock->resetRecordingTime();
856844

857-
// filenameText->setColour(Label::textColourId, Colours::grey);
845+
clock->resetRecordingTime();
858846
}
859847

860848
void ControlPanel::startRecording()
@@ -883,8 +871,6 @@ void ControlPanel::startRecording()
883871
{
884872
CoreServices::RecordNode::createNewRecordingDirectory (recordNodeId);
885873
}
886-
887-
//std::cout << "Recording directory name: " << recordingDirectoryName << std::endl;
888874
}
889875

890876
graph->setRecordState (true);
@@ -1129,13 +1115,6 @@ void ControlPanel::refreshMeters()
11291115
}
11301116
}
11311117

1132-
bool ControlPanel::keyPressed (const KeyPress& key)
1133-
{
1134-
LOGD ("Control panel received", key.getKeyCode());
1135-
1136-
return false;
1137-
}
1138-
11391118
void ControlPanel::toggleState()
11401119
{
11411120
open = ! open;
@@ -1374,7 +1353,6 @@ void ControlPanel::setRecordingDirectoryBaseText (String text)
13741353

13751354
String ControlPanel::generateFilenameFromFields (bool usePlaceholderText)
13761355
{
1377-
//bool checkForExistingFilename = false;
13781356

13791357
String filename = "";
13801358

Source/UI/ControlPanel.h

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,6 @@ class TESTABLE ControlPanel : public Component,
364364
void setRecordingDirectoryBaseText (String text);
365365

366366
/** Gets the name of the current recording directory (including prepend and append text)
367-
368367
Returns an empty string if recording has not been started yet.
369368
*/
370369
String getRecordingDirectoryName();
@@ -417,9 +416,9 @@ class TESTABLE ControlPanel : public Component,
417416
/** Updates button colours when colour theme changes */
418417
void updateColours();
419418

419+
/** Pointers to owned components */
420420
std::unique_ptr<FilenameEditorButton> filenameText;
421421
std::unique_ptr<FilenameConfigWindow> filenameConfigWindow;
422-
423422
std::unique_ptr<Clock> clock;
424423

425424
private:
@@ -432,11 +431,32 @@ class TESTABLE ControlPanel : public Component,
432431
/** Generates the next recording directory based on field settings **/
433432
String generateFilenameFromFields (bool usePlaceholderText);
434433

435-
bool hasRecorded;
436-
bool forceRecording;
434+
/* Called by popup window for editing recording filename fields */
435+
void componentBeingDeleted (Component& component);
436+
437+
/** Draws the control panel background */
438+
void paint (Graphics& g);
437439

438-
std::unique_ptr<PlayButton> playButton;
440+
/** Sets sub-component bounds */
441+
void resized();
442+
443+
/** Respond to button clicks */
444+
void buttonClicked (Button* button);
439445

446+
/** Respond to ComboBox changes */
447+
void comboBoxChanged (ComboBox* combo);
448+
449+
/** Controls timing of meter animations */
450+
void timerCallback();
451+
452+
/** Updates the values displayed by the CPUMeter and DiskSpaceMeter.*/
453+
void refreshMeters();
454+
455+
/** Draws the boundaries around the FilenameComponent.*/
456+
void createPaths();
457+
458+
/** Pointers to owned components */
459+
std::unique_ptr<PlayButton> playButton;
440460
std::unique_ptr<CPUMeter> cpuMeter;
441461
std::unique_ptr<DiskSpaceMeter> diskMeter;
442462
std::unique_ptr<FilenameComponent> filenameComponent;
@@ -445,47 +465,28 @@ class TESTABLE ControlPanel : public Component,
445465
std::unique_ptr<CustomArrowButton> showHideRecordingOptionsButton;
446466
std::unique_ptr<RecordButton> recordButton;
447467
std::unique_ptr<ComboBox> recordSelector;
448-
449468
Array<std::shared_ptr<FilenameFieldComponent>> filenameFields;
469+
OwnedArray<RecordEngineManager> recordEngines;
470+
std::unique_ptr<UtilityButton> recordOptionsButton;
450471

451-
/* Popup window for editing recording filename fields */
452-
void componentBeingDeleted (Component& component);
453-
472+
/** Pointers to non-owned components */
454473
ProcessorGraph* graph;
455474
AudioComponent* audio;
456475
AudioEditor* audioEditor;
457476

458-
void paint (Graphics& g);
459-
460-
void resized();
461-
462-
void paintButton (Graphics& g);
463-
void buttonClicked (Button* button);
464-
465-
void comboBoxChanged (ComboBox* combo);
466-
467-
bool initialize;
477+
/** Internal state variables */
478+
bool initialize = true;
468479
bool isConsoleApp;
469-
470-
void timerCallback();
471-
472-
/** Updates the values displayed by the CPUMeter and DiskSpaceMeter.*/
473-
void refreshMeters();
474-
475-
bool keyPressed (const KeyPress& key);
476-
477-
bool open;
480+
bool open = false;
481+
bool hasRecorded = false;
482+
bool forceRecording = false;
483+
int lastEngineIndex = -1;
478484

479485
Path p1, p2;
480486

481-
/** Draws the boundaries around the FilenameComponent.*/
482-
void createPaths();
483-
484487
String recordingDirectoryName;
485488

486-
OwnedArray<RecordEngineManager> recordEngines;
487-
std::unique_ptr<UtilityButton> recordOptionsButton;
488-
int lastEngineIndex;
489+
489490
};
490491

491492
#endif // __CONTROLPANEL_H_AD81E528__

0 commit comments

Comments
 (0)