Skip to content

Commit

Permalink
Macros on screen; screen layout more rational
Browse files Browse the repository at this point in the history
  • Loading branch information
baconpaul committed Dec 23, 2024
1 parent 538710e commit 0f0254c
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 26 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ add_library(${PROJECT_NAME}-impl STATIC
src/ui/source-panel.cpp
src/ui/source-sub-panel.cpp
src/ui/preset-manager.cpp
src/ui/macro-panel.cpp

src/synth/synth.cpp
src/synth/voice.cpp
Expand Down
53 changes: 53 additions & 0 deletions src/ui/macro-panel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Six Sines
*
* A synth with audio rate modulation.
*
* Copyright 2024, Paul Walker and Various authors, as described in the github
* transaction log.
*
* This source repo is released under the MIT license, but has
* GPL3 dependencies, as such the combined work will be
* released under GPL3.
*
* The source code and license are at https://github.com/baconpaul/six-sines
*/

#include "macro-panel.h"
#include "six-sines-editor.h"
#include "ui-constants.h"
#include "knob-highlight.h"

namespace baconpaul::six_sines::ui
{
MacroPanel::MacroPanel(SixSinesEditor &e) : jcmp::NamedPanel("Macros"), HasEditor(e)
{
auto &mn = editor.patchCopy.macroNodes;
for (auto i = 0U; i < numOps; ++i)
{
createComponent(editor, *this, mn[i].level.meta.id, knobs[i], knobsData[i], i);
knobs[i]->setDrawLabel(false);
addAndMakeVisible(*knobs[i]);

labels[i] = std::make_unique<jcmp::Label>();
labels[i]->setText("Macro " + std::to_string(i + 1));
addAndMakeVisible(*labels[i]);
}
}
MacroPanel::~MacroPanel() = default;

void MacroPanel::resized()
{
auto b = getContentArea().reduced(uicMargin, 0);
auto x = b.getX();
auto y = b.getY();
for (auto i = 0U; i < numOps; ++i)
{
positionKnobAndLabel(x, y, knobs[i], labels[i]);
y += uicLabeledKnobHeight + uicMargin;
}
}

void MacroPanel::beginEdit(size_t idx) {}

} // namespace baconpaul::six_sines::ui
45 changes: 45 additions & 0 deletions src/ui/macro-panel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Six Sines
*
* A synth with audio rate modulation.
*
* Copyright 2024, Paul Walker and Various authors, as described in the github
* transaction log.
*
* This source repo is released under the MIT license, but has
* GPL3 dependencies, as such the combined work will be
* released under GPL3.
*
* The source code and license are at https://github.com/baconpaul/six-sines
*/

#ifndef BACONPAUL_SIX_SINES_UI_MACRO_PANEL_H
#define BACONPAUL_SIX_SINES_UI_MACRO_PANEL_H

#include <sst/jucegui/components/Knob.h>
#include <sst/jucegui/components/Label.h>
#include <sst/jucegui/components/ToggleButton.h>
#include <sst/jucegui/data/Continuous.h>
#include "six-sines-editor.h"
#include "patch-data-bindings.h"

namespace baconpaul::six_sines::ui
{
namespace jcmp = sst::jucegui::components;
namespace jdat = sst::jucegui::data;

struct MacroPanel : jcmp::NamedPanel, HasEditor
{
MacroPanel(SixSinesEditor &);
~MacroPanel();

void resized() override;

void beginEdit(size_t idx);

std::array<std::unique_ptr<jcmp::Knob>, numOps> knobs;
std::array<std::unique_ptr<PatchContinuous>, numOps> knobsData;
std::array<std::unique_ptr<jcmp::Label>, numOps> labels;
};
} // namespace baconpaul::six_sines::ui
#endif // Macro_PANE_H
72 changes: 46 additions & 26 deletions src/ui/six-sines-editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "ui-constants.h"
#include "juce-lnf.h"
#include "preset-manager.h"
#include "macro-panel.h"

namespace baconpaul::six_sines::ui
{
Expand Down Expand Up @@ -58,6 +59,7 @@ SixSinesEditor::SixSinesEditor(Synth::audioToUIQueue_t &atou, Synth::uiToAudioQu

matrixPanel = std::make_unique<MatrixPanel>(*this);
mixerPanel = std::make_unique<MixerPanel>(*this);
macroPanel = std::make_unique<MacroPanel>(*this);
singlePanel = std::make_unique<jcmp::NamedPanel>("Edit");
sourcePanel = std::make_unique<SourcePanel>(*this);
mainPanel = std::make_unique<MainPanel>(*this);
Expand All @@ -66,6 +68,7 @@ SixSinesEditor::SixSinesEditor(Synth::audioToUIQueue_t &atou, Synth::uiToAudioQu
addAndMakeVisible(*singlePanel);
addAndMakeVisible(*sourcePanel);
addAndMakeVisible(*mainPanel);
addAndMakeVisible(*macroPanel);

mainSubPanel = std::make_unique<MainSubPanel>(*this);
singlePanel->addChildComponent(*mainSubPanel);
Expand Down Expand Up @@ -112,7 +115,7 @@ SixSinesEditor::SixSinesEditor(Synth::audioToUIQueue_t &atou, Synth::uiToAudioQu
}

// Make sure to do this last
setSize(608, 830);
setSize(673, 845);
}
SixSinesEditor::~SixSinesEditor() { idleTimer->stopTimer(); }

Expand Down Expand Up @@ -193,38 +196,50 @@ void SixSinesEditor::paint(juce::Graphics &g)

void SixSinesEditor::resized()
{
auto rdx{1};
int presetHeight{33}, footerHeight{15};

int tpt{33}, tpb{15};
auto lb = getLocalBounds();
auto presetArea = lb.withHeight(presetHeight);
auto panelArea = lb.withTrimmedTop(presetHeight).withTrimmedBottom(footerHeight);

auto but = getLocalBounds().withHeight(tpt).reduced(110, 0).withTrimmedTop(2);
presetButton->setBounds(but);

auto area = getLocalBounds().withTrimmedTop(tpt).withTrimmedBottom(tpb);

auto tp = 100;

auto rb = area.withTrimmedTop(tp);
auto edH = 250 - tpt - tpb;

auto mp = rb.withTrimmedBottom(edH);
mp = mp.withWidth(numOps * (uicPowerKnobWidth + uicMargin) + 2 * uicMargin + 10);
auto panelPadX{2 * uicMargin + 11}, panelPadY{34U};
auto sourceHeight = uicLabeledKnobHeight + panelPadY;

matrixPanel->setBounds(mp.reduced(rdx));
auto matrixWidth = numOps * (uicPowerKnobWidth) + (numOps - 1) * uicMargin + panelPadX;
auto matrixHeight = numOps * uicLabeledKnobHeight + (numOps - 1) * uicMargin + panelPadY;
auto mixerWidth = uicPowerKnobWidth + panelPadX;
auto macroWidth = uicKnobSize + panelPadX;
auto mainWidth = mixerWidth + macroWidth;

auto sp = rb.withTrimmedBottom(mp.getHeight());
sp = sp.translated(0, mp.getHeight());
singlePanel->setBounds(sp.reduced(rdx));
auto editHeight = 220;

auto mx = rb.withTrimmedBottom(edH).withTrimmedLeft(mp.getWidth());
mixerPanel->setBounds(mx.reduced(rdx));
auto panelMargin{1};

auto ta = area.withHeight(tp);
auto sr = ta.withWidth(mp.getWidth());
sourcePanel->setBounds(sr.reduced(rdx));
// Preset button
auto but = presetArea.reduced(110, 0).withTrimmedTop(uicMargin);
presetButton->setBounds(but);

auto mn = ta.withTrimmedLeft(sr.getWidth());
mainPanel->setBounds(mn.reduced(rdx));
auto sourceRect =
juce::Rectangle<int>(panelArea.getX(), panelArea.getY(), matrixWidth, sourceHeight);
auto matrixRect = juce::Rectangle<int>(panelArea.getX(), panelArea.getY() + sourceHeight,
matrixWidth, matrixHeight);
auto mainRect = juce::Rectangle<int>(panelArea.getX() + matrixWidth, panelArea.getY(),
mainWidth, sourceHeight);
auto mixerRect = juce::Rectangle<int>(
panelArea.getX() + matrixWidth, panelArea.getY() + sourceHeight, mixerWidth, matrixHeight);
auto macroRect =
juce::Rectangle<int>(panelArea.getX() + matrixWidth + mixerWidth,
panelArea.getY() + sourceHeight, macroWidth, matrixHeight);
auto editRect =
juce::Rectangle<int>(panelArea.getX(), panelArea.getY() + sourceHeight + matrixHeight,
matrixWidth + mainWidth, editHeight);

sourcePanel->setBounds(sourceRect.reduced(panelMargin));
matrixPanel->setBounds(matrixRect.reduced(panelMargin));
mainPanel->setBounds(mainRect.reduced(panelMargin));
mixerPanel->setBounds(mixerRect.reduced(panelMargin));
macroPanel->setBounds(macroRect.reduced(panelMargin));
singlePanel->setBounds(editRect.reduced(panelMargin));

mainSubPanel->setBounds(singlePanel->getContentArea());
matrixSubPanel->setBounds(singlePanel->getContentArea());
Expand Down Expand Up @@ -265,6 +280,11 @@ void SixSinesEditor::showTooltipOn(juce::Component *c)
y -= c->getHeight() - 3 - toolTip->getHeight();
}

if (x + toolTip->getWidth() > getWidth())
{
x -= toolTip->getWidth() - c->getWidth() / 2;
}

toolTip->setTopLeftPosition(x, y);
toolTip->setVisible(true);
}
Expand Down
3 changes: 3 additions & 0 deletions src/ui/six-sines-editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ struct MixerPanel;
struct MixerSubPanel;
struct SourcePanel;
struct SourceSubPanel;
struct MacroPanel;
struct SixSinesJuceLookAndFeel;

struct SixSinesEditor : jcmp::WindowPanel
Expand Down Expand Up @@ -75,6 +76,8 @@ struct SixSinesEditor : jcmp::WindowPanel
std::unique_ptr<MixerPanel> mixerPanel;
std::unique_ptr<MixerSubPanel> mixerSubPanel;

std::unique_ptr<MacroPanel> macroPanel;

std::unique_ptr<SourcePanel> sourcePanel;
std::unique_ptr<SourceSubPanel> sourceSubPanel;

Expand Down

0 comments on commit 0f0254c

Please sign in to comment.