Simplify handling of modulation config changes via UI.

This commit is contained in:
Jared Boone 2016-02-02 15:20:14 -08:00
parent 10c7c57fd1
commit d9be5677e3
2 changed files with 4 additions and 27 deletions

View File

@ -42,10 +42,9 @@ AMOptionsView::AMOptionsView(
&options_config, &options_config,
} }); } });
options_config.set_selected_index(receiver_model.am_configuration());
options_config.on_change = [this](size_t n, OptionsField::value_t) { options_config.on_change = [this](size_t n, OptionsField::value_t) {
if( on_config_changed ) { receiver_model.set_am_configuration(n);
this->on_config_changed(n);
}
}; };
} }
@ -62,10 +61,9 @@ NBFMOptionsView::NBFMOptionsView(
&options_config, &options_config,
} }); } });
options_config.set_selected_index(receiver_model.nbfm_configuration());
options_config.on_change = [this](size_t n, OptionsField::value_t) { options_config.on_change = [this](size_t n, OptionsField::value_t) {
if( on_config_changed ) { receiver_model.set_nbfm_configuration(n);
this->on_config_changed(n);
}
}; };
} }
@ -261,9 +259,6 @@ void AnalogAudioView::on_show_options_modulation() {
Rect { 0 * 8, 1 * 16, 30 * 8, 1 * 16 }, Rect { 0 * 8, 1 * 16, 30 * 8, 1 * 16 },
&style_options_group &style_options_group
); );
widget->on_config_changed = [this](size_t n) {
this->on_am_config_index_changed(n);
};
set_options_widget(std::move(widget)); set_options_widget(std::move(widget));
} }
if( modulation == ReceiverModel::Mode::NarrowbandFMAudio ) { if( modulation == ReceiverModel::Mode::NarrowbandFMAudio ) {
@ -272,9 +267,6 @@ void AnalogAudioView::on_show_options_modulation() {
Rect { 0 * 8, 1 * 16, 30 * 8, 1 * 16 }, Rect { 0 * 8, 1 * 16, 30 * 8, 1 * 16 },
&style_options_group &style_options_group
); );
widget->on_config_changed = [this](size_t n) {
this->on_nbfm_config_index_changed(n);
};
set_options_widget(std::move(widget)); set_options_widget(std::move(widget));
} }
} }
@ -293,14 +285,6 @@ void AnalogAudioView::on_headphone_volume_changed(int32_t v) {
receiver_model.set_headphone_volume(new_volume); receiver_model.set_headphone_volume(new_volume);
} }
void AnalogAudioView::on_am_config_index_changed(size_t n) {
receiver_model.set_am_configuration(n);
}
void AnalogAudioView::on_nbfm_config_index_changed(size_t n) {
receiver_model.set_nbfm_configuration(n);
}
void AnalogAudioView::update_modulation(const ReceiverModel::Mode modulation) { void AnalogAudioView::update_modulation(const ReceiverModel::Mode modulation) {
const auto is_wideband_spectrum_mode = (modulation == ReceiverModel::Mode::SpectrumAnalysis); const auto is_wideband_spectrum_mode = (modulation == ReceiverModel::Mode::SpectrumAnalysis);
receiver_model.set_baseband_configuration({ receiver_model.set_baseband_configuration({

View File

@ -39,8 +39,6 @@ constexpr Style style_options_group {
class AMOptionsView : public View { class AMOptionsView : public View {
public: public:
std::function<void(size_t)> on_config_changed;
AMOptionsView(const Rect parent_rect, const Style* const style); AMOptionsView(const Rect parent_rect, const Style* const style);
private: private:
@ -62,8 +60,6 @@ private:
class NBFMOptionsView : public View { class NBFMOptionsView : public View {
public: public:
std::function<void(size_t)> on_config_changed;
NBFMOptionsView(const Rect parent_rect, const Style* const style); NBFMOptionsView(const Rect parent_rect, const Style* const style);
private: private:
@ -162,9 +158,6 @@ private:
void on_headphone_volume_changed(int32_t v); void on_headphone_volume_changed(int32_t v);
void on_edit_frequency(); void on_edit_frequency();
void on_am_config_index_changed(size_t n);
void on_nbfm_config_index_changed(size_t n);
void remove_options_widget(); void remove_options_widget();
void set_options_widget(std::unique_ptr<Widget> new_widget); void set_options_widget(std::unique_ptr<Widget> new_widget);