Multi screen support, with dyn alignment (#2801)

This commit is contained in:
Totoo 2025-10-03 19:10:10 +02:00 committed by GitHub
parent 23cabb8b8a
commit 371b6b5079
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
161 changed files with 4042 additions and 4157 deletions

View file

@ -534,7 +534,7 @@ void BigFrequency::paint(Painter& painter) {
_previous_frequency = _frequency;
rf::Frequency frequency{_frequency};
const auto rect = screen_rect();
const auto rect = screen_rect(); // why not use screen_rect() directly for width, ...? it may be too small, but ...
// Erase
painter.fill_rectangle(
@ -544,7 +544,7 @@ void BigFrequency::paint(Painter& painter) {
// Prepare digits
if (!frequency) {
digits.fill(10); // ----.---
digit_pos = {0, rect.location().y()};
digit_pos = {(screen_width - ((7 * digit_width) + 8)) / 2, rect.location().y()};
} else {
frequency /= 1000; // GMMM.KKK(uuu)
@ -561,7 +561,7 @@ void BigFrequency::paint(Painter& painter) {
break;
}
digit_pos = {(Coord)(240 - ((7 * digit_width) + 8) - (i * digit_width)) / 2, rect.location().y()};
digit_pos = {(Coord)(screen_width - ((7 * digit_width) + 8) - (i * digit_width)) / 2, rect.location().y()};
}
segment_color = style().foreground;
@ -1334,24 +1334,57 @@ void NewButton::paint(Painter& painter) {
style.background);
int y = r.top();
if (bitmap_) {
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};
y += bitmap_->size.height() - offset_y;
if (vertical_center_) {
const int bmp_h = bitmap_ ? bitmap_->size.height() : 0;
const int txt_h = !text_.empty() ? style.font.line_height() : 0;
int spacing = 0;
if (bmp_h > 0 && txt_h > 0) {
const int content_height = bmp_h + txt_h;
const int remaining_space = r.height() - content_height;
spacing = std::max(4, remaining_space / 3);
}
const int total_height = bmp_h + txt_h + spacing;
y += (r.height() - total_height) / 2;
painter.draw_bitmap(
bmp_pos,
*bitmap_,
color_,
style.background);
}
if (bitmap_) {
Point bmp_pos = {r.left() + (r.width() / 2) - (bitmap_->size.width() / 2), y};
y += bitmap_->size.height();
if (!text_.empty()) {
const auto label_r = style.font.size_of(text_);
painter.draw_string(
{r.left() + (r.width() - label_r.width()) / 2, y + (r.height() - label_r.height()) / 2},
style,
text_);
painter.draw_bitmap(
bmp_pos,
*bitmap_,
color_,
style.background);
}
if (!text_.empty()) {
const auto label_r = style.font.size_of(text_);
if (bitmap_) {
y += spacing;
}
painter.draw_string(
{r.left() + (r.width() - label_r.width()) / 2, y},
style,
text_);
}
} else { // no valign
if (bitmap_) {
Point bmp_pos = {r.left() + (r.width() / 2) - (bitmap_->size.width() / 2), r.top() + 6};
y += bitmap_->size.height() - 6;
painter.draw_bitmap(
bmp_pos,
*bitmap_,
color_,
style.background);
}
if (!text_.empty()) {
const auto label_r = style.font.size_of(text_);
painter.draw_string(
{r.left() + (r.width() - label_r.width()) / 2, y + (r.height() - label_r.height()) / 2},
style,
text_);
}
}
}
@ -2722,6 +2755,13 @@ bool Waveform::on_touch(const TouchEvent event) {
}
}
void Waveform::set_data(int16_t* new_data) {
if (new_data != data_) {
data_ = new_data;
set_dirty();
}
}
void Waveform::paint(Painter& painter) {
// previously it's upside down , low level is up and high level is down, which doesn't make sense,
// if that was made for a reason, feel free to revert.