Mema
Memory Matrix — multi-channel audio matrix monitor and router
Loading...
Searching...
No Matches
MemaProcessorEditor.h
Go to the documentation of this file.
1/* Copyright (c) 2024, Christian Ahrens
2 *
3 * This file is part of Mema <https://github.com/ChristianAhrens/Mema>
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#pragma once
20
21#include <JuceHeader.h>
22
24
25
26namespace Mema
27{
28
29class PluginControlComponent;
30class InputControlComponent;
31class CrosspointsControlComponent;
32class OutputControlComponent;
33
34
35//==============================================================================
36class IOLabelComponent : public juce::Component
37{
38public:
40 {
42 OI
43 };
44
45public:
52
54 {
55 m_direction = d;
56
57 repaint();
58 };
59
60 void paint(Graphics& g)
61 {
62 // (Our component is opaque, so we must completely fill the background with a solid colour)
63 g.fillAll(getLookAndFeel().findColour(ResizableWindow::backgroundColourId));
64
65 g.setColour(getLookAndFeel().findColour(juce::LookAndFeel_V4::ColourScheme::defaultFill));
66
67 float dashValues[2] = {4, 4};
68 g.drawDashedLine(juce::Line<float>(getLocalBounds().getTopLeft().toFloat(), getLocalBounds().getBottomRight().toFloat()), dashValues, 2);
69
70 auto trString = "";
71 auto blString = "";
72
73 switch (m_direction)
74 {
75 case IO:
76 trString = "O";
77 blString = "I";
78 break;
79 case OI:
80 default:
81 trString = "I";
82 blString = "O";
83 break;
84 }
85
86 g.drawFittedText(trString, getLocalBounds().removeFromTop(getHeight() / 2).removeFromRight(getWidth() / 2), juce::Justification::centred, 1);
87 g.drawFittedText(blString, getLocalBounds().removeFromBottom(getHeight() / 2).removeFromLeft(getWidth() / 2), juce::Justification::centred, 1);
88 }
89
90private:
91 Direction m_direction{ IO };
92};
93
97class MemaProcessorEditor : public juce::AudioProcessorEditor
98{
99public:
100 MemaProcessorEditor(juce::AudioProcessor& processor);
101 MemaProcessorEditor(juce::AudioProcessor* processor);
103
104 //==============================================================================
105 void paint(juce::Graphics&) override;
106 void resized() override;
107
108 //==========================================================================
109 void lookAndFeelChanged() override;
110
111 //==========================================================================
112 std::function<void(juce::Rectangle<int>)> onEditorSizeChangeRequested;
113 std::function<void()> onResetToUnity;
114
115 static constexpr int sc_pluginControlHeight = 20;
116 static constexpr int sc_resetButtonSize = 20;
117
118private:
119 std::unique_ptr<PluginControlComponent> m_pluginControl;
120 std::unique_ptr<IOLabelComponent> m_ioLabel;
121 std::unique_ptr<juce::DrawableButton> m_resetToUnityButton;
122 std::unique_ptr<InputControlComponent> m_inputCtrl;
123 std::unique_ptr<CrosspointsControlComponent> m_crosspointCtrl;
124 std::unique_ptr<OutputControlComponent> m_outputCtrl;
125
126 juce::Grid m_gridLayout;
127
128 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MemaProcessorEditor)
129};
130
131} // namespace Mema
void setDirection(Direction d)
Top-level editor component for the Mema processor — composes the input, crosspoint,...
std::function< void()> onResetToUnity
void paint(juce::Graphics &) override
MemaProcessorEditor(juce::AudioProcessor *processor)
std::function< void(juce::Rectangle< int >)> onEditorSizeChangeRequested
MemaProcessorEditor(juce::AudioProcessor &processor)
static constexpr int sc_resetButtonSize
static constexpr int sc_pluginControlHeight
Definition Mema.cpp:27