@@ -7,11 +7,32 @@ StatusBarComponent::StatusBarComponent()
7
7
addAndMakeVisible (cpuLabel);
8
8
addAndMakeVisible (latencyLabel);
9
9
addAndMakeVisible (sampleRateLabel);
10
-
10
+
11
11
addAndMakeVisible (statusLabel);
12
12
statusLabel.setJustificationType (juce::Justification::centred);
13
13
14
- // Placeholder texts
14
+ juce::FontOptions fontOptions (12 .0f );
15
+
16
+ addAndMakeVisible (attributionText);
17
+ attributionText.setText (" idolLiveAudio is a free and open-source software developed by " , juce::dontSendNotification);
18
+ attributionText.setFont (juce::Font (fontOptions));
19
+ attributionText.setColour (juce::Label::textColourId, juce::Colours::lightgrey);
20
+ attributionText.setJustificationType (juce::Justification::centredRight);
21
+
22
+ addAndMakeVisible (linkText);
23
+ linkText.setText (" DEVCodeWithAI." , juce::dontSendNotification);
24
+ juce::Font boldFont (fontOptions);
25
+ boldFont.setBold (true );
26
+ linkText.setFont (boldFont);
27
+
28
+ linkText.setColour (juce::Label::textColourId, juce::Colour (0xff87CEEB ));
29
+ linkText.setJustificationType (juce::Justification::centredLeft);
30
+
31
+ addAndMakeVisible (linkButton);
32
+ linkButton.setButtonText (" " );
33
+ linkButton.setTooltip (" https://github.com/DEVCodeWithAI" );
34
+ linkButton.setURL (juce::URL (" https://github.com/DEVCodeWithAI" ));
35
+
15
36
cpuLabel.setText (" CPU: --" , juce::dontSendNotification);
16
37
latencyLabel.setText (" Latency: --" , juce::dontSendNotification);
17
38
sampleRateLabel.setText (" Rate: --" , juce::dontSendNotification);
@@ -35,29 +56,50 @@ void StatusBarComponent::resized() {
35
56
auto bounds = getLocalBounds ().reduced (10 , 5 );
36
57
const int padding = 20 ;
37
58
38
- cpuLabel.setBounds (bounds.removeFromLeft (100 ));
39
- bounds.removeFromLeft (padding);
40
- latencyLabel.setBounds (bounds.removeFromLeft (150 ));
41
- bounds.removeFromLeft (padding);
42
- sampleRateLabel.setBounds (bounds.removeFromLeft (100 ));
59
+ juce::TextLayout tl;
60
+ juce::AttributedString linkAttrString;
61
+ linkAttrString.setText (linkText.getText ());
62
+ linkAttrString.setFont (linkText.getFont ());
63
+ tl.createLayout (linkAttrString, 10000 .0f );
64
+ const int linkTextWidth = (int )tl.getWidth ();
43
65
44
- statusLabel.setBounds (bounds);
66
+ juce::AttributedString staticAttrString;
67
+ staticAttrString.setText (attributionText.getText ());
68
+ staticAttrString.setFont (attributionText.getFont ());
69
+ tl.createLayout (staticAttrString, 10000 .0f );
70
+ const int staticTextWidth = (int )tl.getWidth ();
71
+
72
+ const int totalAttributionWidth = staticTextWidth + linkTextWidth;
73
+
74
+ auto rightBounds = bounds.removeFromRight (totalAttributionWidth);
75
+
76
+ attributionText.setBounds (rightBounds.removeFromLeft (staticTextWidth));
77
+ linkText.setBounds (rightBounds);
78
+
79
+ linkButton.setBounds (linkText.getBounds ());
80
+
81
+ auto leftBounds = bounds;
82
+ cpuLabel.setBounds (leftBounds.removeFromLeft (100 ));
83
+ leftBounds.removeFromLeft (padding);
84
+ latencyLabel.setBounds (leftBounds.removeFromLeft (150 ));
85
+ leftBounds.removeFromLeft (padding);
86
+ sampleRateLabel.setBounds (leftBounds.removeFromLeft (100 ));
87
+ statusLabel.setBounds (leftBounds);
45
88
}
46
89
47
- void StatusBarComponent::updateTexts () { }
90
+ void StatusBarComponent::updateTexts () {}
91
+
48
92
void StatusBarComponent::changeListenerCallback (juce::ChangeBroadcaster* source)
49
93
{
50
- (void )source; // Báo cho compiler biết: có lý do để nó ở đây
94
+ (void )source;
51
95
}
52
96
53
97
void StatusBarComponent::updateStatus (double cpuUsage, double latencyMs, double sampleRate)
54
98
{
55
- // Định dạng chuỗi để hiển thị
56
99
juce::String cpuText = " CPU: " + juce::String (cpuUsage, 1 ) + " %" ;
57
100
juce::String latencyText = " Latency: " + juce::String (latencyMs, 2 ) + " ms" ;
58
101
juce::String rateText = " Rate: " + juce::String (sampleRate / 1000.0 , 1 ) + " kHz" ;
59
102
60
- // Cập nhật các label
61
103
cpuLabel.setText (cpuText, juce::dontSendNotification);
62
104
latencyLabel.setText (latencyText, juce::dontSendNotification);
63
105
sampleRateLabel.setText (rateText, juce::dontSendNotification);
0 commit comments