Umsci
Upmix Spatial Control Interface — OCA/OCP.1 spatial audio utility
Loading...
Searching...
No Matches
UmsciConnectingComponent.cpp
Go to the documentation of this file.
1/* Copyright (c) 2026, Christian Ahrens
2 *
3 * This file is part of Umsci <https://github.com/ChristianAhrens/Umsci>
4 *
5 * This tool is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU Lesser General Public License version 3.0 as published
7 * by the Free Software Foundation.
8 *
9 * This tool is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 * details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this tool; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18
20
21#include <CustomLookAndFeel.h>
22
24 : juce::Component()
25{
26 m_startupProgressIndicator = std::make_unique<juce::ProgressBar>(m_progress, juce::ProgressBar::Style::circular);
27 addAndMakeVisible(m_startupProgressIndicator.get());
28}
29
33
35{
36 juce::String statusDescription;
37 switch (status)
38 {
40 statusDescription = "Subscribing to";
41 break;
42 case Status::Reading:
43 statusDescription = "Reading from";
44 break;
46 default:
47 statusDescription = "Connecting to";
48 break;
49 }
50
51 m_connectionStatusDescription = statusDescription;
52}
53
54void UmsciConnectingComponent::setConnectionParameters(const juce::IPAddress& ip, int port)
55{
56 m_connectionParametersDescription = ip.toString() + ":" + juce::String(port);
57 repaint();
58}
59
61{
62 g.fillAll(getLookAndFeel().findColour(juce::ResizableWindow::ColourIds::backgroundColourId));
63
64 g.setColour(getLookAndFeel().findColour(juce::TextEditor::ColourIds::textColourId));
65 g.drawFittedText(m_connectionStatusDescription + "\n" + (m_connectionParametersDescription.isNotEmpty() ? m_connectionParametersDescription : "UNKNOWN"), getLocalBounds().reduced(35), juce::Justification::centred, 2);
66}
67
69{
70 auto bounds = getLocalBounds();
71 if (bounds.getWidth() > bounds.getHeight())
72 bounds.reduce((bounds.getWidth() - bounds.getHeight()) / 2, 0);
73 else
74 bounds.reduce(0, (bounds.getHeight() - bounds.getWidth()) / 2);
75
76 auto progressIndicatorBounds = bounds;
77 progressIndicatorBounds.reduce(35, 35);
78 m_startupProgressIndicator->setBounds(progressIndicatorBounds);
79
80}
81
83{
84 if (m_startupProgressIndicator)
85 m_startupProgressIndicator->setColour(juce::ProgressBar::ColourIds::foregroundColourId, getLookAndFeel().findColour(JUCEAppBasics::CustomLookAndFeel::ColourIds::MeteringRmsColourId));
86}
87
void setConnectionStatus(Status status)
Updates the status text label to reflect the current connection phase.
void paint(juce::Graphics &g) override
void setConnectionParameters(const juce::IPAddress &ip, int port)
Updates the "connecting to ip:port" description line.
Status
Mirrors the subset of DeviceController::State values that this component visualises....
@ Subscribing
AddSubscription commands sent, waiting for ACKs.
@ Connecting
TCP connect in progress.
@ Reading
GetValue responses being collected (DeviceController::GetValues state).