4
0
Эх сурвалжийг харах

Mixer: grade de 4 colunas para efeitos com muitos parâmetros (Effector); --snapshot com LYNX_SNAPSHOT_TRACK/SLOT

Kauan 1 сар өмнө
parent
commit
f861abb827

+ 7 - 0
src/Main.cpp

@@ -818,6 +818,13 @@ private:
             ui.selectTabForSnapshot (2);
             saveSnapshot (ui, prefix + "-playlist.png");
             ui.selectTabForSnapshot (3);
+            // LYNX_SNAPSHOT_TRACK=n: mostra os efeitos dessa trilha do mixer
+            if (const auto track = juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_TRACK", {}); track.isNotEmpty())
+            {
+                ui.selectMixerTrackForSnapshot (track.getIntValue(),
+                                                juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_SLOT", "-1").getIntValue());
+                offline.dispatchPendingMessages();
+            }
             saveSnapshot (ui, prefix + "-mixer.png");
 
             // janelas avulsas, com fundo do tema

+ 6 - 0
src/ui/MainComponent.h

@@ -37,6 +37,12 @@ public:
 
     // Para o modo --snapshot: 0 = Channel Rack, 1 = Piano Roll (no canal com mais notas), 2 = Playlist, 3 = Mixer.
     void selectTabForSnapshot (int tab);
+    void selectMixerTrackForSnapshot (int track, int slot = -1)
+    {
+        mixer.selectTrack (track);
+        if (slot >= 0)
+            mixer.selectSlot (slot);
+    }
 
 private:
     void timerCallback() override;

+ 18 - 7
src/ui/MixerComponent.cpp

@@ -722,7 +722,14 @@ juce::Rectangle<int> EffectsPanel::slotBounds (int slot) const
 juce::Rectangle<int> EffectsPanel::knobBounds (int param) const
 {
     auto top = panelHeader + maxEffectSlots * slotHeight + 40;
-    const auto w = (getWidth() - 16) / 3;
+    // muitos parâmetros (Effector: 12): 4 colunas e linhas mais baixas para caber na altura
+    int count = 0;
+    if (const auto* s = slots(); ! gateSelected() && s != nullptr && selectedSlot >= 0 && selectedSlot < (int) s->size())
+        count = (int) effectInfo ((*s)[(std::size_t) selectedSlot].kind).params.size();
+    const auto columns = count > 9 ? 4 : 3;
+    const auto w = (getWidth() - 16) / columns;
+    const auto rows = juce::jmax (1, (count + columns - 1) / columns);
+    const auto rowHeight = count > 9 ? juce::jlimit (64, 86, (getHeight() - top - 4) / rows) : 86;
 
     // gate de volume: os 32 passos são barras (gateStepsBounds); os knobs são mix/ataque/release
     if (gateSelected())
@@ -733,7 +740,7 @@ juce::Rectangle<int> EffectsPanel::knobBounds (int param) const
         top = gateStepsBounds().getBottom() + 22;
     }
 
-    return { 8 + (param % 3) * w, top + (param / 3) * 86, w, 82 };
+    return { 8 + (param % columns) * w, top + (param / columns) * rowHeight, w, rowHeight - 4 };
 }
 
 bool EffectsPanel::gateSelected() const
@@ -947,7 +954,10 @@ void EffectsPanel::paint (juce::Graphics& g)
     {
         const auto r = knobBounds (p);
         const auto value = slot.params[(std::size_t) p];
-        const auto area = r.withHeight (44).toFloat().withSizeKeepingCentre (38.0f, 38.0f);
+        // knob de 38 px; em grades apertadas (Effector) diminui para caber nome e valor embaixo
+        const auto knobHeight = juce::jlimit (30, 44, r.getHeight() - 30);
+        const auto diameter = (float) knobHeight - 6.0f;
+        const auto area = r.withHeight (knobHeight).toFloat().withSizeKeepingCentre (diameter, diameter);
         const auto centre = area.getCentre();
         constexpr auto start = juce::MathConstants<float>::pi * 1.25f;
         constexpr auto range = juce::MathConstants<float>::pi * 1.5f;
@@ -956,17 +966,18 @@ void EffectsPanel::paint (juce::Graphics& g)
         g.setColour (theme::knobBackground);
         g.fillEllipse (area);
         juce::Path arc;
-        arc.addCentredArc (centre.x, centre.y, 17.0f, 17.0f, 0.0f, start, to, true);
+        arc.addCentredArc (centre.x, centre.y, diameter / 2.0f - 2.0f, diameter / 2.0f - 2.0f, 0.0f, start, to, true);
         g.setColour (slot.enabled ? theme::accentOrange : juce::Colours::grey);
         g.strokePath (arc, juce::PathStrokeType (3.0f));
         g.setColour (juce::Colours::white);
-        g.drawLine (centre.x, centre.y, centre.x + std::sin (to) * 13.0f, centre.y - std::cos (to) * 13.0f, 2.0f);
+        const auto needle = diameter / 2.0f - 6.0f;
+        g.drawLine (centre.x, centre.y, centre.x + std::sin (to) * needle, centre.y - std::cos (to) * needle, 2.0f);
 
         g.setColour (theme::text.withAlpha (0.8f));
         g.setFont (juce::FontOptions (11.0f));
-        g.drawText (utf8 (info.params[(std::size_t) p].name), r.getX(), r.getY() + 46, r.getWidth(), 14, juce::Justification::centred);
+        g.drawText (utf8 (info.params[(std::size_t) p].name), r.getX(), r.getY() + knobHeight + 2, r.getWidth(), 14, juce::Justification::centred);
         g.setColour (theme::accentBlue);
-        g.drawText (juce::String::fromUTF8 (formatEffectParam (slot.kind, p, value, song.bpm).c_str()), r.getX(), r.getY() + 60,
+        g.drawText (juce::String::fromUTF8 (formatEffectParam (slot.kind, p, value, song.bpm).c_str()), r.getX(), r.getY() + knobHeight + 16,
                     r.getWidth(), 14, juce::Justification::centred);
     }
 }

+ 7 - 0
src/ui/MixerComponent.h

@@ -85,6 +85,11 @@ public:
     ~EffectsPanel() override;
 
     void setTrack (int track);
+    void selectSlot (int slot)
+    {
+        selectedSlot = slot;
+        repaint();
+    }
 
     void paint (juce::Graphics& g) override;
     void mouseDown (const juce::MouseEvent& e) override;
@@ -127,6 +132,8 @@ public:
 
     // Seleciona a primeira trilha que tem efeitos (usado pelo modo --snapshot).
     void selectFirstTrackWithEffects();
+    void selectTrack (int track) { strips.selectTrack (track); }
+    void selectSlot (int slot) { effects.selectSlot (slot); }
 
     static constexpr int effectsWidth = 300;