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