blob: b7ccfe52865224b33c894e66ae01d7f028b03586 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2019-2020, William McPherson <willmcpherson2@gmail.com>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "TrackControlsWidget.h"
#include "ProcessorParameterWidget/ParameterWidget.h"
#include <LibGUI/BoxLayout.h>
#include <LibGUI/Frame.h>
#include <LibGUI/GroupBox.h>
#include <LibGUI/Widget.h>
TrackControlsWidget::TrackControlsWidget(WeakPtr<DSP::Track> track)
: m_track(move(track))
{
}
ErrorOr<NonnullRefPtr<TrackControlsWidget>> TrackControlsWidget::try_create(WeakPtr<DSP::Track> track)
{
auto widget = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) TrackControlsWidget(move(track))));
TRY(widget->try_set_layout<GUI::HorizontalBoxLayout>());
widget->set_preferred_width(GUI::SpecialDimension::Grow);
widget->set_fill_with_background_color(true);
auto mastering_parameters = TRY(widget->try_add<GUI::GroupBox>());
TRY(mastering_parameters->try_set_layout<GUI::HorizontalBoxLayout>());
auto strong_track = widget->m_track.value();
for (auto& parameter : strong_track->track_mastering()->parameters())
(void)TRY(mastering_parameters->try_add<ProcessorParameterWidget>(parameter));
TRY(widget->m_processor_groups.try_append(mastering_parameters));
TRY(widget->add_spacer());
for (auto& processor : strong_track->processor_chain()) {
auto processor_parameters = TRY(widget->try_add<GUI::GroupBox>());
TRY(processor_parameters->try_set_layout<GUI::HorizontalBoxLayout>());
for (auto& parameter : processor->parameters())
(void)TRY(processor_parameters->try_add<ProcessorParameterWidget>(parameter));
TRY(widget->m_processor_groups.try_append(processor_parameters));
}
return widget;
}
|