@@ -33,22 +33,61 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
33
33
#include " LookAndFeel/CustomLookAndFeel.h"
34
34
35
35
const int SIZE_AUDIO_EDITOR_MAX_WIDTH = 500 ;
36
- // const int SIZE_AUDIO_EDITOR_MIN_WIDTH = 250;
37
36
38
- ForceNewDirectoryButton::ForceNewDirectoryButton () : Button (" ForceNewDirectory " )
37
+ NewDirectoryButton::NewDirectoryButton () : Button (" NewDirectory " )
39
38
{
39
+ // XmlDocument xmlDoc (R"(
40
+ // <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"
41
+ // fill="currentColor" stroke="currentColor" stroke-width="2" stroke-linecap="round"
42
+ // stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-folder-plus">
43
+ // <path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M12 19h-7a2 2 0 0 1 -2 -2v-11a2 2 0 0 1 2 -2h4l3 3h7a2 2 0 0 1 2 2v3.5" />
44
+ // <path d="M16 19h6" /><path d="M19 16v6" /></svg>)");
45
+
40
46
XmlDocument xmlDoc (R"(
41
- <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-lock" width="44" height="44" viewBox="0 0 24 24" stroke-width="1.5" stroke="#2c3e50" fill="currentColor" stroke-linecap="round" stroke-linejoin="round">
42
- <path stroke="none" d="M0 0h24v24H0z" fill="none"/>
43
- <path d="M5 13a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v6a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-6z" fill="currentColor" />
44
- <path d="M11 16a1 1 0 1 0 2 0a1 1 0 0 0 -2 0" fill="currentColor" />
45
- <path d="M8 11v-4a4 4 0 1 1 8 0v4" fill="currentColor"/>
46
- </svg>)" );
47
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="icon icon-tabler icons-tabler-filled icon-tabler-folder"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M9 3a1 1 0 0 1 .608 .206l.1 .087l2.706 2.707h6.586a3 3 0 0 1 2.995 2.824l.005 .176v8a3 3 0 0 1 -2.824 2.995l-.176 .005h-14a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-11a3 3 0 0 1 2.824 -2.995l.176 -.005h4z" /></svg>)" );
47
48
48
- forceNewDirectoryIcon = Drawable::createFromSVG (*xmlDoc.getDocumentElement ().get ());
49
+ // XmlDocument xmlDoc (R"(
50
+ // <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="icon icon-tabler icons-tabler-filled icon-tabler-lock"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M12 2a5 5 0 0 1 5 5v3a3 3 0 0 1 3 3v6a3 3 0 0 1 -3 3h-10a3 3 0 0 1 -3 -3v-6a3 3 0 0 1 3 -3v-3a5 5 0 0 1 5 -5m0 12a2 2 0 0 0 -1.995 1.85l-.005 .15a2 2 0 1 0 2 -2m0 -10a3 3 0 0 0 -3 3v3h6v-3a3 3 0 0 0 -3 -3" /></svg>)");
51
+
52
+ newDirectoryIcon = Drawable::createFromSVG (*xmlDoc.getDocumentElement ().get ());
53
+
54
+ newDirectoryIcon->replaceColour (Colours::black, Colours::black);
49
55
50
56
setClickingTogglesState (true );
57
+ }
58
+
59
+ void NewDirectoryButton::paintButton (Graphics& g, bool isMouseOver, bool isButtonDown)
60
+ {
61
+ Colour buttonColour;
51
62
63
+ if (getToggleState ())
64
+ buttonColour = findColour (ThemeColours::highlightedFill);
65
+ else
66
+ buttonColour = findColour (ThemeColours::controlPanelBackground);
67
+
68
+ if (isMouseOver)
69
+ buttonColour = buttonColour.brighter (0 .2f );
70
+
71
+ g.setColour (Colours::black);
72
+ g.fillRoundedRectangle (0 , 0 , getWidth (), getHeight (), 5 );
73
+ g.setColour (buttonColour);
74
+ g.fillRoundedRectangle (1 , 1 , getWidth () - 2 , getHeight () - 2 , 3 );
75
+
76
+ g.setColour (Colours::black);
77
+ newDirectoryIcon->drawWithin (g, juce::Rectangle<float >(2 ,2.5 ,18 ,18 ), RectanglePlacement::centred, 1 .0f );
78
+ g.setColour (buttonColour);
79
+ g.drawRect (10 , 9 , 2 , 6 );
80
+ g.drawRect (8 , 11 , 6 , 2 );
81
+ }
82
+
83
+ ForceNewDirectoryButton::ForceNewDirectoryButton () : Button (" ForceNewDirectory" )
84
+ {
85
+ XmlDocument xmlDoc (R"(
86
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="icon icon-tabler icons-tabler-filled icon-tabler-lock"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M12 2a5 5 0 0 1 5 5v3a3 3 0 0 1 3 3v6a3 3 0 0 1 -3 3h-10a3 3 0 0 1 -3 -3v-6a3 3 0 0 1 3 -3v-3a5 5 0 0 1 5 -5m0 12a2 2 0 0 0 -1.995 1.85l-.005 .15a2 2 0 1 0 2 -2m0 -10a3 3 0 0 0 -3 3v3h6v-3a3 3 0 0 0 -3 -3" /></svg>)" );
87
+
88
+ forceNewDirectoryIcon = Drawable::createFromSVG (*xmlDoc.getDocumentElement ().get ());
89
+
90
+ setClickingTogglesState (true );
52
91
}
53
92
54
93
void ForceNewDirectoryButton::paintButton (Graphics& g, bool isMouseOver, bool isButtonDown)
@@ -58,7 +97,7 @@ void ForceNewDirectoryButton::paintButton (Graphics& g, bool isMouseOver, bool i
58
97
if (getToggleState ())
59
98
buttonColour = findColour (ThemeColours::highlightedFill);
60
99
else
61
- buttonColour = findColour (ThemeColours::defaultText );
100
+ buttonColour = findColour (ThemeColours::controlPanelText );
62
101
63
102
if (isMouseOver)
64
103
buttonColour = buttonColour.brighter (0 .2f );
@@ -152,7 +191,8 @@ void RecordButton::updateImages (bool recordingIsActive)
152
191
setImages (&normal, &over, &down);
153
192
}
154
193
155
- CPUMeter::CPUMeter () : Label (" CPU Meter" , " 0.0" ), cpu (0 .0f )
194
+ CPUMeter::CPUMeter () : Label (" CPU Meter" , " 0.0" ),
195
+ cpu (0 .0f )
156
196
{
157
197
font = FontOptions (" Silkscreen" , " Regular" , 14 );
158
198
@@ -375,8 +415,8 @@ void Clock::mouseDown (const MouseEvent& e)
375
415
}
376
416
377
417
ControlPanel::ControlPanel (ProcessorGraph* graph_, AudioComponent* audio_, bool isConsoleApp_)
378
- : graph (graph_),
379
- audio (audio_),
418
+ : graph (graph_),
419
+ audio (audio_),
380
420
isConsoleApp (isConsoleApp_)
381
421
{
382
422
AccessClass::setControlPanel (this );
@@ -420,16 +460,15 @@ ControlPanel::ControlPanel (ProcessorGraph* graph_, AudioComponent* audio_, bool
420
460
recordOptionsButton->setTooltip (" Configure options for selected record engine" );
421
461
addChildComponent (recordOptionsButton.get ());
422
462
423
- newDirectoryButton = std::make_unique<UtilityButton> (" +" );
424
- newDirectoryButton->setFont (FontOptions (" Silkscreen" , " Regular" , 15 ));
463
+ newDirectoryButton = std::make_unique<NewDirectoryButton>();
425
464
newDirectoryButton->setEnabled (false );
426
465
newDirectoryButton->addListener (this );
427
466
newDirectoryButton->setTooltip (" Start a new data directory for next recording" );
428
467
newDirectoryButton->setToggleState (true , sendNotification);
429
468
newDirectoryButton->setClickingTogglesState (true );
430
469
addChildComponent (newDirectoryButton.get ());
431
470
432
- forceNewDirectoryButton = std::make_unique<ForceNewDirectoryButton> ();
471
+ forceNewDirectoryButton = std::make_unique<ForceNewDirectoryButton>();
433
472
forceNewDirectoryButton->setEnabled (true );
434
473
forceNewDirectoryButton->addListener (this );
435
474
forceNewDirectoryButton->setTooltip (" Force a new data directory for each recording" );
@@ -542,7 +581,6 @@ void ControlPanel::startAcquisition (bool recordingShouldAlsoStart)
542
581
543
582
graph->startAcquisition (); // inform processors that acquisition will start
544
583
545
-
546
584
if (recordingShouldAlsoStart)
547
585
{
548
586
startRecording ();
@@ -563,9 +601,8 @@ void ControlPanel::startAcquisition (bool recordingShouldAlsoStart)
563
601
recordSelector->setEnabled (false ); // why is this outside the "if" statement?
564
602
recordOptionsButton->setEnabled (false );
565
603
}
566
-
604
+
567
605
audio->beginCallbacks (); // starts acquisition callbacks
568
-
569
606
}
570
607
}
571
608
@@ -950,7 +987,7 @@ void ControlPanel::componentBeingDeleted (Component& component)
950
987
filenameText->setButtonText (generateFilenameFromFields (true ));
951
988
952
989
// TODO: Assumes any change in filename settings should start a new directory next recording
953
- if (!newDirectoryButton->getToggleState ())
990
+ if (! newDirectoryButton->getToggleState ())
954
991
newDirectoryButton->setToggleState (true , dontSendNotification);
955
992
956
993
CoreServices::saveRecoveryConfig ();
@@ -991,18 +1028,21 @@ void ControlPanel::buttonClicked (Button* button)
991
1028
if (button == newDirectoryButton.get ())
992
1029
{
993
1030
// Setting the button state only takes effect on the next recording
1031
+
994
1032
return ;
995
1033
}
996
1034
997
1035
if (button == forceNewDirectoryButton.get ())
998
1036
{
999
- if (button->getToggleState ()) {
1037
+ if (button->getToggleState ())
1038
+ {
1000
1039
newDirectoryButton->setToggleState (true , dontSendNotification);
1001
1040
newDirectoryButton->setEnabled (false );
1002
1041
}
1003
1042
else
1004
1043
{
1005
- newDirectoryButton->setEnabled (true );
1044
+ if (hasRecorded)
1045
+ newDirectoryButton->setEnabled (true );
1006
1046
}
1007
1047
return ;
1008
1048
}
@@ -1262,7 +1302,8 @@ String ControlPanel::getRecordingDirectoryName()
1262
1302
void ControlPanel::createNewRecordingDirectory ()
1263
1303
{
1264
1304
// TODO: Remove depdendency on button states/callbacks
1265
- MessageManager::callAsync ([this ] { buttonClicked (newDirectoryButton.get ()); });
1305
+ MessageManager::callAsync ([this ]
1306
+ { buttonClicked (newDirectoryButton.get ()); });
1266
1307
}
1267
1308
1268
1309
String ControlPanel::getRecordingDirectoryPrependText ()
@@ -1395,15 +1436,15 @@ void ControlPanel::setRecordingDirectoryBaseText (String text)
1395
1436
1396
1437
String ControlPanel::generateFilenameFromFields (bool usePlaceholderText)
1397
1438
{
1398
-
1399
1439
String filename = " " ;
1400
1440
1401
1441
for (auto & field : filenameFields) // loops in order through prepend, main, append
1402
1442
{
1403
1443
filename += field->getNextValue (usePlaceholderText);
1404
1444
}
1405
1445
1406
- MessageManager::callAsync ([this , filename] { filenameText->setButtonText (filename); });
1446
+ MessageManager::callAsync ([this , filename]
1447
+ { filenameText->setButtonText (filename); });
1407
1448
1408
1449
return filename;
1409
1450
}
0 commit comments