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
19
#include "
UmsciConnectingComponent.h
"
20
21
#include <CustomLookAndFeel.h>
22
23
UmsciConnectingComponent::UmsciConnectingComponent
()
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
30
UmsciConnectingComponent::~UmsciConnectingComponent
()
31
{
32
}
33
34
void
UmsciConnectingComponent::setConnectionStatus
(
Status
status)
35
{
36
juce::String statusDescription;
37
switch
(status)
38
{
39
case
Status::Subscribing
:
40
statusDescription =
"Subscribing to"
;
41
break
;
42
case
Status::Reading
:
43
statusDescription =
"Reading from"
;
44
break
;
45
case
Status::Connecting
:
46
default
:
47
statusDescription =
"Connecting to"
;
48
break
;
49
}
50
51
m_connectionStatusDescription = statusDescription;
52
}
53
54
void
UmsciConnectingComponent::setConnectionParameters
(
const
juce::IPAddress& ip,
int
port)
55
{
56
m_connectionParametersDescription = ip.toString() +
":"
+ juce::String(port);
57
repaint();
58
}
59
60
void
UmsciConnectingComponent::paint
(Graphics& g)
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
68
void
UmsciConnectingComponent::resized
()
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
82
void
UmsciConnectingComponent::lookAndFeelChanged
()
83
{
84
if
(m_startupProgressIndicator)
85
m_startupProgressIndicator->setColour(juce::ProgressBar::ColourIds::foregroundColourId, getLookAndFeel().findColour(JUCEAppBasics::CustomLookAndFeel::ColourIds::MeteringRmsColourId));
86
}
87
UmsciConnectingComponent.h
UmsciConnectingComponent::~UmsciConnectingComponent
~UmsciConnectingComponent() override
Definition
UmsciConnectingComponent.cpp:30
UmsciConnectingComponent::UmsciConnectingComponent
UmsciConnectingComponent()
Definition
UmsciConnectingComponent.cpp:23
UmsciConnectingComponent::resized
void resized() override
Definition
UmsciConnectingComponent.cpp:68
UmsciConnectingComponent::setConnectionStatus
void setConnectionStatus(Status status)
Updates the status text label to reflect the current connection phase.
Definition
UmsciConnectingComponent.cpp:34
UmsciConnectingComponent::lookAndFeelChanged
void lookAndFeelChanged() override
Definition
UmsciConnectingComponent.cpp:82
UmsciConnectingComponent::paint
void paint(juce::Graphics &g) override
Definition
UmsciConnectingComponent.cpp:60
UmsciConnectingComponent::setConnectionParameters
void setConnectionParameters(const juce::IPAddress &ip, int port)
Updates the "connecting to ip:port" description line.
Definition
UmsciConnectingComponent.cpp:54
UmsciConnectingComponent::Status
Status
Mirrors the subset of DeviceController::State values that this component visualises....
Definition
UmsciConnectingComponent.h:45
UmsciConnectingComponent::Subscribing
@ Subscribing
AddSubscription commands sent, waiting for ACKs.
Definition
UmsciConnectingComponent.h:47
UmsciConnectingComponent::Connecting
@ Connecting
TCP connect in progress.
Definition
UmsciConnectingComponent.h:46
UmsciConnectingComponent::Reading
@ Reading
GetValue responses being collected (DeviceController::GetValues state).
Definition
UmsciConnectingComponent.h:48
Source
UmsciConnectingComponent.cpp
Generated by
1.9.8