From 9ac242c22d86f1a32afe90510b0e2365d01cc5f2 Mon Sep 17 00:00:00 2001 From: cflip Date: Wed, 22 Dec 2021 16:26:04 -0700 Subject: Use sequence parameters for step colours Just a nice little visual effect. --- gui.cpp | 9 ++++++--- gui.h | 2 ++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/gui.cpp b/gui.cpp index 5a8a231..5e1479d 100644 --- a/gui.cpp +++ b/gui.cpp @@ -22,6 +22,7 @@ bool Knob::InBounds(int x, int y) } GUI::GUI(Sequence& seq) + : m_sequence(seq) { int i = 0; for (auto& step : seq.steps) { @@ -63,14 +64,14 @@ void GUI::OnMouseMove(int x, int y) void GUI::Repaint(SDL_Renderer* renderer, int currentStep) { SDL_Rect rect = { - (640 - 8 * (32 + 8)) / 2, - (320 - 32) / 2, + 40, + 40, 32, 32 }; for (int i = 0; i < 8; i++) { - SDL_SetRenderDrawColor(renderer, 128, i * (255 / 8), 255, 255); + SDL_SetRenderDrawColor(renderer, m_sequence.steps[i].modDepth * 8, m_sequence.steps[i].modFreq * 2, m_sequence.steps[i].carrierFreq / 3, 255); if (i == currentStep) SDL_RenderFillRect(renderer, &rect); @@ -80,6 +81,8 @@ void GUI::Repaint(SDL_Renderer* renderer, int currentStep) rect.x += rect.w + 8; } + SDL_SetRenderDrawColor(renderer, 127, 127, 255, 255); + for (Knob& knob : m_knobs) { knob.Draw(renderer); } diff --git a/gui.h b/gui.h index 9bd8545..b8b1f2b 100644 --- a/gui.h +++ b/gui.h @@ -30,6 +30,8 @@ public: void Repaint(SDL_Renderer*, int currentStep); private: std::vector m_knobs; + + Sequence& m_sequence; Knob* m_activeKnob{ nullptr }; int m_dragStart{ 0 }; }; \ No newline at end of file -- cgit v1.2.3