mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-08-05 05:04:27 -04:00
Improve clipping of RSSI, baseband, audio bar graphs.
This commit is contained in:
parent
018b54c711
commit
6917a38106
3 changed files with 37 additions and 27 deletions
|
@ -23,6 +23,8 @@
|
|||
|
||||
#include "event_m0.hpp"
|
||||
|
||||
#include "utility.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace ui {
|
||||
|
@ -42,14 +44,15 @@ void Channel::on_hide() {
|
|||
void Channel::paint(Painter& painter) {
|
||||
const auto r = screen_rect();
|
||||
|
||||
const int32_t db_min = -r.width();
|
||||
const int32_t x_0 = 0;
|
||||
const int32_t x_max = std::max(x_0, max_db_ - db_min);
|
||||
const int32_t x_lim = r.width();
|
||||
constexpr int db_min = -96;
|
||||
constexpr int db_max = 0;
|
||||
constexpr int db_delta = db_max - db_min;
|
||||
const range_t<int> x_max_range { 0, r.width() - 1 };
|
||||
const auto x_max = x_max_range.clip((max_db_ - db_min) * r.width() / db_delta);
|
||||
|
||||
const Rect r0 {
|
||||
static_cast<ui::Coord>(r.left() + x_0), r.top(),
|
||||
static_cast<ui::Dim>(x_max - x_0), r.height()
|
||||
static_cast<ui::Coord>(r.left()), r.top(),
|
||||
static_cast<ui::Dim>(x_max), r.height()
|
||||
};
|
||||
painter.fill_rectangle(
|
||||
r0,
|
||||
|
@ -67,7 +70,7 @@ void Channel::paint(Painter& painter) {
|
|||
|
||||
const Rect r2 {
|
||||
static_cast<ui::Coord>(r.left() + x_max + 1), r.top(),
|
||||
static_cast<ui::Dim>(x_lim - (x_max + 1)), r.height()
|
||||
static_cast<ui::Dim>(r.width() - (x_max + 1)), r.height()
|
||||
};
|
||||
painter.fill_rectangle(
|
||||
r2,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue