Skip to content

Commit cead34b

Browse files
committed
Add project link footer to the UI
1 parent 538eb4b commit cead34b

File tree

2 files changed

+61
-14
lines changed

2 files changed

+61
-14
lines changed

Source/GUI/Layout/StatusBarComponent.cpp

Lines changed: 54 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,32 @@ StatusBarComponent::StatusBarComponent()
77
addAndMakeVisible(cpuLabel);
88
addAndMakeVisible(latencyLabel);
99
addAndMakeVisible(sampleRateLabel);
10-
10+
1111
addAndMakeVisible(statusLabel);
1212
statusLabel.setJustificationType(juce::Justification::centred);
1313

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+
1536
cpuLabel.setText("CPU: --", juce::dontSendNotification);
1637
latencyLabel.setText("Latency: --", juce::dontSendNotification);
1738
sampleRateLabel.setText("Rate: --", juce::dontSendNotification);
@@ -35,29 +56,50 @@ void StatusBarComponent::resized() {
3556
auto bounds = getLocalBounds().reduced(10, 5);
3657
const int padding = 20;
3758

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();
4365

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);
4588
}
4689

47-
void StatusBarComponent::updateTexts() { }
90+
void StatusBarComponent::updateTexts() {}
91+
4892
void StatusBarComponent::changeListenerCallback(juce::ChangeBroadcaster* source)
4993
{
50-
(void)source; // Báo cho compiler biết: có lý do để nó ở đây
94+
(void)source;
5195
}
5296

5397
void StatusBarComponent::updateStatus(double cpuUsage, double latencyMs, double sampleRate)
5498
{
55-
// Định dạng chuỗi để hiển thị
5699
juce::String cpuText = "CPU: " + juce::String(cpuUsage, 1) + " %";
57100
juce::String latencyText = "Latency: " + juce::String(latencyMs, 2) + " ms";
58101
juce::String rateText = "Rate: " + juce::String(sampleRate / 1000.0, 1) + " kHz";
59102

60-
// Cập nhật các label
61103
cpuLabel.setText(cpuText, juce::dontSendNotification);
62104
latencyLabel.setText(latencyText, juce::dontSendNotification);
63105
sampleRateLabel.setText(rateText, juce::dontSendNotification);

Source/GUI/Layout/StatusBarComponent.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#pragma once
1+
#pragma once
22
#include "JuceHeader.h"
33
#include "../../Data/LanguageManager/LanguageManager.h"
44

@@ -18,5 +18,10 @@ class StatusBarComponent : public juce::Component, public juce::ChangeListener {
1818
void updateTexts();
1919

2020
juce::Label cpuLabel, latencyLabel, sampleRateLabel;
21-
juce::Label statusLabel; // Replaces errorLabel for general messages
21+
juce::Label statusLabel;
22+
23+
// <<< SỬA: Dùng 2 Label riêng biệt >>>
24+
juce::Label attributionText; // Cho phần text thường
25+
juce::Label linkText; // Cho phần text in đậm
26+
juce::HyperlinkButton linkButton; // Vẫn là button vô hình
2227
};

0 commit comments

Comments
 (0)