Made back button always focusable with left key

This commit is contained in:
furrtek 2017-04-21 00:31:21 +01:00
parent 6464cfeaef
commit eff96276c3
6 changed files with 22 additions and 7 deletions

View File

@ -89,6 +89,7 @@ SystemStatusView::SystemStatusView() {
&sd_card_status_view,
});
button_back.id = -1; // Special ID used by FocusManager
title.set_style(&style_systemstatus);
if (!portapack::persistent_memory::ui_config_textentry())

View File

@ -49,8 +49,6 @@ size_t StreamOutput::read(void* const data, const size_t length) {
// We need a full buffer...
if( !fifo_buffers_full.out(active_buffer) ) {
// ...but none are available. Samples were dropped.
//active_buffer = nullptr; // Testing ! Jumpstart
creg::m4txevent::assert();
break;
}
}

View File

@ -48,12 +48,12 @@ private:
FIFO<StreamBuffer*> fifo_buffers_empty;
FIFO<StreamBuffer*> fifo_buffers_full;
std::array<StreamBuffer, buffer_count_max> buffers;
std::array<StreamBuffer*, buffer_count_max> buffers_empty;
std::array<StreamBuffer*, buffer_count_max> buffers_full;
std::array<StreamBuffer, buffer_count_max> buffers { };
std::array<StreamBuffer*, buffer_count_max> buffers_empty { };
std::array<StreamBuffer*, buffer_count_max> buffers_full { };
StreamBuffer* active_buffer { nullptr };
ReplayConfig* const config { nullptr };
std::unique_ptr<uint8_t[]> data;
std::unique_ptr<uint8_t[]> data { };
};
#endif/*__STREAM_OUTPUT_H__*/

View File

@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2016 Furrtek
*
* This file is part of PortaPack.
*
@ -162,6 +163,13 @@ void FocusManager::update(
return { nullptr, 0 };
};
const auto find_back_fn = [](ui::Widget* const w) -> test_result_t {
if( w->focusable() && (w->id == -1) )
return { w, 0 };
else
return { nullptr, 0 };
};
test_collection_t collection;
widget_collect_visible(top_widget, test_fn, collection);
@ -175,6 +183,14 @@ void FocusManager::update(
//focus->blur();
const auto new_focus = (*nearest).first;
set_focus_widget(new_focus);
} else {
if ((focus_widget()->id >= 0) && (event == KeyEvent::Left)) {
// Stuck left, move to back button
collection.clear();
widget_collect_visible(top_widget, find_back_fn, collection);
if (!collection.empty())
set_focus_widget(collection[0].first);
}
}
}
}

View File

@ -108,7 +108,7 @@ public:
void set_style(const Style* new_style);
const Style& style() const;
uint16_t id = 0;
int16_t id = 0;
// State management methods.
void set_dirty();

Binary file not shown.