mirror of
https://github.com/AquaMorph/Droplets.git
synced 2025-04-30 09:45:35 +00:00
Moved text writing to util
This commit is contained in:
parent
6cdbf33d21
commit
91a31ecd9d
@ -45,14 +45,12 @@ std::string Menu::FilterMenuText(int position) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Menu::CreateMenuItem(std::string text, int position, bool highlighted) {
|
void Menu::CreateMenuItem(std::string text, int position, bool highlighted) {
|
||||||
char* cstr = &text[0];
|
|
||||||
text.insert(text.end(), MAX_CHAR_LENGTH-text.size(), ' ');
|
text.insert(text.end(), MAX_CHAR_LENGTH-text.size(), ' ');
|
||||||
patch->display.SetCursor(MENU_X[position-1], MENU_Y[position-1]);
|
|
||||||
if (highlighted) {
|
if (highlighted) {
|
||||||
DrawSolidRect(*patch, 0, MENU_Y[2], SSD1309_WIDTH, MENU_Y[2]+17, true);
|
DrawSolidRect(*patch, 0, MENU_Y[2], SSD1309_WIDTH, MENU_Y[2]+17, true);
|
||||||
patch->display.WriteString(cstr, Font_11x18, !highlighted);
|
WriteString(*patch, MENU_X[position-1], MENU_Y[position-1], Font_11x18, text, !highlighted);
|
||||||
} else {
|
} else {
|
||||||
patch->display.WriteString(cstr, Font_7x10, !highlighted);
|
WriteString(*patch, MENU_X[position-1], MENU_Y[position-1], Font_7x10, text, !highlighted);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef CASCADE_MENU_H_
|
||||||
|
#define CASCADE_MENU_H_
|
||||||
|
|
||||||
#include "daisy_patch.h"
|
#include "daisy_patch.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
@ -21,3 +24,5 @@ class Menu {
|
|||||||
void UpdateMenuPosition();
|
void UpdateMenuPosition();
|
||||||
std::string SelectedName();
|
std::string SelectedName();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif // CASCADE_MENU_H_
|
||||||
|
18
src/util.cpp
18
src/util.cpp
@ -11,8 +11,20 @@ void DrawSolidRect(DaisyPatch patch,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteString(DaisyPatch patch, int x, int y, FontDef font, std::string text) {
|
void WriteString(DaisyPatch patch,
|
||||||
|
int x,
|
||||||
|
int y,
|
||||||
|
FontDef font,
|
||||||
|
std::string text,
|
||||||
|
bool on) {
|
||||||
patch.display.SetCursor(x, y);
|
patch.display.SetCursor(x, y);
|
||||||
char* cstr = &text[0];
|
patch.display.WriteString(&text[0], font, on);
|
||||||
patch.display.WriteString(cstr, font, true);
|
}
|
||||||
|
|
||||||
|
void WriteString(DaisyPatch patch,
|
||||||
|
int x,
|
||||||
|
int y,
|
||||||
|
FontDef font,
|
||||||
|
std::string text) {
|
||||||
|
WriteString(patch, x, y, font, text, true);
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,13 @@ void DrawSolidRect(DaisyPatch,
|
|||||||
uint8_t,
|
uint8_t,
|
||||||
bool);
|
bool);
|
||||||
|
|
||||||
|
void WriteString(DaisyPatch,
|
||||||
|
int,
|
||||||
|
int,
|
||||||
|
FontDef,
|
||||||
|
std::string,
|
||||||
|
bool);
|
||||||
|
|
||||||
void WriteString(DaisyPatch,
|
void WriteString(DaisyPatch,
|
||||||
int,
|
int,
|
||||||
int,
|
int,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user