spectrum cursor opt again (#2634)

* spectrum cursor opt

* fmt

* remove blink

* remove End event

* cleanup
This commit is contained in:
sommermorgentraum 2025-04-22 21:14:31 +08:00 committed by GitHub
parent 9aff3f4121
commit de3212cba5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 23 deletions

View file

@ -123,14 +123,12 @@ void FrequencyScale::paint(Painter& painter) {
draw_filter_ranges(painter, r);
draw_frequency_ticks(painter, r);
if (_blink) {
const Rect r_cursor{
118 + cursor_position, r.bottom() - filter_band_height,
5, filter_band_height};
painter.fill_rectangle(
r_cursor,
Color::red());
}
const Rect r_cursor{
118 + cursor_position, r.bottom() - filter_band_height,
5, filter_band_height};
painter.fill_rectangle(
r_cursor,
Color::red());
}
void FrequencyScale::clear() {
@ -214,16 +212,10 @@ void FrequencyScale::draw_filter_ranges(Painter& painter, const Rect r) {
}
void FrequencyScale::on_focus() {
_blink = true;
on_tick_second();
signal_token_tick_second = rtc_time::signal_tick_second += [this]() {
this->on_tick_second();
};
set_dirty();
}
void FrequencyScale::on_blur() {
rtc_time::signal_tick_second -= signal_token_tick_second;
_blink = false;
set_dirty();
}
@ -243,6 +235,7 @@ bool FrequencyScale::on_key(const KeyEvent key) {
if (on_select) {
on_select((cursor_position * spectrum_sampling_rate) / 240);
cursor_position = 0;
set_dirty();
return true;
}
}
@ -259,11 +252,6 @@ bool FrequencyScale::on_touch(const TouchEvent touch) {
return true;
}
void FrequencyScale::on_tick_second() {
set_dirty();
_blink = !_blink;
}
/* WaterfallWidget *********************************************************/
// TODO: buffer and use "paint" instead of immediate drawing would help with
// preventing flicker from drawing. Would use more RAM however.

View file

@ -91,9 +91,6 @@ class FrequencyScale : public Widget {
private:
static constexpr int filter_band_height = 4;
void on_tick_second();
bool _blink{false};
int32_t cursor_position{0};
SignalToken signal_token_tick_second{};
int spectrum_sampling_rate{0};