Rework spectrum/console UI clearing and resetting.

This commit is contained in:
Jared Boone 2015-10-16 19:36:07 -07:00
parent dc30911e0f
commit d0f35cf89d
4 changed files with 23 additions and 29 deletions

View File

@ -32,6 +32,7 @@ void Console::clear() {
Color::black()
);
pos = { 0, 0 };
display.scroll_set_position(0);
}
void Console::write(const std::string message) {
@ -64,10 +65,10 @@ void Console::paint(Painter& painter) {
}
void Console::on_show() {
clear();
const auto screen_r = screen_rect();
display.scroll_set_area(screen_r.top(), screen_r.bottom());
clear();
}
void Console::on_hide() {

View File

@ -504,13 +504,7 @@ void ReceiverView::on_hide() {
context().message_map.unregister_handler(Message::ID::FSKPacket);
}
void ReceiverView::set_parent_rect(const Rect new_parent_rect) {
const ui::Dim header_height = 3 * 16;
waterfall.set_parent_rect({
0, header_height,
new_parent_rect.width(), static_cast<ui::Dim>(new_parent_rect.height() - header_height)
});
}
void ReceiverView::focus() {
@ -568,7 +562,6 @@ void ReceiverView::on_modulation_changed(int32_t modulation) {
break;
}
waterfall.clear();
}
void ReceiverView::on_show_options_frequency() {

View File

@ -363,8 +363,6 @@ public:
ReceiverView(NavigationView& nav, ReceiverModel& receiver_model);
~ReceiverView();
void set_parent_rect(const Rect new_parent_rect) override;
void focus() override;
void on_show() override;

View File

@ -40,6 +40,10 @@ namespace spectrum {
class FrequencyScale : public Widget {
public:
void on_show() override {
clear();
}
void set_spectrum_sampling_rate(const uint32_t new_sampling_rate, const size_t new_spectrum_bins) {
if( (spectrum_sampling_rate != new_sampling_rate) ||
(spectrum_bins != new_spectrum_bins) ) {
@ -75,12 +79,6 @@ public:
draw_frequency_ticks(painter, r);
}
void clear() {
spectrum_sampling_rate = 0;
spectrum_bins = 0;
set_dirty();
}
private:
static constexpr Dim filter_band_height = 4;
@ -89,6 +87,12 @@ private:
uint32_t channel_filter_pass_frequency { 0 };
uint32_t channel_filter_stop_frequency { 0 };
void clear() {
spectrum_sampling_rate = 0;
spectrum_bins = 0;
set_dirty();
}
void clear_background(Painter& painter, const Rect r) {
painter.fill_rectangle(r, Color::black());
}
@ -187,6 +191,8 @@ private:
class WaterfallView : public Widget {
public:
void on_show() override {
clear();
const auto screen_r = screen_rect();
display.scroll_set_area(screen_r.top(), screen_r.bottom());
}
@ -203,13 +209,6 @@ public:
(void)painter;
}
void clear() {
display.fill_rectangle(
screen_rect(),
Color::black()
);
}
void on_channel_spectrum(
const ChannelSpectrum& spectrum
) {
@ -233,6 +232,14 @@ public:
pixel_row
);
}
private:
void clear() {
display.fill_rectangle(
screen_rect(),
Color::black()
);
}
};
class WaterfallWidget : public View {
@ -273,11 +280,6 @@ public:
(void)painter;
}
void clear() {
waterfall_view.clear();
frequency_scale.clear();
}
private:
WaterfallView waterfall_view;
FrequencyScale frequency_scale;