mirror of
https://github.com/AquaMorph/Droplets.git
synced 2025-04-30 01:35:34 +00:00
Titles adjust to droplet size
This commit is contained in:
parent
03c87b94c6
commit
e691e12646
@ -1,12 +1,17 @@
|
||||
#include "droplet.h"
|
||||
|
||||
void Droplet::DrawName(DaisyPatch* patch, std::string name) {
|
||||
int min = 0;
|
||||
int max = SSD1309_WIDTH;
|
||||
WriteCenteredString(*patch, (screen_min + screen_max) / 2, 0,
|
||||
Font_6x8, name);
|
||||
}
|
||||
|
||||
void Droplet::UpdateState(DropletState m_state) {
|
||||
state = m_state;
|
||||
screen_min = 0;
|
||||
screen_max = SSD1309_WIDTH;
|
||||
if (state == DropletState::kLeft) {
|
||||
max = SSD1309_WIDTH / 2;
|
||||
screen_max = SSD1309_WIDTH / 2;
|
||||
} else if (state == DropletState::kRight) {
|
||||
min = SSD1309_WIDTH / 2;
|
||||
screen_min = SSD1309_WIDTH / 2;
|
||||
}
|
||||
WriteCenteredString(*patch, (min + max) / 2, 0, Font_6x8, name);
|
||||
}
|
||||
|
@ -20,8 +20,12 @@ class Droplet {
|
||||
virtual void Control()=0;
|
||||
virtual void Process(float**, float**, size_t)=0;
|
||||
virtual void Draw()=0;
|
||||
const int kTitleHeight = 8;
|
||||
int screen_min;
|
||||
int screen_max;
|
||||
void DrawName(daisy::DaisyPatch*,
|
||||
std::string);
|
||||
void UpdateState(DropletState);
|
||||
};
|
||||
|
||||
#endif // CASCADE_DROPLETS_DROPLET_H_
|
||||
|
@ -6,7 +6,7 @@ NoiseDroplet::NoiseDroplet(DaisyPatch* m_patch,
|
||||
noise.Init();
|
||||
filter.Init();
|
||||
patch = m_patch;
|
||||
state = m_state;
|
||||
UpdateState(m_state);
|
||||
}
|
||||
|
||||
void NoiseDroplet::Control() {}
|
||||
@ -28,5 +28,10 @@ void NoiseDroplet::Process(float** in, float** out, size_t size) {
|
||||
}
|
||||
|
||||
void NoiseDroplet::Draw() {
|
||||
for (int h = 0; h < kTitleHeight; h++) {
|
||||
for (int w = screen_min; w < screen_max; w++) {
|
||||
patch->display.DrawPixel(w, h, rand() % 15 == 0);
|
||||
}
|
||||
}
|
||||
DrawName(patch, "Noise");
|
||||
}
|
||||
|
@ -56,8 +56,8 @@ void ProcessOled() {
|
||||
if (menu.InMenu()) {
|
||||
menu.ProcessMenuOled();
|
||||
} else {
|
||||
droplet->Draw();
|
||||
WriteString(patch, 0, 0, Font_6x8, menu.SelectedName());
|
||||
droplet->Draw();
|
||||
}
|
||||
patch.display.Update();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user