Can't use context() in ui::Widget constructor, move use elsewhere.

TODO: Seems like a design flaw to me... Either eliminate need for context(), or pass into constructors.
This commit is contained in:
Jared Boone 2015-08-14 17:52:29 -07:00
parent a7226820d0
commit 32312a6cfb
2 changed files with 15 additions and 7 deletions

View File

@ -480,7 +480,18 @@ ReceiverView::ReceiverView(
}; };
receiver_model.enable(); receiver_model.enable();
}
ReceiverView::~ReceiverView() {
// TODO: Manipulating audio codec here, and in ui_receiver.cpp. Good to do
// both?
audio_codec.headphone_mute();
receiver_model.disable();
}
void ReceiverView::on_show() {
context().message_map.register_handler(Message::ID::FSKPacket, context().message_map.register_handler(Message::ID::FSKPacket,
[](const Message* const p) { [](const Message* const p) {
const auto message = static_cast<const FSKPacketMessage*>(p); const auto message = static_cast<const FSKPacketMessage*>(p);
@ -489,14 +500,8 @@ ReceiverView::ReceiverView(
); );
} }
ReceiverView::~ReceiverView() { void ReceiverView::on_hide() {
context().message_map.unregister_handler(Message::ID::FSKPacket); context().message_map.unregister_handler(Message::ID::FSKPacket);
// TODO: Manipulating audio codec here, and in ui_receiver.cpp. Good to do
// both?
audio_codec.headphone_mute();
receiver_model.disable();
} }
void ReceiverView::set_parent_rect(const Rect new_parent_rect) { void ReceiverView::set_parent_rect(const Rect new_parent_rect) {

View File

@ -367,6 +367,9 @@ public:
void focus() override; void focus() override;
void on_show() override;
void on_hide() override;
private: private:
ReceiverModel& receiver_model; ReceiverModel& receiver_model;