mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-08-25 13:47:48 +00:00
Clean up UI type static_casts.
So disgusting, but not entirely gone yet...
This commit is contained in:
@@ -49,7 +49,7 @@ void Console::write(const std::string message) {
|
||||
crlf();
|
||||
}
|
||||
const Point pos_glyph {
|
||||
static_cast<Coord>(rect.pos.x + pos.x),
|
||||
rect.pos.x + pos.x,
|
||||
display.scroll_area_y(pos.y)
|
||||
};
|
||||
display.draw_glyph(pos_glyph, glyph, s.foreground, s.background);
|
||||
|
@@ -172,7 +172,7 @@ void RegistersWidget::draw_legend(const Coord left, Painter& painter) {
|
||||
|
||||
for(size_t i=0; i<config.registers_count; i+=config.registers_per_row) {
|
||||
const Point offset {
|
||||
left, static_cast<Coord>((i / config.registers_per_row) * row_height)
|
||||
left, (i / config.registers_per_row) * row_height
|
||||
};
|
||||
|
||||
const auto text = to_string_hex(i, config.legend_length);
|
||||
@@ -192,8 +192,8 @@ void RegistersWidget::draw_values(
|
||||
|
||||
for(size_t i=0; i<config.registers_count; i++) {
|
||||
const Point offset = {
|
||||
static_cast<Coord>(left + config.legend_width() + 8 + (i % config.registers_per_row) * (config.value_width() + 8)),
|
||||
static_cast<Coord>((i / config.registers_per_row) * row_height)
|
||||
left + config.legend_width() + 8 + (i % config.registers_per_row) * (config.value_width() + 8),
|
||||
(i / config.registers_per_row) * row_height
|
||||
};
|
||||
|
||||
const auto value = reader(i);
|
||||
@@ -231,8 +231,8 @@ RegistersView::RegistersView(
|
||||
registers_widget.set_parent_rect({ 0, 48, 240, 192 });
|
||||
|
||||
text_title.set_parent_rect({
|
||||
static_cast<Coord>((240 - title.size() * 8) / 2), 16,
|
||||
static_cast<Dim>(title.size() * 8), 16
|
||||
(240 - title.size() * 8) / 2, 16,
|
||||
title.size() * 8, 16
|
||||
});
|
||||
text_title.set(title);
|
||||
}
|
||||
|
@@ -52,7 +52,7 @@ void MenuItemView::paint(Painter& painter) {
|
||||
);
|
||||
|
||||
painter.draw_string(
|
||||
{ static_cast<Coord>(r.pos.x + 8), static_cast<Coord>(r.pos.y + (r.size.h - font_height) / 2) },
|
||||
{ r.pos.x + 8, r.pos.y + (r.size.h - font_height) / 2 },
|
||||
paint_style,
|
||||
item.text
|
||||
);
|
||||
|
@@ -167,8 +167,8 @@ FrequencyKeypadView::FrequencyKeypadView(
|
||||
};
|
||||
button.on_select = button_fn;
|
||||
button.set_parent_rect({
|
||||
static_cast<Coord>((n % 3) * button_w),
|
||||
static_cast<Coord>((n / 3) * button_h + button_h),
|
||||
(n % 3) * button_w,
|
||||
(n / 3) * button_h + button_h,
|
||||
button_w, button_h
|
||||
});
|
||||
button.set_text(label);
|
||||
|
@@ -88,10 +88,7 @@ void FrequencyScale::clear_background(Painter& painter, const Rect r) {
|
||||
void FrequencyScale::draw_frequency_ticks(Painter& painter, const Rect r) {
|
||||
const auto x_center = r.width() / 2;
|
||||
|
||||
const Rect tick {
|
||||
static_cast<Coord>(r.left() + x_center), r.top(),
|
||||
1, r.height()
|
||||
};
|
||||
const Rect tick { r.left() + x_center, r.top(), 1, r.height() };
|
||||
painter.fill_rectangle(tick, Color::white());
|
||||
|
||||
constexpr uint32_t tick_count_max = 4;
|
||||
@@ -117,15 +114,15 @@ void FrequencyScale::draw_frequency_ticks(Painter& painter, const Rect r) {
|
||||
(magnitude_n >= 3) ? "k" : "";
|
||||
const std::string label = to_string_dec_uint(tick_offset) + zero_pad + unit;
|
||||
|
||||
const Coord offset_low = static_cast<Coord>(r.left() + x_center - pixel_offset);
|
||||
const Coord offset_low = r.left() + x_center - pixel_offset;
|
||||
const Rect tick_low { offset_low, r.top(), 1, r.height() };
|
||||
painter.fill_rectangle(tick_low, Color::white());
|
||||
painter.draw_string({ static_cast<Coord>(offset_low + 2), r.top() }, style(), label );
|
||||
painter.draw_string({ offset_low + 2, r.top() }, style(), label );
|
||||
|
||||
const Coord offset_high = static_cast<Coord>(r.left() + x_center + pixel_offset);
|
||||
const Coord offset_high = r.left() + x_center + pixel_offset;
|
||||
const Rect tick_high { offset_high, r.top(), 1, r.height() };
|
||||
painter.fill_rectangle(tick_high, Color::white());
|
||||
painter.draw_string({ static_cast<Coord>(offset_high + 2), r.top() }, style(), label );
|
||||
painter.draw_string({ offset_high + 2, r.top() }, style(), label );
|
||||
|
||||
tick_offset += tick_interval;
|
||||
}
|
||||
@@ -146,8 +143,8 @@ void FrequencyScale::draw_filter_ranges(Painter& painter, const Rect r) {
|
||||
const auto stop_x_hi = x_center + stop_offset;
|
||||
|
||||
const Rect r_stop_lo {
|
||||
static_cast<Coord>(r.left() + stop_x_lo), static_cast<Coord>(r.bottom() - filter_band_height),
|
||||
static_cast<Dim>(pass_x_lo - stop_x_lo), filter_band_height
|
||||
r.left() + stop_x_lo, r.bottom() - filter_band_height,
|
||||
pass_x_lo - stop_x_lo, filter_band_height
|
||||
};
|
||||
painter.fill_rectangle(
|
||||
r_stop_lo,
|
||||
@@ -155,8 +152,8 @@ void FrequencyScale::draw_filter_ranges(Painter& painter, const Rect r) {
|
||||
);
|
||||
|
||||
const Rect r_stop_hi {
|
||||
static_cast<Coord>(r.left() + pass_x_hi), static_cast<Coord>(r.bottom() - filter_band_height),
|
||||
static_cast<Dim>(stop_x_hi - pass_x_hi), filter_band_height
|
||||
r.left() + pass_x_hi, r.bottom() - filter_band_height,
|
||||
stop_x_hi - pass_x_hi, filter_band_height
|
||||
};
|
||||
painter.fill_rectangle(
|
||||
r_stop_hi,
|
||||
@@ -165,8 +162,8 @@ void FrequencyScale::draw_filter_ranges(Painter& painter, const Rect r) {
|
||||
}
|
||||
|
||||
const Rect r_pass {
|
||||
static_cast<Coord>(r.left() + pass_x_lo), static_cast<Coord>(r.bottom() - filter_band_height),
|
||||
static_cast<Dim>(pass_x_hi - pass_x_lo), filter_band_height
|
||||
r.left() + pass_x_lo, r.bottom() - filter_band_height,
|
||||
pass_x_hi - pass_x_lo, filter_band_height
|
||||
};
|
||||
painter.fill_rectangle(
|
||||
r_pass,
|
||||
@@ -280,7 +277,7 @@ void WaterfallWidget::set_parent_rect(const Rect new_parent_rect) {
|
||||
waterfall_view.set_parent_rect({
|
||||
0, scale_height,
|
||||
new_parent_rect.width(),
|
||||
static_cast<Dim>(new_parent_rect.height() - scale_height)
|
||||
new_parent_rect.height() - scale_height
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user