From 417937b0d5fb76a24241a3f271e71d050ebbf01d Mon Sep 17 00:00:00 2001 From: Christian Colglazier Date: Sun, 27 Sep 2020 11:01:32 -0400 Subject: [PATCH] Waveshape full name displayed --- src/droplets/vco_droplet.cpp | 20 +++++++++++----- src/main.cpp | 2 +- src/util.cpp | 46 ++++++++++++++++++++++++++++++++++++ src/util.h | 36 ++++++++++++++++++++++++++++ 4 files changed, 97 insertions(+), 7 deletions(-) diff --git a/src/droplets/vco_droplet.cpp b/src/droplets/vco_droplet.cpp index 6e139ca..ac235b5 100644 --- a/src/droplets/vco_droplet.cpp +++ b/src/droplets/vco_droplet.cpp @@ -49,10 +49,18 @@ void VCODroplet::Process(float** in, float** out, size_t size) { } void VCODroplet::Draw() { - WriteString(*Patch(), 0, 54, Font_6x8, - WaveToString(wavectrl.Process())); + WriteDoubleCentered(*Patch(), + (GetScreenMax()-GetScreenMin())/2, + 54, + GetScreenMax()-GetScreenMin(), + Font_6x8, + WaveToString(wavectrl.Process())); SetWaveState(wavectrl.Process()); - wave->DrawTile(*Patch(), GetScreenMin(), 0, GetScreenMax(), GetTitleHeight()); + wave->DrawTile(*Patch(), + GetScreenMin(), + 0, + GetScreenMax(), + GetTitleHeight()); if(NeedUpdate()) { wave->AdjustXShift(1); } @@ -73,11 +81,11 @@ std::string VCODroplet::WaveToString(uint8_t wf) { case Oscillator::WAVE_RAMP: return "Ramp"; case Oscillator::WAVE_POLYBLEP_TRI: - return "Poly Triangle"; + return "PolyBLEP Triangle"; case Oscillator::WAVE_POLYBLEP_SQUARE: - return "Poly Square"; + return "PolyBLEP Square"; case Oscillator::WAVE_POLYBLEP_SAW: - return "Poly Saw"; + return "PolyBLEP Saw"; } return ""; } diff --git a/src/main.cpp b/src/main.cpp index 5f074b9..015d7a6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -58,7 +58,7 @@ Droplet* GetDroplet() { switch(menu.GetState()) { case MenuState::kVCO: return new VCODroplet(&patch, - DropletState::kFull, + DropletState::kLeft, sample_rate); case MenuState::kNoise: default: diff --git a/src/util.cpp b/src/util.cpp index 8d47094..b23031b 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -47,3 +47,49 @@ void WriteCenteredString(DaisyPatch patch, std::string text) { WriteCenteredString(patch, x, y, font, text, true); } + +void WriteDoubleCentered(DaisyPatch patch, + int x, + int y, + int width, + FontDef font, + std::string text, + bool on) { + // If only one line is needed + if ((int) text.length() * font.FontWidth < width) { + WriteCenteredString(patch, + x, + y - font.FontHeight/2, + font, + text, + on); + } else { + unsigned int split = text.find(" "); + if (split == std::string::npos) { + split = width / font.FontWidth; + } + std::string row1 = text.substr(0, split); + std::string row2 = text.substr(split+1, text.length()); + WriteCenteredString(patch, + x, + y - font.FontHeight, + font, + row1, + on); + WriteCenteredString(patch, + x, + y, + font, + row2, + on); + } +} + +void WriteDoubleCentered(DaisyPatch patch, + int x, + int y, + int width, + FontDef font, + std::string text) { + WriteDoubleCentered(patch, x, y, width, font, text, true); +} diff --git a/src/util.h b/src/util.h index 5f3cc30..155bd3d 100644 --- a/src/util.h +++ b/src/util.h @@ -90,4 +90,40 @@ void WriteCenteredString(DaisyPatch patch, FontDef font, std::string text); +/* + * Draws text on screen centered taking up two lines. + * + * @param patch daisy patch board + * @param x center of text x coordinate + * @param y start of text y coordinate + * @param width text field width + * @param font text font + * @param text text to be written + * @param on draw screen on or off + */ +void WriteDoubleCentered(DaisyPatch patch, + int x, + int y, + int width, + FontDef font, + std::string text, + bool on); + +/* + * Draws text on screen centered taking up two lines. + * + * @param patch daisy patch board + * @param x center of text x coordinate + * @param y start of text y coordinate + * @param width text field width + * @param font text font + * @param text text to be written + */ +void WriteDoubleCentered(DaisyPatch patch, + int x, + int y, + int width, + FontDef font, + std::string text); + #endif // CASCADE_UTIL_H_