mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-12-18 12:14:30 -05:00
fix gray box & remove multiple line text support for NewButton (#2426)
This commit is contained in:
parent
ee10081854
commit
42da7443b4
@ -765,7 +765,7 @@ static void add_apps(NavigationView& nav, BtnGridView& grid, app_location_t loc)
|
|||||||
void add_external_items(NavigationView& nav, app_location_t location, BtnGridView& grid, uint8_t error_tile_pos) {
|
void add_external_items(NavigationView& nav, app_location_t location, BtnGridView& grid, uint8_t error_tile_pos) {
|
||||||
auto externalItems = ExternalItemsMenuLoader::load_external_items(location, nav);
|
auto externalItems = ExternalItemsMenuLoader::load_external_items(location, nav);
|
||||||
if (externalItems.empty()) {
|
if (externalItems.empty()) {
|
||||||
grid.insert_item({"ExtApp\nError",
|
grid.insert_item({"ExtAppErr",
|
||||||
Theme::getInstance()->error_dark->foreground,
|
Theme::getInstance()->error_dark->foreground,
|
||||||
nullptr,
|
nullptr,
|
||||||
[&nav]() {
|
[&nav]() {
|
||||||
|
@ -323,7 +323,7 @@ class InformationView : public View {
|
|||||||
|
|
||||||
Rectangle backdrop{
|
Rectangle backdrop{
|
||||||
{0, 0 * 16, 240, 16},
|
{0, 0 * 16, 240, 16},
|
||||||
{33, 33, 33}};
|
Theme::getInstance()->bg_darker->background};
|
||||||
|
|
||||||
Text version{
|
Text version{
|
||||||
{2, 0, 11 * 8, 16},
|
{2, 0, 11 * 8, 16},
|
||||||
|
@ -1327,11 +1327,10 @@ void NewButton::paint(Painter& painter) {
|
|||||||
style.background);
|
style.background);
|
||||||
|
|
||||||
int y = r.top();
|
int y = r.top();
|
||||||
|
|
||||||
if (bitmap_) {
|
if (bitmap_) {
|
||||||
int offset_y = vertical_center_ ? (r.height() / 2) - (bitmap_->size.height() / 2) : 6;
|
int offset_y = vertical_center_ ? (r.height() / 2) - (bitmap_->size.height() / 2) : 6;
|
||||||
Point bmp_pos = {r.left() + (r.width() / 2) - (bitmap_->size.width() / 2), r.top() + offset_y};
|
Point bmp_pos = {r.left() + (r.width() / 2) - (bitmap_->size.width() / 2), r.top() + offset_y};
|
||||||
y += bitmap_->size.height() + offset_y;
|
y += bitmap_->size.height() - offset_y;
|
||||||
|
|
||||||
painter.draw_bitmap(
|
painter.draw_bitmap(
|
||||||
bmp_pos,
|
bmp_pos,
|
||||||
@ -1341,38 +1340,11 @@ void NewButton::paint(Painter& painter) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!text_.empty()) {
|
if (!text_.empty()) {
|
||||||
// multi line worker
|
const auto label_r = style.font.size_of(text_);
|
||||||
std::vector<std::string> lines;
|
painter.draw_string(
|
||||||
size_t start = 0;
|
{r.left() + (r.width() - label_r.width()) / 2, y + (r.height() - label_r.height()) / 2},
|
||||||
size_t end = 0;
|
style,
|
||||||
|
text_);
|
||||||
while ((end = text_.find('\n', start)) != std::string::npos) {
|
|
||||||
lines.push_back(text_.substr(start, end - start));
|
|
||||||
start = end + 1;
|
|
||||||
}
|
|
||||||
lines.push_back(text_.substr(start));
|
|
||||||
|
|
||||||
const int line_height = style.font.line_height();
|
|
||||||
const int total_text_height = lines.size() * line_height;
|
|
||||||
|
|
||||||
// satisfy the situation that bitmap is nullptr
|
|
||||||
if (bitmap_) {
|
|
||||||
if (vertical_center_) {
|
|
||||||
y = r.top() + (r.height() - total_text_height) / 2;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
y = r.top() + (r.height() - total_text_height) / 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
// draw worker
|
|
||||||
for (const auto& line : lines) {
|
|
||||||
const auto label_r = style.font.size_of(line);
|
|
||||||
painter.draw_string(
|
|
||||||
{r.left() + (r.width() - label_r.width()) / 2, y},
|
|
||||||
style,
|
|
||||||
line);
|
|
||||||
y += line_height;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user